total-recall-brain 3.23.3 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/bin/total-recall.mjs +1 -0
  2. package/frontend/dist/assets/{index-c6GHGS_j.js → index-CtCDaZYZ.js} +1 -1
  3. package/frontend/dist/index.html +1 -1
  4. package/frontend/src/pages/SecretsPage.tsx +111 -52
  5. package/package.json +3 -2
  6. package/scaffold/.agent/skills/total-recall/SKILL.md +199 -7
  7. package/scaffold/.agent/skills/total-recall/memory-vault/concepts/cli-help-reference.md +13 -4
  8. package/scaffold/.agent/skills/total-recall/memory-vault/invariants/operating-instructions.md +2 -0
  9. package/scaffold/.agent/skills/total-recall/references/api-reference.md +1 -1
  10. package/scaffold/.agent/skills/total-recall/references/cli-reference.md +1 -2
  11. package/scaffold/.agent/skills/total-recall/research-queue.jsonl +7 -0
  12. package/scaffold/.agent/skills/total-recall/skills-registry/index.yaml +2461 -6
  13. package/src/cli/backfill.mjs +176 -0
  14. package/src/cli/init.mjs +1 -1
  15. package/src/cli/proposals.mjs +3 -3
  16. package/src/cli/secret.mjs +84 -0
  17. package/src/core/clarity-rewriter.mjs +25 -39
  18. package/src/core/conclusion-writer.mjs +20 -10
  19. package/src/core/crypto.mjs +86 -16
  20. package/src/core/daemon-loop.mjs +2 -2
  21. package/src/core/dream.mjs +49 -58
  22. package/src/core/env-import.mjs +18 -0
  23. package/src/core/inference-engine.mjs +15 -17
  24. package/src/core/migrate.mjs +5 -1
  25. package/src/core/okf-adapter.mjs +2 -0
  26. package/src/core/post-mortem.mjs +30 -26
  27. package/src/core/proposal-applier.mjs +26 -10
  28. package/src/core/repo-sync.mjs +51 -39
  29. package/src/core/scheduler.mjs +1 -0
  30. package/src/core/schema.mjs +24 -1
  31. package/src/core/search.mjs +1 -1
  32. package/src/core/secrets-env-diff.mjs +132 -0
  33. package/src/core/secrets-rekey.mjs +0 -0
  34. package/src/core/snapshot.mjs +32 -9
  35. package/src/core/ssss-kernel-bridge.mjs +46 -6
  36. package/src/core/task-envelope.mjs +1 -0
  37. package/src/core/validated-write.mjs +68 -5
  38. package/src/core/vault-backfill.mjs +259 -0
  39. package/src/core/vault.mjs +22 -4
  40. package/src/server/auth.mjs +42 -8
  41. package/src/server/routes/brains.mjs +1 -1
  42. package/src/server/routes/proposals.mjs +4 -4
  43. package/src/server/routes/secrets.mjs +1 -1
@@ -5518,7 +5518,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
5518
5518
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jbe(e,t){if(e){if(typeof e==`string`)return E5(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E5(e,t):void 0}}function E5(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Mbe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nbe(e){if(Array.isArray(e))return e}var Pbe=(0,v.createContext)(void 0),Fbe=e=>{var t=e.children,n=kbe((0,v.useState)(`${MK(`recharts`)}-clip`),1)[0],r=v5();if(r==null)return null;var i=r.x,a=r.y,o=r.width,s=r.height;return v.createElement(Pbe.Provider,{value:n},v.createElement(`defs`,null,v.createElement(`clipPath`,{id:n},v.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)};function Ibe(){}function D5(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function Lbe(e,t,n){return O5(e,t,void 0,void 0,void 0,void 0,n)}function O5(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return k5(e,t,a,o)}return k5(e,t,a,o)}function k5(e,t,n,r){if(Object.is(e,t))return!0;let i=dY(e),a=dY(t);if(i===`[object Arguments]`&&(i=wY),a===`[object Arguments]`&&(a=wY),i!==a)return!1;switch(i){case pY:return e.toString()===t.toString();case mY:return GY(e.valueOf(),t.valueOf());case hY:case vY:case _Y:return Object.is(e.valueOf(),t.valueOf());case fY:return e.source===t.source&&e.flags===t.flags;case SY:return e===t}n??=new Map;let o=n.get(e),s=n.get(t);if(o!=null&&s!=null)return o===t;n.set(e,t),n.set(t,e);try{switch(i){case yY:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!O5(a,t.get(i),i,e,t,n,r))return!1;return!0;case bY:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;o<i.length;o++){let s=i[o],c=a.findIndex(i=>O5(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case xY:case DY:case OY:case kY:case AY:case jY:case MY:case NY:case PY:case FY:case IY:case LY:if(zY(e)!==zY(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!O5(e[i],t[i],i,e,t,n,r))return!1;return!0;case CY:return e.byteLength===t.byteLength&&k5(new Uint8Array(e),new Uint8Array(t),n,r);case EY:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:k5(new Uint8Array(e),new Uint8Array(t),n,r);case TY:return e.name===t.name&&e.message===t.message;case wY:{if(!(k5(e.constructor,t.constructor,n,r)||D5(e)&&D5(t)))return!1;let i=[...Object.keys(e),...uY(e)],a=[...Object.keys(t),...uY(t)];if(i.length!==a.length)return!1;for(let a=0;a<i.length;a++){let o=i[a],s=e[o];if(!Object.hasOwn(t,o))return!1;let c=t[o];if(!O5(s,c,o,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function Rbe(e,t){return Lbe(e,t,Ibe)}function A5(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function zbe(e,t,n){return Dbe({width:e.width+t.width,height:e.height+t.height},n)}function Bbe(e,t,n){var r=n===`width`,i=e.x,a=e.y,o=e.width,s=e.height;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function j5(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function Vbe(e,t){return A5(e,t+1)}function Hbe(e,t,n,r,i){for(var a=(r||[]).slice(),o=t.start,s=t.end,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:A5(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||j5(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function Ube(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var o=t.start,s=t.end,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||j5(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),p===0||p!==1);m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function M5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function N5(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?M5(Object(n),!0).forEach(function(t){Wbe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wbe(e,t,n){return(t=Gbe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gbe(e){var t=Kbe(e,`string`);return typeof t==`symbol`?t:t+``}function Kbe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qbe(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,s=t.start,c=t.end,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=N5(N5({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=N5(N5({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&j5(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=N5(N5({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function Jbe(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,c=t.start,l=t.end;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=N5(N5({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&j5(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=N5(N5({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=N5(N5({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=N5(N5({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&j5(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=N5(N5({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function P5(e,t,n){var r=e.tick,i=e.ticks,a=e.viewBox,o=e.minTickGap,s=e.orientation,c=e.interval,l=e.tickFormatter,u=e.unit,d=e.angle;if(!i||!i.length||!r)return[];if(kK(c)||l0.isSsr)return Vbe(i,kK(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?l8(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?zbe(l8(i,{fontSize:t,letterSpacing:n}),m,d):l8(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?EK(_.coordinate-g.coordinate):1,y=Bbe(a,v,p);return c===`equidistantPreserveStart`?Hbe(v,y,h,i,o):c===`equidistantPreserveEnd`?Ube(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?Jbe(v,y,h,i,o,c===`preserveStartEnd`):qbe(v,y,h,i,o),f.filter(e=>e.isShow))}var Ybe=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>l&&(l=t.width)}});var u=n?n.getBoundingClientRect().width:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},Xbe=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.height>l&&(l=t.height)}});var u=n?n.getBoundingClientRect().height:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},F5=g$({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId,a=n.ticks;e[r][i]=UQ(a)},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId;delete e[r][i]}}}),I5=F5.actions,Zbe=I5.setRenderedTicks,Qbe=I5.removeRenderedTicks,$be=F5.reducer,exe=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function L5(e,t){return ixe(e)||rxe(e,t)||nxe(e,t)||txe()}function txe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
5519
5519
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nxe(e,t){if(e){if(typeof e==`string`)return R5(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R5(e,t):void 0}}function R5(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function rxe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ixe(e){if(Array.isArray(e))return e}function axe(e,t){if(e==null)return{};var n,r,i=oxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function oxe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function z5(){return z5=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z5.apply(null,arguments)}function B5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function V5(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?B5(Object(n),!0).forEach(function(t){sxe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sxe(e,t,n){return(t=cxe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cxe(e){var t=lxe(e,`string`);return typeof t==`symbol`?t:t+``}function lxe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var H5={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:M2.axis};function uxe(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=V5(V5(V5({},c),tK(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=V5(V5({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=V5(V5({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return v.createElement(`line`,z5({},l,{className:YG(`recharts-cartesian-axis-line`,xK(s,`className`))}))}function dxe(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=kK(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function fxe(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function pxe(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function mxe(e){var t=e.option,n=e.tickProps,r=e.value,i,a=YG(n.className,`recharts-cartesian-axis-tick-value`);if(v.isValidElement(t))i=v.cloneElement(t,V5(V5({},n),{},{className:a}));else if(typeof t==`function`)i=t(V5(V5({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=YG(o,dye(t))),i=v.createElement(M8,z5({},n,{className:o}),r)}return i}function hxe(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=SX(),a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(r!=null&&n!=null){var e=t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),o=a.current;o!=null&&o.axisId===r&&o.axisType===n&&Rbe(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(Zbe({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,v.useEffect)(()=>r==null||n==null?BK:()=>{i(Qbe({axisId:r,axisType:n}))},[i,r,n]),null}var gxe=(0,v.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,y=e.tickMargin,b=e.fontSize,x=e.letterSpacing,S=e.getTicksConfig,C=e.events,w=e.axisType,T=e.axisId,E=P5(V5(V5({},S),{},{ticks:r}),b,x),D=tK(S),O=nK(i),k=E8(D.textAnchor)?D.textAnchor:fxe(d,f),A=pxe(d,f),j={};typeof a==`object`&&(j=a);var ee=V5(V5({},D),{},{fill:`none`},j),M=E.map(e=>V5({entry:e},dxe(e,p,m,h,g,d,_,f,y))),N=M.map(e=>{var t=e.entry,n=e.line;return v.createElement(mK,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&v.createElement(`line`,z5({},ee,n,{className:YG(`recharts-cartesian-axis-tick-line`,xK(a,`className`))})))}),te=M.map((e,t)=>{var n=e.entry,r=e.tick,a=V5(V5({},V5(V5(V5(V5({verticalAnchor:A},D),{},{textAnchor:k,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:E.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??D.angle??0})),O);return v.createElement(mK,z5({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},zJ(C,n,t)),i&&v.createElement(mxe,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return v.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${w}-ticks`},v.createElement(hxe,{ticks:E,axisId:T,axisType:w}),te.length>0&&v.createElement(B6,{zIndex:M2.label},v.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${w}-tick-labels`,ref:t},te)),N.length>0&&v.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${w}-tick-lines`},N))}),_xe=(0,v.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=axe(e,exe),d=L5((0,v.useState)(``),2),f=d[0],p=d[1],m=L5((0,v.useState)(``),2),h=m[0],g=m[1],_=(0,v.useRef)(null);(0,v.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>Ybe({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>Xbe({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var y=(0,v.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:v.createElement(B6,{zIndex:e.zIndex},v.createElement(mK,{className:YG(`recharts-cartesian-axis`,a)},v.createElement(uxe,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:tK(e)}),v.createElement(gxe,{ref:y,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),v.createElement(Gve,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},v.createElement(tye,{label:e.label,labelRef:e.labelRef}),e.children)))}),U5=v.forwardRef((e,t)=>{var n=GJ(e,H5);return v.createElement(_xe,z5({},n,{ref:t}))});U5.displayName=`CartesianAxis`;var W5=(0,v.createContext)({grid:{stroke:`#ccc`,fill:`none`}});W5.Provider;var vxe=()=>(0,v.useContext)(W5),yxe=[`x1`,`y1`,`x2`,`y2`,`key`],bxe=[`offset`],xxe=[`xAxisId`,`yAxisId`],Sxe=[`xAxisId`,`yAxisId`];function G5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K5(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?G5(Object(n),!0).forEach(function(t){Cxe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):G5(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Cxe(e,t,n){return(t=wxe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wxe(e){var t=Txe(e,`string`);return typeof t==`symbol`?t:t+``}function Txe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function q5(){return q5=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},q5.apply(null,arguments)}function J5(e,t){if(e==null)return{};var n,r,i=Exe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Exe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Dxe=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return v.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function Y5(e){var t=e.option,n=e.lineItemProps,r;if(v.isValidElement(t))r=v.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=tK(J5(n,yxe))??{};l.offset;var u=J5(l,bxe),d=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(`,`):u.strokeDasharray;r=v.createElement(`line`,q5({},u,{strokeDasharray:d,x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function Oxe(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0||r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=J5(e,xxe),s=a.map((e,r)=>{var a=K5(K5({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return v.createElement(Y5,{key:`line-${r}`,option:i,lineItemProps:a})});return v.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function kxe(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0||r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=J5(e,Sxe),s=a.map((e,r)=>{var a=K5(K5({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return v.createElement(Y5,{option:i,lineItemProps:a,key:`line-${r}`})});return v.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function Axe(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return v.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return v.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function jxe(e){var t=e.vertical,n=t===void 0||t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return v.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return v.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var Mxe=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return r1(P5(K5(K5(K5({},H5),n),{},{ticks:i1(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},Nxe=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return r1(P5(K5(K5(K5({},H5),n),{},{ticks:i1(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},Pxe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:M2.grid};function X5(e){var t=I1(),n=L1(),r=F1(),i=K5(K5({},GJ(e,Pxe)),{},{x:kK(e.x)?e.x:r.left,y:kK(e.y)?e.y:r.top,width:kK(e.width)?e.width:r.width,height:kK(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=x1(),h=EX(e=>O3(e,`xAxis`,a,m)),g=EX(e=>O3(e,`yAxis`,o,m)),_=vxe(),y={stroke:i.stroke??_.grid.stroke,strokeWidth:i.strokeWidth??_.grid.strokeWidth,strokeOpacity:i.strokeOpacity??_.grid.strokeOpacity,strokeDasharray:i.strokeDasharray??_.grid.strokeDasharray};if(!Q$(l)||!Q$(u)||!kK(s)||!kK(c))return null;var b=i.verticalCoordinatesGenerator||Mxe,x=i.horizontalCoordinatesGenerator||Nxe,S=i.horizontalPoints,C=i.verticalPoints;if((!S||!S.length)&&typeof x==`function`){var w=f&&f.length,T=x({yAxis:g?K5(K5({},g),{},{ticks:w?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);w1(Array.isArray(T),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(S=T)}if((!C||!C.length)&&typeof b==`function`){var E=p&&p.length,D=b({xAxis:h?K5(K5({},h),{},{ticks:E?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},E?!0:d);w1(Array.isArray(D),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof D}]`),Array.isArray(D)&&(C=D)}return v.createElement(B6,{zIndex:i.zIndex},v.createElement(`g`,{className:`recharts-cartesian-grid`},v.createElement(Dxe,{fill:i.fill??_.grid.fill,fillOpacity:i.fillOpacity??_.grid.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),v.createElement(Axe,q5({},i,{horizontalPoints:S})),v.createElement(jxe,q5({},i,{verticalPoints:C})),v.createElement(Oxe,q5({},i,y,{offset:r,horizontalPoints:S,xAxis:h,yAxis:g})),v.createElement(kxe,q5({},i,y,{offset:r,verticalPoints:C,xAxis:h,yAxis:g}))))}X5.displayName=`CartesianGrid`;var Z5=g$({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),Q5=Z5.actions;Q5.addErrorBar,Q5.replaceErrorBar,Q5.removeErrorBar;var Fxe=Z5.reducer;function $5(e,t){var n=EX(t=>v4(t,e)),r=EX(e=>x4(e,t)),i=n?.allowDataOverflow??g4.allowDataOverflow,a=r?.allowDataOverflow??y4.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function Ixe(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=v5(),a=$5(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=EX(e=>m3(e,t,!1)),u=EX(e=>h3(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,y=s&&u?Math.abs(u[1]-u[0]):m*2;return v.createElement(`clipPath`,{id:`clipPath-${r}`},v.createElement(`rect`,{x:h,y:g,width:_,height:y}))}function Lxe(e){var t=nK(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function e7(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function t7(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var n7=(e,t,n)=>j3(e,`xAxis`,e7(e,t),n),r7=(e,t,n)=>A3(e,`xAxis`,e7(e,t),n),i7=(e,t,n)=>j3(e,`yAxis`,t7(e,t),n),a7=(e,t,n)=>A3(e,`yAxis`,t7(e,t),n),Rxe=$([R1,n7,i7,r7,a7],(e,t,n,r,i)=>n1(e,`xAxis`)?c1(t,r,!1):c1(n,i,!1)),o7=$([D4,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),s7=e=>n1(R1(e),`xAxis`)?`yAxis`:`xAxis`,zxe=(e,t)=>s7(e)===`yAxis`?t7(e,t):e7(e,t),c7=(e,t,n)=>G4(e,s7(e),zxe(e,t),n),Bxe=$([R1,n7,i7,r7,a7,$([o7,c7],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=Q2(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Lme,Rxe,o7,Zme,$([o7,c7],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(zK)}})],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return dSe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Vxe=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Hxe=[`id`,`baseLine`];function l7(){return l7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l7.apply(null,arguments)}function u7(e,t){if(e==null)return{};var n,r,i=Uxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Uxe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Wxe(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!Z$(a)||!Z$(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return kK(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),kK(c)?v.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Gxe(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!Z$(a)||!Z$(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return kK(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),kK(c)?v.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Kxe(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?v.createElement(Gxe,{alpha:t,points:r,baseLine:i,strokeWidth:a}):v.createElement(Wxe,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function qxe(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=u7(e,Vxe),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=c5(),h=d.id,g=d.baseLine,_=tK(u7(d,Hxe)),y=v.createElement(T0,l7({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),b=l!==`none`&&v.createElement(T0,l7({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&v.createElement(T0,l7({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?v.createElement(mK,null,v.createElement(`defs`,null,v.createElement(`clipPath`,{id:m},v.createElement(Kxe,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),v.createElement(mK,{clipPath:`url(#${m})`},y,b,x)):v.createElement(v.Fragment,null,y,b,x)}var Jxe=[`id`],Yxe=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function d7(){return d7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d7.apply(null,arguments)}function f7(e,t){if(e==null)return{};var n,r,i=Xxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xxe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function p7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function m7(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?p7(Object(n),!0).forEach(function(t){Zxe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zxe(e,t,n){return(t=Qxe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qxe(e){var t=$xe(e,`string`);return typeof t==`symbol`?t:t+``}function $xe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var h7={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:n5,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[m7(m7({},e.next),{},{x:FK(e.prev.x,e.next.x,t),y:FK(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:qxe,xAxisId:0,yAxisId:0,zIndex:M2.area};function g7(e,t){return e&&e!==`none`?e:t}var eSe=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:g7(r,i),value:u1(n,t),payload:e}]},tSe=v.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:BK,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:u1(o,t),hide:s,type:u,color:g7(r,a),unit:c,formatter:l,graphicalItemId:d}};return v.createElement(bye,{tooltipEntrySettings:f})});function nSe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=tK(r);return v.createElement(abe,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function rSe(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return m7(m7({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return v.createElement(oye,{value:t?r:void 0},n)}function iSe(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=f7(a,Jxe),_=m7(m7({},rK(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return v.createElement(v.Fragment,null,t?.length>1&&v.createElement(mK,{clipPath:r?`url(#clipPath-${i})`:void 0},v.createElement(yye,{option:m,DefaultShape:h7.shape,shapeProps:_})),v.createElement(nSe,{points:t,props:g,clipPathId:i}))}function aSe(e,t,n){return kK(e)?FK(kK(t)?t:void 0,e,n):LK(e)||DK(e)?FK(kK(t)?t:void 0,0,n):e}function oSe(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,v.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=a5(m,a),g=B1(),_=Iye(r.onAnimationStart,r.onAnimationEnd),y=_.isAnimating,b=_.handleAnimationStart,x=_.handleAnimationEnd,S=h.startValue;if(g==null)return null;var C=Array.isArray(s)&&Array.isArray(S)?i5(S,s,f):Array.isArray(s)?i5(null,s,f):null;return v.createElement(Lye,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:b,onAnimationEnd:x,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(C,i,g):a?s:aSe(s,S,i);return h.syncStepValue(c,i),v.createElement(rSe,{showLabels:!y,points:o},r.children,v.createElement(iSe,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:y||i<1,isEntrance:a}),v.createElement(lye,{label:r.label}))})}function sSe(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,v.useRef)(null),a=(0,v.useRef)();return v.createElement(oSe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var cSe=class extends v.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=YG(`recharts-area`,i),g=f,_=Lxe(n),y=_.r,b=_.strokeWidth,x=Z8(n),S=y*2+b,C=s?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return v.createElement(B6,{zIndex:m},v.createElement(mK,{className:h},s&&v.createElement(`defs`,null,v.createElement(Ixe,{clipPathId:g,xAxisId:c,yAxisId:l}),!x&&v.createElement(`clipPath`,{id:`clipPath-dots-${g}`},v.createElement(`rect`,{x:o-S/2,y:a-S/2,width:u+S,height:d+S}))),v.createElement(sSe,{needClip:s,clipPathId:g,props:this.props})),v.createElement(x5,{points:r,mainColor:g7(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&v.createElement(x5,{points:p,mainColor:g7(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}};function lSe(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=f7(e,Yxe),g=z1(),_=E6(),y=$5(p,m).needClip,b=x1(),x=EX(t=>Bxe(t,e.id,b))??{},S=x.points,C=x.isRange,w=x.baseLine,T=v5();if(g!==`horizontal`&&g!==`vertical`||T==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:v.createElement(cSe,d7({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:y,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var uSe=(e,t,n,r,i)=>{var a=n??t;if(kK(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function dSe(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=uSe(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=t1(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=t1(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>t1(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:a1({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:a1({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function fSe(e){var t=GJ(e,h7),n=x1();return v.createElement(Gye,{id:t.id,type:`area`},e=>v.createElement(v.Fragment,null,v.createElement(xye,{legendPayload:eSe(t)}),v.createElement(tSe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),v.createElement(Xye,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:$ue(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),v.createElement(lSe,d7({},t,{id:e}))))}var _7=v.memo(fSe,J1);_7.displayName=`Area`;var pSe=[`domain`,`range`],mSe=[`domain`,`range`];function v7(e,t){if(e==null)return{};var n,r,i=hSe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function hSe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function y7(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function b7(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=v7(e,pSe),a=t.domain,o=t.range,s=v7(t,mSe);return!y7(n,a)||!y7(r,o)?!1:J1(i,s)}var gSe=[`type`],_Se=[`dangerouslySetInnerHTML`,`ticks`,`scale`],vSe=[`id`,`scale`];function x7(){return x7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},x7.apply(null,arguments)}function S7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function C7(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?S7(Object(n),!0).forEach(function(t){ySe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ySe(e,t,n){return(t=bSe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bSe(e){var t=xSe(e,`string`);return typeof t==`symbol`?t:t+``}function xSe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function w7(e,t){if(e==null)return{};var n,r,i=SSe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function SSe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function CSe(e){var t=SX(),n=(0,v.useRef)(null),r=B1(),i=e.type,a=w7(e,gSe),o=I2(r,`xAxis`,i),s=(0,v.useMemo)(()=>{if(o!=null)return C7(C7({},a),{},{type:o})},[a,o]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(lbe(s)):n.current!==s&&t(ube({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t(dbe(n.current)),null)},[t]),null}var wSe=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=EX(b1),c=x1(),l=SX(),u=`xAxis`,d=EX(e=>k3(e,u,t,c)),f=EX(e=>Yhe(e,t)),p=EX(e=>ege(e,t)),m=EX(e=>_4(e,t));if((0,v.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||z8(i)||(0,v.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(gbe({id:t,height:n}))}}},[d,f,l,i,t,r,m]),f==null||p==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=w7(e,_Se);m.id,m.scale;var g=w7(m,vSe);return v.createElement(U5,x7({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:YG(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},TSe={allowDataOverflow:g4.allowDataOverflow,allowDecimals:g4.allowDecimals,allowDuplicatedCategory:g4.allowDuplicatedCategory,angle:g4.angle,axisLine:H5.axisLine,height:g4.height,hide:!1,includeHidden:g4.includeHidden,interval:g4.interval,label:!1,minTickGap:g4.minTickGap,mirror:g4.mirror,orientation:g4.orientation,padding:g4.padding,reversed:g4.reversed,scale:g4.scale,tick:g4.tick,tickCount:g4.tickCount,tickLine:H5.tickLine,tickSize:H5.tickSize,type:g4.type,niceTicks:g4.niceTicks,xAxisId:0},T7=v.memo(e=>{var t=GJ(e,TSe);return v.createElement(v.Fragment,null,v.createElement(CSe,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),v.createElement(wSe,t))},b7);T7.displayName=`XAxis`;var ESe=[`type`],DSe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],OSe=[`id`,`scale`];function E7(){return E7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},E7.apply(null,arguments)}function D7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function O7(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?D7(Object(n),!0).forEach(function(t){kSe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kSe(e,t,n){return(t=ASe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ASe(e){var t=jSe(e,`string`);return typeof t==`symbol`?t:t+``}function jSe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function k7(e,t){if(e==null)return{};var n,r,i=MSe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function MSe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function NSe(e){var t=SX(),n=(0,v.useRef)(null),r=B1(),i=e.type,a=k7(e,ESe),o=I2(r,`yAxis`,i),s=(0,v.useMemo)(()=>{if(o!=null)return O7(O7({},a),{},{type:o})},[o,a]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(fbe(s)):n.current!==s&&t(pbe({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t(mbe(n.current)),null)},[t]),null}function PSe(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=EX(b1),c=x1(),l=SX(),u=`yAxis`,d=EX(e=>nge(e,t)),f=EX(e=>tge(e,t)),p=EX(e=>k3(e,u,t,c)),m=EX(e=>b4(e,t));if((0,v.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||z8(i)||(0,v.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(hbe({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=k7(e,DSe);m.id,m.scale;var g=k7(m,OSe);return v.createElement(U5,E7({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:YG(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var FSe={allowDataOverflow:y4.allowDataOverflow,allowDecimals:y4.allowDecimals,allowDuplicatedCategory:y4.allowDuplicatedCategory,angle:y4.angle,axisLine:H5.axisLine,hide:!1,includeHidden:y4.includeHidden,interval:y4.interval,label:!1,minTickGap:y4.minTickGap,mirror:y4.mirror,orientation:y4.orientation,padding:y4.padding,reversed:y4.reversed,scale:y4.scale,tick:y4.tick,tickCount:y4.tickCount,tickLine:H5.tickLine,tickSize:H5.tickSize,type:y4.type,niceTicks:y4.niceTicks,width:y4.width,yAxisId:0},A7=v.memo(e=>{var t=GJ(e,FSe);return v.createElement(v.Fragment,null,v.createElement(NSe,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),v.createElement(PSe,t))},b7);A7.displayName=`YAxis`;var j7=$([(e,t)=>t,R1,Y2,r4,d6,p6,$ge,v1],o_e);function ISe(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function M7(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(ISe(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var N7=JQ(`mouseClick`),P7=K$();P7.startListening({actionCreator:N7,effect:(e,t)=>{var n=e.payload,r=j7(t.getState(),M7(n));r?.activeIndex!=null&&t.dispatch(dge({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var F7=JQ(`mouseMove`),I7=K$(),L7=null,R7=null,z7=null;I7.startListening({actionCreator:F7,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);L7!==null&&(cancelAnimationFrame(L7),L7=null),R7!==null&&(typeof i!=`number`||!o)&&(clearTimeout(R7),R7=null),z7=M7(n);var s=()=>{var e=t.getState(),n=F3(e,e.tooltip.settings.shared);if(!z7){L7=null,R7=null;return}if(n===`axis`){var r=j7(e,z7);r?.activeIndex==null?t.dispatch(B3()):t.dispatch(V3({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}L7=null,R7=null};if(!o){s();return}i===`raf`?L7=requestAnimationFrame(s):typeof i==`number`&&R7===null&&(R7=setTimeout(s,i))}});function LSe(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var B7={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},V7=g$({name:`rootProps`,initialState:B7,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??B7.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),RSe=V7.reducer,zSe=V7.actions.updateOptions,H7=g$({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}});H7.actions.updatePolarOptions;var BSe=H7.reducer,U7=JQ(`keyDown`),W7=JQ(`focus`),G7=JQ(`blur`),K7=K$(),q7=null,J7=null,Y7=null;K7.startListening({actionCreator:U7,effect:(e,t)=>{Y7=e.payload,q7!==null&&(cancelAnimationFrame(q7),q7=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);J7!==null&&(typeof r!=`number`||!a)&&(clearTimeout(J7),J7=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=Y7;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=q3(n,a6(e),U4(e),l6(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=p6(e),c=a6(e),l=F3(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=N6(e,l,`hover`,String(n.index));t.dispatch(U3({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=rge(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=U4(e),h=l6(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(q3(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(q3(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=N6(e,l,`hover`,String(p));t.dispatch(U3({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{q7=null,J7=null}};if(!a){o();return}r===`raf`?q7=requestAnimationFrame(o):typeof r==`number`&&J7===null&&(o(),Y7=null,J7=setTimeout(()=>{Y7?o():(J7=null,q7=null)},r))}}),K7.startListening({actionCreator:W7,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=N6(n,F3(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(U3({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),K7.startListening({actionCreator:G7,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(U3({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function X7(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var Z7=JQ(`externalEvent`),Q7=K$(),$7=new Map,e9=new Map,t9=new Map;Q7.startListening({actionCreator:Z7,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=X7(i);t9.set(a,{handler:r,reactEvent:o});var s=$7.get(a);s!==void 0&&(cancelAnimationFrame(s),$7.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=e9.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),e9.delete(a));var p=()=>{var e=t9.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:zge(i),activeDataKey:Lge(i),activeIndex:v6(i),activeLabel:y6(i),activeTooltipIndex:v6(i),isTooltipActive:Bge(i)};n&&n(o,r)}finally{$7.delete(a),e9.delete(a),t9.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);$7.set(a,m)}else if(typeof l==`number`){if(!e9.has(a)){p();var h=setTimeout(p,l);e9.set(a,h)}}else p()}}});var VSe=$([$([Z3],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),n9=JQ(`touchMove`),r9=K$(),i9=null,a9=null,o9=null,s9=null;r9.startListening({actionCreator:n9,effect:(e,t)=>{var n=e.payload;if(n.touches!=null&&n.touches.length!==0){s9=X7(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);i9!==null&&(cancelAnimationFrame(i9),i9=null),a9!==null&&(typeof i!=`number`||!o)&&(clearTimeout(a9),a9=null),o9=Array.from(n.touches).map(e=>M7({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(s9!=null){var e=t.getState(),n=F3(e,e.tooltip.settings.shared);if(n===`axis`){var r=o9?.[0];if(r==null){i9=null,a9=null;return}var i=j7(e,r);i?.activeIndex!=null&&t.dispatch(V3({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=s9.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(ode),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=r6(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=VSe(e,s,c);t.dispatch(uge({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}i9=null,a9=null}};if(!o){s();return}i===`raf`?i9=requestAnimationFrame(s):typeof i==`number`&&a9===null&&(s(),s9=null,a9=setTimeout(()=>{s9?s():(a9=null,i9=null)},i))}}});var c9={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},l9=g$({name:`eventSettings`,initialState:c9,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=UQ(t.payload.throttledEvents))}}}),HSe=l9.actions.setEventSettings,USe=l9.reducer,WSe=_Z({brush:Tbe,cartesianAxis:_be,chartData:M_e,errorBars:Fxe,eventSettings:USe,graphicalItems:Yye,layout:Kue,legend:Kde,options:O_e,polarAxis:uye,polarOptions:BSe,referenceElements:Obe,renderedTicks:$be,rootProps:RSe,tooltip:fge,zIndex:v_e}),GSe=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return o$({reducer:WSe,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([P7.middleware,I7.middleware,K7.middleware,Q7.middleware,r9.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(i$({type:`raf`}))},devTools:l0.devToolsEnabled&&{serialize:{replacer:LSe},name:`recharts-${t}`}})};function KSe(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=x1(),a=(0,v.useRef)(null);if(i)return n;a.current??=GSe(t,r);var o=yX;return v.createElement(ofe,{context:o,store:a.current},n)}function qSe(e){var t=e.layout,n=e.margin,r=SX(),i=x1();return(0,v.useEffect)(()=>{i||(r(Uue(t)),r(Hue(n)))},[r,i,t,n]),null}var JSe=(0,v.memo)(qSe,J1);function YSe(e){var t=SX();return(0,v.useEffect)(()=>{t(zSe(e))},[t,e]),null}var XSe=(0,v.memo)(e=>{var t=SX();return(0,v.useEffect)(()=>{t(HSe(e))},[t,e]),null},J1);function u9(e){var t=e.zIndex,n=e.isPanorama,r=(0,v.useRef)(null),i=SX();return(0,v.useLayoutEffect)(()=>(r.current&&i(g_e({zIndex:t,element:r.current,isPanorama:n})),()=>{i(__e({zIndex:t,isPanorama:n}))}),[i,t,n]),v.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function d9(e){var t=e.children,n=e.isPanorama,r=EX(c_e);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return v.createElement(v.Fragment,null,i.map(e=>v.createElement(u9,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>v.createElement(u9,{key:e,zIndex:e,isPanorama:n})))}var ZSe=[`children`];function QSe(e,t){if(e==null)return{};var n,r,i=$Se(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $Se(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function f9(){return f9=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f9.apply(null,arguments)}var eCe={width:`100%`,height:`100%`,display:`block`},tCe=(0,v.forwardRef)((e,t)=>{var n=I1(),r=L1(),i=h0();if(!Q$(n)||!Q$(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),v.createElement(lK,f9({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:eCe,ref:t}),a)}),nCe=e=>{var t=e.children,n=EX(C1);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return v.createElement(lK,{width:r,height:i,x:o,y:a},t)},p9=(0,v.forwardRef)((e,t)=>{var n=e.children,r=QSe(e,ZSe);return x1()?v.createElement(nCe,null,v.createElement(d9,{isPanorama:!0},n)):v.createElement(tCe,f9({ref:t},r),v.createElement(d9,{isPanorama:!1},n))});function rCe(e,t){return sCe(e)||oCe(e,t)||aCe(e,t)||iCe()}function iCe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
5520
5520
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aCe(e,t){if(e){if(typeof e==`string`)return m9(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m9(e,t):void 0}}function m9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function oCe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function sCe(e){if(Array.isArray(e))return e}function cCe(){var e=SX(),t=rCe((0,v.useState)(null),2),n=t[0],r=t[1],i=EX(ade);return(0,v.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;Z$(t)&&t!==i&&e(Gue(t))}},[n,e,i]),r}function h9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lCe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?h9(Object(n),!0).forEach(function(t){uCe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uCe(e,t,n){return(t=dCe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dCe(e){var t=fCe(e,`string`);return typeof t==`symbol`?t:t+``}function fCe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g9(){return g9=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g9.apply(null,arguments)}function _9(e,t){return gCe(e)||hCe(e,t)||mCe(e,t)||pCe()}function pCe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
5521
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mCe(e,t){if(e){if(typeof e==`string`)return v9(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v9(e,t):void 0}}function v9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hCe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function gCe(e){if(Array.isArray(e))return e}var _Ce=()=>(V_e(),null);function y9(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var vCe=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=_9((0,v.useState)({containerWidth:y9(e.style?.width),containerHeight:y9(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(H1,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,g9({ref:s},e)))}),yCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=_9((0,v.useState)({containerWidth:y9(n),containerHeight:y9(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(H1,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,g9({ref:c},e)))}),bCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(`div`,g9({ref:t},e)))}),xCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(yCe,g9({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(bCe,g9({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(`div`,g9({ref:t},e)))});function SCe(e){return e?vCe:xCe}var CCe=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0||b,S=(0,v.useRef)(null),C=SX(),w=_9((0,v.useState)(null),2),T=w[0],E=w[1],D=_9((0,v.useState)(null),2),O=D[0],k=D[1],A=cCe(),j=N1(),ee=j?.width>0?j.width:_,M=j?.height>0?j.height:i,N=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),te=(0,v.useCallback)(e=>{C(N7(e)),C(Z7({handler:a,reactEvent:e}))},[C,a]),P=(0,v.useCallback)(e=>{C(F7(e)),C(Z7({handler:l,reactEvent:e}))},[C,l]),F=(0,v.useCallback)(e=>{C(B3()),C(Z7({handler:u,reactEvent:e}))},[C,u]),ne=(0,v.useCallback)(e=>{C(F7(e)),C(Z7({handler:d,reactEvent:e}))},[C,d]),re=(0,v.useCallback)(()=>{C(W7())},[C]),ie=(0,v.useCallback)(()=>{C(G7())},[C]),ae=(0,v.useCallback)(e=>{C(U7(e.key))},[C]),oe=(0,v.useCallback)(e=>{C(Z7({handler:o,reactEvent:e}))},[C,o]),se=(0,v.useCallback)(e=>{C(Z7({handler:s,reactEvent:e}))},[C,s]),ce=(0,v.useCallback)(e=>{C(Z7({handler:c,reactEvent:e}))},[C,c]),le=(0,v.useCallback)(e=>{C(Z7({handler:f,reactEvent:e}))},[C,f]),ue=(0,v.useCallback)(e=>{C(Z7({handler:h,reactEvent:e}))},[C,h]),de=(0,v.useCallback)(e=>{x&&C(n9(e)),C(Z7({handler:m,reactEvent:e}))},[C,x,m]),fe=(0,v.useCallback)(e=>{C(Z7({handler:p,reactEvent:e}))},[C,p]),pe=SCe(y);return v.createElement(W6.Provider,{value:T},v.createElement(XK.Provider,{value:O},v.createElement(pe,{width:ee??g?.width,height:M??g?.height,className:YG(`recharts-wrapper`,r),style:lCe({position:`relative`,cursor:`default`,width:ee,height:M},g),onClick:te,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:P,onMouseLeave:F,onMouseMove:ne,onMouseUp:le,onTouchEnd:fe,onTouchMove:de,onTouchStart:ue,ref:N},v.createElement(_Ce,null),n)))}),wCe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function TCe(e,t){if(e==null)return{};var n,r,i=ECe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ECe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var DCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=tK(TCe(e,wCe));return c?v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(p9,{otherAttributes:d,title:l,desc:u},a)):v.createElement(CCe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(p9,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(Fbe,null,a)))});function b9(){return b9=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b9.apply(null,arguments)}function x9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OCe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x9(Object(n),!0).forEach(function(t){kCe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kCe(e,t,n){return(t=ACe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ACe(e){var t=jCe(e,`string`);return typeof t==`symbol`?t:t+``}function jCe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var MCe=OCe({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},c9),NCe=(0,v.forwardRef)(function(e,t){var n=GJ(e.categoricalChartProps,MCe),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return v.createElement(KSe,{preloadedState:{options:c},reduxStoreName:s.id??r},v.createElement(wbe,{chartData:s.data}),v.createElement(JSe,{layout:n.layout,margin:n.margin}),v.createElement(XSe,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(YSe,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(DCe,b9({},n,{ref:t})))}),PCe=[`axis`],FCe=(0,v.forwardRef)((e,t)=>v.createElement(NCe,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:PCe,tooltipPayloadSearcher:D_e,categoricalChartProps:e,ref:t}));function ICe(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=async()=>{try{let e=await Yr();t(e);let n=await gi();r(n),s(null)}catch(e){s(e.message||`Failed to sync budget consumption stats.`)}finally{a(!1)}},h=async(e=!1)=>{d(!0);try{l(await Xr(e)),p(null)}catch(e){p(e.message||`Failed to read provider billing data.`)}finally{d(!1)}};(0,v.useEffect)(()=>{m();let e=setInterval(m,5e3);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{h()},[]);let g=n?.budget?.budget?.daily_cap_usd??5,_=n?.budget?.budget?.weekly_cap_usd??25,y=n?.budget?.budget?.enabled!==!1,b=Math.min(100,(e?.dailyUsd||0)/g*100),x=Math.min(100,(e?.weeklyUsd||0)/_*100),S=e=>e>85?`var(--error)`:e>60?`var(--warning)`:`var(--success)`,C=(0,v.useMemo)(()=>{if(e?.timeseries&&Object.keys(e.timeseries).length>0){let t=e.timeseries;return Object.entries(t).map(([e,t])=>{let n={date:new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},r=0,i=0,a=0,o=0;for(let[,e]of Object.entries(t)){let t=e;t.provider===`gemini`?r+=t.cost:t.provider===`claude`?i+=t.cost:t.provider===`openrouter`?a+=t.cost:o+=t.cost}return n.gemini=+r.toFixed(3),n.claude=+i.toFixed(3),n.openrouter=+a.toFixed(3),n.codex=+o.toFixed(3),n})}return[]},[e]);return i?(0,B.jsxs)(`div`,{className:`page`,style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:[(0,B.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--text-tertiary)`,strokeWidth:`2.5`,style:{animation:`spin 1s linear infinite`,marginBottom:12},children:(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),(0,B.jsx)(`div`,{style:{color:`var(--text-secondary)`},children:`Aggregating token expenditures...`})]}):(0,B.jsxs)(`div`,{className:`page`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflowY:`auto`},children:[(0,B.jsxs)(`div`,{className:`page-header`,style:{marginBottom:24},children:[(0,B.jsx)(`h1`,{children:`Token & Budget Statistics`}),(0,B.jsx)(`p`,{children:`Monitor your token cost expenditure in real time against safety budget limits`})]}),(0,B.jsxs)(`div`,{style:{padding:`16px 20px`,marginBottom:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderLeft:`3px solid var(--accent)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:14},children:[(0,B.jsx)(`span`,{style:{fontSize:24},children:`🛡️`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`#fff`,letterSpacing:.3},children:`Local-first · Self-hosted`}),(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:2},children:`Memory and processing stay on your machine. No vendor lock-in.`})]})]}),o&&(0,B.jsxs)(`div`,{className:`badge badge-error`,style:{marginBottom:20,display:`inline-flex`,padding:`6px 12px`,background:`rgba(239, 68, 68, 0.1)`,border:`1px solid #ef4444`,color:`#f87171`},children:[`⚠️ `,o]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(340px, 1fr))`,gap:24,marginBottom:24},children:[(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:13,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:`Daily Expenditure`}),(0,B.jsxs)(`div`,{style:{fontSize:28,fontWeight:700,marginTop:4,color:`#fff`},children:[`$`,e?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`span`,{className:`badge`,style:{background:`var(--bg-elevated)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,fontSize:11},children:[`Cap: $`,g.toFixed(2)]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:11,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{children:`Consumption Ratio`}),(0,B.jsxs)(`span`,{children:[b.toFixed(1),`%`]})]}),(0,B.jsx)(`div`,{style:{height:6,background:`var(--bg-elevated)`,borderRadius:3,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{height:`100%`,width:`${b}%`,background:S(b),boxShadow:`0 0 8px ${S(b)}`,transition:`width 0.4s ease`}})})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,borderTop:`1px solid var(--border)`,paddingTop:10,marginTop:4},children:[`Status: `,y?`🛡️ Budget supervision active`:`⚠️ Limits unmonitored (disabled)`]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:13,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:`Weekly Expenditure`}),(0,B.jsxs)(`div`,{style:{fontSize:28,fontWeight:700,marginTop:4,color:`#fff`},children:[`$`,e?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`span`,{className:`badge`,style:{background:`var(--bg-elevated)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,fontSize:11},children:[`Cap: $`,_.toFixed(2)]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:11,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{children:`Consumption Ratio`}),(0,B.jsxs)(`span`,{children:[x.toFixed(1),`%`]})]}),(0,B.jsx)(`div`,{style:{height:6,background:`var(--bg-elevated)`,borderRadius:3,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{height:`100%`,width:`${x}%`,background:S(x),boxShadow:`0 0 8px ${S(x)}`,transition:`width 0.4s ease`}})})]}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,borderTop:`1px solid var(--border)`,paddingTop:10,marginTop:4},children:`Rolling window: Last 7 days in local system time`})]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:`Model Engine Spend breakdown`}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`,gap:20},children:[(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`♊`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Gemini CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.gemini/tmp`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(59, 130, 246, 0.1)`,color:`#60a5fa`,border:`1px solid rgba(59, 130, 246, 0.2)`},children:`Google API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.gemini?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.gemini?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.gemini?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🍊`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Claude Code CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.claude`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(239, 107, 107, 0.1)`,color:`#f87171`,border:`1px solid rgba(239, 107, 107, 0.2)`},children:`Anthropic API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.claude?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.claude?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.claude?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`💻`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Codex CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.codex/sessions`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(16, 185, 129, 0.1)`,color:`#34d399`,border:`1px solid rgba(16, 185, 129, 0.2)`},children:`OpenAI API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.codex?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.codex?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.codex?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🌐`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`OpenRouter`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(236, 72, 153, 0.1)`,color:`#f472b6`,border:`1px solid rgba(236, 72, 153, 0.2)`},children:`OR API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.openrouter?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.openrouter?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.openrouter?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🔎`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Tavily Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.tavily?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.tavily?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.tavily?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🦁`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Brave Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.brave?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.brave?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.brave?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`✨`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Exa Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.exa?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.exa?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.exa?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🔍`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Serper Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.serper?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.serper?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.serper?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]})]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:20},children:`30-Day Cost Trend`}),C.length===0?(0,B.jsx)(`div`,{style:{height:300,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-secondary)`},children:`No usage data available for the last 30 days.`}):(0,B.jsx)(Rde,{width:`100%`,height:300,children:(0,B.jsxs)(FCe,{data:C,margin:{top:5,right:20,left:0,bottom:5},children:[(0,B.jsxs)(`defs`,{children:[(0,B.jsxs)(`linearGradient`,{id:`gradGemini`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradClaude`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#e17055`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#e17055`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradOpenRouter`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#74b9ff`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#74b9ff`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradCodex`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#00cec9`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#00cec9`,stopOpacity:0})]})]}),(0,B.jsx)(X5,{strokeDasharray:`3 3`,stroke:`rgba(255,255,255,0.04)`}),(0,B.jsx)(T7,{dataKey:`date`,tick:{fontSize:11,fill:`var(--text-secondary)`},axisLine:{stroke:`var(--border)`},tickLine:!1}),(0,B.jsx)(A7,{tick:{fontSize:11,fill:`var(--text-secondary)`},axisLine:{stroke:`var(--border)`},tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,B.jsx)(eve,{contentStyle:{background:`#1a1a2e`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:8,fontSize:12,color:`#e8e8e8`},labelStyle:{color:`#fff`,fontWeight:600,marginBottom:4},formatter:(e,t)=>[`$${Number(e).toFixed(3)}`,String(t).charAt(0).toUpperCase()+String(t).slice(1)]}),(0,B.jsx)(t0,{wrapperStyle:{fontSize:12,color:`var(--text-secondary)`}}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`gemini`,stackId:`1`,stroke:`#3b82f6`,fill:`url(#gradGemini)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`claude`,stackId:`1`,stroke:`#e17055`,fill:`url(#gradClaude)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`openrouter`,stackId:`1`,stroke:`#74b9ff`,fill:`url(#gradOpenRouter)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`codex`,stackId:`1`,stroke:`#00cec9`,fill:`url(#gradCodex)`,strokeWidth:2})]})})]}),(0,B.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(220px, 1fr))`,gap:16,marginTop:24},children:[{name:`Gemini`,color:`#3b82f6`,emoji:`♊`,key:`gemini`},{name:`Claude`,color:`#e17055`,emoji:`🍊`,key:`claude`},{name:`OpenRouter`,color:`#74b9ff`,emoji:`🌐`,key:`openrouter`},{name:`Codex`,color:`#00cec9`,emoji:`💻`,key:`codex`},{name:`Tavily`,color:`#eab308`,emoji:`🔎`,key:`tavily`},{name:`Brave`,color:`#eab308`,emoji:`🦁`,key:`brave`},{name:`Exa`,color:`#eab308`,emoji:`✨`,key:`exa`},{name:`Serper`,color:`#eab308`,emoji:`🔍`,key:`serper`}].map(t=>{let n=e?.breakdown?.[t.key];return(0,B.jsxs)(`div`,{style:{background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderTop:`4px solid ${t.color}`,borderRadius:10,padding:20,display:`flex`,flexDirection:`column`,gap:12,transition:`transform 0.2s ease, box-shadow 0.2s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`translateY(-2px)`,e.currentTarget.style.boxShadow=`0 8px 24px ${t.color}22`},onMouseLeave:e=>{e.currentTarget.style.transform=`translateY(0)`,e.currentTarget.style.boxShadow=`none`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:20},children:t.emoji}),(0,B.jsx)(`span`,{style:{fontSize:14,fontWeight:700,color:`#fff`},children:t.name})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:t.color},children:[`$`,n?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:t.color},children:[`$`,n?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),n?.dailyTokens!=null&&(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:2,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Tokens (24h)`}),(0,B.jsx)(`span`,{children:n.dailyTokens.toLocaleString()})]})]})]},t.key)})}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:`Per-Model Breakdown`}),(0,B.jsx)(`div`,{style:{overflowX:`auto`},children:(0,B.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`,fontSize:12},children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{style:{borderBottom:`1px solid var(--border)`},children:[`Provider`,`Daily ($)`,`Weekly ($)`,`Daily Tokens`,`Weekly Tokens`].map(e=>(0,B.jsx)(`th`,{style:{textAlign:`left`,padding:`10px 12px`,fontSize:11,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:e},e))})}),(0,B.jsxs)(`tbody`,{children:[[{name:`Gemini`,key:`gemini`,color:`#3b82f6`},{name:`Claude`,key:`claude`,color:`#e17055`},{name:`Codex`,key:`codex`,color:`#00cec9`},{name:`OpenRouter`,key:`openrouter`,color:`#74b9ff`}].map((t,n)=>{let r=t.key===`openrouter`?e?.breakdown?.openrouter:e?.breakdown?.[t.key];return(0,B.jsxs)(`tr`,{style:{background:n%2==1?`rgba(255,255,255,0.02)`:`transparent`,borderBottom:`1px solid var(--border)`},children:[(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:600,color:t.color},children:t.name}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,color:`#fff`},children:[`$`,r?.dailyUsd?.toFixed(4)??`0.0000`]}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,color:`#fff`},children:[`$`,r?.weeklyUsd?.toFixed(4)??`0.0000`]}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`},children:r?.dailyTokens?.toLocaleString()||`—`}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`},children:r?.weeklyTokens?.toLocaleString()||`—`})]},t.key)}),(0,B.jsxs)(`tr`,{style:{borderTop:`2px solid var(--border)`,background:`rgba(108, 92, 231, 0.05)`},children:[(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:`Total`}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:[`$`,((e?.breakdown?.gemini?.dailyUsd||0)+(e?.breakdown?.claude?.dailyUsd||0)+(e?.breakdown?.codex?.dailyUsd||0)+(e?.breakdown?.openrouter?.dailyUsd||0)).toFixed(4)]}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:[`$`,((e?.breakdown?.gemini?.weeklyUsd||0)+(e?.breakdown?.claude?.weeklyUsd||0)+(e?.breakdown?.codex?.weeklyUsd||0)+(e?.breakdown?.openrouter?.weeklyUsd||0)).toFixed(4)]}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`var(--text-secondary)`},children:((e?.breakdown?.gemini?.dailyTokens||0)+(e?.breakdown?.claude?.dailyTokens||0)+(e?.breakdown?.codex?.dailyTokens||0)+(e?.breakdown?.openrouter?.dailyTokens||0)).toLocaleString()}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`var(--text-secondary)`},children:((e?.breakdown?.gemini?.weeklyTokens||0)+(e?.breakdown?.claude?.weeklyTokens||0)+(e?.breakdown?.codex?.weeklyTokens||0)+(e?.breakdown?.openrouter?.weeklyTokens||0)).toLocaleString()})]})]})]})})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,justifyContent:`space-between`,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,margin:0},children:`Reported by Provider`}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[c?.fetched_at&&(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[new Date(c.fetched_at).toLocaleString(),c.from_cache?` (cached)`:``]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{h(!0)},disabled:u,style:{fontSize:11,padding:`4px 10px`,borderRadius:6,border:`1px solid var(--border)`,background:`transparent`,color:`var(--text-secondary)`,cursor:u?`wait`:`pointer`},children:u?`Refreshing…`:`Refresh`})]})]}),f&&(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--error)`,marginBottom:12},children:f}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(260px, 1fr))`,gap:16},children:[Object.entries(c?.providers||{}).map(([e,t])=>(0,B.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderLeft:`3px solid ${t.state===`ok`?`var(--success)`:t.state===`error`?`var(--error)`:`var(--warning)`}`,borderRadius:8,padding:16},children:[(0,B.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:t.label}),t.state===`ok`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{fontSize:22,fontWeight:700,color:`#fff`},children:[`$`,(t.total_cost??0).toFixed(2)]}),(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginTop:4},children:[t.lifetime?`lifetime to date`:`last ${c?.window_days??30} days`,typeof t.balance==`number`?` · $${t.balance.toFixed(2)} remaining`:``]})]}):(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`,lineHeight:1.5},children:t.reason})]},e)),!c&&!f&&(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--text-tertiary)`},children:`Loading provider billing data…`})]})]})]})}function S9(e){return{label:e.label||``,provider:e.provider||``,repos:(e.repos||[]).join(`, `),subscription_tier:e.subscription_tier||``,monthly_cost_usd:e.monthly_cost_usd==null?``:String(e.monthly_cost_usd),monthly_cap_usd:e.monthly_cap_usd==null?``:String(e.monthly_cap_usd),api_docs_url:e.api_docs_url||``,headscale_url:e.headscale_url||``,rotate_every_days:e.rotate_every_days==null?``:String(e.rotate_every_days),auto_rotate:!!e.auto_rotate,notes:e.notes||``,project_path:e.project_path||``,tracking_exempt:!!e.tracking_exempt,shared_value_ok:!!e.shared_value_ok}}function LCe(e){let t=new Map;return e.forEach(e=>{let n=e.provider_name||e.provider;if(!n){let t=e.key.toLowerCase();n=t.includes(`smtp2go`)?`SMTP2GO`:t.includes(`stripe`)?`Stripe`:t.includes(`supabase`)?`Supabase`:t.includes(`openai`)?`OpenAI`:t.includes(`anthropic`)?`Anthropic`:t.includes(`github`)?`GitHub`:t.includes(`google`)?`Google`:t.includes(`aws`)?`AWS`:`Unknown`}let r=n.toLowerCase();t.has(r)||t.set(r,{id:r,label:n.toUpperCase(),kind:`provider`,keys:[]}),t.get(r).keys.push(e)}),[...t.values()].sort((e,t)=>e.id===`unknown`?1:t.id===`unknown`?-1:e.id.localeCompare(t.id))}function C9({provider:e}){let[t,n]=(0,v.useState)(!1);if(!e)return null;let r=e.toLowerCase().replace(/[^a-z0-9]/g,``),i={width:14,height:14,flexShrink:0,borderRadius:2},a={openai:`10a37f`,anthropic:`d97757`,google:`4285F4`,github:`181717`,supabase:`3ECF8E`,elevenlabs:`000000`,sendgrid:`00B3E3`,digitalocean:`0080FF`,aws:`232F3E`,gcp:`4285F4`,stripe:`008CDD`,mailcow:`FFC107`,resend:`000000`},o=r in a,s=a[r]||`64748b`;return t||!o?(0,B.jsx)(`span`,{style:{...i,background:`#`+s,color:`#fff`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontSize:9,fontWeight:`bold`,verticalAlign:`middle`},children:e.charAt(0).toUpperCase()}):(0,B.jsx)(`img`,{src:`https://cdn.simpleicons.org/${r}/${s}`,style:{...i,verticalAlign:`middle`,display:`inline-block`},alt:e,onError:()=>n(!0)})}function RCe(){let[e,t]=(0,v.useState)(`catalog`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(``),[C,w]=(0,v.useState)(`repo`),[T,E]=(0,v.useState)(null),D=(0,v.useRef)(null),[O,k]=(0,v.useState)({label:``,provider:``,repos:``,subscription_tier:``,monthly_cost_usd:``,monthly_cap_usd:``,api_docs_url:``,headscale_url:``,rotate_every_days:``,auto_rotate:!1,notes:``,project_path:``,tracking_exempt:!1,shared_value_ok:!1}),[A,j]=(0,v.useState)(!1),[ee,M]=(0,v.useState)(``),[N,te]=(0,v.useState)(!1),[P,F]=(0,v.useState)(``),[ne,re]=(0,v.useState)(new Set),[ie,ae]=(0,v.useState)(!1),[oe,se]=(0,v.useState)(!1),[ce,le]=(0,v.useState)(!1),[ue,de]=(0,v.useState)(null),[fe,pe]=(0,v.useState)(null),[me,he]=(0,v.useState)(``),[ge,_e]=(0,v.useState)(!1),[ve,ye]=(0,v.useState)([]),[be,xe]=(0,v.useState)(``),[I,Se]=(0,v.useState)(null),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)([]),[L,De]=(0,v.useState)(new Set),[Oe,ke]=(0,v.useState)(!1),[Ae,je]=(0,v.useState)(``),[Me,Ne]=(0,v.useState)(``),[Pe,Fe]=(0,v.useState)([]),[Ie,Le]=(0,v.useState)(null),[Re,ze]=(0,v.useState)(!1),[Be,Ve]=(0,v.useState)([{time:new Date().toLocaleTimeString(),event:`Secrets system initialized`,status:`info`}]),He=(0,v.useCallback)(async()=>{try{let e=await bi();Fe(e.nodes||[]),Le(e.localChecksum)}catch(e){b(e instanceof Error?e.message:`Failed to load sync status`)}},[]),Ue=async()=>{ze(!0),b(null);let e=new Date().toLocaleTimeString();Ve(t=>[{time:e,event:`Initiating mesh secrets synchronization...`,status:`info`},...t]);try{let e=await yi(),t=`Mesh sync complete: ${e.results.filter(e=>e.success).length}/${e.results.length} nodes responded successfully.`;Ve(e=>[{time:new Date().toLocaleTimeString(),event:t,status:`success`},...e]),await He()}catch(e){let t=`Sync trigger failed: ${e instanceof Error?e.message:String(e)}`;Ve(e=>[{time:new Date().toLocaleTimeString(),event:t,status:`error`},...e]),b(e instanceof Error?e.message:`Failed to trigger synchronization`)}finally{ze(!1)}},We=async e=>{if(e.preventDefault(),!Ae.trim()||!Me.trim()){b(`Key name and secret value are required`);return}te(!0),b(null);try{let e=O.repos?O.repos.split(`,`).map(e=>e.trim()).filter(Boolean):[];await vi(Ae.trim(),Me.trim(),{provider:O.provider||`openai`,scope:O.repos?`project`:`global`,repos:e,subscription_tier:O.subscription_tier||void 0,monthly_cost_usd:O.monthly_cost_usd?parseFloat(O.monthly_cost_usd):void 0,monthly_cap_usd:O.monthly_cap_usd?parseFloat(O.monthly_cap_usd):void 0,api_docs_url:O.api_docs_url||void 0,headscale_url:O.provider.trim().toLowerCase()===`headscale`&&O.headscale_url||void 0,rotate_every_days:O.rotate_every_days?parseInt(O.rotate_every_days,10):void 0,auto_rotate:!!O.auto_rotate,notes:O.notes||void 0,project_path:O.project_path||void 0,label:O.label||void 0}),ke(!1),je(``),Ne(``),await Ge()}catch(e){b(e instanceof Error?e.message:`Failed to create secret`)}finally{te(!1)}};(0,v.useEffect)(()=>{e===`sync`&&setTimeout(()=>void He(),0)},[e,He]);let Ge=(0,v.useCallback)(async()=>{_(!0),b(null);try{try{let e=await gi();e.secrets||={},e.brain||={},r(e);let t=await ai().catch(()=>[]);a(t);let n=await oi().catch(()=>[]);s(n);let i=await si().catch(()=>[]);l(i);let o=await ci().catch(()=>[]);d(o)}catch{}let e=await kr();h(e);let t=D.current;if(t){let n=e.keys.find(e=>e.key===t);E(n||null),n?k(S9(n)):D.current=null}}catch(e){b(e.message)}finally{_(!1)}},[]),Ke=(0,v.useCallback)(async()=>{try{let e=await Cr();ye(e.keys||[])}catch{}},[]),qe=(0,v.useCallback)(async()=>{try{de(await Rr())}catch{de(null)}},[]);(0,v.useEffect)(()=>{setTimeout(()=>{Ge(),Ke(),qe()},0)},[Ge,Ke,qe]);let Je=(e,t)=>{n&&r({...n,secrets:{...n.secrets,[e]:t}})},Ye=(e,t)=>{n&&r({...n,brain:{...n.brain,[e]:t}})},Xe=async()=>{if(n){te(!0),b(null),p(null);try{await _i(n),p(`Configuration saved successfully. Kernel will hot-reload settings.`),setTimeout(()=>p(null),4e3)}catch(e){b(e.message||`Failed to save configuration.`)}finally{te(!1)}}};function Ze(e,t){D.current=e.key,E(e),k(S9(e)),M(``),F(``),pe(null),he(``),t&&re(e=>{let n=new Set(e);return n.add(t),n})}async function Qe(){if(!NG()){b(`This browser does not support passkeys / WebAuthn`);return}_e(!0),b(null);try{await Br(await HG({optionsJSON:await zr()}),`Touch ID / platform`),await qe(),F(`Passkey registered — use it to reveal secret values`)}catch(e){b(e.message||`Passkey registration cancelled`)}finally{_e(!1)}}async function $e(){return(await Hr(await qG({optionsJSON:await Vr()}))).step_up_token}async function et(){if(!me.trim())throw Error(`Enter dashboard password`);let e=await Ur(me);return he(``),e.step_up_token}async function tt(e){if(T){_e(!0),b(null),pe(null);try{let t=e===`passkey`?await $e():await et(),n=await Lr(T.key,t);pe(n.value),F(`Revealed ${T.key} (auto-hides in 30s)`),window.setTimeout(()=>pe(null),3e4)}catch(e){b(e.message)}finally{_e(!1)}}}async function nt(){if(fe)try{await navigator.clipboard.writeText(fe),F(`Copied to clipboard`)}catch{b(`Clipboard copy failed`)}}function rt(e){re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function it(e){re(new Set([e]))}function at(e){re(new Set(e))}function ot(){re(new Set)}async function st(){if(T){te(!0),F(``);try{let e=O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean);if(e.length>1){b(`Each key may bind to only ONE repo (you entered ${e.length}: ${e.join(`, `)}). Pick one product repo, or leave empty for Developer secrets (tooling).`),te(!1);return}let t={label:O.label.trim()||null,provider:O.provider.trim()||null,repos:e,subscription_tier:O.subscription_tier.trim()||null,monthly_cost_usd:O.monthly_cost_usd.trim()===``?null:Number(O.monthly_cost_usd),monthly_cap_usd:O.monthly_cap_usd.trim()===``?null:Number(O.monthly_cap_usd),api_docs_url:O.api_docs_url.trim()||null,headscale_url:O.provider.trim().toLowerCase()===`headscale`&&O.headscale_url.trim()||null,rotate_every_days:O.rotate_every_days.trim()===``?null:Number(O.rotate_every_days),auto_rotate:!!O.auto_rotate,notes:O.notes.trim()||null,project_path:O.project_path.trim()||null,tracking_exempt:!!O.tracking_exempt,shared_value_ok:!!O.shared_value_ok};O.tracking_exempt&&(t.tracking_status=`exempt`),await jr(T.key,t),F(`Metadata saved`),await Ge()}catch(e){b(e.message)}finally{te(!1)}}}async function ct(){if(!(!T||!ee)){te(!0);try{let e=await Mr(T.key,ee,{export_env:!0,export_all:!0});M(``);let t=e.exports?.filter(e=>e.ok).length??0;F(t>0?`Rotated ${T.key} · exported .env to ${t} target(s)`:`Rotated ${T.key} · store updated (no project paths matched — bind --repo or Export .env)`),await Ge()}catch(e){b(e.message)}finally{te(!1)}}}async function lt(){if(T&&confirm(`Delete secret ${T.key}?`))try{await Nr(T.key),E(null),D.current=null,await Ge()}catch(e){b(e.message)}}async function ut(){if(T)try{await Pr({key_ref:T.key,provider:T.provider||`unknown`,cost_usd:.01,model:`manual-sample`,source:`dashboard`}),F(`Sample usage event recorded ($0.01)`),await Ge()}catch(e){b(e.message)}}async function dt(){try{let e=await Er();Ee(e.candidates||[]),De(new Set((e.candidates||[]).filter(e=>!e.already_set).map(e=>e.key))),t(`import`)}catch(e){b(e.message)}}async function ft(){try{let e=await Or({keys:[...L]});F(`Imported ${e.imported_count}, skipped ${e.skipped_count}`),await Ge(),t(`catalog`)}catch(e){b(e.message)}}let pt=(m?.keys||[]).filter(e=>{if(!x.trim())return!0;let t=x.toLowerCase();return e.key.toLowerCase().includes(t)||(e.provider||``).toLowerCase().includes(t)||(e.repos||[]).some(e=>e.toLowerCase().includes(t))||(e.label||``).toLowerCase().includes(t)}),mt=(0,v.useMemo)(()=>{if(!m?.keys)return[];let e=x.toLowerCase(),t=m.keys.filter(t=>t.key.toLowerCase().includes(e)||(t.provider||``).toLowerCase().includes(e)||(t.repos||[]).some(t=>t.toLowerCase().includes(e))||(t.label||``).toLowerCase().includes(e));return C===`api`?LCe(t):UCe(t)},[m,x,C]);(0,v.useEffect)(()=>{if(ie||!mt.length)return;let e=new Set;for(let t of mt)t.kind===`error`&&e.add(t.id);let t=mt.find(e=>e.kind!==`error`);t&&e.add(t.id),re(e),ae(!0)},[mt,ie]);let ht=m?.summary;return(0,B.jsxs)(`div`,{className:`page`,style:{maxWidth:T?1400:1100},children:[(0,B.jsxs)(`div`,{className:`page-header`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,flexWrap:`wrap`,gap:12,marginBottom:12},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{style:{marginBottom:4},children:`Secrets & Access`}),(0,B.jsx)(`p`,{style:{margin:0,fontSize:13,color:`var(--text-secondary)`},children:`Provider keys (SSOT) · one key → one repo · empty repo = Developer secrets · PATs separate`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:async()=>{try{let e=await Fr({all_projects:!0}),t=e.results?.filter(e=>e.ok).length??e.count??0;F(`Exported .env to ${t} project(s) from secrets store`)}catch(e){b(e.message)}},children:`Export .env → projects`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:async()=>{try{let e=await Ir(),t=e.tasks?.filter(e=>e.status===`created`).length??0,n=e.tasks?.filter(e=>e.status===`exists`).length??0;F(`Rotation queue: ${e.due??0} due · ${t} task(s) created · ${n} already pending`),await Ge()}catch(e){b(e.message)}},children:`Enqueue rotations`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void dt(),children:`Migrate import`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:A,onClick:async()=>{j(!0),b(null);try{let e=await Ar({strict:!0});F(e.healthy?`Account sync OK — ${e.ok??0}/${e.total??0} tracked`:`Account sync: ${e.errors??`?`} tracking error(s) — ${e.message||`see catalog`}`),e.healthy||b(e.message||`Tracking errors remain after account-sync`),await Ge()}catch(e){b(e.message)}finally{j(!1)}},children:A?`Syncing accounts…`:`Sync provider accounts`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void Ge(),children:`Refresh`})]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginBottom:10,fontSize:11},onClick:()=>se(e=>!e),children:oe?`▾ Hide model notes`:`▸ How secrets work`}),oe&&(0,B.jsx)(`div`,{className:`card`,style:{padding:12,marginBottom:12,fontSize:12,color:`var(--text-secondary)`,lineHeight:1.5,borderColor:`var(--border-accent)`},children:(0,B.jsxs)(`ul`,{style:{margin:0,paddingLeft:18},children:[(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`SSOT`}),` — keys in TR store; `,(0,B.jsx)(`strong`,{children:`export-env`}),` writes repo `,(0,B.jsx)(`code`,{children:`.env`}),`.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`One key → one product repo`}),`; multi-repo is an error. Empty = Developer secrets (tooling).`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`import-env`}),` = one-time migrate. `,(0,B.jsx)(`strong`,{children:`PATs`}),` = brain API tokens only.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Account tracking`}),` — every billable key must have live account/usage/subscription data or an explicit tracking exempt + monthly cost.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Shared values`}),` — same credential material under multiple key names/apps is an error; issue a unique API key per app, then rotate each secret name.`]})]})}),y&&(0,B.jsxs)(`div`,{className:`badge badge-error`,style:{marginBottom:16,display:`block`,padding:12},children:[y,(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginLeft:12},onClick:()=>b(null),children:`Dismiss`})]}),P&&(0,B.jsx)(`div`,{style:{marginBottom:12,fontSize:13,color:`#34d399`},children:P}),m?.store&&(0,B.jsxs)(`div`,{style:{marginBottom:12,fontSize:11,color:`var(--text-tertiary)`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,wordBreak:`break-all`},children:[`Store (global SSOT — not filtered by brain selector): `,m.store,typeof m?.summary?.total_keys==`number`?` · ${m.summary.total_keys} keys`:``]}),ht&&(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(140px, 1fr))`,gap:12,marginBottom:20},children:[(0,B.jsx)(w9,{label:`Keys`,value:String(ht.total_keys),accent:`#60a5fa`}),(0,B.jsx)(w9,{label:`Providers`,value:String(ht.providers_active),accent:`#a78bfa`}),(0,B.jsx)(w9,{label:`Planned / mo`,value:`$${(ht.monthly_subscription_usd||0).toFixed(0)}`,accent:`#fbbf24`}),(0,B.jsx)(w9,{label:`Usage 30d`,value:`$${(ht.usage_30d?.cost_usd||0).toFixed(2)}`,accent:`#34d399`}),(0,B.jsx)(w9,{label:`Usage 7d`,value:`$${(ht.usage_7d?.cost_usd||0).toFixed(2)}`,accent:`#22d3ee`}),(0,B.jsx)(w9,{label:`Rotate due`,value:String(ht.rotation_overdue||0),accent:ht.rotation_overdue?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Multi-repo errors`,value:String(ht.multi_repo_violations||0),accent:ht.multi_repo_violations?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Shared keys`,value:String(ht.shared_value_groups||0),accent:ht.shared_value_healthy===!1?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Tracking errors`,value:String(ht.tracking_errors||0),accent:ht.tracking_healthy===!1?`#f87171`:`#34d399`}),(0,B.jsx)(w9,{label:`Developer`,value:String(ht.developer_keys||0),accent:`#a78bfa`})]}),(ht?.multi_repo_violations||0)>0&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(248,113,113,0.5)`,background:`rgba(248,113,113,0.08)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsx)(`strong`,{style:{color:`#f87171`},children:`Multi-repo binding error`}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 0`,color:`var(--text-secondary)`},children:[ht?.multi_repo_violations,` key(s) are bound to more than one repo. Each secret must be unique to a single product repo, or left unbound as a `,(0,B.jsx)(`strong`,{children:`Developer secret`}),` `,`(tooling / personal). Fix in the red “Needs fix” section below — set `,(0,B.jsx)(`em`,{children:`one`}),` repo or clear the field.`]})]}),ht?.shared_value_healthy===!1&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(251,146,60,0.55)`,background:`rgba(251,146,60,0.1)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsxs)(`strong`,{style:{color:`#fb923c`},children:[`Shared credential values — `,ht.shared_value_groups||0,` group(s) ·`,` `,ht.shared_value_keys||0,` key(s)`]}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 8px`,color:`var(--text-secondary)`},children:[`The same API key material is stored under multiple secret names and/or apps. Issue a`,` `,(0,B.jsx)(`strong`,{children:`unique key per app`}),` in the vendor console, then rotate each secret name. CLI: `,(0,B.jsx)(`code`,{children:`npx total-recall secret shared`})]}),(ht.shared_value_errors||[]).slice(0,8).map(e=>(0,B.jsxs)(`div`,{style:{fontSize:11,fontFamily:`ui-monospace, monospace`,marginBottom:6,color:`var(--text-secondary)`},children:[(0,B.jsxs)(`span`,{style:{color:`#fb923c`},children:[`fp `,e.fingerprint||`—`]}),` · apps [`,(e.apps||[]).join(`, `),`] · `,(e.keys||[]).join(`, `)]},e.fingerprint||(e.keys||[]).join(`,`)))]}),ht?.tracking_healthy===!1&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(248,113,113,0.5)`,background:`rgba(248,113,113,0.08)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsxs)(`strong`,{style:{color:`#f87171`},children:[`Account / usage tracking errors — `,ht.tracking_errors||0]}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 8px`,color:`var(--text-secondary)`},children:[`Every set credential must be tracked (live provider account/usage API) or explicitly exempt with a monthly cost. Run `,(0,B.jsx)(`strong`,{children:`Sync provider accounts`}),` or CLI`,` `,(0,B.jsx)(`code`,{children:`npx total-recall secret account-sync`}),`.`]}),(ht.tracking_error_keys||[]).slice(0,10).map(e=>(0,B.jsxs)(`div`,{style:{fontSize:11,fontFamily:`ui-monospace, monospace`,marginBottom:4,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{style:{color:`#f87171`},children:e.key}),e.provider?` (${e.provider})`:``,`: `,(e.error||``).slice(0,120)]},e.key))]}),m?.by_provider&&m.by_provider.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginBottom:8,fontSize:11},onClick:()=>le(e=>!e),children:ce?`▾ Hide cost chart`:`▸ Cost by provider`}),ce&&(0,B.jsx)(`div`,{className:`card`,style:{marginBottom:12,padding:12},children:(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:m.by_provider.map(e=>{let t=Math.max(...m.by_provider.map(e=>e.cost_30d+e.monthly_cost),1),n=e.cost_30d+e.monthly_cost,r=Math.min(100,n/t*100);return(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`100px 1fr 80px`,gap:10,alignItems:`center`},children:[(0,B.jsx)(`span`,{style:{fontSize:12,fontWeight:600},children:e.provider}),(0,B.jsx)(`div`,{style:{height:6,background:`rgba(148,163,184,0.12)`,borderRadius:99,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{width:`${r}%`,height:`100%`,background:`linear-gradient(90deg, #3b82f6, #22d3ee)`,borderRadius:99}})}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,textAlign:`right`},children:[`$`,n.toFixed(2),` · `,e.keys,`k`]})]},e.provider)})})})]}),(0,B.jsx)(`div`,{style:{display:`flex`,gap:8,marginBottom:12,flexWrap:`wrap`},children:[{id:`catalog`,label:`Provider secrets (env)`},{id:`import`,label:`Import from env`},{id:`cloud`,label:`Cloud Models (API)`},{id:`pats`,label:`TR PATs (key generator)`},{id:`sync`,label:`Mesh Sync Status`}].map(n=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`btn btn-sm ${e===n.id?`btn-primary`:`btn-ghost`}`,children:n.label},n.id))}),e===`usage`&&(0,B.jsx)(`div`,{style:{height:`calc(100vh - 280px)`,minHeight:420,position:`relative`,overflowY:`auto`},children:(0,B.jsx)(ICe,{})}),e===`catalog`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`calc(100vh - 280px)`,minHeight:420,marginRight:T||Oe?440:0,transition:`margin 0.15s ease`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`center`,marginBottom:16,flexWrap:`wrap`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,background:`var(--bg-tertiary)`,borderRadius:6,padding:2},children:[(0,B.jsx)(`button`,{onClick:()=>w(`repo`),style:{padding:`4px 10px`,fontSize:11,fontWeight:500,borderRadius:4,cursor:`pointer`,border:`none`,background:C===`repo`?`var(--bg-active)`:`transparent`,color:C===`repo`?`var(--text-primary)`:`var(--text-secondary)`},children:`By Repo`}),(0,B.jsx)(`button`,{onClick:()=>w(`api`),style:{padding:`4px 10px`,fontSize:11,fontWeight:500,borderRadius:4,cursor:`pointer`,border:`none`,background:C===`api`?`var(--bg-active)`:`transparent`,color:C===`api`?`var(--text-primary)`:`var(--text-secondary)`},children:`By API`})]}),(0,B.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),placeholder:`Filter key, provider, repo, tier…`,style:{flex:`1 1 200px`,minWidth:160,padding:`8px 12px`,borderRadius:10,border:`1px solid var(--border)`,background:`var(--bg-primary)`,color:`var(--text-primary)`,outline:`none`}}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,style:{padding:`8px 16px`,fontSize:13,borderRadius:10,cursor:`pointer`},onClick:()=>{E(null),ke(!0),k({label:``,provider:`openai`,repos:``,subscription_tier:``,monthly_cost_usd:``,monthly_cap_usd:``,api_docs_url:``,headscale_url:``,rotate_every_days:``,auto_rotate:!1,notes:``,project_path:``,tracking_exempt:!1,shared_value_ok:!1}),je(``),Ne(``)},children:`+ Create Secret`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`center`,marginBottom:8,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:11},onClick:()=>at(mt.map(e=>e.id)),children:`Expand all`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:11},onClick:ot,children:`Collapse all`}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[pt.length,` shown`,T?` · editing ${T.key}`:``]})]}),mt.length>0&&(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginBottom:8,flexShrink:0,maxHeight:72,overflowY:`auto`},children:mt.map(e=>{let t=ne.has(e.id);return(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-sm`,style:{fontSize:11,padding:`4px 10px`,background:t?e.kind===`error`?`rgba(248,113,113,0.2)`:`rgba(59,130,246,0.18)`:`transparent`,borderColor:e.kind===`error`?`rgba(248,113,113,0.45)`:t?`var(--border-accent)`:`var(--border)`,color:e.kind===`error`?`#f87171`:`var(--text-primary)`,display:`inline-flex`,alignItems:`center`},onClick:()=>{t&&ne.size===1?at(mt.map(e=>e.id)):it(e.id)},title:t?`Currently expanded`:`Expand this repo only`,children:[t?`▾ `:`▸ `,C===`api`&&(0,B.jsx)(C9,{provider:e.id}),e.label,(0,B.jsx)(`span`,{style:{marginLeft:6,opacity:.7},children:e.keys.length})]},`chip-${e.id}`)})}),g&&!m?(0,B.jsx)(`p`,{style:{color:`var(--text-tertiary)`},children:`Loading catalog…`}):pt.length===0?(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,textAlign:`center`,color:`var(--text-secondary)`},children:[(0,B.jsxs)(`p`,{style:{marginBottom:12},children:[`No provider secrets in the global store`,x?` matching “${x}”`:``,`.`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void dt(),children:`Scan / migrate import`})]}):(0,B.jsx)(`div`,{className:`card`,style:{flex:1,minHeight:0,overflowY:`auto`,padding:0,display:`flex`,flexDirection:`column`},children:mt.map(e=>{let t=ne.has(e.id);return(0,B.jsxs)(`section`,{style:{borderBottom:`1px solid var(--border)`,background:e.kind===`error`?`rgba(248,113,113,0.04)`:e.kind===`developer`?`rgba(167,139,250,0.04)`:void 0},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>rt(e.id),style:{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 14px`,background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsxs)(`div`,{style:{fontSize:13,fontWeight:700,color:e.kind===`error`?`#f87171`:`var(--text-primary)`},children:[t?`▾`:`▸`,` `,C===`api`&&(0,B.jsx)(C9,{provider:e.id}),` `,e.label]}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginTop:2},children:e.kind===`error`?`Fix: one repo only, or clear for Developer secrets`:e.kind===`developer`?`Tooling / unbound`:e.kind===`provider`?[...new Set(e.keys.flatMap(e=>e.repos||[]))].join(`, `)||`Global`:`Product repo`})]}),(0,B.jsx)(`span`,{style:{fontSize:11,fontWeight:600,flexShrink:0,padding:`2px 8px`,borderRadius:99,background:e.kind===`error`?`rgba(248,113,113,0.15)`:`rgba(148,163,184,0.12)`,color:e.kind===`error`?`#f87171`:`var(--text-secondary)`},children:e.keys.length})]}),t&&(0,B.jsx)(`div`,{style:{padding:`0 8px 8px`},children:e.keys.map(t=>(0,B.jsx)(WCe,{k:t,selected:T?.key===t.key,onOpen:()=>Ze(t,e.id),groupBy:C},`${e.id}::${t.key}`))})]},e.id)})}),(T||Oe)&&(0,B.jsxs)(`div`,{role:`dialog`,"aria-label":T?`Edit ${T.key}`:`Create Secret`,style:{position:`fixed`,top:0,right:0,bottom:0,width:`min(420px, 100vw)`,zIndex:80,background:`var(--bg-secondary, #0f1419)`,borderLeft:`1px solid var(--border)`,boxShadow:`-12px 0 40px rgba(0,0,0,0.35)`,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,B.jsxs)(`div`,{style:{flexShrink:0,padding:`14px 16px`,borderBottom:`1px solid var(--border)`,display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:10,background:`rgba(0,0,0,0.2)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.06em`},children:T?`Edit secret`:`Create secret`}),(0,B.jsx)(`strong`,{style:{fontFamily:`ui-monospace, monospace`,fontSize:13,wordBreak:`break-all`,display:`block`,marginTop:2},children:T?T.key:`New Secret`}),T&&(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginTop:4},children:[T.masked||`••••`,T.subscription_tier?` · ${T.subscription_tier}`:``,T.monthly_cost_usd==null?``:` · $${T.monthly_cost_usd}/mo`]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{E(null),D.current=null,ke(!1)},children:`✕`})]}),(0,B.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:16},children:[Oe&&(0,B.jsxs)(`form`,{onSubmit:e=>{We(e)},style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(T9,{title:`Credentials`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:`secret-key-name`,className:`field-label`,style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`},children:`Secret Key Name`}),(0,B.jsx)(`input`,{id:`secret-key-name`,className:`input font-mono`,placeholder:`e.g. OPENAI_API_KEY`,value:Ae,onChange:e=>je(e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,width:`100%`,marginTop:4,boxSizing:`border-box`},required:!0})]}),(0,B.jsxs)(`div`,{style:{marginTop:12},children:[(0,B.jsx)(`label`,{htmlFor:`secret-value`,className:`field-label`,style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`},children:`Secret Value`}),(0,B.jsx)(`input`,{id:`secret-value`,type:`password`,className:`input`,placeholder:`Enter credential value`,value:Me,onChange:e=>Ne(e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,width:`100%`,marginTop:4,boxSizing:`border-box`},required:!0})]})]}),(0,B.jsxs)(T9,{title:`Identity`,children:[(0,B.jsx)(E9,{label:`Label`,value:O.label,onChange:e=>k({...O,label:e})}),(0,B.jsx)(E9,{label:`Provider`,value:O.provider,onChange:e=>k({...O,provider:e})})]}),(0,B.jsxs)(T9,{title:`Binding (one repo max)`,children:[(0,B.jsx)(E9,{label:`Product repo (exactly one name, or empty = Developer secrets)`,value:O.repos,onChange:e=>k({...O,repos:e})}),O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean).length>1&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:`Error: only one repo allowed. Remove extras before save.`}),(0,B.jsx)(E9,{label:`Project path (optional)`,value:O.project_path,onChange:e=>k({...O,project_path:e})})]}),(0,B.jsxs)(T9,{title:`Subscription & cost`,children:[(0,B.jsx)(E9,{label:`Subscription level / tier`,value:O.subscription_tier,onChange:e=>k({...O,subscription_tier:e}),placeholder:`e.g. free, pro, team, enterprise, payg`}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10,marginBottom:4},children:[(0,B.jsx)(E9,{label:`Monthly cost $`,value:O.monthly_cost_usd,onChange:e=>k({...O,monthly_cost_usd:e}),placeholder:`20`}),(0,B.jsx)(E9,{label:`Monthly cap $ (budget)`,value:O.monthly_cap_usd,onChange:e=>k({...O,monthly_cap_usd:e}),placeholder:`100`})]})]}),(0,B.jsxs)(T9,{title:`Docs & rotation`,children:[O.provider.trim().toLowerCase()===`headscale`&&(0,B.jsx)(E9,{label:`Headscale HTTPS URL`,value:O.headscale_url,onChange:e=>k({...O,headscale_url:e}),placeholder:`https://headscale.example.com`}),(0,B.jsx)(E9,{label:`API docs URL`,value:O.api_docs_url,onChange:e=>k({...O,api_docs_url:e})}),(0,B.jsx)(E9,{label:`Rotate every (days)`,value:O.rotate_every_days,onChange:e=>k({...O,rotate_every_days:e})}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:10},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.auto_rotate,onChange:e=>k({...O,auto_rotate:e.target.checked})}),`Auto-rotate when due`]}),(0,B.jsx)(E9,{label:`Notes`,value:O.notes,onChange:e=>k({...O,notes:e})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,style:{flex:1},disabled:N,children:N?`Creating...`:`Create Secret`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ke(!1),children:`Cancel`})]})]}),T&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(T9,{title:`Reveal value (passkey)`,hint:`Full secret values require step-up auth — passkey preferred, password fallback`,children:[(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginBottom:8},children:[`Passkeys: `,ue?.count??0,!NG()&&` · browser unsupported`]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginBottom:10},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:ge||!NG(),onClick:()=>void Qe(),children:ue?.has_passkeys?`Add another passkey`:`Register passkey (Touch ID)`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:ge||!ue?.has_passkeys,onClick:()=>void tt(`passkey`),children:`Reveal with passkey`}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,flex:1},children:(0,B.jsx)(`input`,{type:`password`,value:me,onChange:e=>he(e.target.value),placeholder:`Or re-enter dashboard password`,style:{...D9,width:`100%`,marginTop:0}})}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:ge||!me,onClick:()=>void tt(`password`),children:`Reveal`})]})]}),fe!=null&&(0,B.jsxs)(`div`,{style:{padding:10,borderRadius:8,background:`rgba(52,211,153,0.08)`,border:`1px solid rgba(52,211,153,0.35)`,marginBottom:8},children:[(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginBottom:4},children:`PLAINTEXT (hides in 30s) — never paste into chat/vault`}),(0,B.jsx)(`code`,{style:{fontSize:11,wordBreak:`break-all`,display:`block`,color:`var(--text-primary)`},children:fe}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void nt(),children:`Copy`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>pe(null),children:`Hide now`})]})]})]}),T.schema&&(0,B.jsxs)(`div`,{style:{fontSize:11,marginBottom:12,padding:10,borderRadius:8,background:`rgba(59,130,246,0.08)`,border:`1px solid var(--border-accent)`},children:[(0,B.jsx)(`div`,{style:{fontWeight:700,marginBottom:4},children:`Schema`}),(0,B.jsxs)(`div`,{children:[`auth: `,T.schema.auth]}),T.schema.header&&(0,B.jsx)(`div`,{style:{fontFamily:`monospace`},children:T.schema.header}),T.schema_notes&&(0,B.jsx)(`div`,{style:{marginTop:4,color:`var(--text-tertiary)`},children:T.schema_notes})]}),(0,B.jsxs)(T9,{title:`Identity`,children:[(0,B.jsx)(E9,{label:`Label`,value:O.label,onChange:e=>k({...O,label:e})}),(0,B.jsx)(E9,{label:`Provider`,value:O.provider,onChange:e=>k({...O,provider:e})})]}),(0,B.jsxs)(T9,{title:`Binding (one repo max)`,children:[(0,B.jsx)(E9,{label:`Product repo (exactly one name, or empty = Developer secrets)`,value:O.repos,onChange:e=>k({...O,repos:e})}),O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean).length>1&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:`Error: only one repo allowed. Remove extras before save.`}),T.multi_repo_error&&T.binding_error&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:T.binding_error}),(0,B.jsx)(E9,{label:`Project path (optional)`,value:O.project_path,onChange:e=>k({...O,project_path:e})})]}),(0,B.jsxs)(T9,{title:`Subscription & cost`,hint:`Plan level + what you pay monthly for this key/provider`,children:[(0,B.jsx)(E9,{label:`Subscription level / tier`,value:O.subscription_tier,onChange:e=>k({...O,subscription_tier:e}),placeholder:`e.g. free, pro, team, enterprise, payg`}),(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4,marginBottom:10},children:(T.tiers?.length?T.tiers:GCe).map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:10,padding:`2px 8px`,borderColor:O.subscription_tier===e.id?`var(--border-accent)`:void 0,background:O.subscription_tier===e.id?`rgba(59,130,246,0.15)`:void 0},onClick:()=>k({...O,subscription_tier:e.id,monthly_cost_usd:e.monthly_usd==null?O.monthly_cost_usd:String(e.monthly_usd)}),children:[e.label,e.monthly_usd==null?``:` $${e.monthly_usd}`]},e.id))}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10,marginBottom:4},children:[(0,B.jsx)(E9,{label:`Monthly cost $`,value:O.monthly_cost_usd,onChange:e=>k({...O,monthly_cost_usd:e}),placeholder:`20`}),(0,B.jsx)(E9,{label:`Monthly cap $ (budget)`,value:O.monthly_cap_usd,onChange:e=>k({...O,monthly_cap_usd:e}),placeholder:`100`})]}),(O.subscription_tier||O.monthly_cost_usd)&&(0,B.jsxs)(`div`,{style:{fontSize:12,marginBottom:10,padding:`8px 10px`,borderRadius:8,background:`rgba(251,191,36,0.08)`,border:`1px solid rgba(251,191,36,0.25)`,color:`var(--text-secondary)`},children:[`Plan preview:`,` `,(0,B.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:O.subscription_tier||`—`}),O.monthly_cost_usd?` · $${O.monthly_cost_usd}/mo`:` · no monthly cost set`,O.monthly_cap_usd?` · cap $${O.monthly_cap_usd}`:``]})]}),(0,B.jsxs)(T9,{title:`Tracking & shared-key health`,hint:`Billable keys need live account/usage APIs; shared values across apps must be unique per app`,children:[(0,B.jsxs)(`div`,{style:{fontSize:12,marginBottom:10,lineHeight:1.45},children:[(0,B.jsxs)(`div`,{children:[`Tracking:`,` `,(0,B.jsx)(`strong`,{style:{color:T.tracking_status===`ok`||T.tracking_exempt?`#34d399`:T.tracking_status===`exempt`?`#fbbf24`:`#f87171`},children:T.tracking_exempt?`exempt`:T.tracking_status||`never synced`}),T.key_valid!=null&&(0,B.jsxs)(`span`,{style:{color:`var(--text-tertiary)`},children:[` `,`· key `,T.key_valid?`valid`:`invalid`]})]}),T.tracking_error&&(0,B.jsx)(`div`,{style:{color:`#f87171`,fontSize:11,marginTop:4},children:T.tracking_error}),T.tracking_usage!=null&&(0,B.jsx)(`pre`,{style:{fontSize:10,marginTop:6,padding:8,borderRadius:6,background:`rgba(0,0,0,0.25)`,overflow:`auto`,maxHeight:100},children:JSON.stringify(T.tracking_usage,null,2)}),(0,B.jsxs)(`div`,{style:{marginTop:8},children:[`Shared value:`,` `,(0,B.jsx)(`strong`,{style:{color:T.shared_value&&T.shared_value_severity===`error`?`#fb923c`:T.shared_value?`#fbbf24`:`#34d399`},children:T.shared_value?T.shared_value_severity===`error`?`ERROR — same material in multiple keys/apps`:`shared (waived)`:`unique`})]}),T.shared_with&&T.shared_with.length>0&&(0,B.jsxs)(`div`,{style:{fontSize:11,marginTop:4,color:`var(--text-secondary)`},children:[`Same value as:`,` `,T.shared_with.map(e=>`${e.key} (${e.app})`).join(`, `)]}),T.shared_value_error&&(0,B.jsx)(`div`,{style:{color:`#fb923c`,fontSize:11,marginTop:4},children:T.shared_value_error})]}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:8},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.tracking_exempt,onChange:e=>k({...O,tracking_exempt:e.target.checked})}),`Tracking exempt (no vendor account API — set monthly cost)`]}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:8},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.shared_value_ok,onChange:e=>k({...O,shared_value_ok:e.target.checked})}),`Shared value OK (intentional mirror — prefer unique keys per app)`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:A,style:{marginTop:4},onClick:async()=>{j(!0);try{let e=await Ar({key:T.key,strict:!0});F(`Synced ${T.key}: ${e.tracking_status||`?`}${e.error?` — ${e.error.slice(0,80)}`:``}`),await Ge()}catch(e){b(e.message)}finally{j(!1)}},children:`Re-probe this key`})]}),(0,B.jsxs)(T9,{title:`Docs & rotation`,children:[O.provider.trim().toLowerCase()===`headscale`&&(0,B.jsx)(E9,{label:`Headscale HTTPS URL`,value:O.headscale_url,onChange:e=>k({...O,headscale_url:e}),placeholder:`https://headscale.example.com`}),(0,B.jsx)(E9,{label:`API docs URL`,value:O.api_docs_url,onChange:e=>k({...O,api_docs_url:e})}),(0,B.jsx)(E9,{label:`Rotate every (days)`,value:O.rotate_every_days,onChange:e=>k({...O,rotate_every_days:e})}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:10},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.auto_rotate,onChange:e=>k({...O,auto_rotate:e.target.checked})}),`Auto-rotate when due (flag — use CLI/agent to supply new value)`]}),(0,B.jsx)(E9,{label:`Notes`,value:O.notes,onChange:e=>k({...O,notes:e})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:N,onClick:()=>void st(),children:`Save metadata`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void ut(),children:`Record sample usage $0.01`})]}),(0,B.jsxs)(`div`,{style:{marginTop:16,borderTop:`1px solid var(--border)`,paddingTop:12},children:[(0,B.jsx)(`div`,{style:{fontSize:11,fontWeight:700,marginBottom:8},children:`Rotate value`}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{type:`password`,value:ee,onChange:e=>M(e.target.value),placeholder:`New secret value`,style:D9})}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,style:{marginTop:8,width:`100%`},disabled:!ee||N,onClick:()=>void ct(),children:`Rotate + export .env`}),(0,B.jsxs)(`p`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginTop:8},children:[`Browser assist CLI: `,(0,B.jsxs)(`code`,{children:[`npx total-recall secret rotate-browser `,T.key]})]}),T.next_rotate_due&&(0,B.jsxs)(`div`,{style:{fontSize:11,color:T.rotation_overdue?`#f87171`:`var(--text-tertiary)`,marginTop:6},children:[`Next due: `,new Date(T.next_rotate_due).toLocaleDateString(),T.rotation_overdue?` — overdue`:``]})]}),(0,B.jsxs)(`div`,{style:{marginTop:12,fontSize:11,color:`var(--text-tertiary)`},children:[`30d usage: `,T.usage_30d?.events||0,` events · $`,(T.usage_30d?.cost_usd||0).toFixed(4)]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12},children:[T.console_url&&(0,B.jsx)(`a`,{href:T.console_url,target:`_blank`,rel:`noreferrer`,className:`btn btn-ghost btn-sm`,children:`Console`}),T.pricing_url&&(0,B.jsx)(`a`,{href:T.pricing_url,target:`_blank`,rel:`noreferrer`,className:`btn btn-ghost btn-sm`,children:`Pricing`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{color:`#f87171`,marginLeft:`auto`},onClick:()=>void lt(),children:`Delete`})]}),(0,B.jsxs)(`div`,{style:{marginTop:12,fontSize:10,color:`var(--text-tertiary)`,fontFamily:`monospace`},children:[`CLI: secret meta `,T.key,` --repo my-app --tier pro --monthly-cost 25 --rotate-days 90`]})]})]})]})]}),e===`import`&&(0,B.jsxs)(`div`,{className:`card`,style:{padding:20},children:[(0,B.jsx)(`h3`,{style:{marginBottom:8},children:`One-time migrate (import-env)`}),(0,B.jsxs)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginBottom:12,lineHeight:1.45},children:[`Pull legacy keys from local `,(0,B.jsx)(`code`,{children:`.env`}),` files into the TR store. Steady-state path is the opposite:`,` `,(0,B.jsx)(`strong`,{children:`export-env`}),` writes projections out from the store.`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void dt(),style:{marginBottom:12},children:`Re-scan`}),Te.length===0?(0,B.jsx)(`p`,{style:{color:`var(--text-tertiary)`,fontSize:13},children:`No candidates — click Re-scan or use onboarding paste.`}):(0,B.jsxs)(B.Fragment,{children:[Te.map(e=>(0,B.jsxs)(`label`,{style:{display:`flex`,gap:10,padding:`8px 0`,borderBottom:`1px solid var(--border)`,opacity:e.already_set?.5:1},children:[(0,B.jsx)(`input`,{type:`checkbox`,disabled:!!e.already_set,checked:L.has(e.key),onChange:()=>{De(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n})}}),(0,B.jsx)(`span`,{style:{fontFamily:`monospace`,fontSize:12},children:e.key}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[e.masked,` · `,e.source_label]})]},e.key)),(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{marginTop:14},onClick:()=>void ft(),children:[`Import `,L.size,` key(s)`]})]})]}),e===`pats`&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`p`,{style:{fontSize:13,color:`var(--text-secondary)`,marginBottom:16},children:[(0,B.jsx)(`strong`,{children:`Original Total Recall feature:`}),` issue Personal Access Tokens that authenticate to`,` `,(0,B.jsx)(`code`,{children:`this`}),` brain (`,(0,B.jsx)(`code`,{children:`Authorization: Bearer …`}),` on `,(0,B.jsx)(`code`,{children:`/api/*`}),`). These are`,` `,(0,B.jsx)(`em`,{children:`not`}),` OpenAI/Anthropic keys — they only unlock your TR API.`]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:16,display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,B.jsx)(`input`,{value:be,onChange:e=>xe(e.target.value),placeholder:`PAT name`,style:{...D9,flex:1,minWidth:160}}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!be.trim(),onClick:async()=>{try{let e=await wr(be.trim(),[`*`]);Se(e),xe(``),await Ke()}catch(e){b(e.message)}},children:`Issue PAT`})]}),I&&(0,B.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:16,borderColor:`rgba(52,211,153,0.4)`},children:[(0,B.jsx)(`strong`,{children:`Copy now — shown once`}),(0,B.jsx)(`div`,{style:{fontFamily:`monospace`,fontSize:12,marginTop:8,wordBreak:`break-all`},children:I.token}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,style:{marginTop:8},onClick:()=>{navigator.clipboard.writeText(I.token),we(!0),setTimeout(()=>we(!1),2e3)},children:Ce?`Copied`:`Copy`})]}),ve.filter(e=>!e.revoked).map(e=>(0,B.jsxs)(`div`,{className:`card`,style:{padding:12,marginBottom:8,display:`flex`,justifyContent:`space-between`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontWeight:600},children:e.name}),(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[e.token_preview,`… · `,e.scopes?.join(`, `)]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{color:`#f87171`},onClick:()=>void Tr(e.id).then(Ke),children:`Revoke`})]},e.id))]}),e===`cloud`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:8},children:(0,B.jsx)(`button`,{onClick:Xe,disabled:N,className:`btn btn-primary`,style:{minWidth:120},children:N?`Saving...`:`Save Configuration`})}),f&&(0,B.jsxs)(`div`,{className:`badge badge-success`,style:{padding:`6px 12px`,background:`rgba(16, 185, 129, 0.1)`,border:`1px solid #10b981`,color:`#34d399`},children:[`✓ `,f]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,borderBottom:`1px solid var(--border)`,paddingBottom:12},children:[(0,B.jsx)(`span`,{style:{fontSize:20},children:`🔑`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:600},children:`Cloud & Search APIs`}),(0,B.jsx)(`p`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:`Bring your own cloud models`})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`google_api_key`,style:{fontSize:13,fontWeight:500},children:`Google Gemini API Key`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`gemini`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`gemini`,onChange:()=>Ye(`preferred_agent`,`gemini`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`google_api_key`,type:`password`,autoComplete:`off`,placeholder:`AIzaSy...`,value:n?.secrets?.google_api_key||``,onChange:e=>Je(`google_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.google_api_key,value:n?.brain?.gemini_model||``,onChange:e=>Ye(`gemini_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default Gemini Model`}),i.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.google_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`anthropic_api_key`,style:{fontSize:13,fontWeight:500},children:`Anthropic API Key (Claude)`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`claude`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`claude`,onChange:()=>Ye(`preferred_agent`,`claude`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`anthropic_api_key`,type:`password`,placeholder:`sk-ant-...`,value:n?.secrets?.anthropic_api_key||``,onChange:e=>Je(`anthropic_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.anthropic_api_key,value:n?.brain?.claude_model||``,onChange:e=>Ye(`claude_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default Claude Model`}),o.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.anthropic_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`openai_api_key`,style:{fontSize:13,fontWeight:500},children:`OpenAI API Key (Codex)`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`codex`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`codex`,onChange:()=>Ye(`preferred_agent`,`codex`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`openai_api_key`,type:`password`,placeholder:`sk-proj-...`,value:n?.secrets?.openai_api_key||``,onChange:e=>Je(`openai_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.openai_api_key,value:n?.brain?.openai_model||``,onChange:e=>Ye(`openai_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default OpenAI Model`}),c.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.openai_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`openrouter_api_key`,style:{fontSize:13,fontWeight:500},children:`OpenRouter API Key`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`openrouter`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`openrouter`,onChange:()=>Ye(`preferred_agent`,`openrouter`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`openrouter_api_key`,type:`password`,placeholder:`sk-or-...`,value:n?.secrets?.openrouter_api_key||``,onChange:e=>Je(`openrouter_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),g&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,padding:`0 4px`},children:`Fetching models...`}),!g&&u.length===0&&n?.secrets?.openrouter_api_key?.startsWith(`sk-or-`)&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--accent-red)`,padding:`0 4px`},children:`Failed to fetch OpenRouter models.`}),!g&&u.length>0&&(0,B.jsxs)(`select`,{id:`openrouter_model`,value:n?.brain?.openrouter_model||``,onChange:e=>Ye(`openrouter_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default OpenRouter Model`}),(()=>{let e={};return u.forEach(t=>{let n=t.id.split(`/`)[0].toUpperCase();e[n]||(e[n]=[]),e[n].push(t)}),Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>{let n=e[t].sort((e,t)=>e.id.localeCompare(t.id));return(0,B.jsx)(`optgroup`,{label:t,children:n.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})},t)})})()]})]}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`These keys are stored locally and injected into the CLI reasoning agents on dispatch.`})]})]}),e===`sync`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,flexWrap:`wrap`,gap:10},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:16,fontWeight:600},children:`Mesh Secrets Sync Status`}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-tertiary)`},children:`Checksum of local encrypted secrets database. Sync pushes updates to all configured mesh nodes.`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[Ie&&(0,B.jsxs)(`div`,{className:`badge`,style:{padding:`6px 12px`,fontSize:12,background:`rgba(255,255,255,0.05)`,border:`1px solid var(--border)`},children:[`Local Checksum: `,(0,B.jsx)(`code`,{style:{color:`var(--accent)`},children:Ie.slice(0,8)})]}),(0,B.jsxs)(`button`,{onClick:Ue,disabled:Re,className:`btn btn-primary`,style:{display:`flex`,alignItems:`center`,gap:6},children:[Re&&(0,B.jsx)(`span`,{className:`spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`,style:{width:12,height:12,border:`2px solid currentColor`,borderRightColor:`transparent`,borderRadius:`50%`,display:`inline-block`,animation:`spin 0.75s linear infinite`}}),Re?`Syncing...`:`Trigger Sync`]})]})]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(280px, 1fr))`,gap:16},children:[(0,B.jsxs)(`div`,{className:`card`,style:{padding:20,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`h4`,{style:{fontSize:14,fontWeight:600,borderBottom:`1px solid var(--border)`,paddingBottom:10,margin:0},children:[`Mesh Nodes (`,Pe.length,`)`]}),(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10,maxHeight:300,overflowY:`auto`},children:Pe.length===0?(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-tertiary)`,textAlign:`center`,margin:`20px 0`},children:`No mesh nodes configured or reachable.`}):Pe.map(e=>(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,background:`rgba(255,255,255,0.02)`,border:`1px solid rgba(255,255,255,0.05)`,borderRadius:8},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontSize:13,fontWeight:500},children:e.hostname}),(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:e.ip})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[e.checksum&&(0,B.jsx)(`code`,{style:{fontSize:11,color:`var(--text-secondary)`},children:e.checksum.slice(0,8)}),(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:e.status===`synced`?`#22c55e`:e.status===`out_of_sync`?`#eab308`:`#ef4444`,boxShadow:e.status===`synced`?`0 0 6px rgba(34,197,94,0.5)`:e.status===`out_of_sync`?`0 0 6px rgba(234,179,8,0.5)`:`0 0 6px rgba(239,68,68,0.5)`},title:e.status})]})]},e.hostname))})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:20,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsx)(`h4`,{style:{fontSize:14,fontWeight:600,borderBottom:`1px solid var(--border)`,paddingBottom:10,margin:0},children:`Sync Activity Log`}),(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,maxHeight:300,overflowY:`auto`,fontFamily:`monospace`,fontSize:11},children:Be.map((e,t)=>(0,B.jsxs)(`div`,{style:{color:e.status===`success`?`#34d399`:e.status===`error`?`#f87171`:`var(--text-secondary)`},children:[(0,B.jsxs)(`span`,{style:{color:`var(--text-tertiary)`,marginRight:8},children:[`[`,e.time,`]`]}),e.event]},t))})]})]})]}),(0,B.jsxs)(`p`,{style:{marginTop:24,fontSize:11,color:`var(--text-tertiary)`},children:[`CLI: `,(0,B.jsx)(`code`,{children:`secret catalog`}),` · `,(0,B.jsx)(`code`,{children:`secret meta KEY --repo app --tier pro --monthly-cost 25 --rotate-days 90`}),` ·`,` `,(0,B.jsx)(`code`,{children:`secret rotation-due`}),` · `,(0,B.jsx)(`code`,{children:`secret usage`}),` · `,(0,B.jsx)(`code`,{children:`secret providers`})]})]})}var zCe=`__developer__`,BCe=`__multi_repo_error__`,VCe=`__shared_value_error__`,HCe=`__tracking_error__`;function UCe(e){let t=new Map,n=[],r=[],i=[],a=[];for(let o of e){o.shared_value&&o.shared_value_severity===`error`&&i.push(o),o.set&&o.tracking_status!==`ok`&&o.tracking_status!==`exempt`&&!o.tracking_exempt&&a.push(o);let e=(o.repos||[]).map(e=>e.trim()).filter(Boolean);if(e.length>1||o.multi_repo_error){r.push(o);continue}if(!e.length){n.push(o);continue}let s=e[0];t.has(s)||t.set(s,[]),t.get(s).push(o)}let o=[];i.length&&o.push({id:VCe,label:`Needs fix — shared key across apps`,keys:i.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`}),a.length&&o.push({id:HCe,label:`Needs fix — account/usage not tracked`,keys:a.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`}),r.length&&o.push({id:BCe,label:`Needs fix — multi-repo binding`,keys:r.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`});for(let[e,n]of[...t.entries()].sort(([e],[t])=>e.localeCompare(t,void 0,{sensitivity:`base`})))o.push({id:e.replace(/[^a-zA-Z0-9._-]+/g,`-`),label:e,keys:n.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`repo`});return n.length&&o.push({id:zCe,label:`Developer secrets`,keys:n.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`developer`}),o}function WCe({k:e,selected:t,onOpen:n,groupBy:r}){return(0,B.jsxs)(`button`,{type:`button`,onClick:n,style:{width:`100%`,display:`grid`,gridTemplateColumns:`minmax(0, 1.4fr) minmax(0, 1fr) auto`,gap:8,alignItems:`center`,padding:`8px 10px`,marginBottom:4,borderRadius:8,border:`1px solid ${t?`var(--border-accent)`:`transparent`}`,background:t?`rgba(59,130,246,0.14)`:e.multi_repo_error||e.rotation_overdue||e.shared_value&&e.shared_value_severity===`error`||e.tracking_status&&e.tracking_status!==`ok`&&e.tracking_status!==`exempt`&&!e.tracking_exempt?`rgba(248,113,113,0.06)`:`rgba(148,163,184,0.04)`,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsxs)(`div`,{style:{fontFamily:`ui-monospace, monospace`,fontWeight:650,fontSize:12,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.key,e.shared_value&&e.shared_value_severity===`error`&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#fb923c`},children:`SHARED`}),e.tracking_status&&e.tracking_status!==`ok`&&e.tracking_status!==`exempt`&&!e.tracking_exempt&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`TRACK`}),e.tracking_status===`ok`&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#34d399`},children:`OK`}),e.multi_repo_error&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`MULTI`}),e.rotation_overdue&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`DUE`})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[r===`api`?e.repos?.length?e.repos.join(`, `):`Developer`:e.provider_name||e.provider||`—`,` · `,e.masked||`••••`,e.shared_value&&e.shared_apps?.length?` · apps: ${e.shared_apps.join(`, `)}`:``,e.multi_repo_error?` · ${e.repos.join(`, `)}`:``]})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-secondary)`,minWidth:0},children:[(0,B.jsx)(`span`,{style:{color:e.subscription_tier?`#fbbf24`:`var(--text-tertiary)`},children:e.subscription_tier||`no tier`}),` · `,(0,B.jsx)(`span`,{style:{color:e.monthly_cost_usd==null?`var(--text-tertiary)`:`#34d399`},children:e.monthly_cost_usd==null?`no $/mo`:`$${e.monthly_cost_usd}/mo`}),` · `,(0,B.jsx)(`span`,{style:{color:e.usage_30d?.cost_usd>0?`#22d3ee`:`var(--text-tertiary)`},title:`${e.usage_30d?.events||0} events`,children:e.usage_30d?.cost_usd>0?`$${e.usage_30d.cost_usd.toFixed(2)} used`:`no usage`})]}),(0,B.jsx)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,flexShrink:0},children:`›`})]})}function w9({label:e,value:t,accent:n}){return(0,B.jsxs)(`div`,{className:`card`,style:{padding:`14px 16px`,borderLeft:`3px solid ${n}`},children:[(0,B.jsx)(`div`,{style:{fontSize:20,fontWeight:700,letterSpacing:`-0.02em`},children:t}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.06em`,marginTop:2},children:e})]})}var GCe=[{id:`free`,label:`Free`,monthly_usd:0},{id:`payg`,label:`Pay-as-you-go`,monthly_usd:null},{id:`pro`,label:`Pro`,monthly_usd:20},{id:`team`,label:`Team`,monthly_usd:30},{id:`business`,label:`Business`,monthly_usd:50},{id:`enterprise`,label:`Enterprise`,monthly_usd:null}];function T9({title:e,hint:t,children:n}){return(0,B.jsxs)(`div`,{style:{marginBottom:14,paddingBottom:12,borderBottom:`1px solid var(--border)`},children:[(0,B.jsx)(`div`,{style:{fontSize:11,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.06em`,color:`var(--text-secondary)`,marginBottom:4},children:e}),t&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginBottom:8,lineHeight:1.4},children:t}),n]})}function E9({label:e,value:t,onChange:n,placeholder:r}){return(0,B.jsxs)(`label`,{style:{display:`block`,marginBottom:10},children:[(0,B.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.05em`},children:e}),(0,B.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:r,style:{...D9,marginTop:4}})]})}var D9={width:`100%`,boxSizing:`border-box`,padding:`8px 10px`,borderRadius:8,border:`1px solid var(--border)`,background:`var(--bg-primary)`,color:`var(--text-primary)`,fontSize:12},O9=[{id:`antigravity`,name:`Antigravity`,surface:`.agents/skills/total-recall/SKILL.md`,command:`npx total-recall connect antigravity`,snippet:()=>`Injects SSSS vault directly into Antigravity skill definitions.`},{id:`gemini`,name:`Gemini CLI`,surface:`GEMINI.md`,command:`npx total-recall connect gemini`,snippet:()=>`Compiles project memory into GEMINI.md for the Gemini CLI.`},{id:`cursor`,name:`Cursor`,surface:`.cursor/rules/total-recall.mdc`,command:`npx total-recall connect cursor`,snippet:()=>`Continuously updates Cursor workspace rules with extracted memories.`},{id:`claude-code`,name:`Claude Code`,surface:`CLAUDE.md`,command:`npx total-recall connect claude-code`,snippet:()=>`Continuously updates Claude project instructions with extracted memories.`},{id:`codex`,name:`Codex / OpenAI`,surface:`AGENTS.md`,command:`npx total-recall connect codex`,snippet:()=>`Injects SSSS knowledge graph into Codex target surfaces.`},{id:`vscode`,name:`VS Code Copilot`,surface:`.github/copilot-instructions.md`,command:`npx total-recall connect vscode`,snippet:()=>`Auto-compiles memory insights into Copilot repository instructions.`},{id:`pi`,name:`Pi Coding Agent`,surface:`~/.pi/agent/AGENTS.md`,command:`npx total-recall connect pi`,snippet:()=>`Symlinks the compiled global agent surface for Pi terminal use.`},{id:`hermes`,name:`Hermes Agent`,surface:`~/.hermes/memories/MEMORY.md`,command:`npx total-recall connect hermes`,snippet:()=>`Pushes truncated memory surface projections to autonomous Hermes.`},{id:`openclaw`,name:`OpenClaw`,surface:`MEMORY.md`,command:`npx total-recall connect openclaw`,snippet:()=>`Mounts the Total Recall memory target for local OpenClaw runtimes.`}];function KCe({activeBrainId:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(null),d=(0,v.useMemo)(()=>{let e=In();return e?e.replace(/\/$/,``):window.location.origin},[]);(0,v.useEffect)(()=>{let e=!0;return hi().then(t=>{e&&t.success&&Array.isArray(t.active)&&c(t.active)}).catch(t=>{e&&o({type:`error`,text:`Failed to fetch active integrations: ${t.message||`Unknown error`}`})}),di().then(t=>{e&&u(t)}).catch(t=>{e&&o({type:`error`,text:`Failed to fetch extension status: ${t.message||`Unknown error`}`})}),()=>{e=!1}},[e]);let f=(0,v.useMemo)(()=>s.length===0?O9:O9.filter(e=>s.includes(e.id)),[s]),p=async(e,t)=>{await navigator.clipboard.writeText(t),n(e),setTimeout(()=>n(null),1800)},m=async e=>{i(e),o(null);try{let t=await mi(e,d);if(t.success){o({type:`success`,text:`Successfully enabled ${e} integration! Total Recall is now injecting memories.`});let t=await hi();t.success&&Array.isArray(t.active)&&c(t.active)}else o({type:`error`,text:`Failed to enable integration: ${t.message}`})}catch(e){o({type:`error`,text:e.message||`Failed to connect.`})}finally{i(null)}};return(0,B.jsxs)(`div`,{className:`page`,children:[(0,B.jsxs)(`div`,{className:`page-header`,children:[(0,B.jsx)(`h1`,{children:`Integrations`}),(0,B.jsx)(`p`,{children:`Enable automated memory injection for your local IDEs and agents`})]}),a&&(0,B.jsxs)(`div`,{style:{padding:`12px 16px`,borderRadius:8,marginBottom:16,fontSize:14,fontWeight:500,background:a.type===`success`?`rgba(16, 185, 129, 0.15)`:`rgba(239, 68, 68, 0.15)`,border:a.type===`success`?`1px solid rgba(16, 185, 129, 0.3)`:`1px solid rgba(239, 68, 68, 0.3)`,color:a.type===`success`?`#34d399`:`#f87171`,display:`flex`,justifyContent:`space-between`,alignItems:`center`,backdropFilter:`blur(8px)`,boxShadow:`0 4px 12px rgba(0,0,0,0.1)`},children:[(0,B.jsx)(`span`,{children:a.text}),(0,B.jsx)(`button`,{onClick:()=>o(null),style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,fontSize:18,padding:`0 4px`,lineHeight:`1`},children:`×`})]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:16},children:[(0,B.jsxs)(`div`,{style:{border:`1px solid var(--border)`,background:`var(--bg-secondary)`,borderRadius:12,padding:18,display:`flex`,flexDirection:`column`,gap:12,position:`relative`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{margin:`0 0 4px`},children:`Chrome Extension`}),(0,B.jsx)(`div`,{style:{color:`var(--text-tertiary)`,fontSize:12},children:`Browser Overlay Panel & Capture`})]}),l?l.connected?(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(16, 185, 129, 0.1)`,border:`1px solid rgba(16, 185, 129, 0.3)`,fontSize:12,color:`#34d399`,fontWeight:500},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#10b981`,boxShadow:`0 0 8px #10b981`}}),`Connected`]}):(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(245, 158, 11, 0.1)`,border:`1px solid rgba(245, 158, 11, 0.3)`,fontSize:12,color:`#fbbf24`,fontWeight:500},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#f59e0b`}}),`Not Connected`]}):(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(255, 255, 255, 0.05)`,border:`1px solid rgba(255, 255, 255, 0.1)`,fontSize:12,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#94a3b8`}}),`Checking...`]})]}),(0,B.jsx)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontSize:13,color:`var(--text-secondary)`,lineHeight:`1.4`},children:`Install the Total Recall extension to passively capture context, store quick notes, and access the active brain search overlay inside any Chrome tab.`}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontFamily:`monospace`,fontSize:11,whiteSpace:`pre-wrap`,color:`var(--text-tertiary)`},children:[`1. Download zip & unzip locally.`,`
5521
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mCe(e,t){if(e){if(typeof e==`string`)return v9(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v9(e,t):void 0}}function v9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hCe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function gCe(e){if(Array.isArray(e))return e}var _Ce=()=>(V_e(),null);function y9(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var vCe=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=_9((0,v.useState)({containerWidth:y9(e.style?.width),containerHeight:y9(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(H1,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,g9({ref:s},e)))}),yCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=_9((0,v.useState)({containerWidth:y9(n),containerHeight:y9(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(H1,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,g9({ref:c},e)))}),bCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(`div`,g9({ref:t},e)))}),xCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(yCe,g9({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(bCe,g9({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(`div`,g9({ref:t},e)))});function SCe(e){return e?vCe:xCe}var CCe=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0||b,S=(0,v.useRef)(null),C=SX(),w=_9((0,v.useState)(null),2),T=w[0],E=w[1],D=_9((0,v.useState)(null),2),O=D[0],k=D[1],A=cCe(),j=N1(),ee=j?.width>0?j.width:_,M=j?.height>0?j.height:i,N=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),te=(0,v.useCallback)(e=>{C(N7(e)),C(Z7({handler:a,reactEvent:e}))},[C,a]),P=(0,v.useCallback)(e=>{C(F7(e)),C(Z7({handler:l,reactEvent:e}))},[C,l]),F=(0,v.useCallback)(e=>{C(B3()),C(Z7({handler:u,reactEvent:e}))},[C,u]),ne=(0,v.useCallback)(e=>{C(F7(e)),C(Z7({handler:d,reactEvent:e}))},[C,d]),re=(0,v.useCallback)(()=>{C(W7())},[C]),ie=(0,v.useCallback)(()=>{C(G7())},[C]),ae=(0,v.useCallback)(e=>{C(U7(e.key))},[C]),oe=(0,v.useCallback)(e=>{C(Z7({handler:o,reactEvent:e}))},[C,o]),se=(0,v.useCallback)(e=>{C(Z7({handler:s,reactEvent:e}))},[C,s]),ce=(0,v.useCallback)(e=>{C(Z7({handler:c,reactEvent:e}))},[C,c]),le=(0,v.useCallback)(e=>{C(Z7({handler:f,reactEvent:e}))},[C,f]),ue=(0,v.useCallback)(e=>{C(Z7({handler:h,reactEvent:e}))},[C,h]),de=(0,v.useCallback)(e=>{x&&C(n9(e)),C(Z7({handler:m,reactEvent:e}))},[C,x,m]),fe=(0,v.useCallback)(e=>{C(Z7({handler:p,reactEvent:e}))},[C,p]),pe=SCe(y);return v.createElement(W6.Provider,{value:T},v.createElement(XK.Provider,{value:O},v.createElement(pe,{width:ee??g?.width,height:M??g?.height,className:YG(`recharts-wrapper`,r),style:lCe({position:`relative`,cursor:`default`,width:ee,height:M},g),onClick:te,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:P,onMouseLeave:F,onMouseMove:ne,onMouseUp:le,onTouchEnd:fe,onTouchMove:de,onTouchStart:ue,ref:N},v.createElement(_Ce,null),n)))}),wCe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function TCe(e,t){if(e==null)return{};var n,r,i=ECe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ECe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var DCe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=tK(TCe(e,wCe));return c?v.createElement(v.Fragment,null,v.createElement(H1,{width:n,height:r}),v.createElement(p9,{otherAttributes:d,title:l,desc:u},a)):v.createElement(CCe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(p9,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(Fbe,null,a)))});function b9(){return b9=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b9.apply(null,arguments)}function x9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OCe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x9(Object(n),!0).forEach(function(t){kCe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kCe(e,t,n){return(t=ACe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ACe(e){var t=jCe(e,`string`);return typeof t==`symbol`?t:t+``}function jCe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var MCe=OCe({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},c9),NCe=(0,v.forwardRef)(function(e,t){var n=GJ(e.categoricalChartProps,MCe),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return v.createElement(KSe,{preloadedState:{options:c},reduxStoreName:s.id??r},v.createElement(wbe,{chartData:s.data}),v.createElement(JSe,{layout:n.layout,margin:n.margin}),v.createElement(XSe,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(YSe,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(DCe,b9({},n,{ref:t})))}),PCe=[`axis`],FCe=(0,v.forwardRef)((e,t)=>v.createElement(NCe,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:PCe,tooltipPayloadSearcher:D_e,categoricalChartProps:e,ref:t}));function ICe(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=async()=>{try{let e=await Yr();t(e);let n=await gi();r(n),s(null)}catch(e){s(e.message||`Failed to sync budget consumption stats.`)}finally{a(!1)}},h=async(e=!1)=>{d(!0);try{l(await Xr(e)),p(null)}catch(e){p(e.message||`Failed to read provider billing data.`)}finally{d(!1)}};(0,v.useEffect)(()=>{m();let e=setInterval(m,5e3);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{h()},[]);let g=n?.budget?.budget?.daily_cap_usd??5,_=n?.budget?.budget?.weekly_cap_usd??25,y=n?.budget?.budget?.enabled!==!1,b=Math.min(100,(e?.dailyUsd||0)/g*100),x=Math.min(100,(e?.weeklyUsd||0)/_*100),S=e=>e>85?`var(--error)`:e>60?`var(--warning)`:`var(--success)`,C=(0,v.useMemo)(()=>{if(e?.timeseries&&Object.keys(e.timeseries).length>0){let t=e.timeseries;return Object.entries(t).map(([e,t])=>{let n={date:new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},r=0,i=0,a=0,o=0;for(let[,e]of Object.entries(t)){let t=e;t.provider===`gemini`?r+=t.cost:t.provider===`claude`?i+=t.cost:t.provider===`openrouter`?a+=t.cost:o+=t.cost}return n.gemini=+r.toFixed(3),n.claude=+i.toFixed(3),n.openrouter=+a.toFixed(3),n.codex=+o.toFixed(3),n})}return[]},[e]);return i?(0,B.jsxs)(`div`,{className:`page`,style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:[(0,B.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--text-tertiary)`,strokeWidth:`2.5`,style:{animation:`spin 1s linear infinite`,marginBottom:12},children:(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),(0,B.jsx)(`div`,{style:{color:`var(--text-secondary)`},children:`Aggregating token expenditures...`})]}):(0,B.jsxs)(`div`,{className:`page`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflowY:`auto`},children:[(0,B.jsxs)(`div`,{className:`page-header`,style:{marginBottom:24},children:[(0,B.jsx)(`h1`,{children:`Token & Budget Statistics`}),(0,B.jsx)(`p`,{children:`Monitor your token cost expenditure in real time against safety budget limits`})]}),(0,B.jsxs)(`div`,{style:{padding:`16px 20px`,marginBottom:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderLeft:`3px solid var(--accent)`,borderRadius:10,display:`flex`,alignItems:`center`,gap:14},children:[(0,B.jsx)(`span`,{style:{fontSize:24},children:`🛡️`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontSize:14,fontWeight:700,color:`#fff`,letterSpacing:.3},children:`Local-first · Self-hosted`}),(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:2},children:`Memory and processing stay on your machine. No vendor lock-in.`})]})]}),o&&(0,B.jsxs)(`div`,{className:`badge badge-error`,style:{marginBottom:20,display:`inline-flex`,padding:`6px 12px`,background:`rgba(239, 68, 68, 0.1)`,border:`1px solid #ef4444`,color:`#f87171`},children:[`⚠️ `,o]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(340px, 1fr))`,gap:24,marginBottom:24},children:[(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:13,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:`Daily Expenditure`}),(0,B.jsxs)(`div`,{style:{fontSize:28,fontWeight:700,marginTop:4,color:`#fff`},children:[`$`,e?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`span`,{className:`badge`,style:{background:`var(--bg-elevated)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,fontSize:11},children:[`Cap: $`,g.toFixed(2)]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:11,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{children:`Consumption Ratio`}),(0,B.jsxs)(`span`,{children:[b.toFixed(1),`%`]})]}),(0,B.jsx)(`div`,{style:{height:6,background:`var(--bg-elevated)`,borderRadius:3,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{height:`100%`,width:`${b}%`,background:S(b),boxShadow:`0 0 8px ${S(b)}`,transition:`width 0.4s ease`}})})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,borderTop:`1px solid var(--border)`,paddingTop:10,marginTop:4},children:[`Status: `,y?`🛡️ Budget supervision active`:`⚠️ Limits unmonitored (disabled)`]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:13,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:`Weekly Expenditure`}),(0,B.jsxs)(`div`,{style:{fontSize:28,fontWeight:700,marginTop:4,color:`#fff`},children:[`$`,e?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`span`,{className:`badge`,style:{background:`var(--bg-elevated)`,color:`var(--text-secondary)`,border:`1px solid var(--border)`,fontSize:11},children:[`Cap: $`,_.toFixed(2)]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:11,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{children:`Consumption Ratio`}),(0,B.jsxs)(`span`,{children:[x.toFixed(1),`%`]})]}),(0,B.jsx)(`div`,{style:{height:6,background:`var(--bg-elevated)`,borderRadius:3,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{height:`100%`,width:`${x}%`,background:S(x),boxShadow:`0 0 8px ${S(x)}`,transition:`width 0.4s ease`}})})]}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,borderTop:`1px solid var(--border)`,paddingTop:10,marginTop:4},children:`Rolling window: Last 7 days in local system time`})]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:`Model Engine Spend breakdown`}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`,gap:20},children:[(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`♊`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Gemini CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.gemini/tmp`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(59, 130, 246, 0.1)`,color:`#60a5fa`,border:`1px solid rgba(59, 130, 246, 0.2)`},children:`Google API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.gemini?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.gemini?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.gemini?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🍊`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Claude Code CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.claude`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(239, 107, 107, 0.1)`,color:`#f87171`,border:`1px solid rgba(239, 107, 107, 0.2)`},children:`Anthropic API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.claude?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.claude?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.claude?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`💻`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Codex CLI`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`~/.codex/sessions`})]})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(16, 185, 129, 0.1)`,color:`#34d399`,border:`1px solid rgba(16, 185, 129, 0.2)`},children:`OpenAI API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.codex?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.codex?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.codex?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🌐`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`OpenRouter`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(236, 72, 153, 0.1)`,color:`#f472b6`,border:`1px solid rgba(236, 72, 153, 0.2)`},children:`OR API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.openrouter?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.openrouter?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.openrouter?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🔎`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Tavily Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.tavily?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.tavily?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.tavily?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🦁`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Brave Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.brave?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.brave?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.brave?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`✨`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Exa Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.exa?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.exa?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.exa?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-tertiary)`,border:`1px solid var(--border)`,padding:16,borderRadius:10,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:18},children:`🔍`}),(0,B.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#fff`},children:`Serper Search`})]}),(0,B.jsx)(`span`,{className:`badge`,style:{background:`rgba(234, 179, 8, 0.1)`,color:`#eab308`,border:`1px solid rgba(234, 179, 8, 0.2)`},children:`Web API`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.serper?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly Spend:`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:`#fff`},children:[`$`,e?.breakdown?.serper?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:4,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Rolling Tokens:`}),(0,B.jsxs)(`span`,{children:[e?.breakdown?.serper?.dailyTokens?.toLocaleString()||0,` (24h)`]})]})]})]})]})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:20},children:`30-Day Cost Trend`}),C.length===0?(0,B.jsx)(`div`,{style:{height:300,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-secondary)`},children:`No usage data available for the last 30 days.`}):(0,B.jsx)(Rde,{width:`100%`,height:300,children:(0,B.jsxs)(FCe,{data:C,margin:{top:5,right:20,left:0,bottom:5},children:[(0,B.jsxs)(`defs`,{children:[(0,B.jsxs)(`linearGradient`,{id:`gradGemini`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradClaude`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#e17055`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#e17055`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradOpenRouter`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#74b9ff`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#74b9ff`,stopOpacity:0})]}),(0,B.jsxs)(`linearGradient`,{id:`gradCodex`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,B.jsx)(`stop`,{offset:`5%`,stopColor:`#00cec9`,stopOpacity:.4}),(0,B.jsx)(`stop`,{offset:`95%`,stopColor:`#00cec9`,stopOpacity:0})]})]}),(0,B.jsx)(X5,{strokeDasharray:`3 3`,stroke:`rgba(255,255,255,0.04)`}),(0,B.jsx)(T7,{dataKey:`date`,tick:{fontSize:11,fill:`var(--text-secondary)`},axisLine:{stroke:`var(--border)`},tickLine:!1}),(0,B.jsx)(A7,{tick:{fontSize:11,fill:`var(--text-secondary)`},axisLine:{stroke:`var(--border)`},tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,B.jsx)(eve,{contentStyle:{background:`#1a1a2e`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:8,fontSize:12,color:`#e8e8e8`},labelStyle:{color:`#fff`,fontWeight:600,marginBottom:4},formatter:(e,t)=>[`$${Number(e).toFixed(3)}`,String(t).charAt(0).toUpperCase()+String(t).slice(1)]}),(0,B.jsx)(t0,{wrapperStyle:{fontSize:12,color:`var(--text-secondary)`}}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`gemini`,stackId:`1`,stroke:`#3b82f6`,fill:`url(#gradGemini)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`claude`,stackId:`1`,stroke:`#e17055`,fill:`url(#gradClaude)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`openrouter`,stackId:`1`,stroke:`#74b9ff`,fill:`url(#gradOpenRouter)`,strokeWidth:2}),(0,B.jsx)(_7,{type:`monotone`,dataKey:`codex`,stackId:`1`,stroke:`#00cec9`,fill:`url(#gradCodex)`,strokeWidth:2})]})})]}),(0,B.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(220px, 1fr))`,gap:16,marginTop:24},children:[{name:`Gemini`,color:`#3b82f6`,emoji:`♊`,key:`gemini`},{name:`Claude`,color:`#e17055`,emoji:`🍊`,key:`claude`},{name:`OpenRouter`,color:`#74b9ff`,emoji:`🌐`,key:`openrouter`},{name:`Codex`,color:`#00cec9`,emoji:`💻`,key:`codex`},{name:`Tavily`,color:`#eab308`,emoji:`🔎`,key:`tavily`},{name:`Brave`,color:`#eab308`,emoji:`🦁`,key:`brave`},{name:`Exa`,color:`#eab308`,emoji:`✨`,key:`exa`},{name:`Serper`,color:`#eab308`,emoji:`🔍`,key:`serper`}].map(t=>{let n=e?.breakdown?.[t.key];return(0,B.jsxs)(`div`,{style:{background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(12px)`,border:`1px solid var(--border)`,borderTop:`4px solid ${t.color}`,borderRadius:10,padding:20,display:`flex`,flexDirection:`column`,gap:12,transition:`transform 0.2s ease, box-shadow 0.2s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`translateY(-2px)`,e.currentTarget.style.boxShadow=`0 8px 24px ${t.color}22`},onMouseLeave:e=>{e.currentTarget.style.transform=`translateY(0)`,e.currentTarget.style.boxShadow=`none`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{fontSize:20},children:t.emoji}),(0,B.jsx)(`span`,{style:{fontSize:14,fontWeight:700,color:`#fff`},children:t.name})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,fontSize:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Daily`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:t.color},children:[`$`,n?.dailyUsd?.toFixed(4)??`0.0000`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Weekly`}),(0,B.jsxs)(`span`,{style:{fontWeight:600,color:t.color},children:[`$`,n?.weeklyUsd?.toFixed(4)??`0.0000`]})]}),n?.dailyTokens!=null&&(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid var(--border)`,paddingTop:6,marginTop:2,fontSize:11,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{children:`Tokens (24h)`}),(0,B.jsx)(`span`,{children:n.dailyTokens.toLocaleString()})]})]})]},t.key)})}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:`Per-Model Breakdown`}),(0,B.jsx)(`div`,{style:{overflowX:`auto`},children:(0,B.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`,fontSize:12},children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{style:{borderBottom:`1px solid var(--border)`},children:[`Provider`,`Daily ($)`,`Weekly ($)`,`Daily Tokens`,`Weekly Tokens`].map(e=>(0,B.jsx)(`th`,{style:{textAlign:`left`,padding:`10px 12px`,fontSize:11,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5},children:e},e))})}),(0,B.jsxs)(`tbody`,{children:[[{name:`Gemini`,key:`gemini`,color:`#3b82f6`},{name:`Claude`,key:`claude`,color:`#e17055`},{name:`Codex`,key:`codex`,color:`#00cec9`},{name:`OpenRouter`,key:`openrouter`,color:`#74b9ff`}].map((t,n)=>{let r=t.key===`openrouter`?e?.breakdown?.openrouter:e?.breakdown?.[t.key];return(0,B.jsxs)(`tr`,{style:{background:n%2==1?`rgba(255,255,255,0.02)`:`transparent`,borderBottom:`1px solid var(--border)`},children:[(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:600,color:t.color},children:t.name}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,color:`#fff`},children:[`$`,r?.dailyUsd?.toFixed(4)??`0.0000`]}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,color:`#fff`},children:[`$`,r?.weeklyUsd?.toFixed(4)??`0.0000`]}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`},children:r?.dailyTokens?.toLocaleString()||`—`}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,color:`var(--text-secondary)`},children:r?.weeklyTokens?.toLocaleString()||`—`})]},t.key)}),(0,B.jsxs)(`tr`,{style:{borderTop:`2px solid var(--border)`,background:`rgba(108, 92, 231, 0.05)`},children:[(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:`Total`}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:[`$`,((e?.breakdown?.gemini?.dailyUsd||0)+(e?.breakdown?.claude?.dailyUsd||0)+(e?.breakdown?.codex?.dailyUsd||0)+(e?.breakdown?.openrouter?.dailyUsd||0)).toFixed(4)]}),(0,B.jsxs)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`#fff`},children:[`$`,((e?.breakdown?.gemini?.weeklyUsd||0)+(e?.breakdown?.claude?.weeklyUsd||0)+(e?.breakdown?.codex?.weeklyUsd||0)+(e?.breakdown?.openrouter?.weeklyUsd||0)).toFixed(4)]}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`var(--text-secondary)`},children:((e?.breakdown?.gemini?.dailyTokens||0)+(e?.breakdown?.claude?.dailyTokens||0)+(e?.breakdown?.codex?.dailyTokens||0)+(e?.breakdown?.openrouter?.dailyTokens||0)).toLocaleString()}),(0,B.jsx)(`td`,{style:{padding:`10px 12px`,fontWeight:700,color:`var(--text-secondary)`},children:((e?.breakdown?.gemini?.weeklyTokens||0)+(e?.breakdown?.claude?.weeklyTokens||0)+(e?.breakdown?.codex?.weeklyTokens||0)+(e?.breakdown?.openrouter?.weeklyTokens||0)).toLocaleString()})]})]})]})})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,marginTop:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,justifyContent:`space-between`,borderBottom:`1px solid var(--border)`,paddingBottom:10,marginBottom:16},children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:.5,margin:0},children:`Reported by Provider`}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[c?.fetched_at&&(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[new Date(c.fetched_at).toLocaleString(),c.from_cache?` (cached)`:``]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{h(!0)},disabled:u,style:{fontSize:11,padding:`4px 10px`,borderRadius:6,border:`1px solid var(--border)`,background:`transparent`,color:`var(--text-secondary)`,cursor:u?`wait`:`pointer`},children:u?`Refreshing…`:`Refresh`})]})]}),f&&(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--error)`,marginBottom:12},children:f}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(260px, 1fr))`,gap:16},children:[Object.entries(c?.providers||{}).map(([e,t])=>(0,B.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderLeft:`3px solid ${t.state===`ok`?`var(--success)`:t.state===`error`?`var(--error)`:`var(--warning)`}`,borderRadius:8,padding:16},children:[(0,B.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:`#fff`,marginBottom:8},children:t.label}),t.state===`ok`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{fontSize:22,fontWeight:700,color:`#fff`},children:[`$`,(t.total_cost??0).toFixed(2)]}),(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginTop:4},children:[t.lifetime?`lifetime to date`:`last ${c?.window_days??30} days`,typeof t.balance==`number`?` · $${t.balance.toFixed(2)} remaining`:``]})]}):(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-secondary)`,lineHeight:1.5},children:t.reason})]},e)),!c&&!f&&(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--text-tertiary)`},children:`Loading provider billing data…`})]})]})]})}function S9(e){return{label:e.label||``,provider:e.provider||``,repos:(e.repos||[]).join(`, `),subscription_tier:e.subscription_tier||``,monthly_cost_usd:e.monthly_cost_usd==null?``:String(e.monthly_cost_usd),monthly_cap_usd:e.monthly_cap_usd==null?``:String(e.monthly_cap_usd),api_docs_url:e.api_docs_url||``,headscale_url:e.headscale_url||``,rotate_every_days:e.rotate_every_days==null?``:String(e.rotate_every_days),auto_rotate:!!e.auto_rotate,notes:e.notes||``,project_path:e.project_path||``,tracking_exempt:!!e.tracking_exempt,shared_value_ok:!!e.shared_value_ok}}function LCe(e){let t=new Map;return e.forEach(e=>{let n=e.provider_name||e.provider;if(!n){let t=e.key.toLowerCase();n=t.includes(`smtp2go`)?`SMTP2GO`:t.includes(`stripe`)?`Stripe`:t.includes(`supabase`)?`Supabase`:t.includes(`openai`)?`OpenAI`:t.includes(`anthropic`)?`Anthropic`:t.includes(`github`)?`GitHub`:t.includes(`google`)?`Google`:t.includes(`aws`)?`AWS`:`Unknown`}let r=n.toLowerCase();t.has(r)||t.set(r,{id:r,label:n.toUpperCase(),kind:`provider`,keys:[]}),t.get(r).keys.push(e)}),[...t.values()].sort((e,t)=>e.id===`unknown`?1:t.id===`unknown`?-1:e.id.localeCompare(t.id))}function C9({provider:e}){let[t,n]=(0,v.useState)(!1);if(!e)return null;let r=e.toLowerCase().replace(/[^a-z0-9]/g,``),i={width:14,height:14,flexShrink:0,borderRadius:2},a={openai:`10a37f`,anthropic:`d97757`,google:`4285F4`,github:`181717`,supabase:`3ECF8E`,elevenlabs:`000000`,sendgrid:`00B3E3`,digitalocean:`0080FF`,aws:`232F3E`,gcp:`4285F4`,stripe:`008CDD`,mailcow:`FFC107`,resend:`000000`},o=r in a,s=a[r]||`64748b`;return t||!o?(0,B.jsx)(`span`,{style:{...i,background:`#`+s,color:`#fff`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontSize:9,fontWeight:`bold`,verticalAlign:`middle`},children:e.charAt(0).toUpperCase()}):(0,B.jsx)(`img`,{src:`https://cdn.simpleicons.org/${r}/${s}`,style:{...i,verticalAlign:`middle`,display:`inline-block`},alt:e,onError:()=>n(!0)})}function RCe(){let[e,t]=(0,v.useState)(`catalog`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(``),[C,w]=(0,v.useState)(`repo`),[T,E]=(0,v.useState)(null),D=(0,v.useRef)(null),[O,k]=(0,v.useState)({label:``,provider:``,repos:``,subscription_tier:``,monthly_cost_usd:``,monthly_cap_usd:``,api_docs_url:``,headscale_url:``,rotate_every_days:``,auto_rotate:!1,notes:``,project_path:``,tracking_exempt:!1,shared_value_ok:!1}),[A,j]=(0,v.useState)(!1),[ee,M]=(0,v.useState)(``),[N,te]=(0,v.useState)(!1),[P,F]=(0,v.useState)(``),[ne,re]=(0,v.useState)(new Set),[ie,ae]=(0,v.useState)(!1),[oe,se]=(0,v.useState)(!1),[ce,le]=(0,v.useState)(!1),[ue,de]=(0,v.useState)(null),[fe,pe]=(0,v.useState)(null),[me,he]=(0,v.useState)(``),[ge,_e]=(0,v.useState)(!1),[ve,ye]=(0,v.useState)([]),[be,xe]=(0,v.useState)(``),[I,Se]=(0,v.useState)(null),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)([]),[L,De]=(0,v.useState)(new Set),[Oe,ke]=(0,v.useState)(!1),[Ae,je]=(0,v.useState)(``),[Me,Ne]=(0,v.useState)(``),[Pe,Fe]=(0,v.useState)([]),[Ie,Le]=(0,v.useState)(null),[Re,ze]=(0,v.useState)(!1),[Be,Ve]=(0,v.useState)([{time:new Date().toLocaleTimeString(),event:`Secrets system initialized`,status:`info`}]),He=(0,v.useCallback)(async()=>{try{let e=await bi();Fe(e.nodes||[]),Le(e.localChecksum)}catch(e){b(e instanceof Error?e.message:`Failed to load sync status`)}},[]),Ue=async()=>{ze(!0),b(null);let e=new Date().toLocaleTimeString();Ve(t=>[{time:e,event:`Initiating mesh secrets synchronization...`,status:`info`},...t]);try{let e=await yi(),t=`Mesh sync complete: ${e.results.filter(e=>e.success).length}/${e.results.length} nodes responded successfully.`;Ve(e=>[{time:new Date().toLocaleTimeString(),event:t,status:`success`},...e]),await He()}catch(e){let t=`Sync trigger failed: ${e instanceof Error?e.message:String(e)}`;Ve(e=>[{time:new Date().toLocaleTimeString(),event:t,status:`error`},...e]),b(e instanceof Error?e.message:`Failed to trigger synchronization`)}finally{ze(!1)}},We=async e=>{if(e.preventDefault(),!Ae.trim()||!Me.trim()){b(`Key name and secret value are required`);return}te(!0),b(null);try{let e=O.repos?O.repos.split(`,`).map(e=>e.trim()).filter(Boolean):[];await vi(Ae.trim(),Me.trim(),{provider:O.provider||`openai`,scope:O.repos?`project`:`global`,repos:e,subscription_tier:O.subscription_tier||void 0,monthly_cost_usd:O.monthly_cost_usd?parseFloat(O.monthly_cost_usd):void 0,monthly_cap_usd:O.monthly_cap_usd?parseFloat(O.monthly_cap_usd):void 0,api_docs_url:O.api_docs_url||void 0,headscale_url:O.provider.trim().toLowerCase()===`headscale`&&O.headscale_url||void 0,rotate_every_days:O.rotate_every_days?parseInt(O.rotate_every_days,10):void 0,auto_rotate:!!O.auto_rotate,notes:O.notes||void 0,project_path:O.project_path||void 0,label:O.label||void 0}),ke(!1),je(``),Ne(``),await Ge()}catch(e){b(e instanceof Error?e.message:`Failed to create secret`)}finally{te(!1)}};(0,v.useEffect)(()=>{if(e!==`sync`)return;let t=!1;return Promise.resolve().then(()=>{t||He()}),()=>{t=!0}},[e,He]);let Ge=(0,v.useCallback)(async()=>{_(!0),b(null);try{let e=await kr();h(e);let t=D.current;if(t){let n=e.keys.find(e=>e.key===t);E(n||null),n?k(S9(n)):D.current=null}}catch(e){b(e.message)}finally{_(!1)}},[]),Ke=(0,v.useCallback)(async()=>{try{let e=await gi();e.secrets||={},e.brain||={},r(e)}catch{}},[]),qe=(0,v.useCallback)(async()=>{let[e,t,n,r]=await Promise.all([ai().catch(()=>[]),oi().catch(()=>[]),si().catch(()=>[]),ci().catch(()=>[])]);a(e),s(t),l(n),d(r)},[]),Je=(0,v.useCallback)(async()=>{try{let e=await Cr();ye(e.keys||[])}catch{}},[]),Ye=(0,v.useCallback)(async()=>{try{de(await Rr())}catch{de(null)}},[]);(0,v.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>{e||(Ge(),Je(),Ye(),Ke())}),()=>{e=!0}},[Ge,Je,Ye,Ke]);let Xe=(0,v.useRef)(!1);(0,v.useEffect)(()=>{e!==`cloud`||Xe.current||(Xe.current=!0,qe())},[e,qe]);let Ze=(e,t)=>{n&&r({...n,secrets:{...n.secrets,[e]:t}})},Qe=(e,t)=>{n&&r({...n,brain:{...n.brain,[e]:t}})},$e=async()=>{if(n){te(!0),b(null),p(null);try{await _i(n),p(`Configuration saved successfully. Kernel will hot-reload settings.`),setTimeout(()=>p(null),4e3)}catch(e){b(e.message||`Failed to save configuration.`)}finally{te(!1)}}},et=(0,v.useCallback)((e,t)=>{D.current=e.key,E(e),k(S9(e)),M(``),F(``),pe(null),he(``),t&&re(e=>{let n=new Set(e);return n.add(t),n})},[]);async function tt(){if(!NG()){b(`This browser does not support passkeys / WebAuthn`);return}_e(!0),b(null);try{await Br(await HG({optionsJSON:await zr()}),`Touch ID / platform`),await Ye(),F(`Passkey registered — use it to reveal secret values`)}catch(e){b(e.message||`Passkey registration cancelled`)}finally{_e(!1)}}async function nt(){return(await Hr(await qG({optionsJSON:await Vr()}))).step_up_token}async function rt(){if(!me.trim())throw Error(`Enter dashboard password`);let e=await Ur(me);return he(``),e.step_up_token}async function it(e){if(T){_e(!0),b(null),pe(null);try{let t=e===`passkey`?await nt():await rt(),n=await Lr(T.key,t);pe(n.value),F(`Revealed ${T.key} (auto-hides in 30s)`),window.setTimeout(()=>pe(null),3e4)}catch(e){b(e.message)}finally{_e(!1)}}}async function at(){if(fe)try{await navigator.clipboard.writeText(fe),F(`Copied to clipboard`)}catch{b(`Clipboard copy failed`)}}function ot(e){re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function st(e){re(new Set([e]))}function ct(e){re(new Set(e))}function lt(){re(new Set)}async function ut(){if(T){te(!0),F(``);try{let e=O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean);if(e.length>1){b(`Each key may bind to only ONE repo (you entered ${e.length}: ${e.join(`, `)}). Pick one product repo, or leave empty for Developer secrets (tooling).`),te(!1);return}let t={label:O.label.trim()||null,provider:O.provider.trim()||null,repos:e,subscription_tier:O.subscription_tier.trim()||null,monthly_cost_usd:O.monthly_cost_usd.trim()===``?null:Number(O.monthly_cost_usd),monthly_cap_usd:O.monthly_cap_usd.trim()===``?null:Number(O.monthly_cap_usd),api_docs_url:O.api_docs_url.trim()||null,headscale_url:O.provider.trim().toLowerCase()===`headscale`&&O.headscale_url.trim()||null,rotate_every_days:O.rotate_every_days.trim()===``?null:Number(O.rotate_every_days),auto_rotate:!!O.auto_rotate,notes:O.notes.trim()||null,project_path:O.project_path.trim()||null,tracking_exempt:!!O.tracking_exempt,shared_value_ok:!!O.shared_value_ok};O.tracking_exempt&&(t.tracking_status=`exempt`),await jr(T.key,t),F(`Metadata saved`),await Ge()}catch(e){b(e.message)}finally{te(!1)}}}async function dt(){if(!(!T||!ee)){te(!0);try{let e=await Mr(T.key,ee,{export_env:!0,export_all:!0});M(``);let t=e.exports?.filter(e=>e.ok).length??0;F(t>0?`Rotated ${T.key} · exported .env to ${t} target(s)`:`Rotated ${T.key} · store updated (no project paths matched — bind --repo or Export .env)`),await Ge()}catch(e){b(e.message)}finally{te(!1)}}}async function ft(){if(T&&confirm(`Delete secret ${T.key}?`))try{await Nr(T.key),E(null),D.current=null,await Ge()}catch(e){b(e.message)}}async function pt(){if(T)try{await Pr({key_ref:T.key,provider:T.provider||`unknown`,cost_usd:.01,model:`manual-sample`,source:`dashboard`}),F(`Sample usage event recorded ($0.01)`),await Ge()}catch(e){b(e.message)}}async function mt(){try{let e=await Er();Ee(e.candidates||[]),De(new Set((e.candidates||[]).filter(e=>!e.already_set).map(e=>e.key))),t(`import`)}catch(e){b(e.message)}}async function ht(){try{let e=await Or({keys:[...L]});F(`Imported ${e.imported_count}, skipped ${e.skipped_count}`),await Ge(),t(`catalog`)}catch(e){b(e.message)}}let gt=(0,v.useMemo)(()=>{let e=m?.keys||[],t=x.trim().toLowerCase();return t?e.filter(e=>e.key.toLowerCase().includes(t)||(e.provider||``).toLowerCase().includes(t)||(e.repos||[]).some(e=>e.toLowerCase().includes(t))||(e.label||``).toLowerCase().includes(t)):e},[m,x]),_t=(0,v.useMemo)(()=>m?.keys?C===`api`?LCe(gt):UCe(gt):[],[m,gt,C]);(0,v.useEffect)(()=>{if(ie||!_t.length)return;let e=new Set;for(let t of _t)t.kind===`error`&&e.add(t.id);let t=_t.find(e=>e.kind!==`error`);t&&e.add(t.id),re(e),ae(!0)},[_t,ie]);let vt=m?.summary;return(0,B.jsxs)(`div`,{className:`page`,style:{maxWidth:T?1400:1100},children:[(0,B.jsxs)(`div`,{className:`page-header`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,flexWrap:`wrap`,gap:12,marginBottom:12},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{style:{marginBottom:4},children:`Secrets & Access`}),(0,B.jsx)(`p`,{style:{margin:0,fontSize:13,color:`var(--text-secondary)`},children:`Provider keys (SSOT) · one key → one repo · empty repo = Developer secrets · PATs separate`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:async()=>{try{let e=await Fr({all_projects:!0}),t=e.results?.filter(e=>e.ok).length??e.count??0;F(`Exported .env to ${t} project(s) from secrets store`)}catch(e){b(e.message)}},children:`Export .env → projects`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:async()=>{try{let e=await Ir(),t=e.tasks?.filter(e=>e.status===`created`).length??0,n=e.tasks?.filter(e=>e.status===`exists`).length??0;F(`Rotation queue: ${e.due??0} due · ${t} task(s) created · ${n} already pending`),await Ge()}catch(e){b(e.message)}},children:`Enqueue rotations`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void mt(),children:`Migrate import`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:A,onClick:async()=>{j(!0),b(null);try{let e=await Ar({strict:!0});F(e.healthy?`Account sync OK — ${e.ok??0}/${e.total??0} tracked`:`Account sync: ${e.errors??`?`} tracking error(s) — ${e.message||`see catalog`}`),e.healthy||b(e.message||`Tracking errors remain after account-sync`),await Ge()}catch(e){b(e.message)}finally{j(!1)}},children:A?`Syncing accounts…`:`Sync provider accounts`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void Ge(),children:`Refresh`})]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginBottom:10,fontSize:11},onClick:()=>se(e=>!e),children:oe?`▾ Hide model notes`:`▸ How secrets work`}),oe&&(0,B.jsx)(`div`,{className:`card`,style:{padding:12,marginBottom:12,fontSize:12,color:`var(--text-secondary)`,lineHeight:1.5,borderColor:`var(--border-accent)`},children:(0,B.jsxs)(`ul`,{style:{margin:0,paddingLeft:18},children:[(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`SSOT`}),` — keys in TR store; `,(0,B.jsx)(`strong`,{children:`export-env`}),` writes repo `,(0,B.jsx)(`code`,{children:`.env`}),`.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`One key → one product repo`}),`; multi-repo is an error. Empty = Developer secrets (tooling).`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`import-env`}),` = one-time migrate. `,(0,B.jsx)(`strong`,{children:`PATs`}),` = brain API tokens only.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Account tracking`}),` — every billable key must have live account/usage/subscription data or an explicit tracking exempt + monthly cost.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Shared values`}),` — same credential material under multiple key names/apps is an error; issue a unique API key per app, then rotate each secret name.`]})]})}),y&&(0,B.jsxs)(`div`,{className:`badge badge-error`,style:{marginBottom:16,display:`block`,padding:12},children:[y,(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginLeft:12},onClick:()=>b(null),children:`Dismiss`})]}),P&&(0,B.jsx)(`div`,{style:{marginBottom:12,fontSize:13,color:`#34d399`},children:P}),m?.store&&(0,B.jsxs)(`div`,{style:{marginBottom:12,fontSize:11,color:`var(--text-tertiary)`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,wordBreak:`break-all`},children:[`Store (global SSOT — not filtered by brain selector): `,m.store,typeof m?.summary?.total_keys==`number`?` · ${m.summary.total_keys} keys`:``]}),vt&&(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(140px, 1fr))`,gap:12,marginBottom:20},children:[(0,B.jsx)(w9,{label:`Keys`,value:String(vt.total_keys),accent:`#60a5fa`}),(0,B.jsx)(w9,{label:`Providers`,value:String(vt.providers_active),accent:`#a78bfa`}),(0,B.jsx)(w9,{label:`Planned / mo`,value:`$${(vt.monthly_subscription_usd||0).toFixed(0)}`,accent:`#fbbf24`}),(0,B.jsx)(w9,{label:`Usage 30d`,value:`$${(vt.usage_30d?.cost_usd||0).toFixed(2)}`,accent:`#34d399`}),(0,B.jsx)(w9,{label:`Usage 7d`,value:`$${(vt.usage_7d?.cost_usd||0).toFixed(2)}`,accent:`#22d3ee`}),(0,B.jsx)(w9,{label:`Rotate due`,value:String(vt.rotation_overdue||0),accent:vt.rotation_overdue?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Multi-repo errors`,value:String(vt.multi_repo_violations||0),accent:vt.multi_repo_violations?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Shared keys`,value:String(vt.shared_value_groups||0),accent:vt.shared_value_healthy===!1?`#f87171`:`#64748b`}),(0,B.jsx)(w9,{label:`Tracking errors`,value:String(vt.tracking_errors||0),accent:vt.tracking_healthy===!1?`#f87171`:`#34d399`}),(0,B.jsx)(w9,{label:`Developer`,value:String(vt.developer_keys||0),accent:`#a78bfa`})]}),(vt?.multi_repo_violations||0)>0&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(248,113,113,0.5)`,background:`rgba(248,113,113,0.08)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsx)(`strong`,{style:{color:`#f87171`},children:`Multi-repo binding error`}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 0`,color:`var(--text-secondary)`},children:[vt?.multi_repo_violations,` key(s) are bound to more than one repo. Each secret must be unique to a single product repo, or left unbound as a `,(0,B.jsx)(`strong`,{children:`Developer secret`}),` `,`(tooling / personal). Fix in the red “Needs fix” section below — set `,(0,B.jsx)(`em`,{children:`one`}),` repo or clear the field.`]})]}),vt?.shared_value_healthy===!1&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(251,146,60,0.55)`,background:`rgba(251,146,60,0.1)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsxs)(`strong`,{style:{color:`#fb923c`},children:[`Shared credential values — `,vt.shared_value_groups||0,` group(s) ·`,` `,vt.shared_value_keys||0,` key(s)`]}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 8px`,color:`var(--text-secondary)`},children:[`The same API key material is stored under multiple secret names and/or apps. Issue a`,` `,(0,B.jsx)(`strong`,{children:`unique key per app`}),` in the vendor console, then rotate each secret name. CLI: `,(0,B.jsx)(`code`,{children:`npx total-recall secret shared`})]}),(vt.shared_value_errors||[]).slice(0,8).map(e=>(0,B.jsxs)(`div`,{style:{fontSize:11,fontFamily:`ui-monospace, monospace`,marginBottom:6,color:`var(--text-secondary)`},children:[(0,B.jsxs)(`span`,{style:{color:`#fb923c`},children:[`fp `,e.fingerprint||`—`]}),` · apps [`,(e.apps||[]).join(`, `),`] · `,(e.keys||[]).join(`, `)]},e.fingerprint||(e.keys||[]).join(`,`)))]}),vt?.tracking_healthy===!1&&(0,B.jsxs)(`div`,{className:`card`,style:{marginBottom:16,padding:14,borderColor:`rgba(248,113,113,0.5)`,background:`rgba(248,113,113,0.08)`,fontSize:13,lineHeight:1.5},children:[(0,B.jsxs)(`strong`,{style:{color:`#f87171`},children:[`Account / usage tracking errors — `,vt.tracking_errors||0]}),(0,B.jsxs)(`p`,{style:{margin:`6px 0 8px`,color:`var(--text-secondary)`},children:[`Every set credential must be tracked (live provider account/usage API) or explicitly exempt with a monthly cost. Run `,(0,B.jsx)(`strong`,{children:`Sync provider accounts`}),` or CLI`,` `,(0,B.jsx)(`code`,{children:`npx total-recall secret account-sync`}),`.`]}),(vt.tracking_error_keys||[]).slice(0,10).map(e=>(0,B.jsxs)(`div`,{style:{fontSize:11,fontFamily:`ui-monospace, monospace`,marginBottom:4,color:`var(--text-secondary)`},children:[(0,B.jsx)(`span`,{style:{color:`#f87171`},children:e.key}),e.provider?` (${e.provider})`:``,`: `,(e.error||``).slice(0,120)]},e.key))]}),m?.by_provider&&m.by_provider.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{marginBottom:8,fontSize:11},onClick:()=>le(e=>!e),children:ce?`▾ Hide cost chart`:`▸ Cost by provider`}),ce&&(0,B.jsx)(`div`,{className:`card`,style:{marginBottom:12,padding:12},children:(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:m.by_provider.map(e=>{let t=Math.max(...m.by_provider.map(e=>e.cost_30d+e.monthly_cost),1),n=e.cost_30d+e.monthly_cost,r=Math.min(100,n/t*100);return(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`100px 1fr 80px`,gap:10,alignItems:`center`},children:[(0,B.jsx)(`span`,{style:{fontSize:12,fontWeight:600},children:e.provider}),(0,B.jsx)(`div`,{style:{height:6,background:`rgba(148,163,184,0.12)`,borderRadius:99,overflow:`hidden`},children:(0,B.jsx)(`div`,{style:{width:`${r}%`,height:`100%`,background:`linear-gradient(90deg, #3b82f6, #22d3ee)`,borderRadius:99}})}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,textAlign:`right`},children:[`$`,n.toFixed(2),` · `,e.keys,`k`]})]},e.provider)})})})]}),(0,B.jsx)(`div`,{style:{display:`flex`,gap:8,marginBottom:12,flexWrap:`wrap`},children:[{id:`catalog`,label:`Provider secrets (env)`},{id:`import`,label:`Import from env`},{id:`cloud`,label:`Cloud Models (API)`},{id:`pats`,label:`TR PATs (key generator)`},{id:`sync`,label:`Mesh Sync Status`}].map(n=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`btn btn-sm ${e===n.id?`btn-primary`:`btn-ghost`}`,children:n.label},n.id))}),e===`usage`&&(0,B.jsx)(`div`,{style:{height:`calc(100vh - 280px)`,minHeight:420,position:`relative`,overflowY:`auto`},children:(0,B.jsx)(ICe,{})}),e===`catalog`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`calc(100vh - 280px)`,minHeight:420,marginRight:T||Oe?440:0,transition:`margin 0.15s ease`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`center`,marginBottom:16,flexWrap:`wrap`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,background:`var(--bg-tertiary)`,borderRadius:6,padding:2},children:[(0,B.jsx)(`button`,{onClick:()=>w(`repo`),style:{padding:`4px 10px`,fontSize:11,fontWeight:500,borderRadius:4,cursor:`pointer`,border:`none`,background:C===`repo`?`var(--bg-active)`:`transparent`,color:C===`repo`?`var(--text-primary)`:`var(--text-secondary)`},children:`By Repo`}),(0,B.jsx)(`button`,{onClick:()=>w(`api`),style:{padding:`4px 10px`,fontSize:11,fontWeight:500,borderRadius:4,cursor:`pointer`,border:`none`,background:C===`api`?`var(--bg-active)`:`transparent`,color:C===`api`?`var(--text-primary)`:`var(--text-secondary)`},children:`By API`})]}),(0,B.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),placeholder:`Filter key, provider, repo, tier…`,style:{flex:`1 1 200px`,minWidth:160,padding:`8px 12px`,borderRadius:10,border:`1px solid var(--border)`,background:`var(--bg-primary)`,color:`var(--text-primary)`,outline:`none`}}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,style:{padding:`8px 16px`,fontSize:13,borderRadius:10,cursor:`pointer`},onClick:()=>{E(null),ke(!0),k({label:``,provider:`openai`,repos:``,subscription_tier:``,monthly_cost_usd:``,monthly_cap_usd:``,api_docs_url:``,headscale_url:``,rotate_every_days:``,auto_rotate:!1,notes:``,project_path:``,tracking_exempt:!1,shared_value_ok:!1}),je(``),Ne(``)},children:`+ Create Secret`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`center`,marginBottom:8,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:11},onClick:()=>ct(_t.map(e=>e.id)),children:`Expand all`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:11},onClick:lt,children:`Collapse all`}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[gt.length,` shown`,T?` · editing ${T.key}`:``]})]}),_t.length>0&&(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginBottom:8,flexShrink:0,maxHeight:72,overflowY:`auto`},children:_t.map(e=>{let t=ne.has(e.id);return(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-sm`,style:{fontSize:11,padding:`4px 10px`,background:t?e.kind===`error`?`rgba(248,113,113,0.2)`:`rgba(59,130,246,0.18)`:`transparent`,borderColor:e.kind===`error`?`rgba(248,113,113,0.45)`:t?`var(--border-accent)`:`var(--border)`,color:e.kind===`error`?`#f87171`:`var(--text-primary)`,display:`inline-flex`,alignItems:`center`},onClick:()=>{t&&ne.size===1?ct(_t.map(e=>e.id)):st(e.id)},title:t?`Currently expanded`:`Expand this repo only`,children:[t?`▾ `:`▸ `,C===`api`&&(0,B.jsx)(C9,{provider:e.id}),e.label,(0,B.jsx)(`span`,{style:{marginLeft:6,opacity:.7},children:e.keys.length})]},`chip-${e.id}`)})}),g&&!m?(0,B.jsx)(`p`,{style:{color:`var(--text-tertiary)`},children:`Loading catalog…`}):gt.length===0?(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,textAlign:`center`,color:`var(--text-secondary)`},children:[(0,B.jsxs)(`p`,{style:{marginBottom:12},children:[`No provider secrets in the global store`,x?` matching “${x}”`:``,`.`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void mt(),children:`Scan / migrate import`})]}):(0,B.jsx)(`div`,{className:`card`,style:{flex:1,minHeight:0,overflowY:`auto`,padding:0,display:`flex`,flexDirection:`column`},children:_t.map(e=>{let t=ne.has(e.id);return(0,B.jsxs)(`section`,{style:{borderBottom:`1px solid var(--border)`,background:e.kind===`error`?`rgba(248,113,113,0.04)`:e.kind===`developer`?`rgba(167,139,250,0.04)`:void 0},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>ot(e.id),style:{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 14px`,background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsxs)(`div`,{style:{fontSize:13,fontWeight:700,color:e.kind===`error`?`#f87171`:`var(--text-primary)`},children:[t?`▾`:`▸`,` `,C===`api`&&(0,B.jsx)(C9,{provider:e.id}),` `,e.label]}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginTop:2},children:e.kind===`error`?`Fix: one repo only, or clear for Developer secrets`:e.kind===`developer`?`Tooling / unbound`:e.kind===`provider`?[...new Set(e.keys.flatMap(e=>e.repos||[]))].join(`, `)||`Global`:`Product repo`})]}),(0,B.jsx)(`span`,{style:{fontSize:11,fontWeight:600,flexShrink:0,padding:`2px 8px`,borderRadius:99,background:e.kind===`error`?`rgba(248,113,113,0.15)`:`rgba(148,163,184,0.12)`,color:e.kind===`error`?`#f87171`:`var(--text-secondary)`},children:e.keys.length})]}),t&&(0,B.jsx)(`div`,{style:{padding:`0 8px 8px`},children:e.keys.map(t=>(0,B.jsx)(WCe,{k:t,sectionId:e.id,selected:T?.key===t.key,onOpen:et,groupBy:C},`${e.id}::${t.key}`))})]},e.id)})}),(T||Oe)&&(0,B.jsxs)(`div`,{role:`dialog`,"aria-label":T?`Edit ${T.key}`:`Create Secret`,style:{position:`fixed`,top:0,right:0,bottom:0,width:`min(420px, 100vw)`,zIndex:80,background:`var(--bg-secondary, #0f1419)`,borderLeft:`1px solid var(--border)`,boxShadow:`-12px 0 40px rgba(0,0,0,0.35)`,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,B.jsxs)(`div`,{style:{flexShrink:0,padding:`14px 16px`,borderBottom:`1px solid var(--border)`,display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:10,background:`rgba(0,0,0,0.2)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.06em`},children:T?`Edit secret`:`Create secret`}),(0,B.jsx)(`strong`,{style:{fontFamily:`ui-monospace, monospace`,fontSize:13,wordBreak:`break-all`,display:`block`,marginTop:2},children:T?T.key:`New Secret`}),T&&(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginTop:4},children:[T.masked||`••••`,T.subscription_tier?` · ${T.subscription_tier}`:``,T.monthly_cost_usd==null?``:` · $${T.monthly_cost_usd}/mo`]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{E(null),D.current=null,ke(!1)},children:`✕`})]}),(0,B.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:16},children:[Oe&&(0,B.jsxs)(`form`,{onSubmit:e=>{We(e)},style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(T9,{title:`Credentials`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:`secret-key-name`,className:`field-label`,style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`},children:`Secret Key Name`}),(0,B.jsx)(`input`,{id:`secret-key-name`,className:`input font-mono`,placeholder:`e.g. OPENAI_API_KEY`,value:Ae,onChange:e=>je(e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,width:`100%`,marginTop:4,boxSizing:`border-box`},required:!0})]}),(0,B.jsxs)(`div`,{style:{marginTop:12},children:[(0,B.jsx)(`label`,{htmlFor:`secret-value`,className:`field-label`,style:{fontSize:11,fontWeight:600,color:`var(--text-secondary)`},children:`Secret Value`}),(0,B.jsx)(`input`,{id:`secret-value`,type:`password`,className:`input`,placeholder:`Enter credential value`,value:Me,onChange:e=>Ne(e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,width:`100%`,marginTop:4,boxSizing:`border-box`},required:!0})]})]}),(0,B.jsxs)(T9,{title:`Identity`,children:[(0,B.jsx)(E9,{label:`Label`,value:O.label,onChange:e=>k({...O,label:e})}),(0,B.jsx)(E9,{label:`Provider`,value:O.provider,onChange:e=>k({...O,provider:e})})]}),(0,B.jsxs)(T9,{title:`Binding (one repo max)`,children:[(0,B.jsx)(E9,{label:`Product repo (exactly one name, or empty = Developer secrets)`,value:O.repos,onChange:e=>k({...O,repos:e})}),O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean).length>1&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:`Error: only one repo allowed. Remove extras before save.`}),(0,B.jsx)(E9,{label:`Project path (optional)`,value:O.project_path,onChange:e=>k({...O,project_path:e})})]}),(0,B.jsxs)(T9,{title:`Subscription & cost`,children:[(0,B.jsx)(E9,{label:`Subscription level / tier`,value:O.subscription_tier,onChange:e=>k({...O,subscription_tier:e}),placeholder:`e.g. free, pro, team, enterprise, payg`}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10,marginBottom:4},children:[(0,B.jsx)(E9,{label:`Monthly cost $`,value:O.monthly_cost_usd,onChange:e=>k({...O,monthly_cost_usd:e}),placeholder:`20`}),(0,B.jsx)(E9,{label:`Monthly cap $ (budget)`,value:O.monthly_cap_usd,onChange:e=>k({...O,monthly_cap_usd:e}),placeholder:`100`})]})]}),(0,B.jsxs)(T9,{title:`Docs & rotation`,children:[O.provider.trim().toLowerCase()===`headscale`&&(0,B.jsx)(E9,{label:`Headscale HTTPS URL`,value:O.headscale_url,onChange:e=>k({...O,headscale_url:e}),placeholder:`https://headscale.example.com`}),(0,B.jsx)(E9,{label:`API docs URL`,value:O.api_docs_url,onChange:e=>k({...O,api_docs_url:e})}),(0,B.jsx)(E9,{label:`Rotate every (days)`,value:O.rotate_every_days,onChange:e=>k({...O,rotate_every_days:e})}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:10},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.auto_rotate,onChange:e=>k({...O,auto_rotate:e.target.checked})}),`Auto-rotate when due`]}),(0,B.jsx)(E9,{label:`Notes`,value:O.notes,onChange:e=>k({...O,notes:e})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,style:{flex:1},disabled:N,children:N?`Creating...`:`Create Secret`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>ke(!1),children:`Cancel`})]})]}),T&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(T9,{title:`Reveal value (passkey)`,hint:`Full secret values require step-up auth — passkey preferred, password fallback`,children:[(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginBottom:8},children:[`Passkeys: `,ue?.count??0,!NG()&&` · browser unsupported`]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginBottom:10},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:ge||!NG(),onClick:()=>void tt(),children:ue?.has_passkeys?`Add another passkey`:`Register passkey (Touch ID)`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:ge||!ue?.has_passkeys,onClick:()=>void it(`passkey`),children:`Reveal with passkey`}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,flex:1},children:(0,B.jsx)(`input`,{type:`password`,value:me,onChange:e=>he(e.target.value),placeholder:`Or re-enter dashboard password`,style:{...D9,width:`100%`,marginTop:0}})}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:ge||!me,onClick:()=>void it(`password`),children:`Reveal`})]})]}),fe!=null&&(0,B.jsxs)(`div`,{style:{padding:10,borderRadius:8,background:`rgba(52,211,153,0.08)`,border:`1px solid rgba(52,211,153,0.35)`,marginBottom:8},children:[(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginBottom:4},children:`PLAINTEXT (hides in 30s) — never paste into chat/vault`}),(0,B.jsx)(`code`,{style:{fontSize:11,wordBreak:`break-all`,display:`block`,color:`var(--text-primary)`},children:fe}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void at(),children:`Copy`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>pe(null),children:`Hide now`})]})]})]}),T.schema&&(0,B.jsxs)(`div`,{style:{fontSize:11,marginBottom:12,padding:10,borderRadius:8,background:`rgba(59,130,246,0.08)`,border:`1px solid var(--border-accent)`},children:[(0,B.jsx)(`div`,{style:{fontWeight:700,marginBottom:4},children:`Schema`}),(0,B.jsxs)(`div`,{children:[`auth: `,T.schema.auth]}),T.schema.header&&(0,B.jsx)(`div`,{style:{fontFamily:`monospace`},children:T.schema.header}),T.schema_notes&&(0,B.jsx)(`div`,{style:{marginTop:4,color:`var(--text-tertiary)`},children:T.schema_notes})]}),(0,B.jsxs)(T9,{title:`Identity`,children:[(0,B.jsx)(E9,{label:`Label`,value:O.label,onChange:e=>k({...O,label:e})}),(0,B.jsx)(E9,{label:`Provider`,value:O.provider,onChange:e=>k({...O,provider:e})})]}),(0,B.jsxs)(T9,{title:`Binding (one repo max)`,children:[(0,B.jsx)(E9,{label:`Product repo (exactly one name, or empty = Developer secrets)`,value:O.repos,onChange:e=>k({...O,repos:e})}),O.repos.split(/[,]+/).map(e=>e.trim()).filter(Boolean).length>1&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:`Error: only one repo allowed. Remove extras before save.`}),T.multi_repo_error&&T.binding_error&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`#f87171`,marginBottom:10},children:T.binding_error}),(0,B.jsx)(E9,{label:`Project path (optional)`,value:O.project_path,onChange:e=>k({...O,project_path:e})})]}),(0,B.jsxs)(T9,{title:`Subscription & cost`,hint:`Plan level + what you pay monthly for this key/provider`,children:[(0,B.jsx)(E9,{label:`Subscription level / tier`,value:O.subscription_tier,onChange:e=>k({...O,subscription_tier:e}),placeholder:`e.g. free, pro, team, enterprise, payg`}),(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4,marginBottom:10},children:(T.tiers?.length?T.tiers:GCe).map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{fontSize:10,padding:`2px 8px`,borderColor:O.subscription_tier===e.id?`var(--border-accent)`:void 0,background:O.subscription_tier===e.id?`rgba(59,130,246,0.15)`:void 0},onClick:()=>k({...O,subscription_tier:e.id,monthly_cost_usd:e.monthly_usd==null?O.monthly_cost_usd:String(e.monthly_usd)}),children:[e.label,e.monthly_usd==null?``:` $${e.monthly_usd}`]},e.id))}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10,marginBottom:4},children:[(0,B.jsx)(E9,{label:`Monthly cost $`,value:O.monthly_cost_usd,onChange:e=>k({...O,monthly_cost_usd:e}),placeholder:`20`}),(0,B.jsx)(E9,{label:`Monthly cap $ (budget)`,value:O.monthly_cap_usd,onChange:e=>k({...O,monthly_cap_usd:e}),placeholder:`100`})]}),(O.subscription_tier||O.monthly_cost_usd)&&(0,B.jsxs)(`div`,{style:{fontSize:12,marginBottom:10,padding:`8px 10px`,borderRadius:8,background:`rgba(251,191,36,0.08)`,border:`1px solid rgba(251,191,36,0.25)`,color:`var(--text-secondary)`},children:[`Plan preview:`,` `,(0,B.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:O.subscription_tier||`—`}),O.monthly_cost_usd?` · $${O.monthly_cost_usd}/mo`:` · no monthly cost set`,O.monthly_cap_usd?` · cap $${O.monthly_cap_usd}`:``]})]}),(0,B.jsxs)(T9,{title:`Tracking & shared-key health`,hint:`Billable keys need live account/usage APIs; shared values across apps must be unique per app`,children:[(0,B.jsxs)(`div`,{style:{fontSize:12,marginBottom:10,lineHeight:1.45},children:[(0,B.jsxs)(`div`,{children:[`Tracking:`,` `,(0,B.jsx)(`strong`,{style:{color:T.tracking_status===`ok`||T.tracking_exempt?`#34d399`:T.tracking_status===`exempt`?`#fbbf24`:`#f87171`},children:T.tracking_exempt?`exempt`:T.tracking_status||`never synced`}),T.key_valid!=null&&(0,B.jsxs)(`span`,{style:{color:`var(--text-tertiary)`},children:[` `,`· key `,T.key_valid?`valid`:`invalid`]})]}),T.tracking_error&&(0,B.jsx)(`div`,{style:{color:`#f87171`,fontSize:11,marginTop:4},children:T.tracking_error}),T.tracking_usage!=null&&(0,B.jsx)(`pre`,{style:{fontSize:10,marginTop:6,padding:8,borderRadius:6,background:`rgba(0,0,0,0.25)`,overflow:`auto`,maxHeight:100},children:JSON.stringify(T.tracking_usage,null,2)}),(0,B.jsxs)(`div`,{style:{marginTop:8},children:[`Shared value:`,` `,(0,B.jsx)(`strong`,{style:{color:T.shared_value&&T.shared_value_severity===`error`?`#fb923c`:T.shared_value?`#fbbf24`:`#34d399`},children:T.shared_value?T.shared_value_severity===`error`?`ERROR — same material in multiple keys/apps`:`shared (waived)`:`unique`})]}),T.shared_with&&T.shared_with.length>0&&(0,B.jsxs)(`div`,{style:{fontSize:11,marginTop:4,color:`var(--text-secondary)`},children:[`Same value as:`,` `,T.shared_with.map(e=>`${e.key} (${e.app})`).join(`, `)]}),T.shared_value_error&&(0,B.jsx)(`div`,{style:{color:`#fb923c`,fontSize:11,marginTop:4},children:T.shared_value_error})]}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:8},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.tracking_exempt,onChange:e=>k({...O,tracking_exempt:e.target.checked})}),`Tracking exempt (no vendor account API — set monthly cost)`]}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:8},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.shared_value_ok,onChange:e=>k({...O,shared_value_ok:e.target.checked})}),`Shared value OK (intentional mirror — prefer unique keys per app)`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:A,style:{marginTop:4},onClick:async()=>{j(!0);try{let e=await Ar({key:T.key,strict:!0});F(`Synced ${T.key}: ${e.tracking_status||`?`}${e.error?` — ${e.error.slice(0,80)}`:``}`),await Ge()}catch(e){b(e.message)}finally{j(!1)}},children:`Re-probe this key`})]}),(0,B.jsxs)(T9,{title:`Docs & rotation`,children:[O.provider.trim().toLowerCase()===`headscale`&&(0,B.jsx)(E9,{label:`Headscale HTTPS URL`,value:O.headscale_url,onChange:e=>k({...O,headscale_url:e}),placeholder:`https://headscale.example.com`}),(0,B.jsx)(E9,{label:`API docs URL`,value:O.api_docs_url,onChange:e=>k({...O,api_docs_url:e})}),(0,B.jsx)(E9,{label:`Rotate every (days)`,value:O.rotate_every_days,onChange:e=>k({...O,rotate_every_days:e})}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12,marginBottom:10},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!O.auto_rotate,onChange:e=>k({...O,auto_rotate:e.target.checked})}),`Auto-rotate when due (flag — use CLI/agent to supply new value)`]}),(0,B.jsx)(E9,{label:`Notes`,value:O.notes,onChange:e=>k({...O,notes:e})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginTop:8},children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:N,onClick:()=>void ut(),children:`Save metadata`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void pt(),children:`Record sample usage $0.01`})]}),(0,B.jsxs)(`div`,{style:{marginTop:16,borderTop:`1px solid var(--border)`,paddingTop:12},children:[(0,B.jsx)(`div`,{style:{fontSize:11,fontWeight:700,marginBottom:8},children:`Rotate value`}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{type:`password`,value:ee,onChange:e=>M(e.target.value),placeholder:`New secret value`,style:D9})}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,style:{marginTop:8,width:`100%`},disabled:!ee||N,onClick:()=>void dt(),children:`Rotate + export .env`}),(0,B.jsxs)(`p`,{style:{fontSize:10,color:`var(--text-tertiary)`,marginTop:8},children:[`Browser assist CLI: `,(0,B.jsxs)(`code`,{children:[`npx total-recall secret rotate-browser `,T.key]})]}),T.next_rotate_due&&(0,B.jsxs)(`div`,{style:{fontSize:11,color:T.rotation_overdue?`#f87171`:`var(--text-tertiary)`,marginTop:6},children:[`Next due: `,new Date(T.next_rotate_due).toLocaleDateString(),T.rotation_overdue?` — overdue`:``]})]}),(0,B.jsxs)(`div`,{style:{marginTop:12,fontSize:11,color:`var(--text-tertiary)`},children:[`30d usage: `,T.usage_30d?.events||0,` events · $`,(T.usage_30d?.cost_usd||0).toFixed(4)]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12},children:[T.console_url&&(0,B.jsx)(`a`,{href:T.console_url,target:`_blank`,rel:`noreferrer`,className:`btn btn-ghost btn-sm`,children:`Console`}),T.pricing_url&&(0,B.jsx)(`a`,{href:T.pricing_url,target:`_blank`,rel:`noreferrer`,className:`btn btn-ghost btn-sm`,children:`Pricing`}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{color:`#f87171`,marginLeft:`auto`},onClick:()=>void ft(),children:`Delete`})]}),(0,B.jsxs)(`div`,{style:{marginTop:12,fontSize:10,color:`var(--text-tertiary)`,fontFamily:`monospace`},children:[`CLI: secret meta `,T.key,` --repo my-app --tier pro --monthly-cost 25 --rotate-days 90`]})]})]})]})]}),e===`import`&&(0,B.jsxs)(`div`,{className:`card`,style:{padding:20},children:[(0,B.jsx)(`h3`,{style:{marginBottom:8},children:`One-time migrate (import-env)`}),(0,B.jsxs)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginBottom:12,lineHeight:1.45},children:[`Pull legacy keys from local `,(0,B.jsx)(`code`,{children:`.env`}),` files into the TR store. Steady-state path is the opposite:`,` `,(0,B.jsx)(`strong`,{children:`export-env`}),` writes projections out from the store.`]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void mt(),style:{marginBottom:12},children:`Re-scan`}),Te.length===0?(0,B.jsx)(`p`,{style:{color:`var(--text-tertiary)`,fontSize:13},children:`No candidates — click Re-scan or use onboarding paste.`}):(0,B.jsxs)(B.Fragment,{children:[Te.map(e=>(0,B.jsxs)(`label`,{style:{display:`flex`,gap:10,padding:`8px 0`,borderBottom:`1px solid var(--border)`,opacity:e.already_set?.5:1},children:[(0,B.jsx)(`input`,{type:`checkbox`,disabled:!!e.already_set,checked:L.has(e.key),onChange:()=>{De(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n})}}),(0,B.jsx)(`span`,{style:{fontFamily:`monospace`,fontSize:12},children:e.key}),(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[e.masked,` · `,e.source_label]})]},e.key)),(0,B.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{marginTop:14},onClick:()=>void ht(),children:[`Import `,L.size,` key(s)`]})]})]}),e===`pats`&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`p`,{style:{fontSize:13,color:`var(--text-secondary)`,marginBottom:16},children:[(0,B.jsx)(`strong`,{children:`Original Total Recall feature:`}),` issue Personal Access Tokens that authenticate to`,` `,(0,B.jsx)(`code`,{children:`this`}),` brain (`,(0,B.jsx)(`code`,{children:`Authorization: Bearer …`}),` on `,(0,B.jsx)(`code`,{children:`/api/*`}),`). These are`,` `,(0,B.jsx)(`em`,{children:`not`}),` OpenAI/Anthropic keys — they only unlock your TR API.`]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:16,display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,B.jsx)(`input`,{value:be,onChange:e=>xe(e.target.value),placeholder:`PAT name`,style:{...D9,flex:1,minWidth:160}}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!be.trim(),onClick:async()=>{try{let e=await wr(be.trim(),[`*`]);Se(e),xe(``),await Je()}catch(e){b(e.message)}},children:`Issue PAT`})]}),I&&(0,B.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:16,borderColor:`rgba(52,211,153,0.4)`},children:[(0,B.jsx)(`strong`,{children:`Copy now — shown once`}),(0,B.jsx)(`div`,{style:{fontFamily:`monospace`,fontSize:12,marginTop:8,wordBreak:`break-all`},children:I.token}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,style:{marginTop:8},onClick:()=>{navigator.clipboard.writeText(I.token),we(!0),setTimeout(()=>we(!1),2e3)},children:Ce?`Copied`:`Copy`})]}),ve.filter(e=>!e.revoked).map(e=>(0,B.jsxs)(`div`,{className:`card`,style:{padding:12,marginBottom:8,display:`flex`,justifyContent:`space-between`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontWeight:600},children:e.name}),(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:[e.token_preview,`… · `,e.scopes?.join(`, `)]})]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,style:{color:`#f87171`},onClick:()=>void Tr(e.id).then(Je),children:`Revoke`})]},e.id))]}),e===`cloud`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:8},children:(0,B.jsx)(`button`,{onClick:$e,disabled:N,className:`btn btn-primary`,style:{minWidth:120},children:N?`Saving...`:`Save Configuration`})}),f&&(0,B.jsxs)(`div`,{className:`badge badge-success`,style:{padding:`6px 12px`,background:`rgba(16, 185, 129, 0.1)`,border:`1px solid #10b981`,color:`#34d399`},children:[`✓ `,f]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:24,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,borderBottom:`1px solid var(--border)`,paddingBottom:12},children:[(0,B.jsx)(`span`,{style:{fontSize:20},children:`🔑`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:14,fontWeight:600},children:`Cloud & Search APIs`}),(0,B.jsx)(`p`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:`Bring your own cloud models`})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`google_api_key`,style:{fontSize:13,fontWeight:500},children:`Google Gemini API Key`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`gemini`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`gemini`,onChange:()=>Qe(`preferred_agent`,`gemini`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`google_api_key`,type:`password`,autoComplete:`off`,placeholder:`AIzaSy...`,value:n?.secrets?.google_api_key||``,onChange:e=>Ze(`google_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.google_api_key,value:n?.brain?.gemini_model||``,onChange:e=>Qe(`gemini_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default Gemini Model`}),i.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.google_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`anthropic_api_key`,style:{fontSize:13,fontWeight:500},children:`Anthropic API Key (Claude)`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`claude`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`claude`,onChange:()=>Qe(`preferred_agent`,`claude`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`anthropic_api_key`,type:`password`,placeholder:`sk-ant-...`,value:n?.secrets?.anthropic_api_key||``,onChange:e=>Ze(`anthropic_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.anthropic_api_key,value:n?.brain?.claude_model||``,onChange:e=>Qe(`claude_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default Claude Model`}),o.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.anthropic_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:16,borderBottom:`1px solid rgba(255,255,255,0.05)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`openai_api_key`,style:{fontSize:13,fontWeight:500},children:`OpenAI API Key (Codex)`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`codex`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`codex`,onChange:()=>Qe(`preferred_agent`,`codex`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`openai_api_key`,type:`password`,placeholder:`sk-proj-...`,value:n?.secrets?.openai_api_key||``,onChange:e=>Ze(`openai_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),(0,B.jsxs)(`select`,{disabled:!n?.secrets?.openai_api_key,value:n?.brain?.openai_model||``,onChange:e=>Qe(`openai_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default OpenAI Model`}),c.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})]}),!n?.secrets?.openai_api_key&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-error, #f44336)`,marginTop:8},children:`⚠ API Key required to unlock model selection`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,paddingBottom:8},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,B.jsx)(`label`,{htmlFor:`openrouter_api_key`,style:{fontSize:13,fontWeight:500},children:`OpenRouter API Key`}),(0,B.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11,cursor:`pointer`,color:n?.brain?.preferred_agent===`openrouter`?`var(--accent)`:`var(--text-tertiary)`},children:[(0,B.jsx)(`input`,{type:`radio`,name:`preferred_agent`,checked:n?.brain?.preferred_agent===`openrouter`,onChange:()=>Qe(`preferred_agent`,`openrouter`)}),`Set Active`]})]}),(0,B.jsx)(`form`,{onSubmit:e=>e.preventDefault(),style:{display:`inline`,margin:0,padding:0,width:`100%`},children:(0,B.jsx)(`input`,{id:`openrouter_api_key`,type:`password`,placeholder:`sk-or-...`,value:n?.secrets?.openrouter_api_key||``,onChange:e=>Ze(`openrouter_api_key`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13}})}),g&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,padding:`0 4px`},children:`Fetching models...`}),!g&&u.length===0&&n?.secrets?.openrouter_api_key?.startsWith(`sk-or-`)&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--accent-red)`,padding:`0 4px`},children:`Failed to fetch OpenRouter models.`}),!g&&u.length>0&&(0,B.jsxs)(`select`,{id:`openrouter_model`,value:n?.brain?.openrouter_model||``,onChange:e=>Qe(`openrouter_model`,e.target.value),style:{background:`var(--bg-tertiary)`,color:`var(--text-primary)`,border:`1px solid var(--border)`,padding:`8px 12px`,borderRadius:6,outline:`none`,fontSize:13,marginTop:4},children:[(0,B.jsx)(`option`,{value:``,children:`Default OpenRouter Model`}),(()=>{let e={};return u.forEach(t=>{let n=t.id.split(`/`)[0].toUpperCase();e[n]||(e[n]=[]),e[n].push(t)}),Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>{let n=e[t].sort((e,t)=>e.id.localeCompare(t.id));return(0,B.jsx)(`optgroup`,{label:t,children:n.map(e=>{let t=``;return e.pricing&&e.pricing.prompt&&e.pricing.completion&&(t=` - ${(parseFloat(e.pricing.prompt)*1e6).toFixed(2)}/${(parseFloat(e.pricing.completion)*1e6).toFixed(2)} per 1M`),(0,B.jsxs)(`option`,{value:e.id,children:[e.displayName,` (`,e.id,`)`,t]},e.id)})},t)})})()]})]}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`},children:`These keys are stored locally and injected into the CLI reasoning agents on dispatch.`})]})]}),e===`sync`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,flexWrap:`wrap`,gap:10},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{fontSize:16,fontWeight:600},children:`Mesh Secrets Sync Status`}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-tertiary)`},children:`Checksum of local encrypted secrets database. Sync pushes updates to all configured mesh nodes.`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[Ie&&(0,B.jsxs)(`div`,{className:`badge`,style:{padding:`6px 12px`,fontSize:12,background:`rgba(255,255,255,0.05)`,border:`1px solid var(--border)`},children:[`Local Checksum: `,(0,B.jsx)(`code`,{style:{color:`var(--accent)`},children:Ie.slice(0,8)})]}),(0,B.jsxs)(`button`,{onClick:Ue,disabled:Re,className:`btn btn-primary`,style:{display:`flex`,alignItems:`center`,gap:6},children:[Re&&(0,B.jsx)(`span`,{className:`spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`,style:{width:12,height:12,border:`2px solid currentColor`,borderRightColor:`transparent`,borderRadius:`50%`,display:`inline-block`,animation:`spin 0.75s linear infinite`}}),Re?`Syncing...`:`Trigger Sync`]})]})]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(280px, 1fr))`,gap:16},children:[(0,B.jsxs)(`div`,{className:`card`,style:{padding:20,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`h4`,{style:{fontSize:14,fontWeight:600,borderBottom:`1px solid var(--border)`,paddingBottom:10,margin:0},children:[`Mesh Nodes (`,Pe.length,`)`]}),(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10,maxHeight:300,overflowY:`auto`},children:Pe.length===0?(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-tertiary)`,textAlign:`center`,margin:`20px 0`},children:`No mesh nodes configured or reachable.`}):Pe.map(e=>(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,background:`rgba(255,255,255,0.02)`,border:`1px solid rgba(255,255,255,0.05)`,borderRadius:8},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{style:{fontSize:13,fontWeight:500},children:e.hostname}),(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:e.ip})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[e.checksum&&(0,B.jsx)(`code`,{style:{fontSize:11,color:`var(--text-secondary)`},children:e.checksum.slice(0,8)}),(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:e.status===`synced`?`#22c55e`:e.status===`out_of_sync`?`#eab308`:`#ef4444`,boxShadow:e.status===`synced`?`0 0 6px rgba(34,197,94,0.5)`:e.status===`out_of_sync`?`0 0 6px rgba(234,179,8,0.5)`:`0 0 6px rgba(239,68,68,0.5)`},title:e.status})]})]},e.hostname))})]}),(0,B.jsxs)(`div`,{className:`card`,style:{padding:20,background:`rgba(18, 18, 26, 0.6)`,backdropFilter:`blur(8px)`,border:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsx)(`h4`,{style:{fontSize:14,fontWeight:600,borderBottom:`1px solid var(--border)`,paddingBottom:10,margin:0},children:`Sync Activity Log`}),(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,maxHeight:300,overflowY:`auto`,fontFamily:`monospace`,fontSize:11},children:Be.map((e,t)=>(0,B.jsxs)(`div`,{style:{color:e.status===`success`?`#34d399`:e.status===`error`?`#f87171`:`var(--text-secondary)`},children:[(0,B.jsxs)(`span`,{style:{color:`var(--text-tertiary)`,marginRight:8},children:[`[`,e.time,`]`]}),e.event]},t))})]})]})]}),(0,B.jsxs)(`p`,{style:{marginTop:24,fontSize:11,color:`var(--text-tertiary)`},children:[`CLI: `,(0,B.jsx)(`code`,{children:`secret catalog`}),` · `,(0,B.jsx)(`code`,{children:`secret meta KEY --repo app --tier pro --monthly-cost 25 --rotate-days 90`}),` ·`,` `,(0,B.jsx)(`code`,{children:`secret rotation-due`}),` · `,(0,B.jsx)(`code`,{children:`secret usage`}),` · `,(0,B.jsx)(`code`,{children:`secret providers`})]})]})}var zCe=`__developer__`,BCe=`__multi_repo_error__`,VCe=`__shared_value_error__`,HCe=`__tracking_error__`;function UCe(e){let t=new Map,n=[],r=[],i=[],a=[];for(let o of e){o.shared_value&&o.shared_value_severity===`error`&&i.push(o),o.set&&o.tracking_status!==`ok`&&o.tracking_status!==`exempt`&&!o.tracking_exempt&&a.push(o);let e=(o.repos||[]).map(e=>e.trim()).filter(Boolean);if(e.length>1||o.multi_repo_error){r.push(o);continue}if(!e.length){n.push(o);continue}let s=e[0];t.has(s)||t.set(s,[]),t.get(s).push(o)}let o=[];i.length&&o.push({id:VCe,label:`Needs fix — shared key across apps`,keys:i.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`}),a.length&&o.push({id:HCe,label:`Needs fix — account/usage not tracked`,keys:a.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`}),r.length&&o.push({id:BCe,label:`Needs fix — multi-repo binding`,keys:r.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`error`});for(let[e,n]of[...t.entries()].sort(([e],[t])=>e.localeCompare(t,void 0,{sensitivity:`base`})))o.push({id:e.replace(/[^a-zA-Z0-9._-]+/g,`-`),label:e,keys:n.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`repo`});return n.length&&o.push({id:zCe,label:`Developer secrets`,keys:n.slice().sort((e,t)=>e.key.localeCompare(t.key)),kind:`developer`}),o}var WCe=(0,v.memo)(function({k:e,selected:t,sectionId:n,onOpen:r,groupBy:i}){return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e,n),style:{width:`100%`,display:`grid`,gridTemplateColumns:`minmax(0, 1.4fr) minmax(0, 1fr) auto`,gap:8,alignItems:`center`,padding:`8px 10px`,marginBottom:4,borderRadius:8,border:`1px solid ${t?`var(--border-accent)`:`transparent`}`,background:t?`rgba(59,130,246,0.14)`:e.multi_repo_error||e.rotation_overdue||e.shared_value&&e.shared_value_severity===`error`||e.tracking_status&&e.tracking_status!==`ok`&&e.tracking_status!==`exempt`&&!e.tracking_exempt?`rgba(248,113,113,0.06)`:`rgba(148,163,184,0.04)`,color:`inherit`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0},children:[(0,B.jsxs)(`div`,{style:{fontFamily:`ui-monospace, monospace`,fontWeight:650,fontSize:12,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.key,e.shared_value&&e.shared_value_severity===`error`&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#fb923c`},children:`SHARED`}),e.tracking_status&&e.tracking_status!==`ok`&&e.tracking_status!==`exempt`&&!e.tracking_exempt&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`TRACK`}),e.tracking_status===`ok`&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#34d399`},children:`OK`}),e.multi_repo_error&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`MULTI`}),e.rotation_overdue&&(0,B.jsx)(`span`,{style:{marginLeft:6,fontSize:9,color:`#f87171`},children:`DUE`})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[i===`api`?e.repos?.length?e.repos.join(`, `):`Developer`:e.provider_name||e.provider||`—`,` · `,e.masked||`••••`,e.shared_value&&e.shared_apps?.length?` · apps: ${e.shared_apps.join(`, `)}`:``,e.multi_repo_error?` · ${e.repos.join(`, `)}`:``]})]}),(0,B.jsxs)(`div`,{style:{fontSize:10,color:`var(--text-secondary)`,minWidth:0},children:[(0,B.jsx)(`span`,{style:{color:e.subscription_tier?`#fbbf24`:`var(--text-tertiary)`},children:e.subscription_tier||`no tier`}),` · `,(0,B.jsx)(`span`,{style:{color:e.monthly_cost_usd==null?`var(--text-tertiary)`:`#34d399`},children:e.monthly_cost_usd==null?`no $/mo`:`$${e.monthly_cost_usd}/mo`}),` · `,(0,B.jsx)(`span`,{style:{color:e.usage_30d?.cost_usd>0?`#22d3ee`:`var(--text-tertiary)`},title:`${e.usage_30d?.events||0} events`,children:e.usage_30d?.cost_usd>0?`$${e.usage_30d.cost_usd.toFixed(2)} used`:`no usage`})]}),(0,B.jsx)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`,flexShrink:0},children:`›`})]})});function w9({label:e,value:t,accent:n}){return(0,B.jsxs)(`div`,{className:`card`,style:{padding:`14px 16px`,borderLeft:`3px solid ${n}`},children:[(0,B.jsx)(`div`,{style:{fontSize:20,fontWeight:700,letterSpacing:`-0.02em`},children:t}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.06em`,marginTop:2},children:e})]})}var GCe=[{id:`free`,label:`Free`,monthly_usd:0},{id:`payg`,label:`Pay-as-you-go`,monthly_usd:null},{id:`pro`,label:`Pro`,monthly_usd:20},{id:`team`,label:`Team`,monthly_usd:30},{id:`business`,label:`Business`,monthly_usd:50},{id:`enterprise`,label:`Enterprise`,monthly_usd:null}];function T9({title:e,hint:t,children:n}){return(0,B.jsxs)(`div`,{style:{marginBottom:14,paddingBottom:12,borderBottom:`1px solid var(--border)`},children:[(0,B.jsx)(`div`,{style:{fontSize:11,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.06em`,color:`var(--text-secondary)`,marginBottom:4},children:e}),t&&(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--text-tertiary)`,marginBottom:8,lineHeight:1.4},children:t}),n]})}function E9({label:e,value:t,onChange:n,placeholder:r}){return(0,B.jsxs)(`label`,{style:{display:`block`,marginBottom:10},children:[(0,B.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.05em`},children:e}),(0,B.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:r,style:{...D9,marginTop:4}})]})}var D9={width:`100%`,boxSizing:`border-box`,padding:`8px 10px`,borderRadius:8,border:`1px solid var(--border)`,background:`var(--bg-primary)`,color:`var(--text-primary)`,fontSize:12},O9=[{id:`antigravity`,name:`Antigravity`,surface:`.agents/skills/total-recall/SKILL.md`,command:`npx total-recall connect antigravity`,snippet:()=>`Injects SSSS vault directly into Antigravity skill definitions.`},{id:`gemini`,name:`Gemini CLI`,surface:`GEMINI.md`,command:`npx total-recall connect gemini`,snippet:()=>`Compiles project memory into GEMINI.md for the Gemini CLI.`},{id:`cursor`,name:`Cursor`,surface:`.cursor/rules/total-recall.mdc`,command:`npx total-recall connect cursor`,snippet:()=>`Continuously updates Cursor workspace rules with extracted memories.`},{id:`claude-code`,name:`Claude Code`,surface:`CLAUDE.md`,command:`npx total-recall connect claude-code`,snippet:()=>`Continuously updates Claude project instructions with extracted memories.`},{id:`codex`,name:`Codex / OpenAI`,surface:`AGENTS.md`,command:`npx total-recall connect codex`,snippet:()=>`Injects SSSS knowledge graph into Codex target surfaces.`},{id:`vscode`,name:`VS Code Copilot`,surface:`.github/copilot-instructions.md`,command:`npx total-recall connect vscode`,snippet:()=>`Auto-compiles memory insights into Copilot repository instructions.`},{id:`pi`,name:`Pi Coding Agent`,surface:`~/.pi/agent/AGENTS.md`,command:`npx total-recall connect pi`,snippet:()=>`Symlinks the compiled global agent surface for Pi terminal use.`},{id:`hermes`,name:`Hermes Agent`,surface:`~/.hermes/memories/MEMORY.md`,command:`npx total-recall connect hermes`,snippet:()=>`Pushes truncated memory surface projections to autonomous Hermes.`},{id:`openclaw`,name:`OpenClaw`,surface:`MEMORY.md`,command:`npx total-recall connect openclaw`,snippet:()=>`Mounts the Total Recall memory target for local OpenClaw runtimes.`}];function KCe({activeBrainId:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(null),d=(0,v.useMemo)(()=>{let e=In();return e?e.replace(/\/$/,``):window.location.origin},[]);(0,v.useEffect)(()=>{let e=!0;return hi().then(t=>{e&&t.success&&Array.isArray(t.active)&&c(t.active)}).catch(t=>{e&&o({type:`error`,text:`Failed to fetch active integrations: ${t.message||`Unknown error`}`})}),di().then(t=>{e&&u(t)}).catch(t=>{e&&o({type:`error`,text:`Failed to fetch extension status: ${t.message||`Unknown error`}`})}),()=>{e=!1}},[e]);let f=(0,v.useMemo)(()=>s.length===0?O9:O9.filter(e=>s.includes(e.id)),[s]),p=async(e,t)=>{await navigator.clipboard.writeText(t),n(e),setTimeout(()=>n(null),1800)},m=async e=>{i(e),o(null);try{let t=await mi(e,d);if(t.success){o({type:`success`,text:`Successfully enabled ${e} integration! Total Recall is now injecting memories.`});let t=await hi();t.success&&Array.isArray(t.active)&&c(t.active)}else o({type:`error`,text:`Failed to enable integration: ${t.message}`})}catch(e){o({type:`error`,text:e.message||`Failed to connect.`})}finally{i(null)}};return(0,B.jsxs)(`div`,{className:`page`,children:[(0,B.jsxs)(`div`,{className:`page-header`,children:[(0,B.jsx)(`h1`,{children:`Integrations`}),(0,B.jsx)(`p`,{children:`Enable automated memory injection for your local IDEs and agents`})]}),a&&(0,B.jsxs)(`div`,{style:{padding:`12px 16px`,borderRadius:8,marginBottom:16,fontSize:14,fontWeight:500,background:a.type===`success`?`rgba(16, 185, 129, 0.15)`:`rgba(239, 68, 68, 0.15)`,border:a.type===`success`?`1px solid rgba(16, 185, 129, 0.3)`:`1px solid rgba(239, 68, 68, 0.3)`,color:a.type===`success`?`#34d399`:`#f87171`,display:`flex`,justifyContent:`space-between`,alignItems:`center`,backdropFilter:`blur(8px)`,boxShadow:`0 4px 12px rgba(0,0,0,0.1)`},children:[(0,B.jsx)(`span`,{children:a.text}),(0,B.jsx)(`button`,{onClick:()=>o(null),style:{background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,fontSize:18,padding:`0 4px`,lineHeight:`1`},children:`×`})]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:16},children:[(0,B.jsxs)(`div`,{style:{border:`1px solid var(--border)`,background:`var(--bg-secondary)`,borderRadius:12,padding:18,display:`flex`,flexDirection:`column`,gap:12,position:`relative`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{margin:`0 0 4px`},children:`Chrome Extension`}),(0,B.jsx)(`div`,{style:{color:`var(--text-tertiary)`,fontSize:12},children:`Browser Overlay Panel & Capture`})]}),l?l.connected?(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(16, 185, 129, 0.1)`,border:`1px solid rgba(16, 185, 129, 0.3)`,fontSize:12,color:`#34d399`,fontWeight:500},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#10b981`,boxShadow:`0 0 8px #10b981`}}),`Connected`]}):(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(245, 158, 11, 0.1)`,border:`1px solid rgba(245, 158, 11, 0.3)`,fontSize:12,color:`#fbbf24`,fontWeight:500},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#f59e0b`}}),`Not Connected`]}):(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(255, 255, 255, 0.05)`,border:`1px solid rgba(255, 255, 255, 0.1)`,fontSize:12,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#94a3b8`}}),`Checking...`]})]}),(0,B.jsx)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontSize:13,color:`var(--text-secondary)`,lineHeight:`1.4`},children:`Install the Total Recall extension to passively capture context, store quick notes, and access the active brain search overlay inside any Chrome tab.`}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontFamily:`monospace`,fontSize:11,whiteSpace:`pre-wrap`,color:`var(--text-tertiary)`},children:[`1. Download zip & unzip locally.`,`
5522
5522
  `,`2. Go to chrome://extensions in browser.`,`
5523
5523
  `,`3. Enable "Developer mode" (top right).`,`
5524
5524
  `,`4. Click "Load unpacked" & select unzipped folder.`]}),(0,B.jsx)(`div`,{style:{display:`flex`,gap:10,marginTop:`auto`,paddingTop:8},children:(0,B.jsx)(`a`,{href:`${d}/api/extension/download`,download:!0,className:`btn btn-sm btn-primary`,style:{background:`linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)`,border:`none`,boxShadow:`0 2px 4px rgba(59, 130, 246, 0.3)`,fontWeight:600,cursor:`pointer`,textDecoration:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,padding:`6px 12px`,borderRadius:`6px`,color:`#fff`,fontSize:`12px`},children:`⬇ Download Extension Zip`})})]}),f.map(e=>{let n=e.snippet(d),i=s.includes(e.id),a=(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(255, 255, 255, 0.05)`,border:`1px solid rgba(255, 255, 255, 0.1)`,fontSize:12,color:`var(--text-tertiary)`},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#94a3b8`}}),`Inactive`]});return i&&(a=(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,padding:`4px 8px`,borderRadius:6,background:`rgba(16, 185, 129, 0.1)`,border:`1px solid rgba(16, 185, 129, 0.3)`,fontSize:12,color:`#34d399`,fontWeight:500},children:[(0,B.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`#10b981`,boxShadow:`0 0 8px #10b981`}}),`Injecting Memories`]})),(0,B.jsxs)(`div`,{style:{border:`1px solid var(--border)`,background:`var(--bg-secondary)`,borderRadius:12,padding:18,display:`flex`,flexDirection:`column`,gap:12,position:`relative`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{margin:`0 0 4px`},children:e.name}),(0,B.jsxs)(`div`,{style:{color:`var(--text-tertiary)`,fontSize:12},children:[`Target: `,(0,B.jsx)(`code`,{children:e.surface})]})]}),a]}),(0,B.jsx)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontSize:13,color:`var(--text-secondary)`,lineHeight:`1.4`},children:n}),(0,B.jsx)(`div`,{style:{background:`var(--bg-primary)`,border:`1px solid var(--border)`,borderRadius:8,padding:10,fontFamily:`monospace`,fontSize:12,whiteSpace:`pre-wrap`,color:`var(--text-secondary)`},children:e.command}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:4},children:[(0,B.jsx)(`button`,{className:`btn btn-sm btn-primary`,onClick:()=>m(e.id),disabled:r!==null||i,style:{background:i?`rgba(255, 255, 255, 0.1)`:`linear-gradient(135deg, #10b981 0%, #047857 100%)`,border:`none`,boxShadow:i?`none`:`0 2px 4px rgba(16, 185, 129, 0.3)`,fontWeight:600,cursor:i?`default`:`pointer`,color:i?`var(--text-tertiary)`:`#fff`},children:r===e.id?`Enabling...`:i?`Enabled`:`Enable Injection`}),(0,B.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>p(e.id,e.command),style:{background:`rgba(255, 255, 255, 0.05)`,border:`1px solid var(--border)`,color:`var(--text-secondary)`,cursor:`pointer`},children:t===e.id?`Copied!`:`Copy Command`})]})]},e.id)})]})]})}async function qCe(){let e=await Bn(`/api/mesh/leader`);if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function JCe(){return(await Bn(`/api/mesh/nodes`)).nodes}async function YCe(){return Bn(`/api/mesh/access/proposals`)}async function XCe(){return Vn(`/api/mesh/access/import`,{})}async function ZCe(e){return Vn(`/api/mesh/access`,e)}async function QCe(){let e=await Vn(`/api/mesh/election/refresh`,{});if(!e.leader)throw Error(`No online mesh leader is available`);return e.leader}async function $Ce(){return(await Bn(`/api/mesh/election/history`)).events||[]}async function ewe(e){return Vn(`/api/mesh/election/log`,e)}async function twe(){return Bn(`/api/mesh/latency`)}async function nwe(){return Bn(`/api/mesh/interfaces`)}async function rwe(e){let t=new URLSearchParams;e?.probe===!1&&t.set(`probe`,`0`),e?.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return Bn(`/api/mesh/lan${n?`?${n}`:``}`)}async function iwe(){return Bn(`/api/mesh/io`)}async function awe(){return Bn(`/api/mesh/enrollment`)}async function owe(e){return Vn(`/api/mesh/enroll`,e||{})}async function swe(e){return Vn(`/api/mesh/lan/register`,{probe:e?.probe!==!1,limit:e?.limit??32})}async function cwe(){let e=await Bn(`/api/headscale/node`);return e.nodes||e.machines||[]}async function lwe(e){return Hn(`/api/headscale/node/${encodeURIComponent(e)}`)}async function uwe(e){return(await Bn(`/api/headscale/preauthkey${e?`?user=${encodeURIComponent(e)}`:``}`)).preAuthKeys||[]}async function dwe(e){return Vn(`/api/headscale/preauthkey`,e)}async function fwe(){return(await Bn(`/api/headscale/user`)).users||[]}async function k9(){try{return await Bn(`/api/headscale/policy`)}catch(e){if(e?.status===409)return{policy:null,updatedAt:null,configured:!1,fileMode:!0};throw e}}async function pwe(e){let t=await z(`/api/headscale/policy`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({policy:e})});if(!t.ok){let e=await t.json().catch(()=>({})),n=Error(e.error||`Policy save failed (${t.status})`);throw n.status=t.status,n}return t.json()}function mwe(e=!1){return JSON.stringify({acls:[{action:`accept`,src:[`*`],dst:[`*:*`]}],ssh:[{action:`accept`,src:[`autogroup:member`],dst:[`autogroup:self`],users:e?[`autogroup:nonroot`,`root`]:[`autogroup:nonroot`]}]},null,2)}function hwe({nodes:e,leader:t,latencyMs:n={},onSelectNode:r,selectedHostname:i}){let[a,o]=(0,v.useState)(null),s=(0,v.useMemo)(()=>{let t=e.length;if(t===0)return[];let n=t===1?0:100;return e.map((e,r)=>{let i=t===1?0:2*Math.PI*r/t-Math.PI/2;return{...e,x:200+n*Math.cos(i),y:160+n*Math.sin(i)}})},[e]);return e.length===0?(0,B.jsx)(`div`,{className:`mesh-topology empty`,"data-testid":`mesh-topology`,children:(0,B.jsx)(`p`,{style:{color:`var(--text-secondary)`,textAlign:`center`,padding:24},children:`No mesh nodes to display`})}):(0,B.jsx)(`div`,{className:`mesh-topology`,"data-testid":`mesh-topology`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 400 320`,width:`100%`,height:`320`,role:`img`,"aria-label":`Mesh topology`,children:[s.map((e,t)=>s.slice(t+1).map(t=>(0,B.jsx)(`line`,{x1:e.x,y1:e.y,x2:t.x,y2:t.y,stroke:`var(--border)`,strokeWidth:1,opacity:.6},`${e.hostname}-${t.hostname}`))),s.map(e=>{let s=e.hostname===t?.hostname||e.ip===t?.ip,c=i===e.hostname,l=a===e.hostname,u=n[e.hostname],d=e.online?s?`var(--accent-hover)`:`var(--accent)`:`var(--error)`;return(0,B.jsxs)(`g`,{transform:`translate(${e.x},${e.y})`,style:{cursor:`pointer`},onClick:()=>r?.(e),onMouseEnter:()=>o(e.hostname),onMouseLeave:()=>o(null),"data-testid":`mesh-node-${e.hostname}`,children:[(0,B.jsx)(`circle`,{r:c||l?22:18,fill:d,opacity:e.online?1:.45,stroke:c?`var(--text)`:`transparent`,strokeWidth:2}),(0,B.jsx)(`text`,{y:36,textAnchor:`middle`,fontSize:11,fill:`var(--text)`,style:{pointerEvents:`none`},children:e.hostname?.split(`.`)[0]||e.ip}),u!=null&&!e.self&&(0,B.jsxs)(`text`,{y:-28,textAnchor:`middle`,fontSize:10,fill:`var(--text-secondary)`,style:{pointerEvents:`none`},children:[u,`ms`]})]},e.hostname)})]})})}async function gwe(){return Bn(`/api/embeddings/provider`)}async function _we(e){return Vn(`/api/embeddings/model`,{model:e})}async function vwe(){return Vn(`/api/embeddings/rediscover`,{})}function ywe(e){return e?e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.round(e/1e6)} MB`:`—`}function bwe(e,t){return e.embedding?e.dims===t?``:`${e.dims??`?`} dims — index needs ${t}`:`chat model — cannot embed`}function xwe(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useCallback)(async(e=()=>!0)=>{try{let n=await gwe();if(!e())return;t(n),r(null)}catch(t){if(!e())return;r(t instanceof Error?t.message:String(t))}},[]);(0,v.useEffect)(()=>{let e=!0,t=setTimeout(()=>{o(()=>e)},0);return()=>{e=!1,clearTimeout(t)}},[o]);let s=(0,v.useCallback)(async e=>{a(!0);try{await _we(e),await o(),r(null)}catch(e){r(e instanceof Error?e.message:String(e))}finally{a(!1)}},[o]),c=(0,v.useCallback)(async()=>{a(!0);try{await vwe(),await o(),r(null)}catch(e){r(e instanceof Error?e.message:String(e))}finally{a(!1)}},[o]);if(n&&!e)return(0,B.jsxs)(`div`,{className:`panel`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0},children:`Embedding Provider`}),(0,B.jsx)(`p`,{role:`alert`,children:n})]});if(!e)return(0,B.jsxs)(`div`,{className:`panel`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0},children:`Embedding Provider`}),(0,B.jsx)(`p`,{children:`Loading…`})]});let{local:l,fallbacks:u,dims:d}=e;return(0,B.jsxs)(`div`,{className:`panel`,children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,B.jsx)(`h3`,{style:{margin:0},children:`Embedding Provider`}),(0,B.jsx)(`span`,{"data-testid":`embed-availability`,style:{color:l.available?`var(--ok, #2ea043)`:`var(--warn, #d29922)`},children:l.available?`● local`:`○ hosted fallback`}),(0,B.jsx)(`button`,{type:`button`,onClick:c,disabled:i,children:`Re-discover`})]}),(0,B.jsxs)(`dl`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,gap:`4px 12px`,margin:`12px 0`},children:[(0,B.jsx)(`dt`,{children:`Endpoint`}),(0,B.jsx)(`dd`,{"data-testid":`embed-endpoint`,style:{margin:0},children:l.endpoint??`none reachable`}),(0,B.jsx)(`dt`,{children:`Model`}),(0,B.jsxs)(`dd`,{"data-testid":`embed-selected`,style:{margin:0},children:[l.selected??`—`,l.preferred?` (pinned)`:l.selected?` (auto)`:``]}),(0,B.jsx)(`dt`,{children:`Vector width`}),(0,B.jsx)(`dd`,{style:{margin:0},children:d})]}),l.reason&&(0,B.jsx)(`p`,{role:`status`,children:l.reason}),n&&(0,B.jsx)(`p`,{role:`alert`,children:n}),l.candidates.length>0&&(0,B.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{style:{textAlign:`left`},children:`Model`}),(0,B.jsx)(`th`,{style:{textAlign:`left`},children:`Size`}),(0,B.jsx)(`th`,{style:{textAlign:`left`},children:`Status`}),(0,B.jsx)(`th`,{})]})}),(0,B.jsx)(`tbody`,{children:l.candidates.map(e=>{let t=bwe(e,d),n=e.name===l.selected;return(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.name}),(0,B.jsx)(`td`,{children:ywe(e.size)}),(0,B.jsx)(`td`,{style:{opacity:e.compatible?1:.6},children:e.compatible?`${e.dims} dims`:t}),(0,B.jsxs)(`td`,{style:{textAlign:`right`},children:[e.compatible&&!n&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(e.name),disabled:i,children:`Use`}),n&&l.preferred&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(null),disabled:i,children:`Unpin`})]})]},e.name)})})]}),(0,B.jsxs)(`div`,{style:{marginTop:12,fontSize:`0.9em`,opacity:.8},children:[`Fallback chain:`,` `,u.map((e,t)=>(0,B.jsxs)(`span`,{children:[t>0&&` → `,(0,B.jsx)(`span`,{style:{textDecoration:e.configured?`none`:`line-through`},children:e.provider})]},e.provider))]})]})}function A9({values:e,width:t=96,height:n=28,title:r}){let i=e.filter(e=>typeof e==`number`&&Number.isFinite(e));if(i.length<2)return(0,B.jsx)(`span`,{className:`latency-sparkline latency-sparkline--empty`,title:r||`not enough samples`,children:`—`});let a=Math.max(...i,1),o=Math.min(...i,0),s=Math.max(a-o,1),c=t-4,l=n-4,u=i.map((e,t)=>{let n=2+c*t/(i.length-1),r=2+l*(1-(e-o)/s);return`${n.toFixed(1)},${r.toFixed(1)}`}).join(` `),d=i[i.length-1];return(0,B.jsxs)(`svg`,{className:`latency-sparkline`,width:t,height:n,viewBox:`0 0 ${t} ${n}`,role:`img`,"aria-label":r||`latency trend, last ${d} ms`,"data-testid":`latency-sparkline`,children:[r?(0,B.jsx)(`title`,{children:r}):null,(0,B.jsx)(`polyline`,{fill:`none`,stroke:`var(--accent-hover, #3b82f6)`,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,points:u}),(0,B.jsx)(`circle`,{cx:2+c,cy:2+l*(1-(d-o)/s),r:`2.2`,fill:`var(--accent-hover, #3b82f6)`})]})}var j9=5e3,Swe=3e4,Cwe={ssh_user:``,ssh_port:``,identity_file:``,ssh_host:``};function wwe(e){let t=e?.access;return{ssh_user:t?.ssh_user||``,ssh_port:t?.ssh_port?String(t.ssh_port):``,identity_file:t?.identity_file||``,ssh_host:t?.ssh_host||``}}function Twe(){let[e,t]=(0,v.useState)(`mesh`),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=n.find(e=>e.hostname===o)||null,[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)({}),[p,m]=(0,v.useState)([]),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[ee,M]=(0,v.useState)(null),[N,te]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(null),[oe,se]=(0,v.useState)([]),[ce,le]=(0,v.useState)(!1),[ue,de]=(0,v.useState)(null),[fe,pe]=(0,v.useState)(Cwe),[me,he]=(0,v.useState)(!1),[ge,_e]=(0,v.useState)(null),ve=(0,v.useRef)(null),ye=(0,v.useRef)(j9),be=(0,v.useRef)(!1),[xe,I]=(0,v.useState)([]),[Se,Ce]=(0,v.useState)([]),[we,Te]=(0,v.useState)([]),[Ee,L]=(0,v.useState)(null),[De,Oe]=(0,v.useState)(!1),[ke,Ae]=(0,v.useState)(`default`),[je,Me]=(0,v.useState)(!1),[Ne,Pe]=(0,v.useState)(!1),[Fe,Ie]=(0,v.useState)(`2099-12-31T23:59:59Z`),Le=n.filter(e=>e.access_resolved?.complete===!1),Re=(0,v.useCallback)((e,t)=>{if(!e)return;let n=`${e.hostname}|${e.ip}`;if((ve.current!==n||t!==`observed`)&&(ve.current!==n||t!==`observed`)){let r=new Date().toISOString();m(n=>[{at:r,hostname:e.hostname,ip:e.ip,note:t},...n].slice(0,50)),ve.current=n,ewe({hostname:e.hostname,ip:e.ip,note:t}).catch(()=>{})}},[]),ze=(0,v.useCallback)(e=>{s(e.hostname),pe(wwe(e)),_e(null)},[]),Be=(0,v.useCallback)(e=>{u(e),f(t=>{let n={...t};for(let[t,r]of Object.entries(e))r==null||!Number.isFinite(r)||(n[t]=[...n[t]||[],r].slice(-24));return n})},[]),Ve=(0,v.useCallback)(async()=>{Oe(!0),L(null);try{if(e===`mesh`){let[e,t]=await Promise.all([JCe(),qCe()]);r(e),a(t),Re(t,`observed`),twe().then(e=>Be(e.latency_ms||{})).catch(()=>{}),be.current||(be.current=!0,$Ce().then(e=>{e.length&&m(t=>{let n=new Set(t.map(e=>`${e.at}|${e.hostname}|${e.note}`));return[...e.filter(e=>e.at&&(e.hostname||e.ip)).map(e=>({at:e.at,hostname:e.hostname||e.ip||`unknown`,ip:e.ip||``,note:e.note||`observed`})).filter(e=>!n.has(`${e.at}|${e.hostname}|${e.note}`)),...t].slice(0,50)})}).catch(()=>{})),nwe().then(e=>y(e.summary||[])).catch(()=>{}),rwe({probe:!0,limit:24}).then(e=>{g(e.hosts||[]),x(e.tr_reachable_count||0)}).catch(()=>{}),iwe().then(e=>{C(e.io||null),T(e.ui_hints||e.io?.ui_hints||[])}).catch(()=>{}),(async()=>{try{let e=await k9();M({configured:e.configured,fileMode:e.fileMode})}catch{M(null)}})(),awe().then(D).catch(()=>{}),YCe().then(e=>se(e.proposals||[])).catch(()=>{}),ye.current=j9}else if(e===`headscale-nodes`){let e=await cwe();I(e)}else if(e===`preauthkeys`){let e=await uwe(ke||`default`);Ce(e)}else if(e===`users`){let e=await fwe();Te(e)}}catch(t){L(t instanceof Error?t.message:`Failed to load ${e} data`),ye.current=Math.min(Swe,ye.current*1.5)}finally{Oe(!1)}},[e,ke,Re,Be]);(0,v.useEffect)(()=>{let e=!1,t=null,n=async()=>{e||(await Ve(),!e&&(t=setTimeout(n,ye.current)))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[e,Ve]);async function He(){try{let e=await QCe();Re(e,`manual refresh`),await Ve()}catch(e){L(e instanceof Error?e.message:`Failed to refresh election state`)}}async function Ue(){re(!0),ae(null);try{let e=await swe({probe:!0,limit:24});ae(`Registered ${e.registration?.written_count??0} of ${e.registration?.attempted??0} TR-reachable LAN hosts as mesh_node entities.`),await Ve()}catch(e){L(e instanceof Error?e.message:`LAN register failed`)}finally{re(!1)}}async function We(){le(!0),de(null);try{let e=await XCe();de(e.failed?`Recorded ${e.saved} of ${e.attempted}; ${e.failed} could not be saved.`:`Recorded a login account for ${e.saved} node(s).`),await Ve()}catch(e){de(e instanceof Error?e.message:`Could not import from ssh config`)}finally{le(!1)}}async function Ge(e){if(e.preventDefault(),c){he(!0),_e(null);try{await ZCe({node:c.hostname,...fe}),_e(`Saved to the node entity.`),await Ve()}catch(e){_e(e instanceof Error?e.message:`Could not save access`)}finally{he(!1)}}}async function Ke(){te(!0),F(null);try{await pwe(mwe());let e=await k9();M({configured:e.configured,fileMode:e.fileMode}),F(`Mesh SSH enabled. Nodes pick this up automatically.`)}catch(e){F(e instanceof Error?e.message:`Could not enable mesh SSH`)}finally{te(!1)}}async function qe(){k(!0),j(null);try{let e=await owe();D(e.status),e.ok&&e.changed?j(`Enrolled on the mesh via ${e.method||`control server`}.`):e.ok?j(`This node is already enrolled.`):e.auth_url?j(`Approve the registration link below to finish joining.`):j(e.hint||e.reason||`Enrollment did not complete.`),await Ve()}catch(e){L(e instanceof Error?e.message:`Enrollment failed`)}finally{k(!1)}}async function Je(e){e.preventDefault();try{await dwe({user:ke,reusable:je,ephemeral:Ne,expiration:Fe}),await Ve()}catch(e){L(e instanceof Error?e.message:`Failed to create pre-auth key`)}}async function Ye(e){if(confirm(`Are you sure you want to delete this node from Headscale?`))try{await lwe(e),await Ve()}catch(e){L(e instanceof Error?e.message:`Failed to delete node`)}}return(0,B.jsxs)(`div`,{className:`page-container mesh-page`,children:[(0,B.jsxs)(`div`,{className:`page-header`,children:[(0,B.jsx)(`h1`,{children:`Mesh Operations Center`}),e===`mesh`&&(0,B.jsx)(`button`,{onClick:He,className:`btn btn-primary`,children:`Refresh Election`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,marginBottom:`24px`,borderBottom:`1px solid var(--border)`},children:[(0,B.jsx)(`button`,{className:`btn ${e===`mesh`?`btn-primary`:`btn-ghost`}`,onClick:()=>t(`mesh`),style:e===`mesh`?{}:{borderBottom:`none`},children:`Daemon Status`}),(0,B.jsx)(`button`,{className:`btn ${e===`headscale-nodes`?`btn-primary`:`btn-ghost`}`,onClick:()=>t(`headscale-nodes`),children:`Headscale Nodes`}),(0,B.jsx)(`button`,{className:`btn ${e===`preauthkeys`?`btn-primary`:`btn-ghost`}`,onClick:()=>t(`preauthkeys`),children:`Pre-Auth Keys`}),(0,B.jsx)(`button`,{className:`btn ${e===`users`?`btn-primary`:`btn-ghost`}`,onClick:()=>t(`users`),children:`Users`})]}),Ee&&(0,B.jsx)(`div`,{className:`alert alert-error`,style:{marginBottom:`24px`},children:Ee}),E&&!E.enrolled&&(0,B.jsx)(`div`,{className:`alert alert-warning mesh-enrollment-banner`,style:{marginBottom:`24px`},"data-testid":`enrollment-banner`,children:(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:16,flexWrap:`wrap`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:`This node is not on the mesh`}),(0,B.jsx)(`div`,{style:{fontSize:13,marginTop:4},children:E.state===`client_unavailable`?`No Tailscale client detected. Install Tailscale (or set TR_TAILSCALE_BIN) to join the mesh.`:E.can_auto_enroll?`Ready to enroll automatically against ${E.login_server}.`:E.login_server?`Control server ${E.login_server} — add a Headscale API key to enroll without approving in a browser.`:`No control server configured. Add a Headscale API key with its URL, or set TR_HEADSCALE_URL.`}),E.auth_url&&(0,B.jsxs)(`div`,{style:{fontSize:13,marginTop:8},children:[`Pending registration:`,` `,(0,B.jsx)(`a`,{href:E.auth_url,target:`_blank`,rel:`noreferrer noopener`,children:`approve this node`})]}),A&&(0,B.jsx)(`div`,{style:{fontSize:13,marginTop:8,color:`var(--accent-hover)`},children:A})]}),E.client_available&&(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:qe,disabled:O,children:O?`Enrolling…`:`Enroll this node`})]})}),e===`mesh`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24},children:[ee&&!ee.configured&&(0,B.jsx)(`div`,{className:`alert alert-warning`,"data-testid":`mesh-ssh-banner`,children:(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:16,flexWrap:`wrap`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:`Mesh SSH is off`}),(0,B.jsx)(`div`,{style:{fontSize:13,marginTop:4},children:ee.fileMode?`The control server stores its policy in a file, so it cannot be managed here. Set policy.mode: database in the control server config to enable this.`:`Nodes can reach each other, but each still needs its own SSH keys. Enabling mesh SSH lets the control server authorise connections instead.`}),P&&(0,B.jsx)(`div`,{style:{fontSize:13,marginTop:8,color:`var(--accent-hover)`},children:P})]}),!ee.fileMode&&(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:Ke,disabled:N,children:N?`Enabling…`:`Enable mesh SSH`})]})}),ee?.configured&&P&&(0,B.jsx)(`div`,{className:`alert alert-success`,"data-testid":`mesh-ssh-ok`,children:P}),Le.length>0&&(0,B.jsx)(`div`,{className:`alert alert-warning`,"data-testid":`mesh-access-banner`,children:(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:16,flexWrap:`wrap`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:Le.length===1?`1 node has no recorded login account`:`${Le.length} nodes have no recorded login account`}),(0,B.jsxs)(`div`,{style:{fontSize:13,marginTop:4},children:[`Any node that tries to reach one of these is refused, in exactly the way an unreachable machine refuses. `,oe.length>0?`This host's ssh config can supply ${oe.length} of them.`:`Select a node below to record one.`]}),(0,B.jsx)(`div`,{style:{fontSize:12,marginTop:6,color:`var(--text-secondary)`},children:Le.map(e=>e.hostname).join(`, `)}),oe.length>0&&(0,B.jsx)(`ul`,{style:{margin:`8px 0 0`,paddingLeft:18,fontSize:12},"data-testid":`access-proposals`,children:oe.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:e.hostname}),` → `,e.access.ssh_user,` `,(0,B.jsxs)(`span`,{style:{color:`var(--text-secondary)`},children:[`(from Host `,e.matched_host,`)`]})]},e.hostname))}),ue&&(0,B.jsx)(`div`,{style:{fontSize:13,marginTop:8,color:`var(--accent-hover)`},children:ue})]}),oe.length>0&&(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:We,disabled:ce,children:ce?`Importing…`:`Import from ssh config`})]})}),(0,B.jsx)(`div`,{className:`card`,children:(0,B.jsx)(xwe,{})}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},children:[(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:12},children:`Topology`}),(0,B.jsx)(hwe,{nodes:n,leader:i,latencyMs:l,selectedHostname:o,onSelectNode:ze})]}),(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:12},children:`Node Detail`}),c?(0,B.jsxs)(`dl`,{className:`mesh-node-detail`,style:{margin:0,display:`grid`,gridTemplateColumns:`120px 1fr`,gap:`8px 12px`},children:[(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Title`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.title||c.hostname}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Hostname`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.hostname}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`IP`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.ip||`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Online`}),(0,B.jsxs)(`dd`,{style:{margin:0},children:[c.online?`yes`:`no`,c.vault_only?` (vault-only entity)`:``]}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`OS`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.os||`Unknown`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Election`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.hostname===i?.hostname||c.ip===i?.ip?`LEADER`:`FOLLOWER`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Entity role`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.role||`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Labels`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.labels?.length?c.labels.join(`, `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Capabilities`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.capabilities?.length?c.capabilities.join(`, `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Notes`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.notes||c.description||`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Latency`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.self?`self`:l[c.hostname]==null?`n/a`:`${l[c.hostname]} ms`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Entity`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.has_entity?c.entity_path||`vault mesh_node`:`live discovery only (no vault entity yet)`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Transports`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.transports?.length?c.transports.join(`, `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`LAN IP`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.lan_ip||`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Interfaces`}),(0,B.jsx)(`dd`,{style:{margin:0},children:(c.interfaces?.length?c.interfaces:c.self?_:[]).length===0?`—`:(c.interfaces?.length?c.interfaces:_).map(e=>`${e.name} (${e.kind})`).join(`, `)}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`I/O channels`}),(0,B.jsx)(`dd`,{style:{margin:0},children:(c.self?S?.channels:c.io?.channels)?.length?(c.self?S?.channels:c.io?.channels).join(`, `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`UI hints`}),(0,B.jsx)(`dd`,{style:{margin:0,fontSize:12},children:(c.self?w:c.ui_hints||c.io?.ui_hints)?.length?(c.self?w:c.ui_hints||c.io?.ui_hints).join(` · `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Scope`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.self?`This node`:`Peer`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Login`}),(0,B.jsx)(`dd`,{style:{margin:0,fontFamily:`monospace`,fontSize:12},"data-testid":`node-access-target`,children:c.access_resolved?.complete?c.access_resolved.target:(0,B.jsx)(`span`,{className:`badge badge-offline`,children:`no login recorded`})}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Access source`}),(0,B.jsx)(`dd`,{style:{margin:0},children:c.access?.source&&c.access.source!==`unknown`?c.access.source.replace(`_`,` `):`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Mesh SSH`}),(0,B.jsx)(`dd`,{style:{margin:0},"data-testid":`node-mesh-ssh`,children:c.access_resolved?.mesh_ssh===`available`?`authorised by the control server`:c.access_resolved?.mesh_ssh===`unsupported`?`not served by this build (${c.access_resolved.tailscale_variant}) — needs its own keys`:`unknown`})]}):(0,B.jsx)(`p`,{style:{color:`var(--text-secondary)`},children:`Click a node in the topology to inspect it.`}),c&&(0,B.jsxs)(`form`,{onSubmit:Ge,style:{marginTop:16,borderTop:`1px solid var(--border)`,paddingTop:12},children:[(0,B.jsx)(`h4`,{style:{margin:`0 0 4px`},children:`Access`}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,margin:`0 0 12px`},children:`Stored on the node entity, so every machine and agent resolves it the same way. Leave a box empty to clear it. The address comes from the mesh unless you override it.`}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:8},children:[(0,B.jsxs)(`label`,{style:{fontSize:12},children:[`Login account`,(0,B.jsx)(`input`,{className:`input`,value:fe.ssh_user,placeholder:`e.g. the account you ssh as`,onChange:e=>pe({...fe,ssh_user:e.target.value})})]}),(0,B.jsxs)(`label`,{style:{fontSize:12},children:[`Port`,(0,B.jsx)(`input`,{className:`input`,value:fe.ssh_port,placeholder:`22`,inputMode:`numeric`,onChange:e=>pe({...fe,ssh_port:e.target.value})})]}),(0,B.jsxs)(`label`,{style:{fontSize:12},children:[`Key file`,(0,B.jsx)(`input`,{className:`input`,value:fe.identity_file,placeholder:`~/.ssh/id_ed25519`,onChange:e=>pe({...fe,identity_file:e.target.value})})]}),(0,B.jsxs)(`label`,{style:{fontSize:12},children:[`Address override`,(0,B.jsx)(`input`,{className:`input`,value:fe.ssh_host,placeholder:c.ip||`mesh address`,onChange:e=>pe({...fe,ssh_host:e.target.value})})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginTop:12},children:[(0,B.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-sm`,disabled:me,children:me?`Saving…`:`Save access`}),ge&&(0,B.jsx)(`span`,{style:{fontSize:12,color:`var(--accent-hover)`},"data-testid":`access-save-msg`,children:ge})]})]})]})]}),(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:12},children:`This host — I/O for agent UI`}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:0},children:`Channels (screen, touch, mic, speaker, …) and UI hints so agents can generate UI for the right surfaces. Stored as mesh_node entity variables; vault overrides live detection.`}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginBottom:12},children:[(S?.channels||[]).map(e=>(0,B.jsx)(`span`,{className:`badge badge-leader`,children:e},e)),!S?.channels?.length&&(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`},children:`Detecting…`})]}),(0,B.jsxs)(`dl`,{style:{margin:0,display:`grid`,gridTemplateColumns:`140px 1fr`,gap:`6px 12px`,fontSize:13},children:[(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Display`}),(0,B.jsx)(`dd`,{style:{margin:0},children:S?.display?.present?`yes${S.display.touch?` · touch`:``}${S.display.width&&S.display.height?` · ${S.display.width}×${S.display.height}`:``}`:S?.headless?`headless`:`—`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Audio`}),(0,B.jsxs)(`dd`,{style:{margin:0},children:[`in: `,S?.audio?.input?`yes`:`no`,` · out: `,S?.audio?.output?`yes`:`no`]}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Camera`}),(0,B.jsx)(`dd`,{style:{margin:0},children:S?.camera?.present?`yes`:`no`}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`Input`}),(0,B.jsxs)(`dd`,{style:{margin:0},children:[`kb: `,S?.input?.keyboard?`yes`:`no`,` · pointer: `,S?.input?.pointer?`yes`:`no`,` · touch: `,S?.input?.touch?`yes`:`no`]}),(0,B.jsx)(`dt`,{style:{color:`var(--text-secondary)`},children:`UI hints`}),(0,B.jsx)(`dd`,{style:{margin:0},children:w.length?w.join(` · `):`—`})]})]}),(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:16},children:[(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:12},children:`Local interfaces`}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:0},children:`Kinds are classified from OS interface names (wifi / ethernet / vpn_overlay / …). Variables of this host, not hardcoded devices.`}),(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Name`}),(0,B.jsx)(`th`,{children:`Kind`}),(0,B.jsx)(`th`,{children:`IPv4`})]})}),(0,B.jsxs)(`tbody`,{children:[_.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.name}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`badge badge-follower`,children:e.kind})}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`,fontFamily:`monospace`,fontSize:12},children:(e.ipv4||[]).join(`, `)||`—`})]},e.name)),_.length===0&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:3,style:{color:`var(--text-secondary)`,textAlign:`center`},children:`No external interfaces reported`})})]})]})]}),(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:12,marginBottom:8},children:[(0,B.jsxs)(`h3`,{style:{margin:0},children:[`LAN discovery`,b>0?(0,B.jsxs)(`span`,{style:{marginLeft:8,fontSize:13,fontWeight:400,color:`var(--accent-hover)`},children:[b,` Total Recall reachable`]}):null]}),(0,B.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:ne||b===0,onClick:Ue,title:`Create/update mesh_node vault entities for TR-reachable LAN hosts`,children:ne?`Registering…`:`Register TR peers`})]}),(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:0},children:`Hosts from the OS neighbor/ARP table on private LAN ranges. TR-reachable means /health answered on the brain port. Register upserts entity docs (hostname lan-<ip>) without hardcoding fleet names.`}),ie&&(0,B.jsx)(`p`,{style:{fontSize:12,color:`var(--accent-hover)`},children:ie}),(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`IP`}),(0,B.jsx)(`th`,{children:`MAC`}),(0,B.jsx)(`th`,{children:`IF`}),(0,B.jsx)(`th`,{children:`TR`})]})}),(0,B.jsxs)(`tbody`,{children:[h.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:12},children:e.ip}),(0,B.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:11,color:`var(--text-secondary)`},children:e.mac}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.interface||`—`}),(0,B.jsx)(`td`,{children:e.tr_reachable?(0,B.jsxs)(`span`,{className:`badge badge-online`,children:[`yes`,e.tr_latency_ms==null?``:` ${e.tr_latency_ms}ms`]}):(0,B.jsx)(`span`,{className:`badge badge-offline`,children:`no`})})]},e.ip)),h.length===0&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:4,style:{color:`var(--text-secondary)`,textAlign:`center`},children:`No LAN neighbors discovered (ARP empty or unavailable)`})})]})]})]})]}),(0,B.jsx)(`div`,{className:`card`,style:{padding:0,overflow:`hidden`},children:(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Hostname`}),(0,B.jsx)(`th`,{children:`Mesh IP`}),(0,B.jsx)(`th`,{children:`Role`}),(0,B.jsx)(`th`,{children:`Status`}),(0,B.jsx)(`th`,{children:`Latency`}),(0,B.jsx)(`th`,{children:`Login`}),(0,B.jsx)(`th`,{children:`Operating System`}),(0,B.jsx)(`th`,{children:`Node`})]})}),(0,B.jsxs)(`tbody`,{children:[n.map(e=>{let t=e.hostname===i?.hostname||e.ip===i?.ip;return(0,B.jsxs)(`tr`,{"data-testid":`node-row-${e.hostname}`,className:t?`is-leader`:``,onClick:()=>ze(e),style:{cursor:`pointer`},children:[(0,B.jsxs)(`td`,{style:{fontWeight:500,display:`flex`,alignItems:`center`,gap:`8px`},children:[t&&(0,B.jsx)(`span`,{title:`Leader`,style:{color:`var(--accent-hover)`},children:`👑`}),e.hostname]}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.ip}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`badge ${t?`badge-leader`:`badge-follower`}`,children:t?`LEADER`:`FOLLOWER`})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`badge ${e.online?`badge-online`:`badge-offline`}`,children:e.online?`ONLINE`:`OFFLINE`})}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.self||l[e.hostname]==null?`—`:`${l[e.hostname]} ms`}),(0,B.jsx)(`td`,{style:{fontFamily:`monospace`,fontSize:12},children:e.access_resolved?.complete?e.access_resolved.target:(0,B.jsx)(`span`,{className:`badge badge-offline`,title:`Connecting will fail as though the node were unreachable`,children:`no login`})}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.os||`Unknown`}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`,fontSize:`13px`},children:e.self?`This node`:`Peer`})]},e.hostname)}),n.length===0&&!De&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:8,style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`32px`},children:`No mesh nodes found`})})]})]})}),(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:8},children:`Latency matrix (from this node)`}),(0,B.jsxs)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:0},children:[`Measured via `,(0,B.jsx)(`code`,{children:`GET /api/mesh/latency`}),` through the fetch gate. Full N×N requires each peer to report; this row is what `,(0,B.jsx)(`em`,{children:`this`}),` host measures.`]}),(0,B.jsx)(`div`,{className:`latency-matrix-wrap`,children:(0,B.jsxs)(`table`,{className:`latency-matrix`,"data-testid":`latency-matrix`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{className:`from-label`,children:`From → To`}),n.map(e=>(0,B.jsx)(`th`,{children:e.hostname},`col-${e.hostname}`))]})}),(0,B.jsx)(`tbody`,{children:(()=>{let e=n.find(e=>e.self)||n[0];return e?(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{className:`from-label`,children:[e.hostname,` (this)`]}),n.map(e=>{let t=e.self?0:l[e.hostname],n=e.self?`0 ms`:t==null?e.online?`…`:`—`:`${t} ms`;return(0,B.jsxs)(`td`,{className:`rtt-cell${e.self?` is-self`:``}`,title:e.self?`self`:void 0,children:[(0,B.jsx)(`div`,{children:n}),!e.self&&(0,B.jsx)(A9,{values:d[e.hostname]||[],title:`RTT trend to ${e.hostname}`})]},`cell-${e.hostname}`)})]}):(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:Math.max(n.length+1,2),style:{color:`var(--text-secondary)`},children:`No mesh nodes yet`})})})()})]})}),(0,B.jsxs)(`table`,{className:`data-table`,style:{marginTop:16},children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Peer`}),(0,B.jsx)(`th`,{children:`RTT`}),(0,B.jsx)(`th`,{children:`Trend`})]})}),(0,B.jsxs)(`tbody`,{children:[n.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.hostname}),(0,B.jsx)(`td`,{children:e.self?`0 ms (self)`:l[e.hostname]==null?e.online?`measuring…`:`offline`:`${l[e.hostname]} ms`}),(0,B.jsx)(`td`,{children:e.self?`—`:(0,B.jsx)(A9,{values:d[e.hostname]||[],title:`RTT trend to ${e.hostname}`})})]},`lat-${e.hostname}`)),n.length===0&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:3,style:{color:`var(--text-secondary)`,textAlign:`center`},children:`No peers`})})]})]})]}),(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{style:{marginTop:0,marginBottom:12},children:`Election history`}),(0,B.jsxs)(`p`,{style:{fontSize:12,color:`var(--text-secondary)`,marginTop:0},children:[`Durable SSSS events (`,(0,B.jsx)(`code`,{children:`mesh_election`}),`) plus this session.`]}),p.length===0?(0,B.jsx)(`p`,{style:{color:`var(--text-secondary)`},children:`No leader changes recorded yet.`}):(0,B.jsx)(`ul`,{style:{margin:0,paddingLeft:18,maxHeight:220,overflowY:`auto`},"data-testid":`election-history`,children:p.map((e,t)=>(0,B.jsxs)(`li`,{style:{marginBottom:8},children:[(0,B.jsx)(`strong`,{children:e.hostname}),` (`,e.ip,`) — `,e.note,(0,B.jsx)(`div`,{style:{fontSize:12,color:`var(--text-secondary)`},children:new Date(e.at).toLocaleString()})]},`${e.at}-${t}`))})]})]}),e===`headscale-nodes`&&(0,B.jsx)(`div`,{className:`card`,style:{padding:0,overflow:`hidden`},children:(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`ID`}),(0,B.jsx)(`th`,{children:`Name`}),(0,B.jsx)(`th`,{children:`IP Addresses`}),(0,B.jsx)(`th`,{children:`User`}),(0,B.jsx)(`th`,{children:`Client Version`}),(0,B.jsx)(`th`,{children:`Last Seen`}),(0,B.jsx)(`th`,{children:`Actions`})]})}),(0,B.jsxs)(`tbody`,{children:[xe.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.id}),(0,B.jsx)(`td`,{style:{fontWeight:500},children:e.name}),(0,B.jsx)(`td`,{children:e.ipAddresses.join(`, `)}),(0,B.jsx)(`td`,{children:typeof e.user==`object`?e.user?.name:e.user||``}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.clientVersion}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`,fontSize:`13px`},children:new Date(e.lastSeen).toLocaleString()}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`button`,{className:`btn btn-ghost btn-sm`,style:{color:`var(--error)`},onClick:()=>Ye(e.id),children:`Delete`})})]},e.id)),xe.length===0&&!De&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:7,style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`32px`},children:`No Headscale nodes found.`})})]})]})}),e===`preauthkeys`&&(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`24px`},children:[(0,B.jsxs)(`div`,{className:`card`,children:[(0,B.jsx)(`h3`,{children:`Generate Pre-Auth Key`}),(0,B.jsxs)(`form`,{onSubmit:Je,style:{display:`flex`,gap:`16px`,alignItems:`flex-end`,marginTop:`16px`},children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{style:{display:`block`,fontSize:`12px`,marginBottom:`4px`},children:`User`}),(0,B.jsx)(`input`,{className:`input`,value:ke,onChange:e=>Ae(e.target.value),required:!0})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{style:{display:`block`,fontSize:`12px`,marginBottom:`4px`},children:`Expiration`}),(0,B.jsx)(`input`,{type:`datetime-local`,className:`input`,value:Fe.slice(0,16),onChange:e=>Ie(new Date(e.target.value).toISOString()),required:!0})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,paddingBottom:`8px`},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:je,onChange:e=>Me(e.target.checked),id:`reusable`}),(0,B.jsx)(`label`,{htmlFor:`reusable`,style:{fontSize:`14px`},children:`Reusable`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,paddingBottom:`8px`},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:Ne,onChange:e=>Pe(e.target.checked),id:`ephemeral`}),(0,B.jsx)(`label`,{htmlFor:`ephemeral`,style:{fontSize:`14px`},children:`Ephemeral`})]}),(0,B.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:De,children:`Generate Key`})]})]}),(0,B.jsx)(`div`,{className:`card`,style:{padding:0,overflow:`hidden`},children:(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`ID`}),(0,B.jsx)(`th`,{children:`Key`}),(0,B.jsx)(`th`,{children:`User`}),(0,B.jsx)(`th`,{children:`Reusable`}),(0,B.jsx)(`th`,{children:`Ephemeral`}),(0,B.jsx)(`th`,{children:`Used`}),(0,B.jsx)(`th`,{children:`Expiration`})]})}),(0,B.jsxs)(`tbody`,{children:[Se.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.id}),(0,B.jsx)(`td`,{style:{fontFamily:`monospace`},children:e.key}),(0,B.jsx)(`td`,{children:e.user}),(0,B.jsx)(`td`,{children:e.reusable?`Yes`:`No`}),(0,B.jsx)(`td`,{children:e.ephemeral?`Yes`:`No`}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`badge ${e.used?`badge-offline`:`badge-online`}`,children:e.used?`USED`:`UNUSED`})}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`,fontSize:`13px`},children:new Date(e.expiration).toLocaleString()})]},e.id)),Se.length===0&&!De&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:7,style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`32px`},children:`No pre-auth keys found.`})})]})]})})]}),e===`users`&&(0,B.jsx)(`div`,{className:`card`,style:{padding:0,overflow:`hidden`},children:(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`ID`}),(0,B.jsx)(`th`,{children:`Name`}),(0,B.jsx)(`th`,{children:`Created At`})]})}),(0,B.jsxs)(`tbody`,{children:[we.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.id}),(0,B.jsx)(`td`,{style:{fontWeight:500},children:e.name}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`,fontSize:`13px`},children:new Date(e.createdAt).toLocaleString()})]},e.id)),we.length===0&&!De&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:3,style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`32px`},children:`No users found.`})})]})]})})]})}async function Ewe(){return Bn(`/api/webhooks/configs`)}async function Dwe(e){return Bn(`/api/webhooks/events${e?`?provider=${encodeURIComponent(e)}`:``}`)}async function M9(e){return Vn(`/api/webhooks/configs`,e)}async function Owe(e){return Hn(`/api/webhooks/configs/${encodeURIComponent(e)}`)}async function kwe(e){return Vn(`/api/webhooks/test/${encodeURIComponent(e)}`,{})}async function Awe(e){return Vn(`/api/webhooks/events/${encodeURIComponent(e)}/redeliver`,{})}function jwe({data:e}){let[t,n]=(0,v.useState)(!1);return e?(0,B.jsxs)(`div`,{style:{marginTop:`8px`},children:[(0,B.jsx)(`button`,{onClick:()=>n(!t),className:`json-toggle`,children:t?`▼ Hide Payload`:`▶ Show Payload`}),t&&(0,B.jsx)(`div`,{className:`json-viewer`,children:(0,B.jsx)(`pre`,{style:{margin:0},children:JSON.stringify(e,null,2)})})]}):null}function Mwe(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(1),[m,h]=(0,v.useState)({status:`active`,events:[]}),g=(0,v.useCallback)(async()=>{s(!0),a(null);try{let[e,n]=await Promise.all([Ewe(),Dwe(c||void 0)]);t(e),r(n)}catch(e){a(e instanceof Error?e.message:`Failed to load webhooks data`)}finally{s(!1)}},[c]);(0,v.useEffect)(()=>{setTimeout(()=>{g()},0);let e=setInterval(()=>{g()},1e4);return()=>clearInterval(e)},[g]);async function _(e){try{await kwe(e),await g()}catch(e){a(e instanceof Error?e.message:`Failed to trigger test webhook`)}}async function y(e){try{await Awe(e),await g()}catch(e){a(e instanceof Error?e.message:`Failed to re-deliver webhook event`)}}async function b(){if(m.provider)try{await M9(m),d(!1),p(1),h({status:`active`,events:[]}),await g()}catch(e){a(e instanceof Error?e.message:`Failed to add webhook`)}}async function x(e){if(confirm(`Delete webhook config for ${e}?`))try{await Owe(e),await g()}catch(e){a(e instanceof Error?e.message:`Failed to delete webhook`)}}async function S(e){if(confirm(`Generate a new secret for ${e}? You will need to update the provider with the new secret.`))try{await M9({provider:e,status:`active`,secret:Array.from(crypto.getRandomValues(new Uint8Array(24))).map(e=>e.toString(16).padStart(2,`0`)).join(``)}),await g()}catch(e){a(e instanceof Error?e.message:`Failed to rotate secret`)}}let C=e.filter(e=>e.status===`active`).length;return(0,B.jsxs)(`div`,{className:`page-container webhooks-page`,children:[(0,B.jsxs)(`div`,{className:`page-header`,children:[(0,B.jsx)(`h1`,{children:`Webhooks`}),(0,B.jsx)(`button`,{onClick:()=>d(!0),className:`btn btn-primary`,children:`Add Webhook`})]}),i&&(0,B.jsx)(`div`,{className:`alert alert-error`,style:{marginBottom:`24px`},children:i}),(0,B.jsxs)(`div`,{className:`webhook-stats`,children:[(0,B.jsxs)(`div`,{className:`stat-box`,children:[(0,B.jsx)(`div`,{className:`label`,children:`Configured`}),(0,B.jsx)(`div`,{className:`value`,children:e.length})]}),(0,B.jsxs)(`div`,{className:`stat-box`,children:[(0,B.jsx)(`div`,{className:`label`,children:`Active Providers`}),(0,B.jsx)(`div`,{className:`value`,children:C})]}),(0,B.jsxs)(`div`,{className:`stat-box`,children:[(0,B.jsx)(`div`,{className:`label`,children:`Events Loaded`}),(0,B.jsx)(`div`,{className:`value`,children:n.length})]})]}),(0,B.jsxs)(`div`,{style:{marginBottom:`32px`},children:[(0,B.jsx)(`h2`,{style:{fontSize:`18px`,fontWeight:500,marginBottom:`16px`},children:`Registered Webhooks`}),(0,B.jsx)(`div`,{className:`card`,style:{padding:0,overflow:`hidden`},children:(0,B.jsxs)(`table`,{className:`data-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Provider`}),(0,B.jsx)(`th`,{children:`Status`}),(0,B.jsx)(`th`,{children:`Secret`}),(0,B.jsx)(`th`,{children:`Last Received`}),(0,B.jsx)(`th`,{children:`Total Count`}),(0,B.jsx)(`th`,{children:`Actions`})]})}),(0,B.jsxs)(`tbody`,{children:[e.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{style:{textTransform:`capitalize`,fontWeight:500},children:e.provider}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`badge ${e.status===`active`?`badge-online`:`badge-offline`}`,children:e.status.toUpperCase()})}),(0,B.jsx)(`td`,{children:(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,B.jsx)(`span`,{style:{fontFamily:`monospace`,color:`var(--text-secondary)`},children:e.has_secret?`••••••••`:`Not Set`}),e.has_secret&&(0,B.jsx)(`button`,{onClick:()=>S(e.provider),className:`rotate-btn`,title:`Rotate Secret`,children:`↻`})]})}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.lastReceived?new Date(e.lastReceived).toLocaleString():`Never`}),(0,B.jsx)(`td`,{style:{color:`var(--text-secondary)`},children:e.totalCount||0}),(0,B.jsxs)(`td`,{style:{display:`flex`,gap:`8px`},children:[(0,B.jsx)(`button`,{onClick:()=>_(e.provider),className:`btn btn-ghost btn-sm`,children:`Test`}),(0,B.jsx)(`button`,{onClick:()=>x(e.provider),className:`btn btn-ghost btn-sm`,style:{color:`var(--error)`},children:`Remove`})]})]},e.provider)),e.length===0&&!o&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:6,style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`32px`},children:`No webhook configs found`})})]})]})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`page-header`,style:{marginBottom:`16px`},children:[(0,B.jsx)(`h2`,{style:{fontSize:`18px`,fontWeight:500},children:`Recent Events`}),(0,B.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`input`,style:{width:`200px`},children:[(0,B.jsx)(`option`,{value:``,children:`All Providers`}),e.map(e=>(0,B.jsx)(`option`,{value:e.provider,children:e.provider},e.provider))]})]}),(0,B.jsx)(`div`,{className:`card`,style:{maxHeight:`600px`,overflowY:`auto`},children:n.length===0?(0,B.jsx)(`p`,{style:{textAlign:`center`,color:`var(--text-secondary)`,padding:`16px`},children:`No recent events`}):(0,B.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`16px`},children:n.map(e=>(0,B.jsxs)(`div`,{style:{padding:`16px`,background:`var(--bg-hover)`,borderRadius:`var(--radius-sm)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,flexWrap:`wrap`},children:[(0,B.jsx)(`span`,{style:{textTransform:`capitalize`,fontWeight:600,color:`var(--accent-hover)`},children:e.provider}),(0,B.jsx)(`span`,{className:`badge badge-leader`,children:e.event_type}),e.delivery_status&&(0,B.jsx)(`span`,{className:`badge badge-follower`,style:{fontSize:11},children:e.delivery_status}),e.parent_event_id&&(0,B.jsxs)(`span`,{style:{fontSize:11,color:`var(--text-secondary)`},children:[`re-deliver of `,e.parent_event_id.slice(0,8),`…`]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,B.jsx)(`span`,{style:{color:`var(--text-secondary)`,fontSize:`13px`},children:new Date(e.received_at).toLocaleString()}),e.id&&(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,style:{fontSize:12,padding:`4px 8px`},onClick:()=>y(e.id),title:`Re-run handler for this stored event`,children:`Re-deliver`})]})]}),(0,B.jsx)(jwe,{data:e.payload})]},e.id))})})]}),u&&(0,B.jsx)(`div`,{className:`modal-overlay`,onClick:()=>d(!1),children:(0,B.jsxs)(`div`,{className:`modal-content wizard-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsx)(`div`,{className:`modal-title`,children:`Provider Configuration Wizard`}),(0,B.jsxs)(`div`,{className:`wizard-steps`,children:[(0,B.jsx)(`div`,{className:`wizard-step ${f>=1?`active`:``} ${f>1?`completed`:``}`,children:`1`}),(0,B.jsx)(`div`,{className:`wizard-step ${f>=2?`active`:``} ${f>2?`completed`:``}`,children:`2`}),(0,B.jsx)(`div`,{className:`wizard-step ${f>=3?`active`:``}`,children:`3`})]}),f===1&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{marginBottom:`16px`},children:`Select Provider`}),(0,B.jsxs)(`div`,{className:`form-group`,children:[(0,B.jsx)(`label`,{className:`form-label`,children:`Provider Name`}),(0,B.jsxs)(`select`,{autoFocus:!0,value:m.provider||``,onChange:e=>h({...m,provider:e.target.value.toLowerCase()}),className:`input`,children:[(0,B.jsx)(`option`,{value:``,children:`Choose a provider`}),(0,B.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,B.jsx)(`option`,{value:`stripe`,children:`Stripe`})]}),(0,B.jsxs)(`p`,{style:{fontSize:`12px`,color:`var(--text-muted)`,marginTop:`8px`},children:[`The provider name will dictate the endpoint URL: `,(0,B.jsx)(`code`,{children:`/api/webhooks/[provider]`})]})]}),(0,B.jsxs)(`div`,{className:`modal-actions`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`btn btn-ghost`,children:`Cancel`}),(0,B.jsx)(`button`,{onClick:()=>p(2),className:`btn btn-primary`,disabled:!m.provider,children:`Next`})]})]}),f===2&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{marginBottom:`16px`},children:`Security & Configuration`}),(0,B.jsxs)(`div`,{className:`form-group`,children:[(0,B.jsx)(`label`,{className:`form-label`,children:`Webhook Secret`}),(0,B.jsx)(`input`,{type:`password`,value:m.secret||``,onChange:e=>h({...m,secret:e.target.value}),className:`input`,placeholder:`Shared secret for HMAC validation`}),(0,B.jsx)(`p`,{style:{fontSize:`12px`,color:`var(--text-muted)`,marginTop:`8px`},children:`Without a secret, the webhook will reject incoming requests for security reasons.`})]}),(0,B.jsxs)(`div`,{className:`form-group`,children:[(0,B.jsx)(`label`,{className:`form-label`,children:`Events to Listen For (Comma separated)`}),(0,B.jsx)(`input`,{type:`text`,value:m.events?.join(`,`)||``,onChange:e=>h({...m,events:e.target.value.split(`,`).map(e=>e.trim())}),className:`input`,placeholder:`push, pull_request (optional)`})]}),(0,B.jsxs)(`div`,{className:`modal-actions`,children:[(0,B.jsx)(`button`,{onClick:()=>p(1),className:`btn btn-ghost`,children:`Back`}),(0,B.jsx)(`button`,{onClick:()=>p(3),className:`btn btn-primary`,children:`Next`})]})]}),f===3&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{style:{marginBottom:`16px`},children:`Review & Save`}),(0,B.jsxs)(`div`,{style:{background:`var(--bg-hover)`,padding:`16px`,borderRadius:`8px`,marginBottom:`24px`},children:[(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Provider:`}),` `,m.provider]}),(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Secret:`}),` `,m.secret?`•••••••• (Configured)`:`None (Warning)`]}),(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Events:`}),` `,m.events?.length?m.events.join(`, `):`All Events`]}),(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Status:`}),` `,(0,B.jsx)(`span`,{className:`badge badge-online`,children:`Active`})]}),(0,B.jsxs)(`p`,{style:{marginTop:`16px`,color:`var(--text-muted)`},children:[`Your endpoint URL will be:`,(0,B.jsx)(`br`,{}),(0,B.jsxs)(`code`,{children:[`https://your-domain.com/api/webhooks/`,m.provider]})]})]}),(0,B.jsxs)(`div`,{className:`modal-actions`,children:[(0,B.jsx)(`button`,{onClick:()=>p(2),className:`btn btn-ghost`,children:`Back`}),(0,B.jsx)(`button`,{onClick:b,className:`btn btn-primary`,children:`Save Webhook`})]})]})]})})]})}function N9(e,t=!1){return t?`linear-gradient(135deg, #60a5fa, #34d399)`:e===`global`?`linear-gradient(135deg, #60a5fa, #2563eb)`:e===`tenant`?`linear-gradient(135deg, #c084fc, #7c3aed)`:`linear-gradient(135deg, #34d399, #059669)`}function Nwe(e){return e===`global`?`G`:e===`tenant`?`T`:`P`}function Pwe({activeBrainId:e,onBrainChange:t}){let[n,r]=(0,v.useState)([]),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(null),d=async()=>{s(!0),l(null);try{let e=await z(`${In()}/api/brains`);if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Brains API ${e.status}`)}let t=await e.json(),n=Array.isArray(t.brains)?t.brains:[];r(n)}catch(e){console.error(e),l(e instanceof Error?e.message:`Failed to load brains`),r([])}finally{s(!1)}};(0,v.useEffect)(()=>{setTimeout(()=>{d()},0)},[]),(0,v.useEffect)(()=>{function e(e){u.current&&!u.current.contains(e.target)&&a(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,v.useEffect)(()=>{if(o||n.length===0)return;let r=e.split(`,`).filter(Boolean),i=new Set(n.map(e=>e.id)),a=r.filter(e=>i.has(e));if(a.length===0){let r=n.find(e=>e.id===`global`)?.id||n[0]?.id;r&&r!==e&&t(r);return}a.join(`,`)!==r.join(`,`)&&t(a.join(`,`))},[o,n,e,t]);let f=e.split(`,`).filter(Boolean),p=n.filter(e=>f.includes(e.id)),m=p[0]||n.find(e=>e.id===`global`)||n[0],h=f.length>1,g=p.reduce((e,t)=>e+(t.node_count||0),0)||m?.node_count||0,_=h?`${f.length} brains`:m?.name||`Brain`,y=e=>{let r=e.filter(Boolean);if(r.length===0){let e=n.find(e=>e.id===`global`)?.id||n[0]?.id;e&&t(e);return}t(r.join(`,`))},b=(e,t)=>{t.stopPropagation(),f.includes(e)?y(f.filter(t=>t!==e)):y([...f,e])},x=e=>{y([e]),a(!1)};return o?(0,B.jsx)(`div`,{className:`brain-selector-trigger`,"data-testid":`brain-selector-loading`,style:{opacity:.6},children:(0,B.jsx)(`span`,{style:{fontSize:11,color:`var(--text-tertiary)`},children:`Brains…`})}):c?(0,B.jsxs)(`div`,{"data-testid":`brain-selector-error`,style:{fontSize:10,color:`#ef4444`,padding:`4px 6px`},children:[`Brains failed`,` `,(0,B.jsx)(`button`,{type:`button`,onClick:()=>void d(),style:{cursor:`pointer`,marginLeft:4},children:`Retry`})]}):n.length===0?(0,B.jsx)(`div`,{"data-testid":`brain-selector-empty`,style:{fontSize:10,color:`var(--text-tertiary)`,padding:`4px 6px`},children:`No brains registered`}):(0,B.jsxs)(`div`,{ref:u,className:`brain-selector`,"data-testid":`brain-selector`,style:{position:`relative`},children:[(0,B.jsxs)(`button`,{type:`button`,className:`brain-selector-trigger`,"data-testid":`brain-selector-trigger`,onClick:()=>a(e=>!e),title:`Select active brain (sidebar only)`,style:{width:`100%`,display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,background:i?`rgba(59, 130, 246, 0.12)`:`rgba(148, 163, 184, 0.06)`,border:`1px solid ${i?`var(--border-accent)`:`var(--border)`}`,borderRadius:8,cursor:`pointer`,color:`var(--text-primary)`,textAlign:`left`,transition:`all 0.15s`},children:[(0,B.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:N9(m?.layer||`global`,h),boxShadow:h?`0 0 6px rgba(52, 211, 153, 0.5)`:`0 0 6px rgba(59, 130, 246, 0.45)`,flexShrink:0}}),(0,B.jsx)(`span`,{style:{flex:1,minWidth:0,fontSize:11,fontWeight:600,letterSpacing:`-0.01em`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:_}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--text-tertiary)`,flexShrink:0},children:g}),(0,B.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,style:{opacity:.45,transform:i?`rotate(180deg)`:`none`,transition:`transform 0.15s`,flexShrink:0},children:(0,B.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),i&&(0,B.jsxs)(`div`,{className:`brain-selector-menu`,"data-testid":`brain-selector-menu`,style:{position:`absolute`,bottom:`100%`,left:0,right:0,marginBottom:6,background:`linear-gradient(165deg, rgba(18, 26, 43, 0.98), rgba(8, 12, 22, 0.99))`,border:`1px solid var(--border)`,borderRadius:10,boxShadow:`0 -8px 28px rgba(0,0,0,0.45)`,overflow:`hidden`,zIndex:1e3,maxHeight:280,overflowY:`auto`},children:[(0,B.jsx)(`div`,{style:{padding:`6px 10px`,fontSize:9,fontWeight:700,color:`var(--text-tertiary)`,textTransform:`uppercase`,letterSpacing:`0.08em`,borderBottom:`1px solid var(--border)`},children:`Active brains · checkbox multi · click row = only`}),n.map(e=>{let t=f.includes(e.id);return(0,B.jsxs)(`div`,{role:`button`,tabIndex:0,"data-testid":`brain-option-${e.id}`,onClick:()=>{e.exists&&x(e.id)},onKeyDown:t=>{t.key===`Enter`&&e.exists&&x(e.id)},style:{display:`flex`,alignItems:`center`,gap:8,padding:`7px 10px`,cursor:e.exists?`pointer`:`not-allowed`,opacity:e.exists?1:.45,background:t?`rgba(59, 130, 246, 0.12)`:`transparent`,borderLeft:t?`2px solid #3b82f6`:`2px solid transparent`,transition:`background 0.1s`},onMouseEnter:t=>{e.exists&&(t.currentTarget.style.background=`rgba(148, 163, 184, 0.08)`)},onMouseLeave:e=>{e.currentTarget.style.background=t?`rgba(59, 130, 246, 0.12)`:`transparent`},children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!e.exists,onClick:e=>e.stopPropagation(),onChange:t=>b(e.id,t),"aria-label":`Include ${e.name}`,style:{width:13,height:13,accentColor:`#3b82f6`,cursor:e.exists?`pointer`:`not-allowed`,margin:0,flexShrink:0}}),(0,B.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:N9(e.layer),flexShrink:0}}),(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:11,fontWeight:600,color:`var(--text-primary)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),(0,B.jsxs)(`div`,{style:{fontSize:9,color:`var(--text-tertiary)`,marginTop:1},children:[e.node_count,`n`,e.layer===`project`&&e.project_root?` · ${e.project_root.split(`/`).pop()}`:``,e.exists?``:` · missing`]})]}),(0,B.jsx)(`span`,{style:{fontSize:8,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.04em`,padding:`2px 5px`,borderRadius:4,flexShrink:0,background:e.layer===`global`?`rgba(59, 130, 246, 0.15)`:e.layer===`tenant`?`rgba(168, 85, 247, 0.15)`:`rgba(16, 185, 129, 0.12)`,color:e.layer===`global`?`#93c5fd`:e.layer===`tenant`?`#d8b4fe`:`#6ee7b7`},children:Nwe(e.layer)})]},e.id)})]})]})}function P9(e){let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(t){let e=t[1].match(/version:\s*['"]?([^\n'"]+)/i);if(e)return e[1].trim()}let n=e.match(/#+\s+v(\d+\.\d+(?:\.\d+)?)/);return n?n[1]:`0.0.0`}function Fwe(e){let t=[],n=/#{2,3}\s+v?(\d+\.\d+(?:\.\d+)?)\s*(?:[—–-]\s*(\d{4}-\d{2}-\d{2}))?\s*\n([\s\S]*?)(?=\n#{2,3}\s|$)/g,r;for(;(r=n.exec(e))!==null;){let e=r[3].split(`