@sigmashake/ssg 0.29.86 → 0.29.88

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.
@@ -1,13 +1,31 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ee(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},F={map:ee,forEach:function(e,t,n){ee(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ee(e,function(){t++}),t},toArray:function(e){return ee(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function ee(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ee(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ee(e(t))}catch{}}return null}var te=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function I(e){return{current:e}}function L(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function R(e,t){ie++,re[ie]=e.current,e.current=t}var z=I(null),ae=I(null),oe=I(null),se=I(null);function ce(e,t){switch(R(oe,t),R(ae,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(z),R(z,e)}function le(){L(z),L(ae),L(oe)}function ue(e){e.memoizedState!==null&&R(se,e);var t=z.current,n=Hd(t,e.type);t!==n&&(R(ae,e),R(z,n))}function de(e){ae.current===e&&(L(z),L(ae)),se.current===e&&(L(se),Qf._currentValue=ne)}var fe,pe;function me(e){if(fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);fe=t&&t[1]||``,pe=-1<e.stack.indexOf(`
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ee(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},F={map:ee,forEach:function(e,t,n){ee(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ee(e,function(){t++}),t},toArray:function(e){return ee(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function ee(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ee(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ee(e(t))}catch{}}return null}var te=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function I(e){return{current:e}}function L(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function R(e,t){ie++,re[ie]=e.current,e.current=t}var ae=I(null),z=I(null),oe=I(null),se=I(null);function ce(e,t){switch(R(oe,t),R(z,e),R(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(ae),R(ae,e)}function le(){L(ae),L(z),L(oe)}function ue(e){e.memoizedState!==null&&R(se,e);var t=ae.current,n=Hd(t,e.type);t!==n&&(R(z,e),R(ae,n))}function de(e){z.current===e&&(L(ae),L(z)),se.current===e&&(L(se),Qf._currentValue=ne)}var fe,pe;function me(e){if(fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);fe=t&&t[1]||``,pe=-1<e.stack.indexOf(`
2
2
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
3
  `+fe+e+pe}var he=!1;function ge(e,t){if(!e||he)return``;he=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
4
4
  `),l=s.split(`
5
5
  `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
6
6
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{he=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?me(n):``}function _e(e,t){switch(e.tag){case 26:case 27:case 5:return me(e.type);case 16:return me(`Lazy`);case 13:return e.child!==t&&t!==null?me(`Suspense Fallback`):me(`Suspense`);case 19:return me(`SuspenseList`);case 0:case 15:return ge(e.type,!1);case 11:return ge(e.type.render,!1);case 1:return ge(e.type,!0);case 31:return me(`Activity`);default:return``}}function ve(e){try{var t=``,n=null;do t+=_e(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
7
  Error generating stack: `+e.message+`
8
- `+e.stack}}var ye=Object.prototype.hasOwnProperty,be=t.unstable_scheduleCallback,xe=t.unstable_cancelCallback,Se=t.unstable_shouldYield,Ce=t.unstable_requestPaint,we=t.unstable_now,Te=t.unstable_getCurrentPriorityLevel,Ee=t.unstable_ImmediatePriority,De=t.unstable_UserBlockingPriority,Oe=t.unstable_NormalPriority,B=t.unstable_LowPriority,ke=t.unstable_IdlePriority,V=t.log,Ae=t.unstable_setDisableYieldValue,je=null,Me=null;function Ne(e){if(typeof V==`function`&&Ae(e),Me&&typeof Me.setStrictMode==`function`)try{Me.setStrictMode(je,e)}catch{}}var Pe=Math.clz32?Math.clz32:Le,Fe=Math.log,Ie=Math.LN2;function Le(e){return e>>>=0,e===0?32:31-(Fe(e)/Ie|0)|0}var Re=256,ze=262144,Be=4194304;function Ve(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function He(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ve(n))):i=Ve(o):i=Ve(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ve(n))):i=Ve(o)):i=Ve(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ue(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function We(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ge(){var e=Be;return Be<<=1,!(Be&62914560)&&(Be=4194304),e}function Ke(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function qe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Je(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Pe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ye(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ye(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Pe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Xe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Pe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ze(e,t){var n=t&-t;return n=n&42?1:Qe(n),(n&(e.suspendedLanes|t))===0?n:0}function Qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function $e(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function et(){var e=F.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function tt(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var nt=Math.random().toString(36).slice(2),rt=`__reactFiber$`+nt,it=`__reactProps$`+nt,at=`__reactContainer$`+nt,ot=`__reactEvents$`+nt,st=`__reactListeners$`+nt,ct=`__reactHandles$`+nt,lt=`__reactResources$`+nt,ut=`__reactMarker$`+nt;function dt(e){delete e[rt],delete e[it],delete e[ot],delete e[st],delete e[ct]}function ft(e){var t=e[rt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[at]||n[rt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[rt])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function pt(e){if(e=e[rt]||e[at]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function mt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ht(e){var t=e[lt];return t||=e[lt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function gt(e){e[ut]=!0}var _t=new Set,vt={};function yt(e,t){bt(e,t),bt(e+`Capture`,t)}function bt(e,t){for(vt[e]=t,e=0;e<t.length;e++)_t.add(t[e])}var xt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),St={},Ct={};function wt(e){return ye.call(Ct,e)?!0:ye.call(St,e)?!1:xt.test(e)?Ct[e]=!0:(St[e]=!0,!1)}function Tt(e,t,n){if(wt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Et(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Dt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Ot(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function kt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function At(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function jt(e){if(!e._valueTracker){var t=kt(e)?`checked`:`value`;e._valueTracker=At(e,t,``+e[t])}}function Mt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=kt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Nt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Pt=/[\n"\\]/g;function Ft(e){return e.replace(Pt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function It(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Ot(t)):e.value!==``+Ot(t)&&(e.value=``+Ot(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Rt(e,o,Ot(n)):Rt(e,o,Ot(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Ot(s):e.removeAttribute(`name`)}function Lt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){jt(e);return}n=n==null?``:``+Ot(n),t=t==null?n:``+Ot(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),jt(e)}function Rt(e,t,n){t===`number`&&Nt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function zt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Ot(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Bt(e,t,n){if(t!=null&&(t=``+Ot(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Ot(n)}function Vt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(te(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Ot(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),jt(e)}function Ht(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ut=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Wt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Ut.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Gt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Wt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Wt(e,o,t[o])}function Kt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var qt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Jt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Yt(e){return Jt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Xt(){}var Zt=null;function Qt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $t=null,en=null;function tn(e){var t=pt(e);if(t&&(e=t.stateNode)){var n=e[it]||null;a:switch(e=t.stateNode,t.type){case`input`:if(It(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ft(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[it]||null;if(!a)throw Error(i(90));It(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Mt(r)}break a;case`textarea`:Bt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&zt(e,!!n.multiple,t,!1)}}}var nn=!1;function rn(e,t,n){if(nn)return e(t,n);nn=!0;try{return e(t)}finally{if(nn=!1,($t!==null||en!==null)&&(vu(),$t&&(t=$t,e=en,en=$t=null,tn(t),e)))for(t=0;t<e.length;t++)tn(e[t])}}function an(e,t){var n=e.stateNode;if(n===null)return null;var r=n[it]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var on=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),sn=!1;if(on)try{var cn={};Object.defineProperty(cn,`passive`,{get:function(){sn=!0}}),window.addEventListener(`test`,cn,cn),window.removeEventListener(`test`,cn,cn)}catch{sn=!1}var ln=null,un=null,dn=null;function fn(){if(dn)return dn;var e,t=un,n=t.length,r,i=`value`in ln?ln.value:ln.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return dn=i.slice(e,1<r?1-r:void 0)}function pn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function mn(){return!0}function hn(){return!1}function gn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?mn:hn,this.isPropagationStopped=hn,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=mn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=mn)},persist:function(){},isPersistent:mn}),t}var _n={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vn=gn(_n),yn=h({},_n,{view:0,detail:0}),H=gn(yn),bn,xn,Sn,Cn=h({},yn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Nn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Sn&&(Sn&&e.type===`mousemove`?(bn=e.screenX-Sn.screenX,xn=e.screenY-Sn.screenY):xn=bn=0,Sn=e),bn)},movementY:function(e){return`movementY`in e?e.movementY:xn}}),wn=gn(Cn),Tn=gn(h({},Cn,{dataTransfer:0})),En=gn(h({},yn,{relatedTarget:0})),Dn=gn(h({},_n,{animationName:0,elapsedTime:0,pseudoElement:0})),On=gn(h({},_n,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),kn=gn(h({},_n,{data:0})),U={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},An={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},jn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Mn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=jn[e])?!!t[e]:!1}function Nn(){return Mn}var Pn=gn(h({},yn,{key:function(e){if(e.key){var t=U[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=pn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?An[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Nn,charCode:function(e){return e.type===`keypress`?pn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?pn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Fn=gn(h({},Cn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),In=gn(h({},yn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Nn})),W=gn(h({},_n,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=gn(h({},Cn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Rn=gn(h({},_n,{newState:0,oldState:0})),zn=[9,13,27,32],Bn=on&&`CompositionEvent`in window,Vn=null;on&&`documentMode`in document&&(Vn=document.documentMode);var Hn=on&&`TextEvent`in window&&!Vn,Un=on&&(!Bn||Vn&&8<Vn&&11>=Vn),Wn=` `,Gn=!1;function Kn(e,t){switch(e){case`keyup`:return zn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function qn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Jn=!1;function Yn(e,t){switch(e){case`compositionend`:return qn(t);case`keypress`:return t.which===32?(Gn=!0,Wn):null;case`textInput`:return e=t.data,e===Wn&&Gn?null:e;default:return null}}function Xn(e,t){if(Jn)return e===`compositionend`||!Bn&&Kn(e,t)?(e=fn(),dn=un=ln=null,Jn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Un&&t.locale!==`ko`?null:t.data;default:return null}}var Zn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Zn[e.type]:t===`textarea`}function $n(e,t,n,r){$t?en?en.push(r):en=[r]:$t=r,t=Ed(t,`onChange`),0<t.length&&(n=new vn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var er=null,G=null;function tr(e){vd(e,0)}function nr(e){if(Mt(mt(e)))return e}function rr(e,t){if(e===`change`)return t}var ir=!1;if(on){var K;if(on){var ar=`oninput`in document;if(!ar){var q=document.createElement(`div`);q.setAttribute(`oninput`,`return;`),ar=typeof q.oninput==`function`}K=ar}else K=!1;ir=K&&(!document.documentMode||9<document.documentMode)}function J(){er&&(er.detachEvent(`onpropertychange`,Y),G=er=null)}function Y(e){if(e.propertyName===`value`&&nr(G)){var t=[];$n(t,G,e,Qt(e)),rn(tr,t)}}function or(e,t,n){e===`focusin`?(J(),er=t,G=n,er.attachEvent(`onpropertychange`,Y)):e===`focusout`&&J()}function sr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return nr(G)}function cr(e,t){if(e===`click`)return nr(t)}function lr(e,t){if(e===`input`||e===`change`)return nr(t)}function X(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var ur=typeof Object.is==`function`?Object.is:X;function dr(e,t){if(ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ye.call(t,i)||!ur(e[i],t[i]))return!1}return!0}function fr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pr(e,t){var n=fr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=fr(n)}}function mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Nt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Nt(e.document)}return t}function gr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var _r=on&&`documentMode`in document&&11>=document.documentMode,vr=null,yr=null,br=null,xr=!1;function Sr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xr||vr==null||vr!==Nt(r)||(r=vr,`selectionStart`in r&&gr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),br&&dr(br,r)||(br=r,r=Ed(yr,`onSelect`),0<r.length&&(t=new vn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=vr)))}function Cr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var wr={animationend:Cr(`Animation`,`AnimationEnd`),animationiteration:Cr(`Animation`,`AnimationIteration`),animationstart:Cr(`Animation`,`AnimationStart`),transitionrun:Cr(`Transition`,`TransitionRun`),transitionstart:Cr(`Transition`,`TransitionStart`),transitioncancel:Cr(`Transition`,`TransitionCancel`),transitionend:Cr(`Transition`,`TransitionEnd`)},Tr={},Er={};on&&(Er=document.createElement(`div`).style,`AnimationEvent`in window||(delete wr.animationend.animation,delete wr.animationiteration.animation,delete wr.animationstart.animation),`TransitionEvent`in window||delete wr.transitionend.transition);function Dr(e){if(Tr[e])return Tr[e];if(!wr[e])return e;var t=wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Er)return Tr[e]=t[n];return e}var Or=Dr(`animationend`),kr=Dr(`animationiteration`),Ar=Dr(`animationstart`),jr=Dr(`transitionrun`),Mr=Dr(`transitionstart`),Nr=Dr(`transitioncancel`),Pr=Dr(`transitionend`),Fr=new Map,Ir=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Ir.push(`scrollEnd`);function Lr(e,t){Fr.set(e,t),yt(t,[e])}var Rr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},zr=[],Br=0,Vr=0;function Hr(){for(var e=Br,t=Vr=Br=0;t<e;){var n=zr[t];zr[t++]=null;var r=zr[t];zr[t++]=null;var i=zr[t];zr[t++]=null;var a=zr[t];if(zr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Kr(n,i,a)}}function Ur(e,t,n,r){zr[Br++]=e,zr[Br++]=t,zr[Br++]=n,zr[Br++]=r,Vr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Wr(e,t,n,r){return Ur(e,t,n,r),qr(e)}function Gr(e,t){return Ur(e,null,null,t),qr(e)}function Kr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Pe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function qr(e){if(50<lu)throw lu=0,uu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Jr={};function Yr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(e,t,n,r){return new Yr(e,t,n,r)}function Zr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qr(e,t){var n=e.alternate;return n===null?(n=Xr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function $r(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ei(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Zr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,z.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=Xr(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ti(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=Xr(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=Xr(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=Xr(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Xr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ti(e,t,n,r){return e=Xr(7,e,r,t),e.lanes=n,e}function ni(e,t,n){return e=Xr(6,e,null,t),e.lanes=n,e}function ri(e){var t=Xr(18,null,null,0);return t.stateNode=e,t}function ii(e,t,n){return t=Xr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ai=new WeakMap;function oi(e,t){if(typeof e==`object`&&e){var n=ai.get(e);return n===void 0?(t={value:e,source:t,stack:ve(t)},ai.set(e,t),t):n}return{value:e,source:t,stack:ve(t)}}var si=[],ci=0,li=null,ui=0,di=[],fi=0,pi=null,mi=1,hi=``;function gi(e,t){si[ci++]=ui,si[ci++]=li,li=e,ui=t}function _i(e,t,n){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,pi=e;var r=mi;e=hi;var i=32-Pe(r)-1;r&=~(1<<i),n+=1;var a=32-Pe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,mi=1<<32-Pe(t)+i|n<<i|r,hi=a+e}else mi=1<<a|n<<i|r,hi=e}function vi(e){e.return!==null&&(gi(e,1),_i(e,1,0))}function yi(e){for(;e===li;)li=si[--ci],si[ci]=null,ui=si[--ci],si[ci]=null;for(;e===pi;)pi=di[--fi],di[fi]=null,hi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null}function bi(e,t){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,mi=t.id,hi=t.overflow,pi=e}var xi=null,Si=null,Ci=!1,wi=null,Ti=!1,Ei=Error(i(519));function Di(e){throw Ni(oi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ei}function Oi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[rt]=e,t[it]=r,n){case`dialog`:yd(`cancel`,t),yd(`close`,t);break;case`iframe`:case`object`:case`embed`:yd(`load`,t);break;case`video`:case`audio`:for(n=0;n<gd.length;n++)yd(gd[n],t);break;case`source`:yd(`error`,t);break;case`img`:case`image`:case`link`:yd(`error`,t),yd(`load`,t);break;case`details`:yd(`toggle`,t);break;case`input`:yd(`invalid`,t),Lt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:yd(`invalid`,t);break;case`textarea`:yd(`invalid`,t),Vt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Md(t.textContent,n)?(r.popover!=null&&(yd(`beforetoggle`,t),yd(`toggle`,t)),r.onScroll!=null&&yd(`scroll`,t),r.onScrollEnd!=null&&yd(`scrollend`,t),r.onClick!=null&&(t.onclick=Xt),t=!0):t=!1,t||Di(e,!0)}function ki(e){for(xi=e.return;xi;)switch(xi.tag){case 5:case 31:case 13:Ti=!1;return;case 27:case 3:Ti=!0;return;default:xi=xi.return}}function Ai(e){if(e!==xi)return!1;if(!Ci)return ki(e),Ci=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&Si&&Di(e),ki(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Si=uf(e)}else t===27?(t=Si,Zd(e.type)?(e=lf,lf=null,Si=e):Si=t):Si=xi?cf(e.stateNode.nextSibling):null;return!0}function ji(){Si=xi=null,Ci=!1}function Mi(){var e=wi;return e!==null&&(Yl===null?Yl=e:Yl.push.apply(Yl,e),wi=null),e}function Ni(e){wi===null?wi=[e]:wi.push(e)}var Pi=I(null),Fi=null,Ii=null;function Li(e,t,n){R(Pi,t._currentValue),t._currentValue=n}function Ri(e){e._currentValue=Pi.current,L(Pi)}function zi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Bi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),zi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),zi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Vi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;ur(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===se.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Bi(t,e,n,r),t.flags|=262144}function Hi(e){for(e=e.firstContext;e!==null;){if(!ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ui(e){Fi=e,Ii=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Wi(e){return Ki(Fi,e)}function Gi(e,t){return Fi===null&&Ui(e),Ki(e,t)}function Ki(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ii===null){if(e===null)throw Error(i(308));Ii=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ii=Ii.next=t;return n}var qi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ji=t.unstable_scheduleCallback,Yi=t.unstable_NormalPriority,Xi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Zi(){return{controller:new qi,data:new Map,refCount:0}}function Qi(e){e.refCount--,e.refCount===0&&Ji(Yi,function(){e.controller.abort()})}var $i=null,ea=0,ta=0,na=null;function ra(e,t){if($i===null){var n=$i=[];ea=0,ta=ud(),na={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ea++,t.then(ia,ia),t}function ia(){if(--ea===0&&$i!==null){na!==null&&(na.status=`fulfilled`);var e=$i;$i=null,ta=0,na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function aa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var oa=P.S;P.S=function(e,t){Ql=we(),typeof t==`object`&&t&&typeof t.then==`function`&&ra(e,t),oa!==null&&oa(e,t)};var sa=I(null);function ca(){var e=sa.current;return e===null?Pl.pooledCache:e}function la(e,t){t===null?R(sa,sa.current):R(sa,t.pool)}function ua(){var e=ca();return e===null?null:{parent:Xi._currentValue,pool:e}}var da=Error(i(460)),fa=Error(i(474)),pa=Error(i(542)),ma={then:function(){}};function ha(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ga(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Xt,Xt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e;default:if(typeof t.status==`string`)t.then(Xt,Xt);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e}throw va=t,da}}function _a(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(va=e,da):e}}var va=null;function ya(){if(va===null)throw Error(i(459));var e=va;return va=null,e}function ba(e){if(e===da||e===pa)throw Error(i(483))}var xa=null,Sa=0;function Ca(e){var t=Sa;return Sa+=1,xa===null&&(xa=[]),ga(xa,e,t)}function wa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ta(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ea(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Qr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ni(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&_a(i)===t.type)?(t=a(t,n.props),wa(t,n),t.return=e,t):(t=ei(n.type,n.key,n.props,null,e.mode,r),wa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ii(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ti(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ni(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ei(t.type,t.key,t.props,null,e.mode,n),wa(n,t),n.return=e,n;case v:return t=ii(t,e.mode,n),t.return=e,t;case O:return t=_a(t),f(e,t,n)}if(te(t)||M(t))return t=ti(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ca(t),n);if(t.$$typeof===C)return f(e,Gi(e,t),n);Ta(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=_a(n),p(e,t,n,r)}if(te(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ca(n),r);if(n.$$typeof===C)return p(e,t,Gi(e,n),r);Ta(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=_a(r),m(e,t,n,r,i)}if(te(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ca(r),i);if(r.$$typeof===C)return m(e,t,n,Gi(t,r),i);Ta(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ci&&gi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ci&&gi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ci&&gi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ci&&gi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ci&&gi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ci&&gi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&_a(l)===r.type){n(e,r.sibling),c=a(r,o.props),wa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ti(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ei(o.type,o.key,o.props,null,e.mode,c),wa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ii(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=_a(o),b(e,r,o,c)}if(te(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ca(o),c);if(o.$$typeof===C)return b(e,r,Gi(e,o),c);Ta(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ni(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Sa=0;var i=b(e,t,n,r);return xa=null,i}catch(t){if(t===da||t===pa)throw t;var a=Xr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Da=Ea(!0),Oa=Ea(!1),ka=!1;function Aa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ja(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ma(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Na(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=qr(e),Kr(e,null,n),t}return Ur(e,r,t,n),qr(e)}function Pa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xe(e,n)}}function Fa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ia=!1;function La(){if(Ia){var e=na;if(e!==null)throw e}}function Ra(e,t,n,r){Ia=!1;var i=e.updateQueue;ka=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Fl&f)===f:(r&f)===f){f!==0&&f===ta&&(Ia=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:ka=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Ul|=o,e.lanes=o,e.memoizedState=d}}function za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ba(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)za(n[e],t)}var Va=I(null),Ha=I(0);function Ua(e,t){e=Vl,R(Ha,e),R(Va,t),Vl=e|t.baseLanes}function Wa(){R(Ha,Vl),R(Va,Va.current)}function Ga(){Vl=Ha.current,L(Va),L(Ha)}var Ka=I(null),qa=null;function Ja(e){var t=e.alternate;R($a,$a.current&1),R(Ka,e),qa===null&&(t===null||Va.current!==null||t.memoizedState!==null)&&(qa=e)}function Ya(e){R($a,$a.current),R(Ka,e),qa===null&&(qa=e)}function Xa(e){e.tag===22?(R($a,$a.current),R(Ka,e),qa===null&&(qa=e)):Za(e)}function Za(){R($a,$a.current),R(Ka,Ka.current)}function Qa(e){L(Ka),qa===e&&(qa=null),L($a)}var $a=I(0);function eo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var to=0,Z=null,no=null,ro=null,io=!1,ao=!1,oo=!1,so=0,co=0,lo=null,uo=0;function fo(){throw Error(i(321))}function po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function mo(e,t,n,r,i,a){return to=a,Z=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?js:Ms,oo=!1,a=n(r,i),oo=!1,ao&&(a=go(t,n,r,i)),ho(e),a}function ho(e){P.H=As;var t=no!==null&&no.next!==null;if(to=0,ro=no=Z=null,io=!1,co=0,lo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Hi(e)&&(Ys=!0))}function go(e,t,n,r){Z=e;var a=0;do{if(ao&&(lo=null),co=0,ao=!1,25<=a)throw Error(i(301));if(a+=1,ro=no=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(no===null?null:no.memoizedState)!==e&&(Z.flags|=1024),t}function vo(){var e=so!==0;return so=0,e}function yo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function bo(e){if(io){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}io=!1}to=0,ro=no=Z=null,ao=!1,co=so=0,lo=null}function xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ro===null?Z.memoizedState=ro=e:ro=ro.next=e,ro}function So(){if(no===null){var e=Z.alternate;e=e===null?null:e.memoizedState}else e=no.next;var t=ro===null?Z.memoizedState:ro.next;if(t!==null)ro=t,no=e;else{if(e===null)throw Z.alternate===null?Error(i(467)):Error(i(310));no=e,e={memoizedState:no.memoizedState,baseState:no.baseState,baseQueue:no.baseQueue,queue:no.queue,next:null},ro===null?Z.memoizedState=ro=e:ro=ro.next=e}return ro}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=co;return co+=1,lo===null&&(lo=[]),e=ga(lo,e,t),t=Z,(ro===null?t.memoizedState:ro.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===C)return Wi(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=Z.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Z.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),Z.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),no,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(to&f)===f:(Fl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ta&&(d=!0);else if((to&p)===p){u=u.next,p===ta&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Z.lanes|=p,Ul|=p;f=u.action,oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Z.lanes|=f,Ul|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!ur(o,e.memoizedState)&&(Ys=!0,d&&(n=na,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);ur(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=Z,a=So(),o=Ci;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!ur((no||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ro!==null&&ro.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||to&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Z.updateQueue,t===null?(t=Co(),Z.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch{return!0}}function Io(e){var t=Gr(e,2);t!==null&&pu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){Ne(!0);try{n()}finally{Ne(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,no,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(Ci){var n=Pl.formState;if(n!==null){a:{var r=Z;if(Ci){if(Si){b:{for(var i=Si,a=Ti;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Si=cf(i.nextSibling),r=i.data===`F!`;break a}}Di(r)}r=!1}r&&(t=n[0])}}return n=xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,Z,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,Z,!1,r.queue),r=xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,Z,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),no,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===da?pa:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Z.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=no;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Z.updateQueue,t===null&&(t=Co(),Z.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=xo();Z.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;no!==null&&r!==null&&po(r,no.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(Z.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){Z.flags|=4;var t=Z.updateQueue;if(t===null)t=Co(),Z.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&po(t,r[1]))return r[0];if(r=e(),oo){Ne(!0);try{e()}finally{Ne(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||to&1073741824&&!(Fl&261930)?e.memoizedState=t:(e.memoizedState=n,e=fu(),Z.lanes|=e,Ul|=e,n)}function ps(e,t,n,r){return ur(n,t)?n:Va.current===null?!(to&42)||to&1073741824&&!(Fl&261930)?(Ys=!0,e.memoizedState=n):(e=fu(),Z.lanes|=e,Ul|=e,t):(e=fs(e,n,r),ur(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,Es(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,aa(c,r),du(e)):Ts(e,t,r,du(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},du())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,ne,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:ne},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},du())}function ys(){return Wi(Qf)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=du();e=Ma(n);var r=Na(t,e,n);r!==null&&(pu(r,t,n),Pa(r,t,n)),t={cache:Zi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=du();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Wr(e,t,n,r),n!==null&&(pu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,du())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,ur(s,o))return Ur(e,t,i,0),Pl===null&&Hr(),!1}catch{}if(n=Wr(e,t,i,r),n!==null)return pu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Wr(e,n,r,2),t!==null&&pu(t,e,2)}function Ds(e){var t=e.alternate;return e===Z||t!==null&&t===Z}function Os(e,t){ao=io=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xe(e,n)}}var As={readContext:Wi,use:To,useCallback:fo,useContext:fo,useEffect:fo,useImperativeHandle:fo,useLayoutEffect:fo,useInsertionEffect:fo,useMemo:fo,useReducer:fo,useRef:fo,useState:fo,useDebugValue:fo,useDeferredValue:fo,useTransition:fo,useSyncExternalStore:fo,useId:fo,useHostTransitionStatus:fo,useFormState:fo,useActionState:fo,useOptimistic:fo,useMemoCache:fo,useCacheRefresh:fo};As.useEffectEvent=fo;var js={readContext:Wi,use:To,useCallback:function(e,t){return xo().memoizedState=[e,t===void 0?null:t],e},useContext:Wi,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=xo();t=t===void 0?null:t;var r=e();if(oo){Ne(!0);try{e()}finally{Ne(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=xo();if(n!==void 0){var i=n(t);if(oo){Ne(!0);try{n(t)}finally{Ne(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,Z,e),[r.memoizedState,e]},useRef:function(e){var t=xo();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,Z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(xo(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,Z,e.queue,!0,!1),xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Z,a=xo();if(Ci){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Fl&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=xo(),t=Pl.identifierPrefix;if(Ci){var n=hi,r=mi;n=(r&~(1<<32-Pe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=so++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=uo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,Z,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return xo().memoizedState=Ss.bind(null,Z)},useEffectEvent:function(e){var t=xo(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),no.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return no===null?fs(n,e,t):ps(n,no.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return no===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=du(),r=Ma(n);r.tag=2,t!=null&&(r.callback=t),t=Na(e,r,n),t!==null&&(pu(t,e,n),Pa(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!dr(n,r)||!dr(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Rr(e)}function Bs(e){console.error(e)}function Vs(e){Rr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=Ma(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=Ma(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(tu===null?tu=new Set([this]):tu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Vi(t,n,a,!0),n=Ka.current,n!==null){switch(n.tag){case 31:case 13:return qa===null?Tu():n.alternate===null&&Hl===0&&(Hl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Wu(e,r,a)),!1;case 22:return n.flags|=65536,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Wu(e,r,a)),!1}throw Error(i(435,n.tag))}return Wu(e,r,a),Tu(),!1}if(Ci)return t=Ka.current,t===null?(r!==Ei&&(t=Error(i(423),{cause:r}),Ni(oi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=oi(r,n),a=Ws(e.stateNode,r,a),Fa(e,a),Hl!==4&&(Hl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ei&&(e=Error(i(422),{cause:r}),Ni(oi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=oi(o,n),Jl===null?Jl=[o]:Jl.push(o),Hl!==4&&(Hl=2),t===null)return!0;r=oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Fa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(tu===null||!tu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Fa(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?Oa(t,null,n,r):Da(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ui(t),r=mo(e,t,n,o,a,i),s=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Ci&&s&&vi(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Zr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=ei(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?dr:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=Qr(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(dr(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&la(t,a===null?null:a.cachePool),a===null?Wa():Ua(t,a),Xa(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&la(t,null),Wa(),Za(t)):(la(t,a.cachePool),Ua(t,a),Za(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=ca();return a=a===null?null:{parent:Xi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&la(t,null),Wa(),Xa(t),e!==null&&Vi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Da(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,Qa(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ci){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Ya(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ya(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Vi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Ze(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Gr(e,s),pu(r,e,s),Js;Tu(),t=ic(e,t,n)}else e=o.treeContext,Si=cf(s.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=rc(t,r),t.flags|=4096;return t}return e=Qr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Ui(t),n=mo(e,t,n,r,void 0,i),r=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Ci&&r&&vi(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Ui(t),t.updateQueue=null,n=go(t,r,n,i),ho(e),r=vo(),e!==null&&!Ys?(yo(e,t,a),xc(e,t,a)):(Ci&&r&&vi(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Ui(t),t.stateNode===null){var a=Jr,o=n.contextType;typeof o==`object`&&o&&(a=Wi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Aa(t),o=n.contextType,a.context=typeof o==`object`&&o?Wi(o):Jr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),Ra(t,r,a,i),La(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Jr,typeof u==`object`&&u&&(o=Wi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),ka=!1;var f=t.memoizedState;a.state=f,Ra(t,r,a,i),La(),l=t.memoizedState,s||f!==l||ka?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=ka||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ja(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Jr,typeof l==`object`&&l&&(c=Wi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),ka=!1,f=t.memoizedState,a.state=f,Ra(t,r,a,i),La();var p=t.memoizedState;o!==d||f!==p||ka||e!==null&&e.dependencies!==null&&Hi(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=ka||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Hi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Da(t,e.child,null,i),t.child=Da(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return ji(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:ua()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Kl),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:($a.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ci){if(a?Ja(t):Za(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Za(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ti(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(Ja(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ja(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Za(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ti(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Da(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Za(t),t.child=e.child,t.flags|=128,t=null);else if(Ja(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ni({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Vi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Ze(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Gr(e,r),pu(s,e,r),Js;af(c)||Tu(),t=_c(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Si=cf(c.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Za(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Qr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ti(c,a,n,null),c.flags|=2):c=Qr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=ua():(l=Xi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(Ja(t),n=e.child,e=n.sibling,n=Qr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=Xr(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Da(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),zi(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=$a.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,R($a,o),Xs(e,t,r,n),r=Ci?ui:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&eo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&eo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Vi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Qr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Hi(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:ce(t,t.stateNode.containerInfo),Li(t,Xi,e.memoizedState.cache),ji();break;case 27:case 5:ue(t);break;case 4:ce(t,t.stateNode.containerInfo);break;case 10:Li(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ya(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ja(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(Ja(t),t.flags|=128,null);Ja(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Vi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),R($a,$a.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:Li(t,Xi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,Ci&&t.flags&1048576&&_i(t,ui,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=_a(t.elementType),t.type=e,typeof e==`function`)Zr(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=ee(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(ce(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ja(e,t),Ra(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Li(t,Xi,r),r!==o.cache&&Bi(t,[Xi],n,!0),La(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=oi(Error(i(424)),t),Ni(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Si=cf(e.firstChild),xi=t,Ci=!0,wi=null,Ti=!0,n=Oa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ji(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ci||(n=t.type,e=t.pendingProps,r=Bd(oe.current).createElement(n),r[rt]=t,r[it]=e,Pd(r,n,e),gt(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ue(t),e===null&&Ci&&(r=t.stateNode=ff(t.type,t.pendingProps,oe.current),xi=t,Ti=!0,a=Si,Zd(t.type)?(lf=a,Si=cf(r.firstChild)):Si=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ci&&((a=r=Si)&&(r=tf(r,t.type,t.pendingProps,Ti),r===null?a=!1:(t.stateNode=r,xi=t,Si=cf(r.firstChild),Ti=!1,a=!0)),a||Di(t)),ue(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=mo(e,t,_o,null,null,n),Qf._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&Ci&&((e=n=Si)&&(n=nf(n,t.pendingProps,Ti),n===null?e=!1:(t.stateNode=n,xi=t,Si=null,e=!0)),e||Di(t)),null;case 13:return mc(e,t,n);case 4:return ce(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Da(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Li(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Ui(t),a=Wi(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Ui(t),r=Wi(Xi),e===null?(a=ca(),a===null&&(a=Pl,o=Zi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Aa(t),Li(t,Xi,a)):((e.lanes&n)!==0&&(ja(e,t),Ra(t,null,null,n),La()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Li(t,Xi,r),r!==a.cache&&Bi(t,[Xi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Li(t,Xi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Su())e.flags|=8192;else throw va=ma,fa}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(Su())e.flags|=8192;else throw va=ma,fa}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ge(),e.lanes|=t,ql|=t)}function kc(e,t){if(!Ci)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(yi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ri(Xi),le(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ai(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Mi())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(de(t),n=oe.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=z.current,Ai(t)?Oi(t,e):(e=ff(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(de(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=z.current,Ai(t))Oi(t,o);else{var s=Bd(oe.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[rt]=t,o[it]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=oe.current,Ai(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=xi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[rt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||Di(t,!0)}else e=Bd(e).createTextNode(r),e[rt]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ai(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[rt]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Qa(t),t):(Qa(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ai(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[rt]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Qa(t),t):(Qa(t),null)}return Qa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return le(),e===null&&Sd(t.stateNode.containerInfo),Ac(t),null;case 10:return Ri(t.type),Ac(t),null;case 19:if(L($a),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Hl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=eo(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)$r(n,e),n=n.sibling;return R($a,$a.current&1|2),Ci&&gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&we()>$l&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=eo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ci)return Ac(t),null}else 2*we()-r.renderingStartTime>$l&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=we(),e.sibling=null,n=$a.current,R($a,a?n&1|2:n&1),Ci&&gi(t,r.treeForkCount),e);case 22:case 23:return Qa(t),Ga(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&L(sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ri(Xi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ri(Xi),le(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return de(t),null;case 31:if(t.memoizedState!==null){if(Qa(t),t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Qa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L($a),null;case 4:return le(),null;case 10:return Ri(t.type),null;case 22:case 23:return Qa(t),Ga(),e!==null&&L(sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ri(Xi),null;case 25:return null;default:return null}}function Nc(e,t){switch(yi(t),t.tag){case 3:Ri(Xi),le();break;case 26:case 27:case 5:de(t);break;case 4:le();break;case 31:t.memoizedState!==null&&Qa(t);break;case 13:Qa(t);break;case 19:L($a);break;case 10:Ri(t.type);break;case 22:case 23:Qa(t),Ga(),e!==null&&L(sa);break;case 24:Ri(Xi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Uu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Uu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Uu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ba(t,n)}catch(t){Uu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Uu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Uu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Uu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Uu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Uu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[it]=t}catch(t){Uu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Xt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[rt]=e,t[it]=n}catch(t){Uu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,Rd=sp,e=hr(e),gr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Uu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Uu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Uu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ba(e,t)}catch(e){Uu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qu.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&dt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Me&&typeof Me.onCommitFiberUnmount==`function`)try{Me.onCommitFiberUnmount(je,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;Zd(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),pf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Uu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Uu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Uu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Uu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ju.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[ut]||o[rt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[rt]=e,gt(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[rt]=e,gt(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Ht(a,``)}catch(t){Uu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Uu(e,e.return,t)}}break;case 3:if(Bf=null,a=ul,ul=gf(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Uu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=gf(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Zl=we()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Uu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Uu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Uu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Ht(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Uu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:pf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Uu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)za(c[i],s)}catch(e){Uu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Qi(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Uu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Gf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=gf(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Qi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Wi(Xi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Wi(Xi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Q=null,Fl=0,Il=0,Ll=null,Rl=!1,zl=!1,Bl=!1,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=null,Yl=null,Xl=!1,Zl=0,Ql=0,$l=1/0,eu=null,tu=null,nu=0,ru=null,iu=null,au=0,ou=0,su=null,cu=null,lu=0,uu=null;function du(){return Nl&2&&Fl!==0?Fl&-Fl:P.T===null?et():ud()}function fu(){if(Kl===0)if(!(Fl&536870912)||Ci){var e=ze;ze<<=1,!(ze&3932160)&&(ze=262144),Kl=e}else Kl=536870912;return e=Ka.current,e!==null&&(e.flags|=32),Kl}function pu(e,t,n){(e===Pl&&(Il===2||Il===9)||e.cancelPendingCommit!==null)&&(bu(e,0),_u(e,Fl,Kl,!1)),qe(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Wl|=n),Hl===4&&_u(e,Fl,Kl,!1)),nd(e))}function mu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Ue(e,t),a=r?Ou(e,t):Eu(e,t,!0),o=r;do{if(a===0){zl&&!r&&_u(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!gu(n)){a=Eu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Jl;var l=c.current.memoizedState.isDehydrated;if(l&&(bu(c,s).flags|=256),s=Eu(c,s,!1),s!==2){if(Bl&&!l){c.errorRecoveryDisabledLanes|=o,Wl|=o,a=4;break a}o=Yl,Yl=a,o!==null&&(Yl===null?Yl=o:Yl.push.apply(Yl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){bu(e,0),_u(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:_u(r,t,Kl,!Rl);break a;case 2:Yl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Zl+300-we(),10<a)){if(_u(r,t,Kl,!Rl),He(r,0,!0)!==0)break a;au=t,r.timeoutHandle=Kd(hu.bind(null,r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,`Throttled`,-0,0),a);break a}hu(r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,null,-0,0)}}break}while(1);nd(e)}function hu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xt},Tl(t,a,d);var m=(a&62914560)===a?Zl-we():(a&4194048)===a?Ql-we():0;if(m=qf(d,m),m!==null){au=a,e.cancelPendingCommit=m(Fu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),_u(e,a,o,!l);return}}Fu(e,t,a,n,r,i,o,s,c)}function gu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function _u(e,t,n,r){t&=~Gl,t&=~Wl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Pe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ye(e,n,t)}function vu(){return Nl&6?!0:(rd(0,!1),!1)}function yu(){if(Q!==null){if(Il===0)var e=Q.return;else e=Q,Ii=Fi=null,bo(e),xa=null,Sa=0,e=Q;for(;e!==null;)Nc(e.alternate,e),e=e.return;Q=null}}function bu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),au=0,yu(),Pl=e,Q=n=Qr(e.current,null),Fl=t,Il=0,Ll=null,Rl=!1,zl=Ue(e,t),Bl=!1,ql=Kl=Gl=Wl=Ul=Hl=0,Yl=Jl=null,Xl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Pe(r),a=1<<i;t|=e[i],r&=~a}return Vl=t,Hr(),n}function xu(e,t){Z=null,P.H=As,t===da||t===pa?(t=ya(),Il=3):t===fa?(t=ya(),Il=4):Il=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ll=t,Q===null&&(Hl=1,Hs(e,oi(t,e.current)))}function Su(){var e=Ka.current;return e===null?!0:(Fl&4194048)===Fl?qa===null:(Fl&62914560)===Fl||Fl&536870912?e===qa:!1}function Cu(){var e=P.H;return P.H=As,e===null?As:e}function wu(){var e=P.A;return P.A=jl,e}function Tu(){Hl=4,Rl||(Fl&4194048)!==Fl&&Ka.current!==null||(zl=!0),!(Ul&134217727)&&!(Wl&134217727)||Pl===null||_u(Pl,Fl,Kl,!1)}function Eu(e,t,n){var r=Nl;Nl|=2;var i=Cu(),a=wu();(Pl!==e||Fl!==t)&&(eu=null,bu(e,t)),t=!1;var o=Hl;a:do try{if(Il!==0&&Q!==null){var s=Q,c=Ll;switch(Il){case 8:yu(),o=6;break a;case 3:case 2:case 9:case 6:Ka.current===null&&(t=!0);var l=Il;if(Il=0,Ll=null,Mu(e,s,c,l),n&&zl){o=0;break a}break;default:l=Il,Il=0,Ll=null,Mu(e,s,c,l)}}Du(),o=Hl;break}catch(t){xu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ii=Fi=null,Nl=r,P.H=i,P.A=a,Q===null&&(Pl=null,Fl=0,Hr()),o}function Du(){for(;Q!==null;)Au(Q)}function Ou(e,t){var n=Nl;Nl|=2;var r=Cu(),a=wu();Pl!==e||Fl!==t?(eu=null,$l=we()+500,bu(e,t)):zl=Ue(e,t);a:do try{if(Il!==0&&Q!==null){t=Q;var o=Ll;b:switch(Il){case 1:Il=0,Ll=null,Mu(e,t,o,1);break;case 2:case 9:if(ha(o)){Il=0,Ll=null,ju(t);break}t=function(){Il!==2&&Il!==9||Pl!==e||(Il=7),nd(e)},o.then(t,t);break a;case 3:Il=7;break a;case 4:Il=5;break a;case 7:ha(o)?(Il=0,Ll=null,ju(t)):(Il=0,Ll=null,Mu(e,t,o,7));break;case 5:var s=null;switch(Q.tag){case 26:s=Q.memoizedState;case 5:case 27:var c=Q;if(s?Wf(s):c.stateNode.complete){Il=0,Ll=null;var l=c.sibling;if(l!==null)Q=l;else{var u=c.return;u===null?Q=null:(Q=u,Nu(u))}break b}}Il=0,Ll=null,Mu(e,t,o,5);break;case 6:Il=0,Ll=null,Mu(e,t,o,6);break;case 8:yu(),Hl=6;break a;default:throw Error(i(462))}}ku();break}catch(t){xu(e,t)}while(1);return Ii=Fi=null,P.H=r,P.A=a,Nl=n,Q===null?(Pl=null,Fl=0,Hr(),Hl):0}function ku(){for(;Q!==null&&!Se();)Au(Q)}function Au(e){var t=wc(e.alternate,e,Vl);e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function ju(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Fl);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Fl);break;case 5:bo(t);default:Nc(n,t),t=Q=$r(t,Vl),t=wc(n,t,Vl)}e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function Mu(e,t,n,r){Ii=Fi=null,bo(t),xa=null,Sa=0;var i=t.return;try{if(qs(e,i,t,n,Fl)){Hl=1,Hs(e,oi(n,e.current)),Q=null;return}}catch(t){if(i!==null)throw Q=i,t;Hl=1,Hs(e,oi(n,e.current)),Q=null;return}t.flags&32768?(Ci||r===1?e=!0:zl||Fl&536870912?e=!1:(Rl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ka.current,r!==null&&r.tag===13&&(r.flags|=16384))),Pu(t,e)):Nu(t)}function Nu(e){var t=e;do{if(t.flags&32768){Pu(t,Rl);return}e=t.return;var n=jc(t.alternate,t,Vl);if(n!==null){Q=n;return}if(t=t.sibling,t!==null){Q=t;return}Q=t=e}while(t!==null);Hl===0&&(Hl=5)}function Pu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Q=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Q=e;return}Q=e=n}while(e!==null);Hl=6,Q=null}function Fu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Bu();while(nu!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Vr,Je(e,n,o,s,c,l),e===Pl&&(Q=Pl=null,Fl=0),iu=t,ru=e,au=n,ou=o,su=a,cu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Yu(Oe,function(){return Vu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,F.p=a,P.T=r}}nu=1,Iu(),Lu(),Ru()}}function Iu(){if(nu===1){nu=0;var e=ru,t=iu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=zd,o=hr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&mr(s.ownerDocument.documentElement,s)){if(c!==null&&gr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=pr(s,h),v=pr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{Nl=i,F.p=r,P.T=n}}e.current=t,nu=2}}function Lu(){if(nu===2){nu=0;var e=ru,t=iu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,F.p=r,P.T=n}}nu=3}}function Ru(){if(nu===4||nu===3){nu=0,Ce();var e=ru,t=iu,n=au,r=cu;t.subtreeFlags&10256||t.flags&10256?nu=5:(nu=0,iu=ru=null,zu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(tu=null),$e(n),t=t.stateNode,Me&&typeof Me.onCommitFiberRoot==`function`)try{Me.onCommitFiberRoot(je,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}au&3&&Bu(),nd(e),i=e.pendingLanes,n&261930&&i&42?e===uu?lu++:(lu=0,uu=e):lu=0,rd(0,!1)}}function zu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Qi(t)))}function Bu(){return Iu(),Lu(),Ru(),Vu()}function Vu(){if(nu!==5)return!1;var e=ru,t=ou;ou=0;var n=$e(au),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=su,su=null;var o=ru,s=au;if(nu=0,iu=ru=null,au=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,rd(0,!1),Me&&typeof Me.onPostCommitFiberRoot==`function`)try{Me.onPostCommitFiberRoot(je,o)}catch{}return!0}finally{F.p=a,P.T=r,zu(e,t)}}function Hu(e,t,n){t=oi(n,t),t=Ws(e.stateNode,t,2),e=Na(e,t,2),e!==null&&(qe(e,2),nd(e))}function Uu(e,t,n){if(e.tag===3)Hu(e,e,n);else for(;t!==null;){if(t.tag===3){Hu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(tu===null||!tu.has(r))){e=oi(n,e),n=Gs(2),r=Na(t,n,2),r!==null&&(Ks(n,r,t,e),qe(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Bl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Fl&n)===n&&(Hl===4||Hl===3&&(Fl&62914560)===Fl&&300>we()-Zl?!(Nl&2)&&bu(e,0):Gl|=n,ql===Fl&&(ql=0)),nd(e)}function Ku(e,t){t===0&&(t=Ge()),e=Gr(e,t),e!==null&&(qe(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return be(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Pe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=Fl,a=He(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ue(r,a)||(n=!0,cd(r,a));r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=we(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}nu!==0&&nu!==5||rd(e,!1),td!==0&&(td=0)}function od(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Pe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=We(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Fl,n=He(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Il===2||Il===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&xe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ue(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&xe(r),$e(n)){case 2:case 8:n=De;break;case 32:n=Oe;break;case 268435456:n=ke;break;default:n=Oe}return r=sd.bind(null,e),n=be(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&xe(r),e.callbackPriority=2,e.callbackNode=null,2}function sd(e,t){if(nu!==0&&nu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Bu()&&e.callbackNode!==n)return null;var r=Fl;return r=He(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(mu(e,r,t),od(e,we()),e.callbackNode!=null&&e.callbackNode===n?sd.bind(null,e):null)}function cd(e,t){if(Bu())return null;mu(e,t,!0)}function ld(){Yd(function(){Nl&6?be(Ee,id):ad()})}function ud(){if(td===0){var e=ta;e===0&&(e=Re,Re<<=1,!(Re&261888)&&(Re=256)),td=e}return td}function dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Yt(``+e)}function fd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function pd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=dd((i[it]||null).action),o=r.submitter;o&&(t=(t=o[it]||null)?dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new vn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(td!==0){var e=o?fd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?fd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var md=0;md<Ir.length;md++){var hd=Ir[md];Lr(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}Lr(Or,`onAnimationEnd`),Lr(kr,`onAnimationIteration`),Lr(Ar,`onAnimationStart`),Lr(`dblclick`,`onDoubleClick`),Lr(`focusin`,`onFocus`),Lr(`focusout`,`onBlur`),Lr(jr,`onTransitionRun`),Lr(Mr,`onTransitionStart`),Lr(Nr,`onTransitionCancel`),Lr(Pr,`onTransitionEnd`),bt(`onMouseEnter`,[`mouseout`,`mouseover`]),bt(`onMouseLeave`,[`mouseout`,`mouseover`]),bt(`onPointerEnter`,[`pointerout`,`pointerover`]),bt(`onPointerLeave`,[`pointerout`,`pointerover`]),yt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),yt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),yt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),yt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),yt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),yt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var gd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),_d=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(gd));function vd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Rr(e)}i.currentTarget=null,a=c}}}}function yd(e,t){var n=t[ot];n===void 0&&(n=t[ot]=new Set);var r=e+`__bubble`;n.has(r)||(Cd(t,e,2,!1),n.add(r))}function bd(e,t,n){var r=0;t&&(r|=4),Cd(n,e,r,t)}var xd=`_reactListening`+Math.random().toString(36).slice(2);function Sd(e){if(!e[xd]){e[xd]=!0,_t.forEach(function(t){t!==`selectionchange`&&(_d.has(t)||bd(t,!1,e),bd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[xd]||(t[xd]=!0,bd(`selectionchange`,!1,t))}}function Cd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!sn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function wd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ft(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}rn(function(){var r=a,i=Qt(n),s=[];a:{var c=Fr.get(e);if(c!==void 0){var l=vn,u=e;switch(e){case`keypress`:if(pn(n)===0)break a;case`keydown`:case`keyup`:l=Pn;break;case`focusin`:u=`focus`,l=En;break;case`focusout`:u=`blur`,l=En;break;case`beforeblur`:case`afterblur`:l=En;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=wn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Tn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=In;break;case Or:case kr:case Ar:l=Dn;break;case Pr:l=W;break;case`scroll`:case`scrollend`:l=H;break;case`wheel`:l=Ln;break;case`copy`:case`cut`:case`paste`:l=On;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Fn;break;case`toggle`:case`beforetoggle`:l=Rn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=an(m,p),g!=null&&d.push(Td(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Zt&&(u=n.relatedTarget||n.fromElement)&&(ft(u)||u[at]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ft(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=wn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Fn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:mt(l),h=u==null?c:mt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ft(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Dd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Od(s,c,l,d,!1),u!==null&&f!==null&&Od(s,f,u,d,!0)}}a:{if(c=r?mt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=rr;else if(Qn(c))if(ir)v=lr;else{v=sr;var y=or}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Kt(r.elementType)&&(v=rr):v=cr;if(v&&=v(e,r)){$n(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Rt(c,`number`,c.value)}switch(y=r?mt(r):window,e){case`focusin`:(Qn(y)||y.contentEditable===`true`)&&(vr=y,yr=r,br=null);break;case`focusout`:br=yr=vr=null;break;case`mousedown`:xr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:xr=!1,Sr(s,n,i);break;case`selectionchange`:if(_r)break;case`keydown`:case`keyup`:Sr(s,n,i)}var b;if(Bn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Jn?Kn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Un&&n.locale!==`ko`&&(Jn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Jn&&(b=fn()):(ln=i,un=`value`in ln?ln.value:ln.textContent,Jn=!0)),y=Ed(r,x),0<y.length&&(x=new kn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=qn(n),b!==null&&(x.data=b)))),(b=Hn?Yn(e,n):Xn(e,n))&&(x=Ed(r,`onBeforeInput`),0<x.length&&(y=new kn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),pd(s,e,r,n,i)}vd(s,t)})}function Td(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ed(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=an(e,n),i!=null&&r.unshift(Td(e,i,a)),i=an(e,t),i!=null&&r.push(Td(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Dd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Od(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=an(n,a),l!=null&&o.unshift(Td(n,l,c))):i||(l=an(n,a),l!=null&&o.push(Td(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var kd=/\r\n?/g,Ad=/\u0000|\uFFFD/g;function jd(e){return(typeof e==`string`?e:``+e).replace(kd,`
9
- `).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Ht(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Ht(e,``+r);break;case`className`:Et(e,`class`,r);break;case`tabIndex`:Et(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Et(e,n,r);break;case`style`:Gt(e,r,o);break;case`data`:if(t!==`object`){Et(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Yt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Yt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Xt);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Yt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:yd(`beforetoggle`,e),yd(`toggle`,e),Tt(e,`popover`,r);break;case`xlinkActuate`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Dt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Dt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Tt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=qt.get(n)||n,Tt(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Gt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Ht(e,r):(typeof r==`number`||typeof r==`bigint`)&&Ht(e,``+r);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Xt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[it]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Tt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:yd(`error`,e),yd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,o,s,n,null)}}a&&$(e,t,`srcSet`,n.srcSet,n,null),r&&$(e,t,`src`,n.src,n,null);return;case`input`:yd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:$(e,t,r,d,n,null)}}Lt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in yd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:$(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&zt(e,!!r,n,!0):zt(e,!!r,t,!1);return;case`textarea`:for(s in yd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:$(e,t,s,c,n,null)}Vt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:$(e,t,l,r,n,null)}return;case`dialog`:yd(`beforetoggle`,e),yd(`toggle`,e),yd(`cancel`,e),yd(`close`,e);break;case`iframe`:case`object`:yd(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)yd(gd[r],e);break;case`image`:yd(`error`,e),yd(`load`,e);break;case`details`:yd(`toggle`,e);break;case`embed`:case`source`:case`link`:yd(`error`,e),yd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,u,r,n,null)}return;default:if(Kt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&$(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||$(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&$(e,t,p,m,r,f)}}It(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||$(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&$(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?zt(e,!!n,n?[]:``,!1):zt(e,!!n,t,!0)):zt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:$(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&$(e,t,s,a,r,o)}Bt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:$(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:$(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&$(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:$(e,t,u,p,r,m)}return;default:if(Kt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&$(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||$(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[ut]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),dt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[ut])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);dt(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=vu();return e||t}function yf(e){var t=pt(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Ft(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),gt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ft(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ft(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ft(n.imageSizes)+`"]`)):i+=`[href="`+Ft(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),gt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ft(r)+`"][href="`+Ft(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),gt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=ht(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);gt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=ht(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),gt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=ht(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),gt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=oe.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=ht(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=ht(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=ht(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Ft(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),gt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Ft(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ft(n.href)+`"]`);if(r)return t.instance=r,gt(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),gt(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,gt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),gt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,gt(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),gt(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[ut]||a[rt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,gt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),gt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ke(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ke(0),this.hiddenUpdates=Ke(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Xr(3,null,null,t),e.current=a,a.stateNode=e,t=Zi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Aa(a),e}function tp(e){return e?(e=Jr,e):Jr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ma(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Na(e,r,t),n!==null&&(pu(n,e,t),Pa(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Gr(e,67108864);t!==null&&pu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=du();t=Qe(t);var n=Gr(e,t);n!==null&&pu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)wd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=pt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ve(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Pe(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Nl&6)&&($l=we()+500,rd(0,!1))}}break;case 31:case 13:s=Gr(a,2),s!==null&&pu(s,a,2),vu(),ip(a,2)}if(a=dp(r),a===null&&wd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function dp(e){return e=Qt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ft(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Te()){case Ee:return 2;case De:return 8;case Oe:case B:return 32;case ke:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=pt(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=ft(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,tt(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,tt(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Zt=r,n.target.dispatchEvent(r),Zt=null}else return t=pt(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=pt(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[it]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[it]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,du(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),vu(),t[at]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.4`)throw Error(i(527,Lp,`19.2.4`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{je=zp.inject(Rp),Me=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[at]=t.current,Sd(e),new Fp(t)}})),g=c(o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=500,y=200,b=3e3,x=1e3,S=3e4,C=Object.freeze({counters:Object.freeze({}),latestBurst:null,burstRing:Object.freeze([]),burstSeq:0,lifecycleRing:Object.freeze([]),connectionSeq:0,connected:!1,reconnectAttempts:0,lastErrorAt:null,reconnectDelayMs:x}),w=new Set,T={},E=[],D=[],O=[],k=!1,A=!1,j=null,M=null,N=null,ee=!1,te=typeof localStorage<`u`&&localStorage.getItem(`DEBUG_SSE`)===`1`;function P(e,t){te&&(t?console.debug(`[ssg-sse] ${e}`,t):console.debug(`[ssg-sse] ${e}`))}function F(){ee||(ee=!0,queueMicrotask(ne))}function ne(){ee=!1;let e=Object.keys(T),t=E,n=D,r=O,i=k,a=j!==null||M!==null||N!==null;if(e.length===0&&t.length===0&&n.length===0&&r.length===0&&!i&&!a)return;let o=C.counters;if(e.length>0){let t={...C.counters};for(let n of e)t[n]=(t[n]??0)+(T[n]??0);o=Object.freeze(t),T={}}let s=C.burstRing,c=C.latestBurst,l=C.burstSeq;if(t.length>0){let e=C.burstRing.length+t.length>v?[...C.burstRing,...t].slice(-v):[...C.burstRing,...t];s=Object.freeze(e),c=t[t.length-1]??c,l=C.burstSeq+t.length,E=[]}if(n.length>0){let e=new Map;for(let t of n)e.set(t.tool_use_id,t);let t=!1,r=s.map(n=>{if(!n.tool_use_id)return n;let r=e.get(n.tool_use_id);if(!r)return n;t=!0;let i=n.output_tokens??0,a=n.complete_ts_ms??0,o=Math.max(i,r.output_tokens),s=Math.max(a,r.ts_ms),c=Math.max(n.complete_duration_ms??0,r.duration_ms??0);return{...n,output_tokens:o,complete_ts_ms:s,...c>0?{complete_duration_ms:c}:{}}});t&&(s=Object.freeze(r),l=C.burstSeq+1),D=[]}let u=C.lifecycleRing;if(r.length>0){let e=C.lifecycleRing.length+r.length>y?[...C.lifecycleRing,...r].slice(-y):[...C.lifecycleRing,...r];u=Object.freeze(e),O=[]}let d=C.connected,f=C.connectionSeq;i&&(d=A,f=C.connectionSeq+1,k=!1);let p=C.reconnectAttempts,m=C.lastErrorAt,h=C.reconnectDelayMs;j!==null&&(p=j,j=null),M!==null&&(m=M,M=null),N!==null&&(h=N,N=null),C=Object.freeze({counters:o,latestBurst:c,burstRing:s,burstSeq:l,lifecycleRing:u,connectionSeq:f,connected:d,reconnectAttempts:p,lastErrorAt:m,reconnectDelayMs:h});for(let e of w)e()}var re=null,ie=0,I=new Set,L=new Map,R=null,z=x,ae=null;function oe(e,t){if(e===`eval-burst`){try{let e=JSON.parse(t.data);Array.isArray(e?.bursts)&&(E.push(...e.bursts),F())}catch{}return}if(e===`eval-burst-complete`){try{let e=JSON.parse(t.data);if(e&&typeof e.tool_use_id==`string`&&e.tool_use_id.length>0&&typeof e.output_tokens==`number`&&Number.isFinite(e.output_tokens)&&typeof e.ts_ms==`number`&&Number.isFinite(e.ts_ms)){let t={ts_ms:e.ts_ms,tool_use_id:e.tool_use_id,output_tokens:Math.max(0,e.output_tokens),...typeof e.duration_ms==`number`&&Number.isFinite(e.duration_ms)?{duration_ms:e.duration_ms}:{}};D.push(t),F()}}catch{}return}if(e===`session-lifecycle`){try{let e=JSON.parse(t.data);Array.isArray(e?.events)&&e.events.length>0&&(O.push(...e.events),F())}catch{}return}T[e]=(T[e]??0)+1,F()}function se(e){if(!re||L.has(e))return;let t=t=>oe(e,t);re.addEventListener(e,t),L.set(e,t)}var ce=0,le=0,ue=2e3;function de(){if(re)return;P(`opening EventSource`,{url:`/api/events`}),le=Date.now();let e=new EventSource(`/api/events`);re=e,L.clear();for(let e of I)se(e);e.onopen=()=>{let e=C.lastErrorAt!==null;z=x,ce=0,j=0,N=x,k=!0,A=!0,F(),e&&Se(`reconnect`),P(`connected`)},e.onerror=()=>{e.close(),re=null,L.clear(),k=!0,A=!1,M=Date.now(),F(),ce===0&&Date.now()-le<ue?P(`first-open interrupted (page-load race) — reconnect in ${z}ms`):console.warn(`[ssg-sse] EventSource error — reconnect in ${z}ms (attempt ${ce+1})`),ie>0&&(R=setTimeout(()=>{R=null,ie>0&&de()},z),ce++,j=ce,z=Math.min(z*2,S),N=z,F())}}function fe(){R&&=(clearTimeout(R),null),re?.close(),re=null,L.clear(),z=x,ce=0,j=0,N=x,k=!0,A=!1,F()}typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&ie!==0&&(re||(R&&=(clearTimeout(R),null),P(`visibilitychange → reconnecting`),de()))});function pe(){for(let e of I)e!==`eval-burst`&&(T[e]=(T[e]??0)+1);F()}function me(e){return w.add(e),()=>{w.delete(e)}}function he(){return C}var ge=2e3,_e=1e4,ve=1440*60*1e3,ye=500,be=0,xe=null;function Se(e){let t=Date.now();if(t-be<_e){P(`hydrate skipped (cooldown)`,{reason:e});return}if(xe)return;let n=t-ve,r=C.burstRing[C.burstRing.length-1],i=C.burstRing.length>0&&r!==void 0?r.ts_ms+1:n,a=e===`reconnect`?Math.max(i,n):n,o=t;if(a>=o)return;be=t;let s=new AbortController;xe=s,P(`hydrate start`,{reason:e,since:a,until:o,ringLen:C.burstRing.length}),(async()=>{let t=a,n=0;try{for(;n<ge&&t<o&&!s.signal.aborted;){let r=Math.min(ye,ge-n),i=await fetch(`/api/json/graph/backfill?since_ms=${t}&until_ms=${o}&limit=${r}`,{signal:s.signal,credentials:`same-origin`});if(!i.ok)break;let a=await i.json();if(!Array.isArray(a.bursts)||a.bursts.length===0||(E.push(...a.bursts),F(),n+=a.bursts.length,P(`hydrate page`,{reason:e,page:n,count:a.bursts.length}),a.bursts.length<r))break;let c=a.bursts[a.bursts.length-1];if(c===void 0)break;t=c.ts_ms+1}P(`hydrate done`,{reason:e,fetched:n})}catch(t){t.name!==`AbortError`&&console.warn(`[ssg-sse] ring hydration failed (${e})`,t)}finally{xe=null}})()}function Ce(e){for(let t of e)I.add(t),se(t);return ie++,ie===1&&(Se(`initial`),de(),ae=setInterval(pe,b)),()=>{ie--,ie===0&&(fe(),ae&&=(clearInterval(ae),null))}}var we=Object.freeze([`eval-burst`,`eval-burst-complete`,`counters-updated`]);function Te(){(0,_.useEffect)(()=>Ce(we),[])}function Ee(){return Te(),(0,_.useSyncExternalStore)(me,he).latestBurst}function De(){return Te(),(0,_.useSyncExternalStore)(me,he).burstRing}function Oe(){return Te(),(0,_.useSyncExternalStore)(me,he).burstSeq}function B(){let e=document.querySelector(`meta[name="ssg-csrf"]`)?.content??``;return e?{"X-SigmaShake-Token":e}:{}}function ke(e){let t=(0,_.useSyncExternalStore)(me,he),n=e.join(`,`);(0,_.useEffect)(()=>Ce(e),[n]);let r=(0,_.useRef)({});return(0,_.useMemo)(()=>{let n={},i=!1;for(let a of e){let e=t.counters[a]??0;n[a]=e,r.current[a]!==e&&(i=!0)}return!i&&Object.keys(r.current).length===e.length?r.current:(r.current=n,n)},[t,n])}function V(e,t=[]){let[n,r]=(0,_.useState)({data:null,loading:!0,error:null}),[i,a]=(0,_.useState)(0),o=(0,_.useRef)(null),s=(0,_.useCallback)(()=>{a(e=>e+1)},[]);return(0,_.useEffect)(()=>{let t=new AbortController;return o.current=t,r(e=>({...e,loading:!0,error:null})),fetch(e,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t.signal.aborted||r({data:e,loading:!1,error:null})}).catch(e=>{if(t.signal.aborted)return;let n=e instanceof Error?e.message:String(e);r(e=>({...e,loading:!1,error:n}))}),()=>{t.abort()}},[e,i,...t]),{...n,refetch:s}}var Ae=e=>e,je=e=>({in:t=>t**+e,out:t=>1-(1-t)**e,inOut:t=>t<.5?(2*t)**e/2:1-(-2*t+2)**e/2}),Me=je(2),Ne=je(3),Pe=je(4),Fe=je(5),Ie={in:e=>1-Math.cos(e*Math.PI/2),out:e=>Math.sin(e*Math.PI/2),inOut:e=>-(Math.cos(Math.PI*e)-1)/2},Le={in:e=>e===0?0:2**(10*e-10),out:e=>e===1?1:1-2**(-10*e),inOut:e=>e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2},Re={in:e=>1-Math.sqrt(1-e**2),out:e=>Math.sqrt(1-(e-1)**2),inOut:e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2};function ze(e=1.70158){let t=e;return e=>e*e*((t+1)*e-t)}function Be(e=1.70158){let t=e;return e=>{let n=e-1;return n*n*((t+1)*n+t)+1}}function Ve(e=1.70158){let t=e*1.525;return e=>e<.5?(2*e)**2*((t+1)*2*e-t)/2:((2*e-2)**2*((t+1)*(e*2-2)+t)+2)/2}function He(e=1,t=.3){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>e===0?0:e===1?1:n*2**(-10*e)*Math.sin((e-i)*(Math.PI*2)/r)+1}function Ue(e=1,t=.3){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>e===0?0:e===1?1:-(n*2**(10*(e-1))*Math.sin((e-1-i)*(Math.PI*2)/r))}function We(e=1,t=.45){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>{if(e===0)return 0;if(e===1)return 1;let t=e*2;return t<1?-.5*(n*2**(10*(t-1))*Math.sin((t-1-i)*(Math.PI*2)/r)):n*2**(-10*(t-1))*Math.sin((t-1-i)*(Math.PI*2)/r)*.5+1}}var Ge=7.5625,Ke=2.75,qe=e=>{if(e<1/Ke)return Ge*e*e;if(e<2/Ke){let t=e-1.5/Ke;return Ge*t*t+.75}if(e<2.5/Ke){let t=e-2.25/Ke;return Ge*t*t+.9375}let t=e-2.625/Ke;return Ge*t*t+.984375},Je=e=>1-qe(1-e),Ye=e=>e<.5?(1-qe(1-2*e))/2:(1+qe(2*e-1))/2;function Xe(e){let t=Math.max(1,Math.floor(e));return e=>e>=1?1:e<=0?0:Math.floor(e*t)/t}function Ze(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<1e-5)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;n<r;){let i=u(t);if(Math.abs(i-e)<1e-5)return t;e>i?n=t:r=t,t=(n+r)/2}return t};return e=>e<=0?0:e>=1?1:d(p(e))}function Qe(e={}){let t=Math.max(1,e.stiffness??100),n=Math.max(0,e.damping??10),r=Math.max(.01,e.mass??1),i=e.velocity??0,a=Math.sqrt(t/r),o=n/(2*Math.sqrt(t*r)),s;if(o<1){let e=a*Math.sqrt(1-o*o),t=(o*a+-i)/e;s=n=>1-Math.exp(-o*a*n)*(1*Math.cos(e*n)+t*Math.sin(e*n))}else if(o===1){let e=a+-i;s=t=>1-Math.exp(-a*t)*(1+e*t)}else{let e=Math.sqrt(o*o-1),t=-a*(o-e),n=-a*(o+e),r=(n- -i)/(n-t),c=1-r;s=e=>1-(r*Math.exp(t*e)+c*Math.exp(n*e))}let c=400;for(let e=16;e<=4e3;e+=16){let t=s(e/1e3);if(Math.abs(1-t)<.005){let t=s((e-16)/1e3);if(Math.abs(1-t)<.005){c=e;break}}c=e}let l=c/1e3;return{duration:c,fn:e=>s(Math.max(0,Math.min(1,e))*l)}}var $e={linear:Ae,inQuad:Me.in,outQuad:Me.out,inOutQuad:Me.inOut,inCubic:Ne.in,outCubic:Ne.out,inOutCubic:Ne.inOut,inQuart:Pe.in,outQuart:Pe.out,inOutQuart:Pe.inOut,inQuint:Fe.in,outQuint:Fe.out,inOutQuint:Fe.inOut,inSine:Ie.in,outSine:Ie.out,inOutSine:Ie.inOut,inExpo:Le.in,outExpo:Le.out,inOutExpo:Le.inOut,inCirc:Re.in,outCirc:Re.out,inOutCirc:Re.inOut,inBack:ze(),outBack:Be(),inOutBack:Ve(),inElastic:Ue(),outElastic:He(),inOutElastic:We(),inBounce:Je,outBounce:qe,inOutBounce:Ye};function et(e){if(typeof e==`function`)return e;if(e===void 0)return $e.outCubic;let t=$e[e];if(t)return t;let n=e.match(/^(\w+)\(([^)]*)\)$/);if(n){let e=n[1],t=n[2].split(`,`).map(e=>parseFloat(e.trim())).filter(e=>!Number.isNaN(e));switch(e){case`outElastic`:return He(t[0],t[1]);case`inElastic`:return Ue(t[0],t[1]);case`inOutElastic`:return We(t[0],t[1]);case`outBack`:return Be(t[0]);case`inBack`:return ze(t[0]);case`inOutBack`:return Ve(t[0]);case`steps`:return Xe(t[0]??4);case`cubicBezier`:return t.length>=4?Ze(t[0],t[1],t[2],t[3]):$e.outCubic;default:return $e.outCubic}}return $e.outCubic}function tt(e,t){if(t<=1||e===void 0||e===`first`)return 0;if(e===`last`)return t-1;if(e===`center`)return(t-1)/2;let n=Math.floor(e);return n<0?0:n>t-1?t-1:n}function nt(e,t={}){let n=t.start??0,r=t.direction===`reverse`;return(i,a)=>{if(a<=0)return n;let o=tt(t.from,a),s=Math.abs(i-o),c=Math.max(o,a-1-o),l=c===0?0:s/c,u=r?1-l:l,d;if(Array.isArray(e)){let[t,n]=e;d=t+u*(n-t)}else d=(r?c-s:s)*e;return n+d}}var rt=new Set([`duration`,`delay`,`ease`,`loop`,`alternate`,`onBegin`,`onUpdate`,`onComplete`]);function it(e){if(typeof e==`number`||typeof e==`string`)return e;if(Array.isArray(e)&&e.length===2){let[t,n]=e;if((typeof t==`number`||typeof t==`string`)&&(typeof n==`number`||typeof n==`string`))return[t,n]}return null}function at(e){return e?typeof e==`string`?typeof document>`u`?[]:Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:`length`in e?Array.from(e):[]:[]}function ot(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var st=/^(-?\d*\.?\d+)([a-z%]*)$/i;function ct(e){if(typeof e==`number`)return{value:e,unit:``};let t=e.trim().match(st);return t?{value:parseFloat(t[1]),unit:t[2]??``}:{value:0,unit:``}}function lt(e){return e.unit===``?`${e.value}`:`${e.value}${e.unit}`}var ut=new Set([`translate`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`]),dt=new WeakMap;function ft(e){let t=dt.get(e);return t||(t={values:{}},dt.set(e,t)),t}function pt(e){let t=[];for(let[n,r]of Object.entries(e.values)){let e=r.unit||(n.startsWith(`rotate`)||n.startsWith(`skew`)?`deg`:n.startsWith(`translate`)?`px`:``);t.push(`${n}(${r.value}${e})`)}return t.join(` `)}function mt(e,t,n){if(ut.has(t)){let r=ft(e);r.values[t]=n,e.style.transform=pt(r);return}if(t===`opacity`){e.style.opacity=`${n.value}`;return}e.style.setProperty(t,lt(n))}function ht(e,t){return ut.has(t)?ft(e).values[t]||{value:t.startsWith(`scale`)?1:0,unit:``}:ct(e.style.getPropertyValue(t)||(typeof window<`u`?window.getComputedStyle(e).getPropertyValue(t):``)||(t===`opacity`?`1`:`0`))}function gt(e,t,n){return e+(t-e)*n}function _t(e,t,n){return e===void 0?0:typeof e==`number`?e:e(t,n)}function vt(e){if(e&&typeof e==`object`&&`spring`in e){let t=Qe(e.spring);return{ease:t.fn,duration:t.duration}}return{ease:et(e),duration:null}}var yt=0,bt=new Set;function xt(e){for(let t of bt){if(t.done||e<t.start)continue;let{target:n,options:r}=t,i=e-t.start,a=Math.max(1,n.duration),o=r.loop??!1,s=r.alternate===!0,c=o===!0?1/0:typeof o==`number`?Math.max(1,o):1,l=Math.floor(i/a),u=(i-l*a)/a,d=s&&l%2==1?1-u:u;if(l>=c){for(let e of n.props)mt(n.el,e.name,St(e.from,e.to,s&&c%2==0?0:1));r.onUpdate?.(1,n.el,n.index),r.onComplete?.(n.el,n.index),t.done=!0;continue}for(let e of n.props){let t=e.ease(Math.max(0,Math.min(1,d)));n.el!==null&&mt(n.el,e.name,St(e.from,e.to,t))}n.el!==null&&r.onUpdate?.(d,n.el,n.index)}for(let e of[...bt])e.done&&bt.delete(e);if(bt.size===0){yt=0;return}yt=requestAnimationFrame(xt)}function St(e,t,n){let r=e.unit||t.unit;return{value:gt(e.value,t.value,n),unit:r}}function Ct(){yt===0&&(typeof requestAnimationFrame>`u`||(yt=requestAnimationFrame(xt)))}function wt(e,t){let n=at(e),r=n.length,i=Object.keys(t).filter(e=>!rt.has(e)),a=ot(),{ease:o,duration:s}=vt(t.ease),c=t.duration??s??400,l=[],u=[],d=typeof performance<`u`?performance.now():Date.now(),f=(e,n)=>{let a=[];for(let n of i){let r=t[n];if(r===void 0)continue;let i=it(r);if(i===null)continue;let s,c;Array.isArray(i)?(s=ct(i[0]),c=ct(i[1])):(s=ht(e,n),c=ct(i)),a.push({name:n,from:s,to:c,ease:o})}return{el:e,index:n,props:a,duration:c,delay:_t(t.delay,n,r)}};if(n.length===0)return{cancel:()=>{},finished:Promise.resolve(),get done(){return!0}};let p=!1;for(let e=0;e<n.length;e++){let r=n[e],i=f(r,e),o=d+i.delay;if(t.onBegin?.(r,e),a){for(let e of i.props)mt(r,e.name,e.to);t.onUpdate?.(1,r,e),t.onComplete?.(r,e),u.push(Promise.resolve());continue}for(let e of i.props)mt(r,e.name,e.from);let s={target:i,start:o,options:t,done:!1};l.push(s),bt.add(s),u.push(new Promise(e=>{let n=t.onComplete,r=(t,r)=>{try{n?.(t,r)}finally{e()}};s.options={...t,onComplete:r}}))}return Ct(),{cancel(){if(!p){p=!0;for(let e of l)e.done=!0,bt.delete(e)}},finished:Promise.all(u).then(()=>void 0),get done(){return p||l.every(e=>e.done)}}}function Tt(e={}){let t=(0,_.useRef)(null),n=(0,_.useRef)(!1),r=(0,_.useCallback)(()=>{if(n.current)return;let r=t.current;if(!r)return;let i=r.querySelectorAll(`[data-reveal]`);if(i.length===0)return;if(n.current=!0,ot()){i.forEach(e=>{e.style.opacity=`1`,e.style.transform=``});return}let a=e.staggerMs??40,o=e.maxStaggerMs??320,s=Math.min(a,Math.max(10,o/i.length)),c=e.translateY??14,l=e.durationMs??520,u=e.from??`center`;i.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(${c}px)`,e.style.willChange=`transform, opacity`}),wt(Array.from(i),{opacity:[0,1],translateY:[c,0],duration:l,ease:`outBack(1.2)`,delay:nt(s,{from:u}),onComplete:e=>{e.style.willChange=``}})},[e.staggerMs,e.maxStaggerMs,e.durationMs,e.translateY,e.from]);return(0,_.useEffect)(()=>{let n=t.current;if(!n)return;if(typeof IntersectionObserver>`u`){r();return}let i=!1,a=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting&&!i){r(),a.disconnect();return}},{threshold:.08});a.observe(n);let o=n.querySelectorAll(`[data-reveal]`);if(!ot()){let t=e.translateY??14;o.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(${t}px)`})}let s=n.getBoundingClientRect();return s.top<(window.innerHeight||document.documentElement.clientHeight)&&s.bottom>0&&(r(),a.disconnect()),()=>{i=!0,a.disconnect()}},[r,e.translateY]),t}function Et(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Et(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Dt(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Et(e))&&(r&&(r+=` `),r+=t);return r}var Ot=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,kt=Dt,At=(e,t)=>n=>{if(t?.variants==null)return kt(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Ot(t)||Ot(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return kt(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},jt=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Mt=(e,t)=>({classGroupId:e,validator:t}),Nt=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Pt=`-`,Ft=[],It=`arbitrary..`,Lt=e=>{let t=Bt(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return zt(e);let n=e.split(Pt);return Rt(n,n[0]===``&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?jt(i,t):t:i||Ft}return n[e]||Ft}}},Rt=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Rt(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Pt):e.slice(t).join(Pt),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},zt=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?It+r:void 0})(),Bt=e=>{let{theme:t,classGroups:n}=e;return Vt(n,t)},Vt=(e,t)=>{let n=Nt();for(let r in e){let i=e[r];Ht(i,n,r,t)}return n},Ht=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Ut(i,t,n,r)}},Ut=(e,t,n,r)=>{if(typeof e==`string`){Wt(e,t,n);return}if(typeof e==`function`){Gt(e,t,n,r);return}Kt(e,t,n,r)},Wt=(e,t,n)=>{let r=e===``?t:qt(t,e);r.classGroupId=n},Gt=(e,t,n,r)=>{if(Jt(e)){Ht(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Mt(n,e))},Kt=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ht(o,qt(t,a),n,r)}},qt=(e,t)=>{let n=e,r=t.split(Pt),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Nt(),n.nextPart.set(t,i)),n=i}return n},Jt=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Yt=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Xt=`!`,Zt=`:`,Qt=[],$t=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),en=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Zt){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Xt)?(c=s.slice(0,-1),l=!0):s.startsWith(Xt)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return $t(t,l,c,u)};if(t){let e=t+Zt,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):$t(Qt,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},tn=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},nn=e=>({cache:Yt(e.cacheSize),parseClassName:en(e),sortModifiers:tn(e),...Lt(e)}),rn=/\s+/,an=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(rn),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+Xt:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},on=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=sn(n))&&(i&&(i+=` `),i+=r);return i},sn=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=sn(e[r]))&&(n&&(n+=` `),n+=t);return n},cn=(e,...t)=>{let n,r,i,a,o=o=>(n=nn(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=an(e,n);return i(e,a),a};return a=o,(...e)=>a(on(...e))},ln=[],un=e=>{let t=t=>t[e]||ln;return t.isThemeGetter=!0,t},dn=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,fn=/^\((?:(\w[\w-]*):)?(.+)\)$/i,pn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,mn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,gn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_n=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yn=e=>pn.test(e),H=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),xn=e=>e.endsWith(`%`)&&H(e.slice(0,-1)),Sn=e=>mn.test(e),Cn=()=>!0,wn=e=>hn.test(e)&&!gn.test(e),Tn=()=>!1,En=e=>_n.test(e),Dn=e=>vn.test(e),On=e=>!U(e)&&!W(e),kn=e=>Wn(e,Jn,Tn),U=e=>dn.test(e),An=e=>Wn(e,Yn,wn),jn=e=>Wn(e,Xn,H),Mn=e=>Wn(e,Qn,Cn),Nn=e=>Wn(e,Zn,Tn),Pn=e=>Wn(e,Kn,Tn),Fn=e=>Wn(e,qn,Dn),In=e=>Wn(e,$n,En),W=e=>fn.test(e),Ln=e=>Gn(e,Yn),Rn=e=>Gn(e,Zn),zn=e=>Gn(e,Kn),Bn=e=>Gn(e,Jn),Vn=e=>Gn(e,qn),Hn=e=>Gn(e,$n,!0),Un=e=>Gn(e,Qn,!0),Wn=(e,t,n)=>{let r=dn.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Gn=(e,t,n=!1)=>{let r=fn.exec(e);return r?r[1]?t(r[1]):n:!1},Kn=e=>e===`position`||e===`percentage`,qn=e=>e===`image`||e===`url`,Jn=e=>e===`length`||e===`size`||e===`bg-size`,Yn=e=>e===`length`,Xn=e=>e===`number`,Zn=e=>e===`family-name`,Qn=e=>e===`number`||e===`weight`,$n=e=>e===`shadow`,er=cn(()=>{let e=un(`color`),t=un(`font`),n=un(`text`),r=un(`font-weight`),i=un(`tracking`),a=un(`leading`),o=un(`breakpoint`),s=un(`container`),c=un(`spacing`),l=un(`radius`),u=un(`shadow`),d=un(`inset-shadow`),f=un(`text-shadow`),p=un(`drop-shadow`),m=un(`blur`),h=un(`perspective`),g=un(`aspect`),_=un(`ease`),v=un(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),W,U],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[W,U,c],T=()=>[yn,`full`,`auto`,...w()],E=()=>[bn,`none`,`subgrid`,W,U],D=()=>[`auto`,{span:[`full`,bn,W,U]},bn,W,U],O=()=>[bn,`auto`,W,U],k=()=>[`auto`,`min`,`max`,`fr`,W,U],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[yn,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[yn,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[yn,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,W,U],F=()=>[...b(),zn,Pn,{position:[W,U]}],ne=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],re=()=>[`auto`,`cover`,`contain`,Bn,kn,{size:[W,U]}],ie=()=>[xn,Ln,An],I=()=>[``,`none`,`full`,l,W,U],L=()=>[``,H,Ln,An],R=()=>[`solid`,`dashed`,`dotted`,`double`],z=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ae=()=>[H,xn,zn,Pn],oe=()=>[``,`none`,m,W,U],se=()=>[`none`,H,W,U],ce=()=>[`none`,H,W,U],le=()=>[H,W,U],ue=()=>[yn,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Sn],breakpoint:[Sn],color:[Cn],container:[Sn],"drop-shadow":[Sn],ease:[`in`,`out`,`in-out`],font:[On],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Sn],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Sn],shadow:[Sn],spacing:[`px`,H],text:[Sn],"text-shadow":[Sn],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,yn,U,W,g]}],container:[`container`],columns:[{columns:[H,U,W,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[bn,`auto`,W,U]}],basis:[{basis:[yn,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[H,yn,`auto`,`initial`,`none`,U]}],grow:[{grow:[``,H,W,U]}],shrink:[{shrink:[``,H,W,U]}],order:[{order:[bn,`first`,`last`,`none`,W,U]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Ln,An]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Un,Mn]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,xn,U]}],"font-family":[{font:[Rn,Nn,t]}],"font-features":[{"font-features":[U]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,W,U]}],"line-clamp":[{"line-clamp":[H,`none`,W,jn]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,W,U]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,W,U]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...R(),`wavy`]}],"text-decoration-thickness":[{decoration:[H,`from-font`,`auto`,W,An]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[H,`auto`,W,U]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,W,U]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,W,U]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:re()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},bn,W,U],radial:[``,W,U],conic:[bn,W,U]},Vn,Fn]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:I()}],"rounded-s":[{"rounded-s":I()}],"rounded-e":[{"rounded-e":I()}],"rounded-t":[{"rounded-t":I()}],"rounded-r":[{"rounded-r":I()}],"rounded-b":[{"rounded-b":I()}],"rounded-l":[{"rounded-l":I()}],"rounded-ss":[{"rounded-ss":I()}],"rounded-se":[{"rounded-se":I()}],"rounded-ee":[{"rounded-ee":I()}],"rounded-es":[{"rounded-es":I()}],"rounded-tl":[{"rounded-tl":I()}],"rounded-tr":[{"rounded-tr":I()}],"rounded-br":[{"rounded-br":I()}],"rounded-bl":[{"rounded-bl":I()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":L()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...R(),`hidden`,`none`]}],"divide-style":[{divide:[...R(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...R(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[H,W,U]}],"outline-w":[{outline:[``,H,Ln,An]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,Hn,In]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,Hn,In]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:L()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[H,An]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,Hn,In]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[H,W,U]}],"mix-blend":[{"mix-blend":[...z(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":z()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[H]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[W,U]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[H]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,W,U]}],filter:[{filter:[``,`none`,W,U]}],blur:[{blur:oe()}],brightness:[{brightness:[H,W,U]}],contrast:[{contrast:[H,W,U]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Hn,In]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,H,W,U]}],"hue-rotate":[{"hue-rotate":[H,W,U]}],invert:[{invert:[``,H,W,U]}],saturate:[{saturate:[H,W,U]}],sepia:[{sepia:[``,H,W,U]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,W,U]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[H,W,U]}],"backdrop-contrast":[{"backdrop-contrast":[H,W,U]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,H,W,U]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[H,W,U]}],"backdrop-invert":[{"backdrop-invert":[``,H,W,U]}],"backdrop-opacity":[{"backdrop-opacity":[H,W,U]}],"backdrop-saturate":[{"backdrop-saturate":[H,W,U]}],"backdrop-sepia":[{"backdrop-sepia":[``,H,W,U]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,W,U]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[H,`initial`,W,U]}],ease:[{ease:[`linear`,`initial`,_,W,U]}],delay:[{delay:[H,W,U]}],animate:[{animate:[`none`,v,W,U]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,W,U]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":[`scale-3d`],skew:[{skew:le()}],"skew-x":[{"skew-x":le()}],"skew-y":[{"skew-y":le()}],transform:[{transform:[W,U,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,W,U]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,W,U]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[H,Ln,An,jn]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function G(...e){return er(Dt(e))}function tr(e){let t=Math.max(0,Math.floor((Date.now()-e*1e3)/1e3));if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:`${Math.floor(i/30)}mo ago`}function nr(e){return new Date(e*1e3).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function rr(e,t){try{let e=JSON.parse(t);if(!e||typeof e!=`object`)return t;for(let t of[`command`,`CommandLine`,`Input`,`query`,`Task`,`Prompt`])if(typeof e[t]==`string`&&e[t].length>0)return e[t];for(let t of[`file_path`,`path`,`TargetFile`,`AbsolutePath`,`SearchPath`,`DirectoryPath`,`Url`,`ImageName`])if(typeof e[t]==`string`&&e[t].length>0)return e[t];for(let t of Object.values(e))if(typeof t==`string`&&t.length>0)return t;return``}catch{return t}}var ir=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),K=o(((e,t)=>{t.exports=ir()}))(),ar=At(`hig-card flex flex-col min-h-0 overflow-hidden`,{variants:{variant:{default:``,interactive:`hover:border-[var(--color-line-2)] hover:shadow-[var(--hig-shadow-2)] transition-all cursor-pointer`,flush:`bg-transparent border-[var(--color-line-0)] shadow-none`}},defaultVariants:{variant:`default`}});function q({className:e,variant:t,...n}){return(0,K.jsx)(`div`,{className:G(ar({variant:t,className:e})),...n})}function J({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex items-center justify-between gap-2 px-4 pt-3 pb-2 shrink-0`,e),...t})}function Y({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`px-4 py-3 flex-1 min-h-0 overflow-auto`,e),...t})}var or=At(`inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-[10px] font-mono font-medium leading-none tracking-wide uppercase border whitespace-nowrap`,{variants:{variant:{green:`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`,red:`bg-red-500/8 text-red-300 border-red-500/25`,amber:`bg-amber-500/10 text-amber-300 border-amber-500/30`,blue:`bg-sky-500/8 text-sky-300 border-sky-500/25`,gray:`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`,purple:`bg-violet-500/8 text-violet-300 border-violet-500/25`,outline:`bg-transparent text-[var(--color-fg-3)] border-[var(--color-line-1)]`}},defaultVariants:{variant:`outline`}});function sr({className:e,variant:t,...n}){return(0,K.jsx)(`span`,{className:G(or({variant:t,className:e})),...n})}var cr=At(`hig-button relative overflow-hidden focus-visible:outline-none disabled:pointer-events-none disabled:opacity-45`,{variants:{variant:{primary:`hig-button-primary`,secondary:``,ghost:`hig-button-plain`,danger:`hig-button-destructive`},size:{sm:`hig-button-small`,md:``,icon:`!w-7 !h-7 !min-w-0 !p-0`}},defaultVariants:{variant:`primary`,size:`md`}});function lr(e,t){if(ot())return;let n=e.getBoundingClientRect(),r=Math.hypot(n.width,n.height),i=document.createElement(`span`);i.style.position=`absolute`,i.style.left=`${t.clientX-n.left-r/2}px`,i.style.top=`${t.clientY-n.top-r/2}px`,i.style.width=`${r}px`,i.style.height=`${r}px`,i.style.borderRadius=`50%`,i.style.pointerEvents=`none`,i.style.background=`currentColor`,i.style.opacity=`0.22`,i.style.transform=`scale(0)`,i.style.mixBlendMode=`screen`,e.appendChild(i),wt(i,{scale:[0,1],opacity:[.22,0],duration:540,ease:`outExpo`,onComplete:()=>{i.remove()}})}var X=_.forwardRef(({className:e,variant:t,size:n,onMouseDown:r,onClick:i,...a},o)=>(0,K.jsx)(`button`,{ref:o,className:G(cr({variant:t,size:n,className:e})),onMouseDown:e=>{lr(e.currentTarget,e),r?.(e)},onClick:i,...a}));X.displayName=`Button`;var ur=e=>Math.round(e).toLocaleString(void 0,{useGrouping:!0});function dr(e,t){if(e===`spring`){let e=Qe();return{ease:e.fn,durationMs:e.duration}}return e===`quart`?{ease:Pe.out,durationMs:t}:{ease:Ne.out,durationMs:t}}function fr({value:e,duration:t=320,format:n=ur,className:r,curve:i=`cubic`}){let[a,o]=(0,_.useState)(e),s=(0,_.useRef)(e),c=(0,_.useRef)(e),l=(0,_.useRef)(0),u=(0,_.useRef)(null),d=(0,_.useRef)(ot()),f=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(c.current===e)return;let n=f.current;if(n&&!d.current){for(let e of n.getAnimations())e.id===`lc-value-pulse`&&e.cancel();let e=n.animate([{textShadow:`0 0 0 rgba(245, 158, 11, 0)`},{textShadow:`0 0 10px rgba(245, 158, 11, 0.55)`,offset:.2},{textShadow:`0 0 0 rgba(245, 158, 11, 0)`}],{duration:520,easing:`ease-out`});e.id=`lc-value-pulse`}if(d.current){c.current=e,s.current=e,o(e);return}s.current=a,c.current=e,l.current=performance.now(),u.current!==null&&cancelAnimationFrame(u.current);let{ease:r,durationMs:p}=dr(i,t),m=e=>{let t=Math.min(1,(e-l.current)/p),n=r(t);o(s.current+(c.current-s.current)*n),t<1?u.current=requestAnimationFrame(m):u.current=null};return u.current=requestAnimationFrame(m),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,i]),(0,K.jsx)(`span`,{ref:f,className:G(`tabular-nums`,r),children:n(a)})}function pr({data:e,width:t=80,height:n=24,color:r=`#38bdf8`,threshold:i,maxValue:a}){if(e.length<2)return(0,K.jsx)(`svg`,{width:t,height:n,className:`shrink-0`,children:(0,K.jsx)(`line`,{x1:0,y1:n/2,x2:t,y2:n/2,stroke:`var(--color-line-2)`,strokeWidth:1})});let o=a??Math.max(...e,1),s=t-2,c=n-2,l=e.map((t,n)=>{let r=1+n/(e.length-1)*s,i=1+c-t/o*c;return`${r.toFixed(1)},${i.toFixed(1)}`}),u=i===void 0?null:1+c-Math.min(i,o)/o*c;return(0,K.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,children:[(0,K.jsx)(`polyline`,{points:l.join(` `),fill:`none`,stroke:r,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`}),u!==null&&(0,K.jsx)(`line`,{x1:1,y1:u,x2:t-1,y2:u,stroke:`var(--color-brand)`,strokeWidth:1,strokeDasharray:`3,2`,opacity:.7})]})}var mr=new Set,hr=0,gr=0;function _r(){for(let e of mr)e();mr.size>0&&(hr=requestAnimationFrame(_r))}function vr(e){let t=gr++;return mr.add(e),mr.size===1&&(hr=requestAnimationFrame(_r)),[()=>{mr.delete(e),mr.size===0&&(cancelAnimationFrame(hr),hr=0)},t]}function yr(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function br({value:e,samples:t,maxValue:n,width:r=320,height:i=64,windowMs:a=6e4,color:o=`var(--color-brand)`,fillColor:s=`rgba(245, 158, 11, 0.12)`,className:c}){let l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)([]),f=(0,_.useRef)(t??null),p=(0,_.useRef)(e??0),m=(0,_.useRef)(yr());return(0,_.useEffect)(()=>{f.current=t??null},[t]),(0,_.useEffect)(()=>{t===void 0&&e!==void 0&&e!==p.current&&(p.current=e,d.current.push({ts:Date.now(),v:e}),d.current.length>600&&d.current.splice(0,d.current.length-600))},[e,t]),(0,_.useEffect)(()=>{let e=()=>{let e=Date.now(),t=e-a,o;if(f.current){let e=f.current;o=[];for(let n of e)n.ts>=t&&o.push(n)}else{let n=d.current;for(;n.length>1&&n[1].ts<t;)n.shift();(n.length===0||n[n.length-1].ts<e-200)&&n.push({ts:e,v:p.current}),o=n.filter(e=>e.ts>=t)}if(o.length<2)l.current&&l.current.setAttribute(`points`,``),u.current&&u.current.setAttribute(`points`,``);else{let e=n??Math.max(1,...o.map(e=>e.v)),s=[];for(let n of o){let o=(n.ts-t)/a*r,c=i-n.v/e*(i-2)-1;s.push(`${o.toFixed(1)},${c.toFixed(1)}`)}let c=s.join(` `);if(l.current&&l.current.setAttribute(`points`,c),u.current){let e=s[0].split(`,`),t=s[s.length-1].split(`,`),n=`${e[0]},${i} ${c} ${t[0]},${i}`;u.current.setAttribute(`points`,n)}}};if(m.current){let t=window.setInterval(e,500);return()=>clearInterval(t)}let[t]=vr(e);return t},[r,i,a,n]),(0,K.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 ${r} ${i}`,className:G(`block`,c),preserveAspectRatio:`none`,children:[(0,K.jsx)(`polygon`,{ref:u,fill:s,stroke:`none`}),(0,K.jsx)(`polyline`,{ref:l,fill:`none`,stroke:o,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`})]})}var xr=At(`hero-metric relative flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] px-4 py-3 overflow-hidden`,{variants:{tone:{neutral:`hero-metric--neutral`,amber:`hero-metric--amber`,green:`hero-metric--green`,red:`hero-metric--red`,blue:`hero-metric--blue`,purple:`hero-metric--purple`,gray:`hero-metric--gray`}},defaultVariants:{tone:`neutral`}}),Sr={neutral:`var(--color-fg-1)`,amber:`var(--color-decision-ask)`,green:`var(--color-decision-allow)`,red:`var(--color-decision-block)`,blue:`var(--color-decision-force)`,purple:`var(--color-decision-log)`,gray:`var(--color-fg-3)`},Cr={neutral:`color-mix(in srgb, var(--color-fg-1) 10%, transparent)`,amber:`color-mix(in srgb, var(--color-decision-ask) 14%, transparent)`,green:`color-mix(in srgb, var(--color-decision-allow) 14%, transparent)`,red:`color-mix(in srgb, var(--color-decision-block) 14%, transparent)`,blue:`color-mix(in srgb, var(--color-decision-force) 14%, transparent)`,purple:`color-mix(in srgb, var(--color-decision-log) 14%, transparent)`,gray:`color-mix(in srgb, var(--color-fg-3) 10%, transparent)`},wr={neutral:`text-[var(--color-fg-0)]`,amber:`text-amber-300`,green:`text-emerald-300`,red:`text-red-300`,blue:`text-sky-300`,purple:`text-violet-300`,gray:`text-[var(--color-fg-2)]`},Tr=1e3,Er=.35;function Dr(e,t,n){let r=Date.now(),i=r-n,a=Math.max(2,Math.floor(n/Tr)),o=Array(a).fill(0);for(let n of e){if(t&&!t(n)||n.ts_ms<i||n.ts_ms>r)continue;let e=a-1-Math.floor((r-n.ts_ms)/Tr);e>=0&&e<a&&o[e]++}let s=Array(a),c=o[0];for(let e=0;e<a;e++)c=Er*o[e]+(1-Er)*c,s[e]={ts:i+(e+1)*Tr,v:c};return s}function Or({label:e,value:t,series:n,burstRing:r,filter:i,sparkWindowMs:a=6e4,sub:o,tone:s,format:c,className:l,...u}){let d=s??`neutral`,f=Sr[d]??Sr.neutral,p=Cr[d]??Cr.neutral,m=wr[d]??wr.neutral,h=(0,_.useRef)(null),g=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(g.current===t)return;g.current=t;let e=h.current;e&&wt(e,{"--tick":[0,1],duration:160,ease:`outCubic`,onComplete:()=>{wt(e,{"--tick":[1,0],duration:520,ease:`outCubic`,onComplete:e=>{e.style.removeProperty(`--tick`)}})}})},[t]);let v=(0,_.useMemo)(()=>r?Dr(r,i,a):null,[r,i,a]),y=v!==null,b=!y&&n&&n.length>=2;return(0,K.jsxs)(`div`,{ref:h,className:G(xr({tone:s,className:l})),...u,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:e}),o?(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:o}):null]}),(0,K.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,K.jsx)(fr,{value:t,format:c,className:G(`text-[2.4rem] leading-none font-semibold tracking-tight`,m)}),y?(0,K.jsx)(br,{samples:v,width:108,height:36,windowMs:a,color:f,fillColor:p,className:`shrink-0`}):b?(0,K.jsx)(pr,{data:n,width:96,height:28,color:f}):null]})]})}var kr=135,Ar=405,jr=Ar-kr,Mr=`#34d399`,Nr=`#f59e0b`,Pr=`#ef4444`;function Fr(e,t,n,r){let i=(r-90)*(Math.PI/180);return{x:e+n*Math.cos(i),y:t+n*Math.sin(i)}}function Ir(e,t,n,r,i){let a=Fr(e,t,n,r),o=Fr(e,t,n,i),s=i-r>180?1:0;return`M ${a.x.toFixed(2)} ${a.y.toFixed(2)} A ${n} ${n} 0 ${s} 1 ${o.x.toFixed(2)} ${o.y.toFixed(2)}`}function Lr(e,t){return kr+Math.max(0,Math.min(1,e/Math.max(t,1e-9)))*jr}function Rr(e,t,n){return e+(t-e)*n}function zr(e){let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}function Br(e,t,n){let[r,i,a]=zr(e),[o,s,c]=zr(t);return`rgb(${Math.round(Rr(r,o,n))},${Math.round(Rr(i,s,n))},${Math.round(Rr(a,c,n))})`}function Vr(e,t,n){let r=.04;return e<t-r?Mr:e<t+r?Br(Mr,Nr,(e-(t-r))/(r*2)):e<n-r?Nr:e<n+r?Br(Nr,Pr,(e-(n-r))/(r*2)):Pr}function Hr(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Ur=0;function Wr(){return Ur=Ur+1|0,Ur.toString(36)}function Gr({value:e,max:t,warnAt:n=.7,critAt:r=.9,marker50:i,marker99:a,label:o,display:s,displayFormat:c,scaleLabels:l,mode:u=`needle`,size:d=180,className:f,revLights:p=!0,revLightCount:m=20}){let h=Math.ceil(u===`needle`&&l!==void 0?d*.2:d*.08),g=-h,v=-h,y=d+h*2,b=d+h*2,x=d/2,S=d/2,C=d*.42,w=Math.max(0,Math.min(1,e/Math.max(t,1e-9))),T=(0,_.useMemo)(()=>Ir(x,S,C,kr,Ar),[x,S,C]),E=(0,_.useMemo)(()=>Ir(x,S,C-8,kr,Ar),[x,S,C]),D=kr+n*jr,O=kr+r*jr,k=(0,_.useMemo)(()=>Ir(x,S,C,kr,D),[x,S,C,D]),A=(0,_.useMemo)(()=>Ir(x,S,C,D,O),[x,S,C,D,O]),j=(0,_.useMemo)(()=>Ir(x,S,C,O,Ar),[x,S,C,O]),M=(0,_.useMemo)(()=>Ir(x,S,C-14,300,420),[x,S,C]),N=kr+w*jr,ee=(0,_.useMemo)(()=>Ir(x,S,C,kr,Math.max(kr+.01,N)),[x,S,C,N]),te=Vr(w,n,r),P=(0,_.useMemo)(()=>Wr(),[]),F=`lgf-${P}`,ne=`lgb-${P}`,re=`lgd-${P}`,ie=`lgh-${P}`,I=`lgg-${P}`,L=`lgl-${P}`,R=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=10;t++)e.push(kr+t/10*jr);return e},[u]),z=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=40;t++)t%4!=0&&e.push(kr+t/40*jr);return e},[u]),ae=(0,_.useRef)(null),oe=(0,_.useRef)(null),se=(0,_.useRef)(null),ce=(0,_.useRef)(null),le=(0,_.useRef)(null),ue=(0,_.useRef)(null),de=(0,_.useRef)(null),fe=(0,_.useRef)(null),pe=(0,_.useRef)([]),me=(0,_.useRef)(e),he=(0,_.useRef)(t),ge=(0,_.useRef)(n),_e=(0,_.useRef)(r);(0,_.useEffect)(()=>{me.current=e,he.current=t,ge.current=n,_e.current=r},[e,t,n,r]);let ve=(0,_.useMemo)(()=>{if(!p||u!==`needle`)return[];let e=Math.max(4,m),t=C-11,n=[];for(let r=0;r<e;r++){let i=kr+(r+.5)/e*jr;n.push(Fr(x,S,t,i))}return n},[p,m,u,x,S,C]);pe.current.length!==ve.length&&(pe.current.length=ve.length);let ye=x+C-6,be=x+d*.04,xe=Math.max(2,d*.016),Se=`${ye},${S} ${be},${S-xe} ${be},${S+xe}`,Ce=x-d*.04,we=x-C*.24,Te=Math.max(1.4,d*.012),Ee=`${we},${S} ${Ce},${S-Te} ${Ce},${S+Te}`,De=d*.48,Oe=d*.17,B=x-De/2,ke=S+d*.16,V=ke+Oe*.68;return(0,_.useEffect)(()=>{let e=Hr(),t=performance.now(),n=me.current,r=0,i=me.current,a=0,o=me.current,s=``,l=``,d=``,f=-1,m=``,h=``,[g]=vr(()=>{let g=performance.now(),_=(g-t)/1e3;t=g;let v=Math.min(.04,Math.max(.001,_)),y=me.current,b=he.current,w=ge.current,T=_e.current,E=Math.max(b,1e-9),D=y;if(e)n=y,i=y,o=y,r=0,a=0;else{let e=v/2;for(let t=0;t<2;t++){let t=-210*(n-D)-22*r;r+=t*e,n+=r*e;let o=-55*(i-n)-13*a;a+=o*e,i+=a*e}let t=1-Math.exp(-v*8);o+=(y-o)*t,Math.abs(n-y)<E*1e-5&&Math.abs(r)<1e-4&&(n=y,r=0),Math.abs(o-y)<E*1e-5&&(o=y)}let O=Math.max(0,Math.min(1,n/Math.max(b,1e-9))),k=kr+O*jr,A=kr+Math.max(0,Math.min(1,i/Math.max(b,1e-9)))*jr,j=Vr(O,w,T),M=`rotate(${(k-90).toFixed(3)} ${x} ${S})`;ae.current&&M!==s&&(ae.current.setAttribute(`transform`,M),s=M),j!==d&&(oe.current&&oe.current.setAttribute(`fill`,j),se.current&&se.current.setAttribute(`fill`,j),ce.current&&ce.current.setAttribute(`stroke`,j),ue.current&&ue.current.setAttribute(`fill`,j),d=j);let N=`rotate(${(A-90).toFixed(3)} ${x} ${S})`;if(le.current&&N!==l&&(le.current.setAttribute(`transform`,N),l=N),de.current&&c){let e=c(o);e!==h&&(de.current.textContent=e,h=e)}if(fe.current&&u===`ring`){let e=Ir(x,S,C,kr,Math.max(kr+.01,k));e!==m&&(fe.current.setAttribute(`d`,e),m=e)}if(p&&u===`needle`){let e=Math.round(O*1e3)/1e3;if(e!==f){f=e;let t=pe.current,n=t.length;if(n>0){let e=1/n;for(let r=0;r<n;r++){let i=t[r];if(!i)continue;let a=(r+.5)/n,o=O-a,s=Math.max(0,Math.min(1,.5+o/e));i.setAttribute(`fill`,Vr(a,w,T)),i.setAttribute(`opacity`,s.toFixed(3))}}}}});return g},[x,S,C,u,p,c]),(0,K.jsxs)(`div`,{className:G(`flex flex-col items-center justify-center gap-1 min-h-0 min-w-0`,f),children:[(0,K.jsxs)(`svg`,{width:y,height:b,viewBox:`${g} ${v} ${y} ${b}`,preserveAspectRatio:`xMidYMid meet`,className:`block max-w-full max-h-full min-h-0`,children:[(0,K.jsxs)(`defs`,{children:[(0,K.jsxs)(`filter`,{id:F,x:`-40%`,y:`-40%`,width:`180%`,height:`180%`,children:[(0,K.jsx)(`feGaussianBlur`,{stdDeviation:`1.2`,result:`blur`}),(0,K.jsxs)(`feMerge`,{children:[(0,K.jsx)(`feMergeNode`,{in:`blur`}),(0,K.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,K.jsxs)(`radialGradient`,{id:ne,cx:`50%`,cy:`32%`,r:`80%`,children:[(0,K.jsx)(`stop`,{offset:`0%`,stopColor:`#4e535d`}),(0,K.jsx)(`stop`,{offset:`55%`,stopColor:`#2a2e36`}),(0,K.jsx)(`stop`,{offset:`100%`,stopColor:`#0b0d11`})]}),(0,K.jsxs)(`radialGradient`,{id:re,cx:`50%`,cy:`45%`,r:`75%`,children:[(0,K.jsx)(`stop`,{offset:`0%`,stopColor:`#1b1f27`}),(0,K.jsx)(`stop`,{offset:`80%`,stopColor:`#0a0c10`}),(0,K.jsx)(`stop`,{offset:`100%`,stopColor:`#05060a`})]}),(0,K.jsxs)(`radialGradient`,{id:ie,cx:`40%`,cy:`30%`,r:`70%`,children:[(0,K.jsx)(`stop`,{offset:`0%`,stopColor:`#f4f5f8`}),(0,K.jsx)(`stop`,{offset:`45%`,stopColor:`#aab1bd`}),(0,K.jsx)(`stop`,{offset:`100%`,stopColor:`#1c1f26`})]}),(0,K.jsxs)(`linearGradient`,{id:I,x1:`50%`,y1:`0%`,x2:`50%`,y2:`100%`,children:[(0,K.jsx)(`stop`,{offset:`0%`,stopColor:`#ffffff`,stopOpacity:`0.22`}),(0,K.jsx)(`stop`,{offset:`100%`,stopColor:`#ffffff`,stopOpacity:`0`})]}),(0,K.jsxs)(`linearGradient`,{id:L,x1:`50%`,y1:`0%`,x2:`50%`,y2:`100%`,children:[(0,K.jsx)(`stop`,{offset:`0%`,stopColor:`#0a0c11`}),(0,K.jsx)(`stop`,{offset:`100%`,stopColor:`#15181f`})]})]}),u===`needle`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:x,cy:S,r:C+12,fill:`url(#${ne})`,stroke:`#000`,strokeOpacity:.55,strokeWidth:1}),(0,K.jsx)(`circle`,{cx:x,cy:S,r:C+5,fill:`none`,stroke:`#0a0c11`,strokeWidth:1}),(0,K.jsx)(`circle`,{cx:x,cy:S,r:C-2,fill:`url(#${re})`})]}):null,(0,K.jsx)(`path`,{d:T,fill:`none`,stroke:`var(--color-line-1)`,strokeWidth:u===`ring`?12:3,strokeLinecap:`round`,opacity:u===`ring`?1:.35}),u===`needle`?(0,K.jsx)(`path`,{d:E,fill:`none`,stroke:`var(--color-line-0)`,strokeWidth:1,strokeLinecap:`round`,opacity:.55}):null,u===`needle`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:k,fill:`none`,stroke:Mr,strokeWidth:5,strokeLinecap:`round`,opacity:.78}),(0,K.jsx)(`path`,{d:A,fill:`none`,stroke:Nr,strokeWidth:5,strokeLinecap:`round`,opacity:.82}),(0,K.jsx)(`path`,{d:j,fill:`none`,stroke:Pr,strokeWidth:5,strokeLinecap:`round`,opacity:.9}),z.map((e,t)=>{let n=Fr(x,S,C-4,e),r=Fr(x,S,C+2,e);return(0,K.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`var(--color-fg-4)`,strokeWidth:.9,strokeLinecap:`round`,opacity:.7},`mi-${t}`)}),R.map((e,t)=>{let n=Fr(x,S,C-8,e),r=Fr(x,S,C+4,e);return(0,K.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`var(--color-fg-2)`,strokeWidth:1.8,strokeLinecap:`round`},`ma-${t}`)}),p?ve.map((e,t)=>(0,K.jsx)(`circle`,{ref:e=>{pe.current[t]=e},cx:e.x,cy:e.y,r:Math.max(1.6,d*.013),fill:Mr,opacity:0,filter:`url(#${F})`},t)):null,i===void 0?null:(0,K.jsx)(Kr,{cx:x,cy:S,r:C,angle:Lr(i,t),emphasis:!0}),a===void 0?null:(0,K.jsx)(Kr,{cx:x,cy:S,r:C,angle:Lr(a,t),emphasis:!0}),l?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qr,{cx:x,cy:S,r:C,angle:D,text:l(n),size:d}),(0,K.jsx)(qr,{cx:x,cy:S,r:C,angle:O,text:l(r),size:d}),(0,K.jsx)(qr,{cx:x,cy:S,r:C,angle:Ar,text:l(1),size:d})]}):null,(0,K.jsx)(`path`,{d:M,fill:`none`,stroke:`url(#${I})`,strokeWidth:d*.14,strokeLinecap:`butt`}),c||s!==void 0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:B,y:ke,width:De,height:Oe,rx:d*.022,ry:d*.022,fill:`url(#${L})`,stroke:`#242a33`,strokeWidth:1}),(0,K.jsx)(`rect`,{x:B+1,y:ke+1,width:De-2,height:1,fill:`#ffffff`,opacity:.08})]}):null,(0,K.jsx)(`g`,{ref:le,opacity:.28,children:(0,K.jsx)(`polygon`,{ref:ue,points:Se,fill:te})}),(0,K.jsxs)(`g`,{ref:ae,children:[(0,K.jsx)(`polygon`,{ref:oe,points:Se,fill:te,stroke:`#05070a`,strokeWidth:.6}),(0,K.jsx)(`polygon`,{ref:se,points:Ee,fill:te,opacity:.7})]}),(0,K.jsx)(`circle`,{cx:x,cy:S,r:d*.06,fill:`url(#${ie})`,stroke:`#06080c`,strokeWidth:1}),(0,K.jsx)(`circle`,{ref:ce,cx:x,cy:S,r:d*.036,fill:`#0a0c11`,stroke:te,strokeWidth:1.4}),(0,K.jsx)(`circle`,{cx:x,cy:S,r:d*.012,fill:`#f5f7fb`,opacity:.9})]}):(0,K.jsx)(`path`,{ref:fe,d:ee,fill:`none`,stroke:te,strokeWidth:12,strokeLinecap:`round`}),u===`needle`&&(c||s!==void 0)?c?(0,K.jsx)(`text`,{ref:de,x,y:V,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:c(e)}):(0,K.jsx)(`text`,{x,y:V,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:s}):c?(0,K.jsx)(`text`,{ref:de,x,y:S+4,textAnchor:`middle`,className:`font-mono tabular-nums`,fontSize:d*.13,fill:`var(--color-fg-0)`,children:c(e)}):s===void 0?null:(0,K.jsx)(`text`,{x,y:S+4,textAnchor:`middle`,className:`font-mono tabular-nums`,fontSize:d*.13,fill:`var(--color-fg-0)`,children:s})]}),o?(0,K.jsx)(`span`,{className:`overline shrink-0 tracking-[0.12em] uppercase`,children:o}):null]})}function Kr({cx:e,cy:t,r:n,angle:r,emphasis:i=!1}){let a=Fr(e,t,n-(i?10:6),r),o=Fr(e,t,n+(i?8:6),r);return(0,K.jsx)(`line`,{x1:a.x,y1:a.y,x2:o.x,y2:o.y,stroke:i?`var(--color-fg-1)`:`var(--color-fg-2)`,strokeWidth:i?2:1.5,strokeLinecap:`round`})}function qr({cx:e,cy:t,r:n,angle:r,text:i,size:a}){let o=Fr(e,t,n+Math.max(16,a*.1),r),s=r>=135&&r<215?`end`:r>=325?`start`:`middle`;return(0,K.jsx)(`text`,{x:o.x,y:o.y,textAnchor:s,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:a*.062,fontWeight:600,fill:`var(--color-fg-2)`,stroke:`var(--color-bg-0)`,strokeWidth:3,paintOrder:`stroke`,children:i})}var Jr={containerPaddingY:24,containerPaddingX:24,topToTrendGap:12,scatterHeaderH:18,scatterLegendH:16,scatterInnerGap:8,trendRowH:28,trendRowGap:6,trendTopPad:9,scatterAbsoluteMin:60,scatterAcceptableMin:70,gaugeFootprintFactor:1.36,gaugeAbsoluteMin:84,gaugeAbsoluteMax:240};function Yr(e,t,n=200){let r=Math.max(0,Math.floor(e)),i=Math.max(0,Math.floor(t)),a=Math.max(0,r-Jr.containerPaddingX),o=Math.max(0,i-Jr.containerPaddingY),s=o-(Jr.trendRowH*3+Jr.trendRowGap*2+Jr.trendTopPad+Jr.topToTrendGap),c=s-Jr.scatterHeaderH-Jr.scatterLegendH-Jr.scatterInnerGap>=Jr.scatterAcceptableMin,l=c?s:o,u=l-Jr.scatterHeaderH-Jr.scatterLegendH-Jr.scatterInnerGap,d=u>=Jr.scatterAbsoluteMin,f=u>=Jr.scatterAbsoluteMin&&l>=140,p=Math.floor(l/Jr.gaugeFootprintFactor),m=Math.floor(a*.45/Jr.gaugeFootprintFactor),h=Math.max(Jr.gaugeAbsoluteMin,Math.min(Jr.gaugeAbsoluteMax,n,p,m)),g=Math.ceil(h*Jr.gaugeFootprintFactor+8),_=l-(d?Jr.scatterHeaderH:0)-(f?Jr.scatterLegendH:0)-Jr.scatterInnerGap;return{gaugeSize:h,gaugeColumnMaxWidth:g,scatterMinHeight:Math.max(Jr.scatterAbsoluteMin,Math.min(160,_)),showTrendRows:c,showScatterHeader:d,showLegend:f,variant:o>=480?`wide`:o>=300?`normal`:`compact`}}var Xr={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`};function Zr(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}function Qr({latency:e,bursts:t,gaugeMaxMs:n=10,windowMs:r=3e4,trendWindowSec:i=60,gaugeSize:a=200,compact:o=!1,className:s}){let c=e?e.p50_ns/1e6:0,l=e?e.p95_ns/1e6:0,u=e?e.p99_ns/1e6:0,d=(0,_.useRef)(null),[f,p]=(0,_.useState)((0,_.useMemo)(()=>Yr(a*2,a*2,a),[a]));(0,_.useEffect)(()=>{let e=d.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=0,r=0,i=e=>{let t=Math.round(e.width/4)*4,i=Math.round(e.height/4)*4;t===n&&i===r||(n=t,r=i,p(Yr(t,i,a)))};i(e.getBoundingClientRect());let o=new ResizeObserver(e=>{let n=e[0];n&&(t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(n.contentRect)}))});return o.observe(e),()=>{t&&cancelAnimationFrame(t),o.disconnect()}},[a]);let m=(0,_.useRef)(null),h=(0,_.useRef)([]),g=(0,_.useRef)(0);(0,_.useEffect)(()=>{if(t.length===0)return;let e=h.current,n=g.current,i=n;for(let r of t)r.ts_ms<=n||(e.push({ts:r.ts_ms,durationNs:r.duration_ns,color:Xr[r.decision]??`#6e7076`}),r.ts_ms>i&&(i=r.ts_ms));g.current=i;let a=Date.now()-r*2;for(;e.length&&e[0].ts<a;)e.shift()},[t,r]),(0,_.useEffect)(()=>{let e=m.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let i=0,a=0,o=0,s=8e3,c=.25,l=1e3,u=n*1e6,d=Math.log10(l),f=Math.log10(u),[p]=vr(()=>{let n=window.devicePixelRatio||1,p=e.clientWidth,m=e.clientHeight;if(p===0||m===0)return;(p!==a||m!==o||n!==i)&&(e.width=Math.floor(p*n),e.height=Math.floor(m*n),t.setTransform(n,0,0,n,0,0),a=p,o=m,i=n),t.clearRect(0,0,p,m),t.strokeStyle=`rgba(110, 112, 118, 0.18)`,t.lineWidth=1,t.setLineDash([2,4]);let g=[{ns:1e5,label:`100µs`},{ns:1e6,label:`1ms`},{ns:1e7,label:`10ms`}];t.font=`9px ui-monospace, SFMono-Regular, Menlo, monospace`,t.textBaseline=`middle`,t.fillStyle=`rgba(110, 112, 118, 0.7)`;for(let e of g){if(e.ns<l||e.ns>u)continue;let n=m-(Math.log10(e.ns)-d)/(f-d)*m;t.beginPath(),t.moveTo(0,n),t.lineTo(p-28,n),t.stroke(),t.fillText(e.label,p-26,n)}t.setLineDash([]);let _=Date.now(),v=_-r,y=h.current;for(;y.length&&y[0].ts<v;)y.shift();t.globalCompositeOperation=`source-over`;for(let e of y){let n=(e.ts-v)/r*p,i=Math.max(l,Math.min(u,e.durationNs)),a=m-(Math.log10(i)-d)/(f-d)*m,o=_-e.ts,h;if(o<=s)h=1-o/s*(1-c);else{let e=r-s;h=e>0?Math.max(0,c*(1-(o-s)/e)):0}h<=0||(t.globalAlpha=h,t.fillStyle=e.color,t.beginPath(),t.arc(n,a,2.5,0,Math.PI*2),t.fill())}t.globalAlpha=1,t.fillStyle=`rgba(110, 112, 118, 0.55)`,t.font=`9px ui-monospace, SFMono-Regular, Menlo, monospace`,t.textBaseline=`bottom`,t.textAlign=`left`,t.fillText(`← ${Math.round(r/1e3)} s ago`,4,m-2),t.textAlign=`right`,t.fillText(`now →`,p-4,m-2),t.textAlign=`left`});return p},[r,n]);let v=(0,_.useRef)({p50:[],p95:[],p99:[]});(0,_.useEffect)(()=>{if(!e)return;let t=v.current,n=Date.now(),r=n-i*1e3,a=(e,t)=>{let i=t/1e6;for(e.length===0&&e.push({ts:r,v:i}),e.push({ts:n,v:i});e.length>1&&e[0].ts<r;)e.shift()};a(t.p50,e.p50_ns),a(t.p95,e.p95_ns),a(t.p99,e.p99_ns)},[e,i]);let y=(0,_.useMemo)(()=>{let e=v.current;return{p50:[...e.p50],p95:[...e.p95],p99:[...e.p99]}},[e]);return(0,K.jsxs)(`div`,{ref:d,"data-lt-variant":f.variant,className:G(`flex h-full min-h-0 flex-col gap-3 overflow-hidden rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] p-3`,s),children:[(0,K.jsxs)(`div`,{className:G(`grid gap-3 min-h-0 flex-1`,`grid-cols-[auto_1fr]`),children:[(0,K.jsx)(`div`,{className:`flex items-stretch justify-center overflow-hidden min-h-0 min-w-0`,style:{maxWidth:f.gaugeColumnMaxWidth},children:(0,K.jsx)(Gr,{value:l,max:n,warnAt:Math.min(.85,.5/n),critAt:Math.min(.92,2/n),marker50:c,marker99:u,displayFormat:e=>Zr(e*1e6),scaleLabels:f.gaugeSize>=130?e=>Zr(e*n*1e6):void 0,size:f.gaugeSize,label:`p95 latency`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 min-h-0 flex-1`,children:[f.showScatterHeader?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 shrink-0 min-w-0`,children:[(0,K.jsx)(`span`,{className:`overline truncate min-w-0`,children:`live trace · 30 s scatter`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] shrink min-w-0 truncate text-right`,children:[h.current.length,` live · log-Y`]})]}):null,f.showLegend?(0,K.jsx)(`div`,{className:`shrink-0`,children:(0,K.jsx)($r,{})}):null,(0,K.jsx)(`canvas`,{ref:m,"data-testid":`latency-scatter-canvas`,className:`block w-full flex-1 min-h-0 rounded-sm bg-[var(--color-surface-0)] border border-[var(--color-line-0)]`,style:{minHeight:f.scatterMinHeight}})]})]}),f.showTrendRows?(0,K.jsxs)(`div`,{"data-testid":`latency-trend-rows`,className:`grid grid-cols-1 gap-1.5 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(ei,{label:`p50 · median`,value:Zr(e?.p50_ns??0),color:`#34d399`,fill:`rgba(52, 211, 153, 0.14)`,samples:y.p50,windowMs:i*1e3}),(0,K.jsx)(ei,{label:`p95 · 95th`,value:Zr(e?.p95_ns??0),color:`#38bdf8`,fill:`rgba(56, 189, 248, 0.14)`,samples:y.p95,windowMs:i*1e3}),(0,K.jsx)(ei,{label:`p99 · 99th`,value:Zr(e?.p99_ns??0),color:`#6366f1`,fill:`rgba(99, 102, 241, 0.14)`,samples:y.p99,windowMs:i*1e3})]}):null]})}function $r(){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[{key:`allow`,color:Xr.allow},{key:`ask`,color:Xr.ask},{key:`block`,color:Xr.block},{key:`force`,color:Xr.force},{key:`log`,color:Xr.log},{key:`shadow`,color:Xr.shadow}].map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:e.color}}),(0,K.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.key})]},e.key))})}function ei({label:e,value:t,color:n,fill:r,samples:i,windowMs:a}){return(0,K.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)_92px] items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`overline text-right truncate min-w-0`,children:e}),(0,K.jsx)(br,{samples:i,width:1200,height:28,windowMs:a,color:n,fillColor:r,className:`w-full h-7`}),(0,K.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-right truncate min-w-0`,style:{color:n},title:t,children:t})]})}function ti({counters:e,className:t,showLegend:n=!0}){let r=[{key:`allow`,label:`Allow`,value:e.allow,color:`var(--color-decision-allow)`,textClass:`text-emerald-300`},{key:`ask`,label:`Ask`,value:e.ask,color:`var(--color-decision-ask)`,textClass:`text-amber-300`},{key:`block`,label:`Block`,value:e.block,color:`var(--color-decision-block)`,textClass:`text-red-300`},{key:`force`,label:`Force`,value:e.force,color:`var(--color-decision-force)`,textClass:`text-sky-300`},{key:`log`,label:`Log`,value:e.log,color:`var(--color-decision-log)`,textClass:`text-violet-300`},{key:`shadow`,label:`Shadow`,value:e.shadow,color:`var(--color-decision-shadow)`,textClass:`text-[var(--color-fg-3)]`}],i=r.reduce((e,t)=>e+t.value,0),a=(0,_.useRef)(null),o=(0,_.useRef)({});return(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let t=e.querySelectorAll(`[data-seg]`);if(t.length===0)return;let n=ot();t.forEach(e=>{let t=e.dataset.seg,a=r.find(e=>e.key===t);if(!a)return;let s=i===0?0:a.value/i*100,c=o.current[t]??0;n||Math.abs(c-s)<.01?e.style.width=`${s}%`:wt(e,{width:[`${c}%`,`${s}%`],duration:480,ease:`outExpo`}),o.current[t]=s})},[e,i]),(0,K.jsxs)(`div`,{className:G(`flex flex-col gap-2`,t),children:[(0,K.jsx)(`div`,{ref:a,className:`flex h-3 w-full overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-2)]`,children:i===0?(0,K.jsx)(`div`,{className:`w-full bg-[var(--color-surface-3)]`}):r.map(e=>(0,K.jsx)(`div`,{"data-seg":e.key,style:{width:`${i===0?0:e.value/i*100}%`,background:e.color}},e.key))}),n?(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] font-mono`,children:r.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-sm`,style:{background:e.color}}),(0,K.jsx)(`span`,{className:G(`uppercase tracking-wide truncate`,e.textClass),children:e.label})]}),(0,K.jsx)(fr,{value:e.value,className:`shrink-0 tabular-nums text-[var(--color-fg-1)]`})]},e.key))}):null]})}function ni(e){return e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.floor(e%60)}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function ri(e,t){if(t===void 0||t<=0)return`var(--color-brand)`;let n=e/t;return n>=.9?`var(--color-decision-block)`:n>=.7?`var(--color-decision-ask)`:`var(--color-decision-allow)`}function ii(e){return e===`var(--color-decision-block)`?`color-mix(in srgb, var(--color-decision-block) 14%, transparent)`:e===`var(--color-decision-ask)`?`color-mix(in srgb, var(--color-decision-ask) 14%, transparent)`:e===`var(--color-decision-allow)`?`color-mix(in srgb, var(--color-decision-allow) 14%, transparent)`:e===`var(--color-decision-log)`?`color-mix(in srgb, var(--color-decision-log) 14%, transparent)`:`color-mix(in srgb, var(--color-brand) 12%, transparent)`}function ai(e,t){if(e.length===0)return[];let n=Date.now(),r=t/Math.max(1,e.length),i=Array(e.length);for(let t=0;t<e.length;t++)i[t]={ts:n-(e.length-1-t)*r,v:e[t]};return i}function oi({cpuPct:e,cpuSeries:t,cpuLimit:n,memMb:r,memSeries:i,memLimit:a,heapUsedMb:o,heapTotalMb:s,heapSeries:c,uptimeSec:l,className:u}){let d=6e4,f=ri(e,n),p=ri(r,a),m=`var(--color-decision-log)`,h=(0,_.useMemo)(()=>ai(t,d),[t]),g=(0,_.useMemo)(()=>ai(i,d),[i]),v=(0,_.useMemo)(()=>ai(c,d),[c]),y=(0,_.useRef)([]);(0,_.useEffect)(()=>{let e=y.current.filter(e=>!!e);if(e.length===0)return;e.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(28px) scale(0.94)`});let t=wt(e,{translateY:[28,0],scale:[.94,1],opacity:[0,1],duration:720,delay:nt(140),ease:`outBack(1.25)`,onComplete:e=>{e.style.transform=``}});return()=>t.cancel()},[]);let b=n!==void 0&&n>0&&e>=n*.9,x=a!==void 0&&a>0&&r>=a*.9;return(0,K.jsx)(`div`,{className:G(`rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] p-3`,u),children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,K.jsx)(si,{registerRef:e=>y.current[0]=e,label:`CPU`,color:f,fill:ii(f),pulse:b,valueNode:(0,K.jsxs)(`span`,{children:[(0,K.jsx)(fr,{value:e,format:e=>e.toFixed(1),className:`text-[var(--color-fg-0)]`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:`%`})]}),subText:n?`limit ${n}%`:void 0,samples:h,maxValue:100,windowMs:d}),(0,K.jsx)(si,{registerRef:e=>y.current[1]=e,label:`Memory`,color:p,fill:ii(p),pulse:x,valueNode:(0,K.jsxs)(`span`,{children:[(0,K.jsx)(fr,{value:r,format:e=>e.toFixed(0),className:`text-[var(--color-fg-0)]`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:`MB`})]}),subText:a?`limit ${a} MB`:void 0,samples:g,maxValue:a?a*1.1:void 0,windowMs:d}),(0,K.jsx)(si,{registerRef:e=>y.current[2]=e,label:`Heap`,color:m,fill:ii(m),valueNode:(0,K.jsxs)(`span`,{children:[(0,K.jsx)(fr,{value:o,format:e=>e.toFixed(0),className:`text-[var(--color-fg-0)]`}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:[`/ `,s.toFixed(0),` MB`]})]}),subText:s>0?`${(o/s*100).toFixed(0)}% used`:void 0,samples:v,maxValue:s>0?s:void 0,windowMs:d}),(0,K.jsx)(si,{registerRef:e=>y.current[3]=e,label:`Uptime`,color:`var(--color-fg-2)`,fill:`rgba(214, 215, 217, 0.04)`,valueNode:(0,K.jsx)(`span`,{className:`text-[var(--color-fg-0)] tabular-nums`,children:ni(l)}),subText:`since daemon start`})]})})}function si({label:e,valueNode:t,subText:n,color:r,fill:i,samples:a,maxValue:o,windowMs:s,pulse:c,registerRef:l}){let u=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!c||!u.current)return;let e=!1,t=null,n=()=>{e||!u.current||(t=wt(u.current,{"--breach":[0,1],duration:420,ease:`outCubic`,onComplete:()=>{e||!u.current||(t=wt(u.current,{"--breach":[1,0],duration:560,ease:`outCubic`,onComplete:()=>{e||n()}}))}}))};return n(),()=>{e=!0,t?.cancel();let n=u.current;n&&n.style.removeProperty(`--breach`)}},[c]),(0,K.jsxs)(`div`,{ref:e=>{u.current=e,l(e)},className:`flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-0)] border-[var(--color-line-1)] px-4 py-3 min-h-[140px] system-pulse__tile`,"data-breach":c?`true`:void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:e}),n?(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:n}):null]}),(0,K.jsx)(`span`,{className:`text-[1.9rem] leading-none font-semibold tracking-tight font-mono`,style:{color:r},children:t}),a&&a.length>=2?(0,K.jsx)(`div`,{className:`mt-auto`,children:(0,K.jsx)(br,{samples:a,width:320,height:64,windowMs:s??6e4,color:r,fillColor:i,maxValue:o,className:`w-full`})}):(0,K.jsx)(`div`,{className:`mt-auto h-[64px] flex items-end`,children:(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`— no series —`})})]})}var ci={__daemon:`SigmaShake itself`,bash:`Run a terminal command`,shell:`Run a terminal command`,run_command:`Run a terminal command`,exec:`Run a terminal command`,run_shell_command:`Run a terminal command`,read:`Read a file`,read_file:`Read a file`,view_file:`Read a file`,cat:`Read a file`,view:`Read a file`,write:`Save changes to a file`,write_to_file:`Save changes to a file`,create_file:`Create a new file`,edit:`Edit an existing file`,multiedit:`Edit several spots in a file`,patch:`Edit an existing file`,apply_patch:`Edit an existing file`,replace:`Edit an existing file`,grep:`Search the codebase`,ripgrep:`Search the codebase`,search:`Search the codebase`,search_codebase:`Search the codebase`,glob:`Find files by name`,find:`Find files by name`,list_files:`List files in a folder`,ls:`List files in a folder`,webfetch:`Read a webpage`,fetch:`Read a webpage`,websearch:`Search the web`,search_web:`Search the web`,browser_action:`Use a web browser`,agent:`Ask a helper AI to investigate`,spawn:`Ask a helper AI to investigate`,task:`Update its to-do list`,todowrite:`Update its to-do list`,todo_write:`Update its to-do list`,notebookedit:`Edit a Jupyter notebook`,notebook_edit:`Edit a Jupyter notebook`};function li(e){return e?ci[e.toLowerCase()]||`Use the ${e.replace(/^_+/,``)} tool`:`Take an action`}function ui(e){return e?{"claude-code":`Claude Code`,claudecode:`Claude Code`,cursor:`Cursor`,copilot:`GitHub Copilot`,codex:`OpenAI Codex`,gemini:`Gemini`,antigravity:`Antigravity`,pi:`Pi`,generic:`AI agent`,daemon:`SigmaShake`}[e.toLowerCase()]??e:`AI agent`}function di(e){return e?e.startsWith(`__`):!1}function fi(e){for(let t of[`file_path`,`path`,`TargetFile`,`AbsolutePath`,`filename`,`file`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function pi(e){for(let t of[`command`,`CommandLine`,`cmd`,`Input`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function mi(e){for(let t of[`query`,`pattern`,`Query`,`q`,`search`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function hi(e){for(let t of[`url`,`URL`,`Url`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function gi(e){let t=e.replace(/[\\/]+$/,``),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`\\`),i=Math.max(n,r);return i>=0?t.slice(i+1):t}function _i(e){let t=e.trim(),n=(t.split(/[|;&]/)[0]?.trim()??t).split(/\s+/),r=n[0]?.toLowerCase()??``,i=n[1]?.toLowerCase()??``,a=(e,t)=>({headline:e,detail:t});if(r===`rm`)return a(`Delete files`,`Deleting files from disk: \`${t}\``);if(r===`mkdir`)return a(`Create a folder`,`Creating a new folder: \`${t}\``);if(r===`mv`)return a(`Move or rename a file`,`Moving or renaming: \`${t}\``);if(r===`cp`)return a(`Copy a file`,`Copying files: \`${t}\``);if(r===`cat`||r===`head`||r===`tail`||r===`less`)return a(`Show file contents`,`Printing file contents: \`${t}\``);if(r===`ls`||r===`tree`||r===`find`)return a(`List files`,`Listing files: \`${t}\``);if(r===`cd`||r===`pwd`)return a(`Check the working folder`,`Checking or changing the current folder: \`${t}\``);if(r===`echo`||r===`printf`)return a(`Print a message`,`Printing a message: \`${t}\``);if(r===`curl`||r===`wget`)return a(`Download from the internet`,`Downloading something from the internet: \`${t}\``);if(r===`kill`||r===`pkill`)return a(`Stop a running program`,`Stopping a running program: \`${t}\``);if(r===`git`)return new Set([`status`,`log`,`diff`,`show`,`branch`,`remote`,`blame`,`config`]).has(i)?a(`Check git history`,`Reading git information (\`git ${i}\`) — no changes are made.`):i===`add`||i===`restore`||i===`reset`?a(`Stage or unstage changes`,`Preparing changes for commit (\`git ${i}\`).`):i===`commit`?a(`Save a checkpoint`,`Saving a snapshot of your changes to git history.`):i===`push`?a(`Send code to the remote`,`Uploading your commits to the remote git repository (e.g. GitHub).`):i===`pull`||i===`fetch`?a(`Get latest from the remote`,`Downloading the newest commits from the remote repository.`):i===`checkout`||i===`switch`?a(`Switch git branch`,`Switching which version of the code is loaded (\`git ${i}\`).`):i===`merge`||i===`rebase`?a(`Combine git branches`,`Combining changes from another branch (\`git ${i}\`).`):a(`Use git`,`Running a git command: \`${t}\``);if(r===`npm`||r===`bun`||r===`pnpm`||r===`yarn`){if(i===`install`||i===`i`||i===`add`)return a(`Install packages`,`Downloading project dependencies from the internet (\`${r} ${i}\`).`);if(i===`run`)return a(`Run a project script`,`Running a project script: \`${t}\``);if(i===`test`)return a(`Run automated tests`,`Running the project's automated tests.`);if(i===`build`)return a(`Build the project`,`Compiling the project for release.`)}return r===`pip`||r===`pip3`||r===`uv`?a(`Install Python packages`,`Installing Python packages: \`${t}\``):r===`pytest`||r===`jest`||r===`vitest`||r===`mocha`||r===`bun`&&i===`test`?a(`Run automated tests`,`Running automated tests: \`${t}\``):r===`docker`||r===`podman`?a(`Use Docker`,`Running a container command: \`${t}\``):r===`ssh`||r===`scp`||r===`rsync`?a(`Talk to another machine`,`Connecting to another computer over the network: \`${t}\``):a(`Run a terminal command`,`Running in the terminal: \`${t}\``)}function vi(e,t){let n=e??``,r=n.toLowerCase(),i=li(n),a=null;try{let e=JSON.parse(t);e&&typeof e==`object`&&!Array.isArray(e)&&(a=e)}catch{}if(r===`__daemon`){let e=a?.event,t=a?.detail;return typeof e==`string`&&e.length>0?{headline:`SigmaShake itself`,detail:`SigmaShake ${e===`start`?`started`:e===`stop`?`stopped`:e}${typeof t==`string`&&t.length>0?` — ${t}`:``}.`}:{headline:`SigmaShake itself`,detail:`A SigmaShake lifecycle event.`}}if(!a)return{headline:i,detail:`${i}.`};if(r===`bash`||r===`shell`||r===`run_command`||r===`exec`||r===`run_shell_command`){let e=pi(a);return e?_i(e):{headline:i,detail:`Running a terminal command.`}}if(r===`read`||r===`read_file`||r===`view_file`||r===`cat`||r===`view`){let e=fi(a);return e?{headline:i,detail:`Reading the file \`${gi(e)}\` so it can understand the current code. No changes are made.`}:{headline:i,detail:`Reading a file. No changes are made.`}}if(r===`write`||r===`write_to_file`||r===`create_file`){let e=fi(a);return e?{headline:`Save changes to a file`,detail:`Creating or overwriting the file \`${gi(e)}\`. This will replace anything that was there before.`}:{headline:i,detail:`Creating or overwriting a file.`}}if(r===`edit`||r===`multiedit`||r===`patch`||r===`apply_patch`||r===`replace`){let e=fi(a);return e?{headline:i,detail:`Editing the file \`${gi(e)}\` — changing specific parts of it without rewriting the whole thing.`}:{headline:i,detail:`Editing a file in place.`}}if(r===`grep`||r===`ripgrep`||r===`search`||r===`search_codebase`){let e=mi(a);return e?{headline:i,detail:`Searching the project for the text "${e}".`}:{headline:i,detail:`Searching the project for matching text.`}}if(r===`glob`||r===`find`||r===`list_files`||r===`ls`){let e=mi(a)??fi(a);return e?{headline:i,detail:`Looking for files matching "${e}".`}:{headline:i,detail:`Looking for files in the project.`}}if(r===`webfetch`||r===`fetch`||r===`browser_action`){let e=hi(a);return e?{headline:i,detail:`Reading a webpage from the internet: ${e}`}:{headline:i,detail:`Reading a webpage from the internet.`}}if(r===`websearch`||r===`search_web`){let e=mi(a);return e?{headline:i,detail:`Searching the web for "${e}".`}:{headline:i,detail:`Searching the web.`}}return r===`agent`||r===`spawn`?{headline:i,detail:`Asking a separate helper AI to investigate something on its own, then report back. Helps keep this conversation focused.`}:r===`task`||r===`todowrite`||r===`todo_write`?{headline:i,detail:`Updating its internal to-do list so it can keep track of progress on a multi-step task.`}:{headline:i,detail:`${i}.`}}var yi=At(`relative font-mono text-[11px] overflow-hidden border bg-[var(--color-surface-1)] border-[var(--color-line-1)] rounded-sm`,{variants:{density:{compact:``,roomy:`text-[12px]`}},defaultVariants:{density:`compact`}}),bi={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`},xi={allow:`text-emerald-300`,block:`text-red-300`,ask:`text-amber-300`,log:`text-violet-300`,force:`text-sky-300`,shadow:`text-[var(--color-fg-3)]`};function Si(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function Ci(e){return e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:e<1e9?`${(e/1e6).toFixed(2)} ms`:`${(e/1e9).toFixed(2)} s`}function wi(e){return e.variant===`raw`?(0,K.jsx)(Ei,{...e}):(0,K.jsx)(Ti,{...e})}function Ti({bursts:e,windowSize:t=60,filterDecision:n,filterClient:r,className:i,density:a,height:o=260}){let[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useMemo)(()=>{let i=e;n&&(i=i.filter(e=>e.decision===n)),r&&(i=i.filter(e=>e.client===r));let a=i.slice(-t),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a[a.length-1-e];return o},[e,n,r,t]);s?l.current===null&&(l.current=u):l.current=null;let d=s&&l.current?l.current:u,f=(0,_.useRef)(null),p=(0,_.useRef)(0);return(0,_.useLayoutEffect)(()=>{if(s)return;let e=d[0];if(!e||e.ts_ms===p.current)return;p.current=e.ts_ms;let t=f.current;t&&(ot()||wt(t,{translateX:[-10,0],opacity:[0,1],duration:220,ease:`outExpo`}))},[d,s]),(0,K.jsxs)(`div`,{className:G(yi({density:a,className:i})),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,K.jsx)(`div`,{className:`overflow-auto`,style:{height:o},children:d.length===0?(0,K.jsx)(`div`,{className:`px-3 py-4 text-[var(--color-fg-4)]`,children:`— waiting for events —`}):d.map((e,t)=>{let n=e.input_preview&&e.input_preview.length>0?e.input_preview:e.rule_id?`rule: ${e.rule_id}`:`—`;return(0,K.jsxs)(`div`,{ref:t===0?f:void 0,className:`telemetry-row grid items-center gap-2 px-3 py-1 border-b border-[var(--color-line-0)] last:border-b-0 hover:bg-[var(--color-surface-2)]`,style:{gridTemplateColumns:`90px 56px minmax(80px, 130px) minmax(0, 1fr) 70px 80px`,borderLeft:`3px solid ${bi[e.decision]??`#666`}`},children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:Si(e.ts_ms)}),(0,K.jsx)(`span`,{className:G(`uppercase tracking-wide font-medium`,xi[e.decision]??`text-[var(--color-fg-2)]`),children:e.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,title:e.tool?`${e.tool} — ${li(e.tool)}`:`unknown tool`,children:e.tool||`—`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] truncate`,title:n,children:n}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums text-right`,children:Ci(e.duration_ns)}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate text-right`,title:e.client,children:e.client})]},e.audit_id??`${e.ts_ms}:${e.tool}`)})}),s?(0,K.jsx)(Di,{}):null]})}function Ei({lines:e,windowSize:t=300,className:n,density:r,height:i=260}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useMemo)(()=>{let n=e.slice(-t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[n.length-1-e];return r},[e,t]);a?s.current===null&&(s.current=c):s.current=null;let l=a&&s.current?s.current:c;return(0,K.jsxs)(`div`,{className:G(yi({density:r,className:n})),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,K.jsx)(`div`,{className:`overflow-auto px-3 py-2 leading-relaxed text-[var(--color-fg-2)] whitespace-pre`,style:{height:i},children:l.length===0?(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`— empty —`}):l.map((e,t)=>(0,K.jsx)(`div`,{className:`hover:bg-[var(--color-surface-2)]`,children:e},`${t}:${e.slice(0,40)}`))}),a?(0,K.jsx)(Di,{}):null]})}function Di(){return(0,K.jsx)(`span`,{className:`absolute top-1 right-2 text-[10px] uppercase tracking-wider font-mono text-[var(--color-brand)] bg-[var(--color-surface-0)] px-1.5 py-0.5 border border-[var(--color-brand)]/40 rounded-sm`,children:`paused`})}var Oi=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),ki=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Ai=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ji=e=>{let t=Ai(e);return t.charAt(0).toUpperCase()+t.slice(1)},Mi={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ni=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Pi=(0,_.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,_.createElement)(`svg`,{ref:c,...Mi,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Oi(`lucide`,i),...!a&&!Ni(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Fi=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(Pi,{ref:i,iconNode:t,className:Oi(`lucide-${ki(ji(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ji(e),n},Ii=Fi(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Li=Fi(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Ri=Fi(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),zi=Fi(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Bi=Fi(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Vi=Fi(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Hi=Fi(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Ui=Fi(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Wi=Fi(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Gi=[`hero-metrics`,`graph`,`latency-trace`,`throughput`,`decision-mix`,`telemetry-feed`,`system-pulse`,`pending-approvals`,`recent-blocks`],Ki={"hero-metrics":`Hero metrics`,graph:`Graph intelligence`,"latency-trace":`Latency trace`,throughput:`Throughput`,"decision-mix":`Decision mix`,"telemetry-feed":`Telemetry feed`,"system-pulse":`System pulse`,"pending-approvals":`Pending approvals`,"recent-blocks":`Recent blocks`},qi={"hero-metrics":{minW:6,minH:2,defaultW:12,defaultH:2},graph:{minW:4,minH:3,defaultW:8,defaultH:5},"latency-trace":{minW:4,minH:3,defaultW:8,defaultH:4},throughput:{minW:2,minH:2,defaultW:4,defaultH:2},"decision-mix":{minW:2,minH:2,defaultW:4,defaultH:2},"telemetry-feed":{minW:6,minH:3,defaultW:12,defaultH:4},"system-pulse":{minW:4,minH:3,defaultW:12,defaultH:3},"pending-approvals":{minW:3,minH:2,defaultW:6,defaultH:3},"recent-blocks":{minW:3,minH:2,defaultW:6,defaultH:3}};function Ji({panel:e,isEditing:t,children:n,drag:r}){let i=(0,_.useRef)(null),a={gridColumn:`${e.x+1} / span ${e.w}`,gridRow:`${e.y+1} / span ${e.h}`};return(0,K.jsxs)(`div`,{ref:i,className:`grid-panel ${t?`grid-panel--edit`:``}`,style:a,role:t?`region`:void 0,"aria-label":t?Ki[e.id]:void 0,tabIndex:t?0:void 0,onKeyDown:t?t=>r.onPanelKeyDown(t,e.id):void 0,"data-panel-id":e.id,children:[t&&(0,K.jsx)(`button`,{type:`button`,className:`grid-panel__drag-handle`,title:`Drag ${Ki[e.id]} (or Arrow keys)`,"aria-label":`Drag ${Ki[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onDragPointerDown(t,e.id,n)},children:(0,K.jsx)(Ri,{size:12,strokeWidth:2})}),(0,K.jsx)(`div`,{className:`grid-panel__content`,"data-reveal":t?void 0:``,children:n}),t&&(0,K.jsx)(`button`,{type:`button`,className:`grid-panel__resize-handle`,title:`Resize ${Ki[e.id]} (or Shift+Arrow keys)`,"aria-label":`Resize ${Ki[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onResizePointerDown(t,e.id,n)},children:(0,K.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":!0,children:[(0,K.jsx)(`path`,{d:`M10 0 L10 10 L0 10 Z`,fill:`currentColor`,fillOpacity:`0.4`}),(0,K.jsx)(`path`,{d:`M3 10 L10 3 M6 10 L10 6 M9 10 L10 9`,stroke:`currentColor`,strokeWidth:`0.8`,fill:`none`})]})})]})}var Yi=(0,_.memo)(Ji);function Xi(e){let t=getComputedStyle(e),n=e.getBoundingClientRect(),r=parseFloat(t.rowGap||t.gap||`0`)||0,i=r*11;return{cellWidthPx:(n.width-i)/12+r,cellHeightPx:72+r}}function Zi(e){let t=(0,_.useRef)(null),n=(0,_.useRef)(e);n.current=e;let r=(0,_.useCallback)(()=>{let e=t.current;if(e){e.element.style.transform=``,e.element.style.width=``,e.element.style.height=``,e.element.style.zIndex=``,e.element.classList.remove(`grid-panel--dragging`),e.element.classList.remove(`grid-panel--resizing`);try{e.element.releasePointerCapture(e.pointerId)}catch{}t.current=null}},[]);(0,_.useEffect)(()=>{function e(e){let n=t.current;if(!n||e.pointerId!==n.pointerId)return;let r=e.clientX-n.startPointerX,i=e.clientY-n.startPointerY;if(n.mode===`drag`)n.element.style.transform=`translate3d(${r}px, ${i}px, 0)`;else{let e=qi[n.startPanel.id],t=e.minW*n.cellWidthPx-n.cellWidthPx+40,a=e.minH*n.cellHeightPx-n.cellHeightPx+40,o=Math.max(t,n.startRectW+r),s=Math.max(a,n.startRectH+i);n.element.style.width=`${o}px`,n.element.style.height=`${s}px`}}function i(e,t,n){let r=qi[e.startPanel.id];if(e.mode===`drag`){let r=Math.round(t/e.cellWidthPx),i=Math.round(n/e.cellHeightPx),a=e.startPanel.x+r,o=e.startPanel.y+i;return a<0&&(a=0),a+e.startPanel.w>12&&(a=12-e.startPanel.w),o<0&&(o=0),{id:e.id,x:a,y:o,w:e.startPanel.w,h:e.startPanel.h}}let i=Math.round(t/e.cellWidthPx),a=Math.round(n/e.cellHeightPx),o=e.startPanel.w+i,s=e.startPanel.h+a;return o<r.minW&&(o=r.minW),s<r.minH&&(s=r.minH),e.startPanel.x+o>12&&(o=12-e.startPanel.x),{id:e.id,x:e.startPanel.x,y:e.startPanel.y,w:o,h:s}}function a(e){let a=t.current;if(!a||e.pointerId!==a.pointerId)return;let o=i(a,e.clientX-a.startPointerX,e.clientY-a.startPointerY);r(),o.x===a.startPanel.x&&o.y===a.startPanel.y&&o.w===a.startPanel.w&&o.h===a.startPanel.h||n.current.onCommit(o)}function o(e){let n=t.current;!n||e.pointerId!==n.pointerId||r()}function s(e){e.key===`Escape`&&t.current&&r()}function c(){document.visibilityState===`hidden`&&t.current&&r()}return document.addEventListener(`pointermove`,e),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,o),document.addEventListener(`keydown`,s),document.addEventListener(`visibilitychange`,c),()=>{document.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,o),document.removeEventListener(`keydown`,s),document.removeEventListener(`visibilitychange`,c),t.current&&r()}},[r]);let i=(0,_.useCallback)((e,r,i,a)=>{if(!n.current.enabled||t.current)return;let o=n.current.getPanel(r),s=n.current.gridRef.current;if(!o||!s)return;e.preventDefault(),e.stopPropagation();let{cellWidthPx:c,cellHeightPx:l}=Xi(s),u=i.getBoundingClientRect();t.current={id:r,mode:a,startPointerX:e.clientX,startPointerY:e.clientY,startPanel:o,element:i,cellWidthPx:c,cellHeightPx:l,pointerId:e.pointerId,startRectW:u.width,startRectH:u.height},i.classList.add(a===`drag`?`grid-panel--dragging`:`grid-panel--resizing`),i.style.zIndex=`10`;try{i.setPointerCapture(e.pointerId)}catch{}},[]);return{onDragPointerDown:(0,_.useCallback)((e,t,n)=>i(e,t,n,`drag`),[i]),onResizePointerDown:(0,_.useCallback)((e,t,n)=>i(e,t,n,`resize`),[i]),onPanelKeyDown:(0,_.useCallback)((e,t)=>{if(!n.current.enabled)return;let r=n.current.getPanel(t);if(!r)return;let i=e.shiftKey,a=0,o=0;switch(e.key){case`ArrowLeft`:a=-1;break;case`ArrowRight`:a=1;break;case`ArrowUp`:o=-1;break;case`ArrowDown`:o=1;break;default:return}e.preventDefault(),e.stopPropagation();let s=qi[t];if(i){let e=r.w+a,i=r.h+o;if(e<s.minW&&(e=s.minW),i<s.minH&&(i=s.minH),r.x+e>12&&(e=12-r.x),e===r.w&&i===r.h)return;n.current.onCommit({id:t,x:r.x,y:r.y,w:e,h:i})}else{let e=r.x+a,i=r.y+o;if(e<0&&(e=0),e+r.w>12&&(e=12-r.w),i<0&&(i=0),e===r.x&&i===r.y)return;n.current.onCommit({id:t,x:e,y:i,w:r.w,h:r.h})}},[]),isGesturing:(0,_.useCallback)(()=>t.current!==null,[])}}function Qi(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function $i(e){return{id:e.id,x:e.x,y:e.y,w:e.w,h:e.h}}function ea(e,t){let n=[$i(e)],r=t.map($i);r.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y);for(let e of r){for(;;){let t=!1;for(let r of n)if(Qi(e,r)){let n=r.y+r.h;n>e.y&&(e.y=n,t=!0)}if(!t)break}n.push(e)}return n}function ta(e){if(e.length===0)return[];let t=[...e].map($i).sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y),n=[];for(let e of t){let t=!0;for(;t;){t=!1;for(let r of n)Qi(e,r)&&(e.y=r.y+r.h,t=!0)}n.push(e)}return n}function na(e,t,n){let r=e.findIndex(e=>e.id===t);if(r===-1)return{panels:e.map($i)};let i=ea({id:e[r].id,x:n.x,y:n.y,w:n.w,h:n.h},e.filter((e,t)=>t!==r)),a=new Map(i.map(e=>[e.id,e]));return{panels:ta(e.map(e=>a.get(e.id)).filter(Boolean))}}function ra({panels:e,isEditing:t,renderers:n,onPanelsChange:r}){let i=(0,_.useRef)(null),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n);return t},[e]),s=Zi({gridRef:i,getPanel:(0,_.useCallback)(e=>o.get(e),[o]),onCommit:(0,_.useCallback)(e=>{let t=a.current,{panels:n}=na(t,e.id,{x:e.x,y:e.y,w:e.w,h:e.h});r(n)},[r]),enabled:t});return(0,K.jsx)(`div`,{ref:i,className:`grid-layout ${t?`grid-layout--editing`:``}`,"aria-live":t?`polite`:void 0,children:e.map(e=>(0,K.jsx)(Yi,{panel:e,isEditing:t,drag:s,children:n[e.id]()},e.id))})}function ia({manager:e,isEditing:t,onToggleEditing:n}){let{config:r,activeLayout:i,canAddUserLayout:a,saveError:o,selectLayout:s,saveAs:c,renameActive:l,deleteLayout:u,resetActive:d,exportConfig:f,importConfig:p}=e,[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(i.name),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),k=(0,_.useRef)(null);(0,_.useEffect)(()=>{w(i.name)},[i.name]),(0,_.useEffect)(()=>{o&&h(o)},[o]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]);function A(){y.trim()&&(c(y.trim()),b(``),v(!1),h(`Saved "${y.trim()}"`))}function j(){C.trim()&&(l(C.trim()),S(!1),h(`Renamed`))}function M(){let e=i.name;u(i.id),O(!1),h(`Deleted "${e}"`)}function N(){d(),E(!1),h(`Reset to default`)}function ee(){let e=f(),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=new Date().toISOString().slice(0,10),i=document.createElement(`a`);i.href=n,i.download=`ssg-layout-${r}.json`,i.click(),URL.revokeObjectURL(n),h(`Layout exported`)}function te(e){let t=e.target.files?.[0];e.target.value=``,t&&t.text().then(e=>{h(p(e).message)}).catch(()=>h(`Import failed: could not read file`))}return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(`span`,{className:`overline shrink-0`,children:`layout`}),(0,K.jsxs)(`select`,{value:r.activeLayoutId,onChange:e=>s(e.target.value),className:`bg-[var(--color-surface-2)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[11px] font-mono text-[var(--color-fg-1)] hover:border-[var(--color-line-2)] focus:outline-none focus:ring-1 focus:ring-[var(--color-brand)] cursor-pointer`,"aria-label":`Select layout`,children:[(0,K.jsx)(`optgroup`,{label:`Built-in`,children:r.layouts.filter(e=>e.builtIn).map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))}),r.layouts.some(e=>!e.builtIn)&&(0,K.jsx)(`optgroup`,{label:`Your layouts`,children:r.layouts.filter(e=>!e.builtIn).map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),i.builtIn&&(0,K.jsx)(`span`,{className:`chip text-[var(--color-fg-3)]`,title:`Built-in preset`,children:`built-in`})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:()=>v(!0),disabled:!a,title:a?`Save the current arrangement as a new preset`:`Layout limit reached — delete one first`,children:[(0,K.jsx)(Vi,{size:11,strokeWidth:2.25}),`Save as`]}),!i.builtIn&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>{w(i.name),S(!0)},children:[(0,K.jsx)(zi,{size:11,strokeWidth:2.25}),`Rename`]}),(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>O(!0),children:[(0,K.jsx)(Hi,{size:11,strokeWidth:2.25}),`Delete`]})]}),(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),title:`Replace the current layout with the Default preset`,children:[(0,K.jsx)(Bi,{size:11,strokeWidth:2.25}),`Reset`]}),(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:ee,title:`Download current layouts as JSON`,children:[(0,K.jsx)(Li,{size:11,strokeWidth:2.25}),`Export`]}),(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>k.current?.click(),title:`Load layouts from a JSON file`,children:[(0,K.jsx)(Ui,{size:11,strokeWidth:2.25}),`Import`]}),(0,K.jsx)(`input`,{ref:k,type:`file`,accept:`application/json,.json`,onChange:te,className:`hidden`,"aria-hidden":!0}),(0,K.jsxs)(X,{variant:`primary`,size:`sm`,onClick:()=>n(!1),children:[(0,K.jsx)(Ii,{size:11,strokeWidth:2.5}),`Done`]})]}):(0,K.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:()=>n(!0),children:[(0,K.jsx)(zi,{size:11,strokeWidth:2.25}),`Edit layout`]})}),g&&(0,K.jsx)(aa,{title:`Save layout as`,value:y,placeholder:`My dashboard`,onChange:b,onConfirm:A,onCancel:()=>{v(!1),b(``)},confirmLabel:`Save`}),x&&(0,K.jsx)(aa,{title:`Rename layout`,value:C,placeholder:i.name,onChange:w,onConfirm:j,onCancel:()=>S(!1),confirmLabel:`Rename`}),T&&(0,K.jsx)(oa,{title:`Reset this layout?`,body:`The current arrangement will be replaced with the Default preset. Saved layouts are not affected.`,confirmLabel:`Reset`,onConfirm:N,onCancel:()=>E(!1),destructive:!1}),D&&(0,K.jsx)(oa,{title:`Delete "${i.name}"?`,body:`This layout will be removed. You can always recreate it via Save as.`,confirmLabel:`Delete`,onConfirm:M,onCancel:()=>O(!1),destructive:!0}),m&&(0,K.jsx)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 -translate-x-1/2 z-50 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-3)] px-3 py-2 text-[11px] font-mono text-[var(--color-fg-1)] shadow-lg`,children:m})]})}function aa({title:e,value:t,placeholder:n,onChange:r,onConfirm:i,onCancel:a,confirmLabel:o}){return(0,K.jsx)(`div`,{role:`dialog`,"aria-modal":!0,"aria-label":e,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:a,children:(0,K.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`w-80 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-2)] p-4`,children:[(0,K.jsx)(`div`,{className:`overline mb-2`,children:e}),(0,K.jsx)(`input`,{value:t,onChange:e=>r(e.target.value),placeholder:n,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&i(),e.key===`Escape`&&a()},className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5 text-[13px] font-mono text-[var(--color-fg-1)] focus:outline-none focus:border-[var(--color-brand)]`}),(0,K.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,K.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:a,children:[(0,K.jsx)(Wi,{size:11,strokeWidth:2.25}),`Cancel`]}),(0,K.jsx)(X,{variant:`primary`,size:`sm`,onClick:i,children:o})]})]})})}function oa({title:e,body:t,confirmLabel:n,destructive:r,onConfirm:i,onCancel:a}){return(0,K.jsx)(`div`,{role:`dialog`,"aria-modal":!0,"aria-label":e,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:a,children:(0,K.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`w-96 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-2)] p-4`,children:[(0,K.jsx)(`div`,{className:`overline mb-2`,children:e}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:t}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,K.jsx)(X,{variant:r?`danger`:`primary`,size:`sm`,onClick:i,children:n})]})]})})}var sa={default:`builtin-default`,focusLatency:`builtin-focus-latency`,focusApprovals:`builtin-focus-approvals`,compact:`builtin-compact`},ca={id:sa.default,name:`Default`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`graph`,x:0,y:2,w:8,h:5},{id:`latency-trace`,x:8,y:2,w:4,h:3},{id:`throughput`,x:8,y:5,w:2,h:2},{id:`decision-mix`,x:10,y:5,w:2,h:2},{id:`telemetry-feed`,x:0,y:7,w:12,h:3},{id:`system-pulse`,x:0,y:10,w:12,h:3},{id:`pending-approvals`,x:0,y:13,w:6,h:3},{id:`recent-blocks`,x:6,y:13,w:6,h:3}]},la={id:sa.focusLatency,name:`Focus · Latency`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`latency-trace`,x:0,y:2,w:8,h:5},{id:`graph`,x:8,y:2,w:4,h:5},{id:`throughput`,x:0,y:7,w:6,h:2},{id:`decision-mix`,x:6,y:7,w:6,h:2},{id:`system-pulse`,x:0,y:9,w:12,h:3},{id:`telemetry-feed`,x:0,y:12,w:12,h:3},{id:`pending-approvals`,x:0,y:15,w:6,h:2},{id:`recent-blocks`,x:6,y:15,w:6,h:2}]},ua={id:sa.focusApprovals,name:`Focus · Approvals`,builtIn:!0,panels:[{id:`pending-approvals`,x:0,y:0,w:8,h:4},{id:`graph`,x:8,y:0,w:4,h:4},{id:`recent-blocks`,x:0,y:4,w:12,h:3},{id:`hero-metrics`,x:0,y:7,w:12,h:2},{id:`latency-trace`,x:0,y:9,w:6,h:3},{id:`telemetry-feed`,x:6,y:9,w:6,h:3},{id:`system-pulse`,x:0,y:12,w:12,h:3},{id:`throughput`,x:0,y:15,w:6,h:2},{id:`decision-mix`,x:6,y:15,w:6,h:2}]},da={id:sa.compact,name:`Compact`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`graph`,x:0,y:2,w:8,h:3},{id:`latency-trace`,x:8,y:2,w:4,h:3},{id:`system-pulse`,x:0,y:5,w:12,h:3},{id:`throughput`,x:0,y:8,w:4,h:2},{id:`decision-mix`,x:4,y:8,w:4,h:2},{id:`telemetry-feed`,x:0,y:10,w:12,h:3},{id:`pending-approvals`,x:0,y:13,w:6,h:2},{id:`recent-blocks`,x:6,y:13,w:6,h:2}]},fa=Object.freeze([ca,la,ua,da]);function pa(){return fa.map(e=>({...e,panels:e.panels.map(e=>({...e}))}))}function ma(){return{version:1,activeLayoutId:sa.default,layouts:pa()}}function ha(e){return Object.values(sa).includes(e)}var ga=new Set(Gi),_a=new Set(fa.map(e=>e.id));function va(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ya(e,t,n,r){if(typeof e!=`number`||!Number.isFinite(e))return r;let i=Math.floor(e);return i<t?t:i>n?n:i}function ba(e,t){let n=(typeof e==`string`?e:``).replace(/[\u0000-\u001F\u007F]/g,``).trim();return n.length===0?t:n.slice(0,40)}function xa(e){let t=e.find(e=>e.id===`system-pulse`);if(!t||t.h>=3)return e;let n=3-t.h,r=t.y+t.h;return e.map(e=>e.id===`system-pulse`?{...e,h:3}:e.y>=r?{...e,y:e.y+n}:e)}function Sa(e){for(let t=0;t<e.length;t++){let n=e[t];for(let r=t+1;r<e.length;r++){let t=e[r];if(n.x<t.x+t.w&&n.x+n.w>t.x&&n.y<t.y+t.h&&n.y+n.h>t.y)return!0}}return!1}function Ca(e){if(!va(e))return null;let{id:t}=e;if(typeof t!=`string`||!ga.has(t))return null;let n=t,r=qi[n],i=ya(e.x,0,11,0),a=ya(e.w,r.minW,12,r.defaultW);return{id:n,x:i+a>12?12-a:i,y:ya(e.y,0,999,0),w:a,h:ya(e.h,r.minH,99,r.defaultH)}}function wa(e,t){if(!va(e))return{layout:null,droppedPanels:0};let n=typeof e.id==`string`&&e.id.length>0?e.id:null;if(!n)return{layout:null,droppedPanels:0};let r=ba(e.name,t),i=_a.has(n),a=e.panels;if(!Array.isArray(a))return{layout:null,droppedPanels:0};let o=new Set,s=[],c=0;for(let e of a){let t=Ca(e);if(!t){c+=1;continue}if(o.has(t.id)){c+=1;continue}o.add(t.id),s.push(t)}return s.length===0?{layout:null,droppedPanels:c}:{layout:{id:n,name:r,builtIn:i,panels:xa(s)},droppedPanels:c}}function Ta(e){if(!va(e)||e.version!==1)return{config:ma(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let t=e.layouts;if(!Array.isArray(t)||t.length===0)return{config:ma(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let n=[],r=0,i=0,a=0;for(let e of t){let{layout:t,droppedPanels:o}=wa(e,`Layout ${n.length+1}`);if(r+=o,t){if(!t.builtIn){if(i>=12){a+=1;continue}i+=1}n.push(t)}}if(n.length===0)return{config:ma(),droppedPanels:r,prunedLayouts:a,fellBackToDefault:!0};let o=new Set(n.map(e=>e.id));for(let e of fa)o.has(e.id)||n.push({...e,panels:e.panels.map(e=>({...e}))});let s=new Map(fa.map(e=>[e.id,e])),c=0,l=0;for(let e=0;e<n.length;e++){let t=n[e],r=s.get(t.id);if(!r)continue;if(Sa(t.panels)){n[e]={...r,panels:r.panels.map(e=>({...e}))},l+=1;continue}let i=new Set(t.panels.map(e=>e.id)),a=r.panels.filter(e=>!i.has(e.id));if(a.length===0)continue;let o=t.panels.reduce((e,t)=>Math.max(e,t.y+t.h),0);for(let e of a)t.panels.push({id:e.id,x:0,y:o,w:e.w,h:e.h}),o+=e.h,c+=1}let u=e.activeLayoutId;return{config:{version:1,activeLayoutId:typeof u==`string`&&n.some(e=>e.id===u)?u:fa[0].id,layouts:n},droppedPanels:r,prunedLayouts:a,fellBackToDefault:!1,backfilledPanels:c,refreshedBuiltins:l}}var Ea=`ssg:dashboard-layout:v1`,Da=300;function Oa(){if(typeof localStorage>`u`)return null;try{let e=`__ssg_probe__`;return localStorage.setItem(e,`1`),localStorage.removeItem(e),localStorage}catch{return null}}var ka;function Aa(){return ka===void 0&&(ka=Oa()),ka}function ja(){let e=Aa();if(!e)return{config:ma(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let t=null;try{t=e.getItem(Ea)}catch{t=null}if(t===null)return{config:ma(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let n=null;try{n=JSON.parse(t)}catch{return{config:ma(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0}}return Ta(n)}var Ma=null,Na=null,Pa=null;function Fa(e){return Pa=e,()=>{Pa===e&&(Pa=null)}}function Ia(e){Pa?Pa(e):typeof console<`u`&&console.warn(`[ssg-layout]`,e)}function La(){if(Na=null,!Ma)return;let e=Aa();if(!e){Ma=null;return}let t=Ma;Ma=null;try{e.setItem(Ea,JSON.stringify(t))}catch(e){e instanceof Error&&e.name===`QuotaExceededError`?Ia(`Layout storage full — save skipped`):Ia(`Layout save failed: ${e instanceof Error?e.message:String(e)}`)}}function Ra(e){Ma=e,Na===null&&(Na=setTimeout(La,Da))}function za(e){Ma=e,Na!==null&&(clearTimeout(Na),Na=null),La()}function Ba(e){let t=0;for(let n of e.layouts)n.builtIn||(t+=1);return t}function Va(e){return e.map(e=>({...e}))}function Ha(){return`user-`+Math.random().toString(16).slice(2,11)}function Ua(){let[e,t]=(0,_.useState)(()=>ja().config),[n,r]=(0,_.useState)(null);(0,_.useEffect)(()=>Fa(e=>r(e)),[]),(0,_.useEffect)(()=>{Ra(e)},[e]);let i=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0]??pa()[0],a=Ba(e)<12,o=(0,_.useCallback)(e=>{t(t=>t.layouts.some(t=>t.id===e)?{...t,activeLayoutId:e}:t)},[]),s=(0,_.useCallback)(e=>{t(t=>{let n=t.activeLayoutId;return{...t,layouts:t.layouts.map(t=>t.id===n?{...t,panels:Va(e)}:t)}})},[]),c=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>{if(Ba(e)>=12)return e;let t=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0];if(!t)return e;let r={id:Ha(),name:n,builtIn:!1,panels:Va(t.panels)};return{...e,activeLayoutId:r.id,layouts:[...e.layouts,r]}})},[]),l=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>({...e,layouts:e.layouts.map(t=>t.id===e.activeLayoutId&&!t.builtIn?{...t,name:n}:t)}))},[]),u=(0,_.useCallback)(e=>{t(t=>{let n=t.layouts.find(t=>t.id===e);if(!n||n.builtIn)return t;let r=t.layouts.filter(t=>t.id!==e),i=t.activeLayoutId===e?r[0]?.id??fa[0].id:t.activeLayoutId;return{...t,activeLayoutId:i,layouts:r}})},[]),d=(0,_.useCallback)(()=>{t(e=>{let t=e.layouts.find(t=>t.id===e.activeLayoutId);if(!t)return e;let n=ha(t.id)?fa.find(e=>e.id===t.id):fa[0];return n?{...e,layouts:e.layouts.map(e=>e.id===t.id?{...e,panels:Va(n.panels)}:e)}:e})},[]),f=(0,_.useCallback)(()=>JSON.stringify(e,null,2),[e]),p=(0,_.useCallback)(e=>{let n;try{n=JSON.parse(e)}catch{return{ok:!1,message:`Import failed: not valid JSON`}}let r=Ta(n);if(r.fellBackToDefault)return{ok:!1,message:`Import rejected: schema invalid, no changes applied`};t(r.config),za(r.config);let i=[`Layout imported`];return r.droppedPanels>0&&i.push(`${r.droppedPanels} unrecognized panel(s) dropped`),r.prunedLayouts>0&&i.push(`${r.prunedLayouts} excess layout(s) pruned`),{ok:!0,message:i.join(` · `)}},[]);return(0,_.useEffect)(()=>{e.layouts.length===0&&t(ma())},[e.layouts.length]),{config:e,activeLayout:i,canAddUserLayout:a,saveError:n,selectLayout:o,updateActivePanels:s,saveAs:c,renameActive:l,deleteLayout:u,resetActive:d,exportConfig:f,importConfig:p}}var Wa=new Set([`compact`,`end`,`stop`,`subagent-stop`,`close`]),Ga=Object.freeze([`session-lifecycle`]);function Ka(e){(0,_.useEffect)(()=>Ce(Ga),[]);let t=(0,_.useSyncExternalStore)(me,he),[n,r]=(0,_.useState)(new Map),i=(0,_.useRef)(0);(0,_.useEffect)(()=>{let e=t.lifecycleRing;if(e.length<=i.current)return;let n=e.slice(i.current);i.current=e.length,qa(n,r)},[t.lifecycleRing]);let a=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{!e||e===a.current||(a.current=e,qa(e,r))},[e]),{closedAt:n,isBurstActive(e,t){let r=n.get(e);return r===void 0||t>r}}}function qa(e,t){let n=e.filter(e=>Wa.has(e.event));n.length!==0&&t(e=>{let t=!1,r=new Map(e);for(let e of n){let n=r.get(e.session_key);(n===void 0||e.ts_ms>n)&&(r.set(e.session_key,e.ts_ms),t=!0)}return t?r:e})}function Ja(e){return`${e.client}:${e.agent_id??`solo`}`}var Ya=Object.freeze({allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`}),Xa=5*6e4,Za=1200,Qa=30*6e4,$a=1.4;function eo(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 6;let n=6+Math.log2(1+t/50)*$a;return n<4?4:n>16?16:n}function to(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 0;let n=Math.log2(1+t/50)*$a/10;return n<=0?0:n>=1?1:n}function Z(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function no(e,t){if(t<=0)return e;let n=e.startsWith(`#`)?e.slice(1):e;if(n.length!==6)return e;let r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);if(Number.isNaN(r)||Number.isNaN(i)||Number.isNaN(a))return e;let o=Math.max(r,i,a);if(o===0)return e;let s=t>1?1:t,c=(255-o)*s,l=Math.round(r+r/o*c),u=Math.round(i+i/o*c),d=Math.round(a+a/o*c),f=e=>(e<0?0:e>255?255:e).toString(16).padStart(2,`0`);return`#${f(l)}${f(u)}${f(d)}`}var ro=1440*60*1e3,io=1800*1e3,ao=3e3;function oo(e,t){if(e.length===0)return t.slice();if(t.length===0)return e.slice();let n=new Set,r=[],i=0,a=0;for(;i<e.length&&a<t.length;){let o=e[i].ts_ms<=t[a].ts_ms?e[i++]:t[a++],s=so(o);n.has(s)||(n.add(s),r.push(o))}for(;i<e.length;i++){let t=e[i],a=so(t);n.has(a)||(n.add(a),r.push(t))}for(;a<t.length;a++){let e=t[a],i=so(e);n.has(i)||(n.add(i),r.push(e))}return r}function so(e){return e.audit_id??`${e.ts_ms}:${e.tool}:${e.client}`}function co(e,t){if(e.length===0)return t.slice();if(t.length===0)return e.slice();let n=new Set,r=[];for(let i of[...e,...t]){let e=`${i.session_key}:${i.ts_ms}:${i.event}`;n.has(e)||(n.add(e),r.push(i))}return r}function lo(e,t,n,r=200,i=Qa,a=12){let o=new Map,s=new Map;for(let r of e){if(r.ts_ms>n)break;let e=Ja(r);if(!t(e,r.ts_ms))continue;let i=o.get(e);i?i.push(r):o.set(e,[r]);let a=s.get(e);(a===void 0||r.ts_ms>a)&&s.set(e,r.ts_ms)}let c=n-i,l=[];for(let[e,t]of s)t<c&&l.push(e);for(let e of l)o.delete(e),s.delete(e);if(o.size>a){let e=new Set(Array.from(s.entries()).sort((e,t)=>t[1]-e[1]).slice(0,a).map(([e])=>e));for(let t of[...o.keys()])e.has(t)||o.delete(t)}let u=[];for(let e of o.values()){let t=e.length>r?e.slice(-r):e;u.push(...t)}return u.sort((e,t)=>e.ts_ms-t.ts_ms),u}function uo(e={}){let t=e.windowMs??12e4,n=De(),[r,i]=(0,_.useState)(()=>({mode:`live`,playhead_ms:Date.now(),window_ms:t})),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{p.current=n.length>0||a.length>0},[n,a]),(0,_.useEffect)(()=>{if(r.mode!==`live`)return;let e=()=>{if(!p.current)return;let e=Date.now();i(t=>t.mode===`live`?t.playhead_ms===e?t:{...t,playhead_ms:e}:t)};e();let t=setInterval(e,500);return()=>clearInterval(t)},[r.mode]);let m=(0,_.useMemo)(()=>oo(a,n),[a,n]),{isBurstActive:h}=Ka(s),g=(0,_.useMemo)(()=>lo(m,h,r.playhead_ms),[m,h,r.playhead_ms]),v=m.length>0?m[0].ts_ms:r.playhead_ms,y=m.length>0?m[m.length-1].ts_ms:r.playhead_ms,b=(0,_.useCallback)(async e=>{if(f.current)return;let t=v,n=Math.min(t,(d.current??Date.now())-e);if(n>=t)return;let r=new AbortController;f.current=r,u(!0);try{let e=await fetch(`/api/json/graph/backfill?since_ms=${n}&until_ms=${t}&limit=500`,{signal:r.signal,credentials:`same-origin`});if(!e.ok)throw Error(`backfill ${e.status}`);let i=await e.json();Array.isArray(i.bursts)&&i.bursts.length>0&&o(e=>{let t=oo(e,i.bursts);return t.length>ao?t.slice(-ao):t}),Array.isArray(i.lifecycle)&&i.lifecycle.length>0&&c(e=>co(e,i.lifecycle)),d.current=n}catch(e){e.name!==`AbortError`&&console.warn(`[graph] backfill failed`,e)}finally{f.current=null,u(!1)}},[v]);(0,_.useEffect)(()=>{r.playhead_ms-v<r.window_ms*.5&&b(Xa)},[r.mode,r.playhead_ms,r.window_ms,v,b]);let x=(0,_.useRef)(!1);(0,_.useEffect)(()=>{x.current||(x.current=!0,b(io))},[]),(0,_.useEffect)(()=>()=>{f.current?.abort(),f.current=null},[]);let S=(0,_.useCallback)(e=>{i(t=>e===`live`?{...t,mode:`live`}:{...t,mode:e})},[]),C=(0,_.useCallback)(e=>{i(t=>({...t,mode:t.mode===`live`?`scrubbing`:t.mode,playhead_ms:e}))},[]),w=(0,_.useCallback)(e=>{i(t=>({...t,window_ms:Math.max(1e3,e)}))},[]),T=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now()}))},[]),E=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now(),window_ms:ro})),b(ro)},[b]);return{snapshot:(0,_.useMemo)(()=>({bursts:g,playback:r,oldest_known_ms:v,newest_known_ms:y,loading_backfill:l}),[g,r,v,y,l]),allBursts:m,setMode:S,setPlayhead:C,setWindow:w,jumpToLive:T,requestBackfill:b,jumpTo24h:E}}var fo=2*Math.PI/6e4,po=2.3999632297286535,mo=16,ho=22,go=.4,_o=14,vo=8,yo=24;function bo(e,t,n){let r=new Map;for(let t of e){if(t.exitingAt!=null)continue;let e=r.get(t.session);e?e.push(t):r.set(t.session,[t])}if(r.size===0)return;for(let e of r.values())e.sort((e,t)=>e.ts_ms-t.ts_ms);let i=Math.min(t,n)-yo,a=Array.from(r.keys()).sort(),o=a.length,s=0;for(let e of r.values())e.length>s&&(s=e.length);let c=Math.max(1,Math.min(ho,(i-mo)/Math.max(1,s-1))),l=mo,u=mo+c,d=(l*l+u*u-_o*_o)/(2*l*u),f=Math.max(go,Math.acos(Math.min(1,Math.max(-1,d))));if(o<=vo)for(let e=0;e<o;e++){let t=a[e];if(t===void 0)continue;let n=r.get(t);if(!n)continue;let i=e*2*Math.PI/o;for(let e=0;e<n.length;e++){let t=n[e];t&&(t.slotPhi=i+e*f,t.slotR=mo+e*c)}}else{let e=[];for(let t of r.values())for(let n of t)e.push(n);e.sort((e,t)=>e.ts_ms-t.ts_ms);let t=Math.max(1,Math.min(ho,(i-mo)/Math.max(1,e.length-1)));for(let n=0;n<e.length;n++){let r=e[n];r&&(r.slotPhi=n*po,r.slotR=mo+n*t)}}}function xo(e,t,n,r){for(let i of e)i.exitingAt??(i.slotR==null||i.slotPhi==null||(i.x=t+i.slotR*Math.cos(i.slotPhi+r),i.y=n+i.slotR*Math.sin(i.slotPhi+r)))}function So(e){let t=new Map;for(let n of e){let e=t.get(n.session);e?(e.x+=n.x,e.y+=n.y,e.n+=1):t.set(n.session,{x:n.x,y:n.y,n:1})}for(let e of t.values())e.x/=e.n,e.y/=e.n;return t}function Co(e,t){let n=[],r=new Map;for(let t of e){let e=r.get(t.session);e?e.push(t):r.set(t.session,[t])}for(let e of r.values()){e.sort((e,t)=>e.ts_ms-t.ts_ms);for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];!i||!a||a.ts_ms-i.ts_ms<=t&&n.push({source:i.id,target:a.id,kind:`session`})}}return n}var wo=`SSG_AUDIO`,To=`SSG_AUDIO_VOLUME`,Eo=12,Do=null,Oo=null,ko=!1,Ao=.18,jo=[],Mo=!1;function No(){if(typeof localStorage>`u`)return{enabled:!1,volume:.18};let e=localStorage.getItem(wo)===`1`,t=localStorage.getItem(To);return{enabled:e,volume:t?Math.max(0,Math.min(1,parseFloat(t))):.18}}function Po(){typeof localStorage>`u`||(localStorage.setItem(wo,ko?`1`:`0`),localStorage.setItem(To,Ao.toString()))}function Fo(){if(typeof window>`u`)return null;if(Do)return Do;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;try{Do=new e,Oo=Do.createGain(),Oo.gain.value=Ao,Oo.connect(Do.destination),typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{Do&&(document.visibilityState===`hidden`?Do.suspend():Do.resume())})}catch{Do=null,Oo=null}return Do}function Io(){if(Mo)return;Mo=!0;let{enabled:e,volume:t}=No();ko=e,Ao=t}function Lo(){return Io(),ko}function Ro(e){if(Io(),ko=e,Po(),e){let e=Fo();e&&e.state===`suspended`&&e.resume()}}function zo(){return Io(),Ao}function Bo(e){Io(),Ao=Math.max(0,Math.min(1,e)),Po(),Oo&&(Oo.gain.value=Ao)}function Vo(e){for(;jo.length>0&&e-jo[0]>1e3;)jo.shift();return jo.length>=Eo?!1:(jo.push(e),!0)}var Ho={allow:{type:`sine`,freq:660,durationMs:90,peak:.6},block:{type:`square`,freq:110,durationMs:130,peak:1},force:{type:`sawtooth`,freq:220,freqSweep:440,durationMs:170,peak:.8},ask:{type:`triangle`,freq:880,durationMs:110,peak:.55},log:{type:`sine`,freq:1320,durationMs:30,peak:.35},shadow:{type:`sine`,freq:220,durationMs:60,peak:.18}};function Uo(e){if(Io(),!ko||typeof document<`u`&&document.visibilityState===`hidden`)return;let t=Fo();if(!t||!Oo)return;t.state===`suspended`&&t.resume().catch(()=>{});let n=t.currentTime;if(!Vo(performance.now()))return;let r=Ho[e],i=t.createOscillator();i.type=r.type,i.frequency.value=r.freq,r.freqSweep!==void 0&&(i.frequency.setValueAtTime(r.freq,n),i.frequency.exponentialRampToValueAtTime(Math.max(1,r.freqSweep),n+r.durationMs/1e3));let a=t.createGain();a.gain.setValueAtTime(0,n),a.gain.linearRampToValueAtTime(r.peak,n+.005),a.gain.exponentialRampToValueAtTime(1e-4,n+r.durationMs/1e3),i.connect(a),a.connect(Oo),i.start(n),i.stop(n+r.durationMs/1e3+.05),i.onended=()=>{try{i.disconnect(),a.disconnect()}catch{}}}function Wo(e){let t=e|0;return()=>{t=t+1831565813|0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var Go={"claude-code":`C`,"claude-code-ide":`C`,cursor:`>`,copilot:`H`,codex:`X`,pi:`P`,gemini:`G`,antigravity:`A`};function Ko(e){return Go[e.toLowerCase()]??`.`}function qo(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)|0;return(t>>>0)%360}function Jo(e,t,n){for(let[r,i]of t){let{x:t,y:a,n:o}=i,s=50+Math.min(o,12)*7,c=qo(r),l=n.get(r),u;l&&Math.abs(l.x-t)<2&&Math.abs(l.y-a)<2&&l.r===s?u=l.grad:(u=e.createRadialGradient(t,a,0,t,a,s),u.addColorStop(0,`hsla(${c},80%,55%,0.10)`),u.addColorStop(1,`hsla(${c},80%,55%,0)`),n.set(r,{grad:u,x:t,y:a,r:s})),e.fillStyle=u,e.beginPath(),e.arc(t,a,s,0,Math.PI*2),e.fill()}for(let e of n.keys())t.has(e)||n.delete(e)}function Yo(e,t,n,r,i,a,o){let s=8+a*r,c=Math.max(0,1-r)*o;c<=0||(e.save(),e.globalAlpha=c,e.fillStyle=i,e.beginPath(),e.arc(t,n,s,0,Math.PI*2),e.fill(),e.restore())}var Xo=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,Zo=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,Qo=new Map,$o=256;function es(e,t){let n=Qo.get(t);if(n!==void 0)return n;let r=e.measureText(t).width;if(Qo.size>=$o){let e=Qo.keys().next().value;e!==void 0&&Qo.delete(e)}return Qo.set(t,r),r}function ts(e,t,n,r,i,a,o){let s=(r.split(`:`)[0]??r).slice(0,18),c=Ko(s),l=qo(r),u=Ya[o]??`#6b7280`;e.save(),e.textAlign=`center`;let d=`[${c}] ${s}`,f=`${i.length>14?i.slice(0,14):i} · ${a}`;e.font=Zo;let p=es(e,d);e.font=Xo;let m=es(e,f),h=Math.max(p,m)+10;e.globalAlpha=.82,e.fillStyle=`hsla(${l},25%,5%,0.92)`,e.fillRect(t-h/2,n-2,h,28),e.globalAlpha=.92,e.fillStyle=`hsla(${l},78%,70%,1)`,e.font=Zo,e.fillText(d,t,n+10),e.globalAlpha=.72,e.fillStyle=u,e.font=Xo,e.fillText(f,t,n+21),e.restore()}var ns=`bold 13px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,rs=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;function is(e){if((!Number.isFinite(e)||e<0)&&(e=0),e<6e4)return`${(e/1e3).toFixed(3)}s`;if(e<36e5)return`${Math.floor(e/6e4)}:${(e%6e4/1e3).toFixed(3).padStart(6,`0`)}`;let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),r=(e%6e4/1e3).toFixed(1).padStart(4,`0`);return`${t}:${String(n).padStart(2,`0`)}:${r}`}function as(e,t,n,r,i){e.save(),e.textAlign=`center`,e.font=rs,e.globalAlpha=.7,e.fillStyle=`hsla(${i},78%,72%,0.55)`,e.fillText(`uptime`,t,n),e.font=ns,e.globalAlpha=.96,e.fillStyle=`hsla(${i},78%,82%,1)`,e.fillText(is(r),t,n+13),e.restore()}function os(e,t,n,r){e.save(),e.textAlign=`right`,e.font=rs,e.fillStyle=`rgba(148, 163, 184, 0.55)`,e.globalAlpha=.85,e.fillText(`LIVE`,t,n),e.font=`bold 16px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,e.fillStyle=`#e0e7ff`,e.globalAlpha=.92,e.fillText(is(r),t,n+16),e.restore()}function ss(e,t,n,r,i,a,o){let s=r-t,c=i-n;if(Math.sqrt(s*s+c*c)<24)return;let l=Math.atan2(c,s),u=3.5,d=r-Math.cos(l)*9,f=i-Math.sin(l)*9;e.save(),e.globalAlpha=o*.85,e.fillStyle=a,e.translate(d,f),e.rotate(l),e.beginPath(),e.moveTo(0,0),e.lineTo(-6,-u),e.lineTo(-6,u),e.closePath(),e.fill(),e.restore()}var cs={Read:`▣`,Write:`✎`,Edit:`✎`,MultiEdit:`✎`,NotebookEdit:`✎`,NotebookRead:`▣`,Glob:`✦`,Grep:`✦`,LS:`⊞`,Find:`✦`,ToolSearch:`⊕`,Bash:`$`,Skill:`◈`,WebFetch:`⌬`,WebSearch:`⌬`,Agent:`◇`,Task:`⌘`,TaskCreate:`⌘`,TaskUpdate:`⌘`,TaskList:`⌘`,TaskGet:`⌘`,TaskOutput:`⌘`,TaskStop:`⌘`,TodoWrite:`✓`,TodoRead:`✓`,AskUserQuestion:`?`,EnterPlanMode:`◐`,ExitPlanMode:`◑`,EnterWorktree:`⎇`,ExitWorktree:`⎇`,PushNotification:`⏰`,ScheduleWakeup:`⏰`,CronCreate:`⏰`,CronList:`⏰`,CronDelete:`⏰`,RemoteTrigger:`↗`,Monitor:`◉`};function ls(e){if(!e)return`·`;let t=e.lastIndexOf(`__`);return cs[t>=0?e.slice(t+2):e]??cs[e]??`·`}var us=820,ds=e=>Math.min(1,e),fs=620,ps=e=>1-(1-e)**3,ms=Qe({stiffness:120,damping:22,mass:1}),hs=1800;function gs(e){return e<=2?Math.min(window.devicePixelRatio,2):e<=4?Math.min(window.devicePixelRatio,1.5):Math.min(window.devicePixelRatio,1)}function _s(e){return e<=2?1:e<=4?2:3}function vs(e){return e<=2?24:e<=4?12:6}function ys(e){return e<=4}var bs=!1,xs=!1;function Ss(){if(xs||typeof window>`u`)return;xs=!0;let e=navigator;typeof e.getBattery==`function`&&e.getBattery().then(e=>{let t=()=>{bs=!e.charging&&e.level<.2};t(),e.addEventListener(`chargingchange`,t),e.addEventListener(`levelchange`,t)}).catch(()=>{})}function Cs(){return typeof window>`u`?!1:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||navigator.connection?.saveData?!0:bs}var ws=typeof window<`u`&&new URLSearchParams(window.location.search).get(`fullrate`)===`1`,Ts=typeof window<`u`&&new URLSearchParams(window.location.search).get(`rotate`)!==`0`,Es=typeof window<`u`&&new URLSearchParams(window.location.search).get(`probe`)===`1`;function Ds(e,t,n,r){let i=new Map;for(let t of e)i.set(t.id,t);let a=new Set,o=[];for(let e=0;e<t.length;e++){let s=t[e],c=s.audit_id??`${s.ts_ms}:${s.tool}:${e}`;a.add(c);let l=i.get(c);if(l)l.burst=s,l.exitingAt=void 0,o.push(l);else{let t=Wo(s.ts_ms^e),i=n*.6+(t()-.5)*60,a=r/2+(t()-.5)*40,l=Ja(s);o.push({id:c,burst:s,ts_ms:s.ts_ms,session:l,x:i,y:a,vx:0,vy:0,age:0,tx:i,ty:a})}}let s=performance.now();for(let t of e)a.has(t.id)||(t.exitingAt??=s,s-t.exitingAt<1200&&o.push(t));return o}function Os(e){let{bursts:t,paused:n,selectedId:r,onSelect:i,burstSeq:a,compact:o=!1,activePanelCount:s=1,labelDensity:c=`normal`,onFrameTime:l}=e,u=(0,_.useRef)(l);u.current=l;let d=(0,_.useRef)(c);d.current=c;let f=(0,_.useRef)(null),p=(0,_.useRef)([]),m=(0,_.useRef)([]),h=(0,_.useRef)(null),g=(0,_.useRef)(null),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(0),x=(0,_.useRef)(new Map),S=(0,_.useRef)(new Set),C=(0,_.useRef)(new Set),w=(0,_.useRef)(new Set),[T,E]=(0,_.useState)({w:0,h:0}),D=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(null),A=(0,_.useRef)(Date.now()),j=(0,_.useRef)(new Map),M=(0,_.useRef)({frame:0,cache:null});(0,_.useLayoutEffect)(()=>{let e=f.current?.parentElement;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&E({w:Math.max(40,t.width),h:Math.max(40,t.height)});let n=new ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t.contentRect;e<=0||n<=0||E({w:Math.max(40,e),h:Math.max(40,n)})}});return n.observe(e),()=>n.disconnect()},[]),(0,_.useEffect)(()=>{if(T.w<=0||T.h<=0)return;M.current.frame=0;let e=new Map;for(let t of p.current)e.set(t.id,t);p.current=Ds(p.current,t,T.w,T.h),bo(p.current,T.w/2,T.h/2);let n=Ts&&!ot()?performance.now()*fo:0;for(let t of p.current){if(t.slotR==null||t.slotPhi==null)continue;let r=T.w/2+t.slotR*Math.cos(t.slotPhi+n),i=T.h/2+t.slotR*Math.sin(t.slotPhi+n),a=!e.has(t.id),o=Math.hypot(t.x-r,t.y-i);(a||o>40)&&(t.x=r,t.y=i,t.vx=0,t.vy=0)}if(m.current=Co(p.current,1/0),!ot())for(let t=0;t<p.current.length;t++){let n=p.current[t];!n||e.has(n.id)||Uo(n.burst.decision)}let r=p.current.reduce((e,t)=>t.ts_ms>e?t.ts_ms:e,0);y.current=Math.max(performance.now()+us,performance.now()+Za,r+1500),v.current=performance.now()},[t,T.w,T.h,a]),(0,_.useEffect)(()=>{let e=f.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;Ss();let i=performance.now(),a=0,c=0,l=0,g=.1,[_,E]=vr(()=>{let f=performance.now();if(!ws&&Cs()){if(a^=1,a===1)return}else a!==0&&(a=0);if(!ws){let e=_s(s);if(e>1&&(O.current=(O.current+1)%e,O.current!==0))return}let _=performance.now(),E=_<y.current,D=_-v.current<200,N=_-b.current>500,ee=ot(),te=Ts&&!ee;if(!te&&!E&&!D&&!N)return;b.current=_;let P=f,F=Math.min(50,P-i);i=P;let ne=p.current,re=m.current,ie=te?performance.now()*fo:0;xo(ne,T.w/2,T.h/2,ie);for(let e of ne)e.age<1&&(e.age=Math.min(1,e.age+F/us));let I=typeof window<`u`?gs(s):1,L=T.w,R=T.h;(e.width!==L*I||e.height!==R*I)&&(e.width=L*I,e.height=R*I,e.style.width=`${L}px`,e.style.height=`${R}px`,t.scale(I,I)),t.fillStyle=`#0a0a0f`,t.fillRect(0,0,L,R);let z=`${L}x${R}`,ae=k.current?.key===z?k.current.grad:null;if(ae||(ae=t.createRadialGradient(L/2,R/2,0,L/2,R/2,Math.max(L,R)/1.2),ae.addColorStop(0,`rgba(56, 189, 248, 0.06)`),ae.addColorStop(1,`rgba(0, 0, 0, 0)`),k.current={key:z,grad:ae}),t.fillStyle=ae,t.fillRect(0,0,L,R),!o){let e=M.current;(e.frame++%6==0||e.cache===null)&&(e.cache=So(ne));let n=e.cache;if(Jo(t,n,j.current),!ee){let e=new Map,r=new Map;for(let t of ne)t.exitingAt??(r.set(t.session,(r.get(t.session)??0)+1),e.set(t.session,t));let i=new Map;for(let e of ne){if(e.exitingAt!=null)continue;let t=i.get(e.session);(t===void 0||e.ts_ms<t)&&i.set(e.session,e.ts_ms)}let a=Date.now();for(let[o,s]of n){let n=e.get(o),c=r.get(o)??0;if(!n||c===0)continue;let l=50+Math.min(s.n,12)*7;ts(t,s.x,s.y-l-34,o,n.burst.tool,c,n.burst.decision);let u=i.get(o);if(u!==void 0){let e=Math.max(0,a-u);as(t,s.x,s.y+l+12,e,qo(o))}}}}let oe=e=>e.exitingAt==null?1:Math.max(0,1-(P-e.exitingAt)/Za),se=vs(s),ce=ys(s)&&!ee,le=S.current;if(le.clear(),n)for(let e of ne)le.add(e.id);else{let e=0;for(let t=ne.length-1;t>=0&&e<se;t--){let n=ne[t];!n||n.exitingAt!=null||(le.add(n.id),e++)}}let ue=x.current;ue.clear();for(let e of ne)ue.set(e.id,e);t.lineWidth=2,t.lineCap=`round`,t.lineJoin=`round`;for(let e=0;e<re.length;e++){let n=re[e],r=ue.get(n.source),i=ue.get(n.target);if(!r||!i||le.has(r.id)||le.has(i.id))continue;let a=Math.max(oe(r),oe(i));a<=0||(t.globalAlpha=a,t.strokeStyle=(Ya[i.burst.decision]??`#6b7280`)+`aa`,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(i.x,i.y),t.stroke())}t.globalAlpha=1;let de=d.current===`large`,fe=de?`10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`8px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;for(let e=0;e<re.length;e++){let n=re[e],r=ue.get(n.source),i=ue.get(n.target);if(!r||!i||!le.has(r.id)&&!le.has(i.id))continue;let a=Ya[i.burst.decision]??`#6b7280`,o=Math.max(oe(r),oe(i));if(o<=0)continue;let s=ds(i.age),c=r.x+(i.x-r.x)*s,l=r.y+(i.y-r.y)*s;if(t.globalAlpha=o,t.strokeStyle=a+`aa`,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(c,l),t.stroke(),t.globalAlpha=1,ce){let n=Math.min(s,(P/hs+e*.618033)%1),u=r.x+(i.x-r.x)*n,d=r.y+(i.y-r.y)*n;t.save(),t.globalAlpha=o*Math.sin(n*Math.PI)*.9,t.fillStyle=a,t.beginPath(),t.arc(u,d,2.5,0,Math.PI*2),t.fill(),t.restore(),ss(t,r.x,r.y,c,l,a,o)}let u=i.ts_ms-r.ts_ms,d=u<1e3?`${u}ms`:u<6e4?`${(u/1e3).toFixed(1)}s`:`${Math.floor(u/6e4)}m${Math.floor(u%6e4/1e3)}s`,f=(r.x+c)/2,p=(r.y+l)/2;t.save(),t.globalAlpha=o*.65*s,t.font=fe,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(`${e+1} · ${d}`,f,p-(de?8:7)),t.restore()}t.globalAlpha=1;let pe=C.current;pe.clear();let me=w.current;me.clear();let he=d.current===`large`?10:5;{let e=0;for(let t=ne.length-1;t>=0;t--){let r=ne[t];!r||r.exitingAt!=null||(!n&&e<3&&pe.add(r.id),e<he&&me.add(r.id),e++)}}let ge=r,_e=h.current;for(let e of ne){let r=oe(e);if(r<=0)continue;t.globalAlpha=r;let i=Math.min(1,e.age),a=ds(i);e.displayedRadius=o?4:eo(e.burst);let s=e.displayedRadius,c=o?s*a:(s+2*Math.min(1,e.age))*a,l=Ya[e.burst.decision]??`#6b7280`,u=no(l,to(e.burst));if((e.id===ge||e.id===_e)&&(t.beginPath(),t.arc(e.x,e.y,c+6,0,Math.PI*2),t.fillStyle=u+`33`,t.fill()),ce&&(e.burst.decision===`allow`?Yo(t,e.x,e.y,i,`#22c55e`,14,.3):e.burst.decision===`ask`&&Yo(t,e.x,e.y,i,`#f59e0b`,14,.45)),ce&&(e.burst.decision===`block`||e.burst.decision===`force`)){let n=i*us;if(n<fs){let r=n/fs,i=c+16*ps(r),a=Math.max(0,1-r)*.75;t.beginPath(),t.arc(e.x,e.y,i,0,Math.PI*2),t.strokeStyle=u+Math.floor(a*255).toString(16).padStart(2,`0`),t.lineWidth=1.5,t.stroke()}}if(!ee&&pe.has(e.id)&&(t.beginPath(),t.arc(e.x,e.y,c+2,0,Math.PI*2),t.fillStyle=u+`33`,t.fill()),t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.fillStyle=u,t.fill(),t.strokeStyle=l,t.lineWidth=1.5,t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.stroke(),me.has(e.id)&&(n||le.has(e.id))){let n=d.current===`large`;t.font=n?`11px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.textAlign=`center`,t.fillStyle=u+`cc`,t.fillText(Ko(e.burst.client),e.x,e.y-c-(n?4:3));let i=n?16:12,a=e.burst.tool.length>i?e.burst.tool.slice(0,i):e.burst.tool,o=ls(e.burst.tool),s=o===`·`?a:`${o} ${a}`;t.fillStyle=u+`88`,t.fillText(s,e.x,e.y+c+(n?13:11));let l=e.burst.input_tokens??0,f=e.burst.output_tokens??0;(l>0||f>0)&&(t.globalAlpha=r*(le.has(e.id)?.8:.35),t.font=n?`10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`8px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.fillText(`↓${Z(l)} ↑${Z(f)}`,e.x,e.y+c+(n?25:21)),t.globalAlpha=r),t.textAlign=`left`}(e.id===ge||e.id===_e)&&(t.font=`11px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.fillStyle=`#e0e7ff`,t.fillText(e.burst.tool,e.x+c+6,e.y+3))}if(t.globalAlpha=1,ce&&ne.length>0){let e=null;for(let t=ne.length-1;t>=0;t--)if(ne[t].exitingAt==null){e=ne[t];break}let n=e?Date.now()-e.ts_ms:1/0,r=5e3;if(e&&n<=r){let i=Math.max(0,1-n/r),a=1100,o=P%a/a,s=14+ms.fn(o)*8,c=Math.max(0,1-o)*.85*i,l=Math.floor(c*255).toString(16).padStart(2,`0`);t.beginPath(),t.arc(e.x,e.y,s,0,Math.PI*2),t.strokeStyle=`#38bdf8${l}`,t.lineWidth=2,t.stroke();let u=P%800/800*Math.PI*2,d=100/360*Math.PI*2,f=.85*i,p=Math.floor(f*255).toString(16).padStart(2,`0`);t.save(),t.beginPath(),t.arc(e.x,e.y,22,u,u+d),t.strokeStyle=`#38bdf8${p}`,t.lineWidth=2.5,t.lineCap=`round`,t.stroke(),t.restore()}}if(!o&&L>220&&os(t,L-12,12,Date.now()-A.current),Es){let t,n=0;for(let e of ne)e.exitingAt??(n++,t||=e);e.dataset.probeCount=String(n),e.dataset.probeX0=(t?.x??0).toFixed(2),e.dataset.probeY0=(t?.y??0).toFixed(2)}c=c===0?F:c*(1-g)+F*g;let ve=u.current;ve&&P-l>250&&(l=P,ve(c))});return D.current=E,O.current=E,_},[n,r,T.w,T.h,o,s]);function N(e,t){let n=f.current;if(!n)return null;let r=n.getBoundingClientRect(),i=e-r.left,a=t-r.top,o=null,s=200;for(let e of p.current){let t=e.x-i,n=e.y-a,r=t*t+n*n;r<s&&(s=r,o=e.id)}return o}return(0,K.jsxs)(`div`,{className:`relative w-full h-full rounded-sm border border-[var(--color-line-1)] overflow-hidden bg-black`,children:[(0,K.jsx)(`canvas`,{ref:f,className:`block w-full h-full cursor-crosshair`,onMouseMove:e=>{let t=N(e.clientX,e.clientY);h.current=t;let n=g.current;if(!n)return;if(!t){n.style.display=`none`;return}let r=p.current.find(e=>e.id===t);if(!r){n.style.display=`none`;return}let i=r.burst,a=Ya[i.decision]??`#6b7280`,o;if(i.complete_duration_ms!=null&&i.complete_duration_ms>0){let e=i.complete_duration_ms;o=e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(0)}ms`}else{let e=i.duration_ns/1e6;o=e<1?`${(e*1e3).toFixed(0)}µs`:`${e.toFixed(1)}ms`}let s=[];i.input_tokens!=null&&s.push(`↓${Z(i.input_tokens)}`),i.output_tokens!=null&&s.push(`↑${Z(i.output_tokens)}`);let c=i.input_preview?` · "${i.input_preview.length>45?i.input_preview.slice(0,45)+`…`:i.input_preview}"`:``,l=s.length>0?` · ${s.join(` `)}`:``;n.textContent=`${i.decision} ${i.tool} · ${o}${l}${c}`,n.style.borderColor=a,n.style.color=a;let u=Math.min(e.clientX+14,window.innerWidth-420),d=Math.max(8,e.clientY-36);n.style.left=`${u}px`,n.style.top=`${d}px`,n.style.display=`block`},onMouseLeave:()=>{h.current=null,g.current&&(g.current.style.display=`none`)},onClick:e=>{i(N(e.clientX,e.clientY),{x:e.clientX,y:e.clientY})}}),t.length===0&&(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none px-4 text-center`,children:[(0,K.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`graph · idle`}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[260px]`,children:[`Each dot = one tool call an AI agent made.`,(0,K.jsx)(`br`,{}),`Color = the ssg rule decision · line = same agent's sequence.`]})]}),(0,K.jsx)(`div`,{ref:g,style:{display:`none`,position:`fixed`,zIndex:45,fontSize:`11px`,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,padding:`4px 10px`,background:`rgba(10, 10, 15, 0.92)`,border:`1px solid`,borderRadius:`4px`,pointerEvents:`none`,whiteSpace:`nowrap`,maxWidth:`500px`,overflow:`hidden`,textOverflow:`ellipsis`}})]})}var ks=3e4,As=6e4,js=5e3;function Ms(e,t){let n=t?e.filter(e=>Ja(e)===t):e,r=Date.now(),i=n.length>0?n[n.length-1]:null;if(!i||r-i.ts_ms>js||!i)return{idle:!0,client:``,tool:``,ruleId:null,decision:``,evalsPerSec:`0.0`,allowPct:0,agents:0,topRules:[]};let a=n.filter(e=>r-e.ts_ms<=ks),o=a.filter(e=>e.decision===`allow`).length,s=a.length>0?Math.round(o/a.length*100):0,c=(a.length/(ks/1e3)).toFixed(1),l=new Set(a.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size,u=n.filter(e=>r-e.ts_ms<=As&&e.rule_id),d=new Map;for(let e of u){let t=e.rule_id;t&&d.set(t,(d.get(t)??0)+1)}let f=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,4).map(([e])=>e);return{idle:!1,client:i.client,tool:i.tool,ruleId:i.rule_id,decision:i.decision,evalsPerSec:c,allowPct:s,agents:l,topRules:f}}var Ns={allow:`ALLOW`,block:`BLOCK`,ask:`ASK`,log:`LOG`,force:`FORCE`,shadow:`SHADOW`},Ps={allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`};function Fs({className:e,sessionKey:t}){let n=De(),r=Oe(),i=(0,_.useRef)(-1),a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>{if(i.current===r&&a.current)return a.current;i.current=r;let e=Ms(n,t);return a.current=e,e},[n,r,t]),s=o.decision?Ps[o.decision]??`#6b7280`:`#6b7280`,c=o.decision?Ns[o.decision]??o.decision:``,l=o.client?Ko(o.client):``;return o.idle?(0,K.jsxs)(`div`,{className:G(`pointer-events-none select-none`,`flex items-center justify-center gap-2`,`px-4 py-2 rounded-sm`,`bg-[#0a0a0f]/95`,`border border-[var(--color-line-1,#242424)]`,`font-mono text-[11px] text-[var(--color-fg-4,#5a6071)]`,e),children:[(0,K.jsx)(`span`,{className:`status-dot bg-[var(--color-fg-4)] pulse-soft`}),(0,K.jsx)(`span`,{className:`uppercase tracking-wider`,children:`waiting for activity`})]}):(0,K.jsxs)(`div`,{className:G(`pointer-events-none select-none`,`flex flex-col gap-1 px-4 py-2.5 rounded-sm`,`bg-[#0a0a0f]/96`,`border border-[var(--color-line-1,#242424)]`,`font-mono`,!t&&`min-w-[280px] max-w-[460px]`,e),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest text-[var(--color-fg-4,#5a6071)]`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),(0,K.jsx)(`span`,{children:`now evaluating`}),(0,K.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[o.evalsPerSec,`/s · `,o.allowPct,`% allow · `,o.agents,` `,o.agents===1?`agent`:`agents`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px] text-[var(--color-fg-0,#f5f5f5)] tracking-tight`,children:[(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)] text-[11px] tabular-nums`,children:[`[`,l,`]`]}),(0,K.jsx)(`span`,{className:`text-sky-300`,children:o.client}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-white font-semibold`,children:o.tool}),o.ruleId&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`->`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] text-[12px]`,children:o.ruleId})]}),(0,K.jsx)(`span`,{className:`ml-auto text-[13px] font-bold tabular-nums`,style:{color:s},children:c})]}),o.topRules.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-[var(--color-fg-4)]`,children:[(0,K.jsx)(`span`,{className:`uppercase tracking-wider text-[9px]`,children:`rules`}),o.topRules.map(e=>(0,K.jsx)(`span`,{className:`px-1 py-0.5 rounded-sm bg-[var(--color-surface-2,#121212)] text-[var(--color-fg-3)]`,children:e},e))]})]})}var Is=(0,_.memo)(function({sessionKey:e,bursts:t,activePanelCount:n,selectedId:r,onSelect:i}){let a=t.length>0?t[t.length-1]?.ts_ms??0:0,o=e.indexOf(`:`),s=o>=0?e.slice(0,o):e,c=o>=0?e.slice(o+1):``,l=c!==``&&c!==`solo`,u=t[t.length-1],d=u?Ya[u.decision]??`#6b7280`:`#6b7280`,f=(0,_.useMemo)(()=>t.length>24?t.slice(t.length-24):t,[t]);return(0,K.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 rounded-sm border border-[var(--color-line-1)] bg-black/30 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-[var(--color-line-1)] text-[10px] font-mono shrink-0`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:d},title:u?`latest decision: ${u.decision}`:``}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider truncate`,children:s}),l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate`,children:c})]}),(0,K.jsxs)(`span`,{className:`ml-auto text-[var(--color-fg-4)] tabular-nums shrink-0`,children:[t.length,`n`]})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,K.jsx)(Os,{bursts:f,paused:!1,selectedId:r,onSelect:i,burstSeq:a,compact:!0,activePanelCount:n})})]})});function Ls(e){return e<=1?1:e<=4?2:3}function Rs(){let e=De(),t=Oe(),[n,r]=(0,_.useState)(null),{isBurstActive:i}=Ka(),a=(0,_.useMemo)(()=>lo(e,i,Date.now()),[e,i,t]),o=(0,_.useRef)(new Map),s=(0,_.useMemo)(()=>{let e=new Map;for(let t of a){let n=Ja(t),r=e.get(n);r?r.push(t):e.set(n,[t])}let t=o.current;for(let[n,r]of e){let i=t.get(n);i&&i.length===r.length&&i[i.length-1]===r[r.length-1]&&e.set(n,i)}return o.current=e,Array.from(e.entries()).sort((e,t)=>{let n=e[1][e[1].length-1]?.ts_ms??0;return(t[1][t[1].length-1]?.ts_ms??0)-n})},[a]),c=(0,_.useMemo)(()=>{let e=new Map;for(let t of a){let n=`${t.client}:${t.agent_id??`solo`}`,r=e.get(n);r?r.count+=1:e.set(n,{client:t.client,count:1})}return e},[a]),l=(0,_.useMemo)(()=>{let e={allow:0,block:0,ask:0,other:0};for(let t of a)t.decision===`allow`?e.allow++:t.decision===`block`||t.decision===`force`?e.block++:t.decision===`ask`?e.ask++:e.other++;return e},[a]),u=(0,_.useMemo)(()=>{let e=new Set,t=0;for(let n of a)n.rule_id&&(e.add(n.rule_id),t+=1);return{distinct:e.size,matched:t,topRule:e.values().next().value}},[a]),d=Ls(s.length);return(0,K.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-line-1)]`,children:[(0,K.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`graph · live`}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),a.length]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-mono`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Ya.allow}}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.allow}),(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ml-1`,style:{background:Ya.block}}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.block}),(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ml-1`,style:{background:Ya.ask}}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.ask})]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(`span`,{className:`chip text-violet-300 border-violet-500/30`,title:`${u.matched} tool calls matched ${u.distinct} ssg ${u.distinct===1?`rule`:`rules`} in active sessions`,children:[u.distinct,` `,u.distinct===1?`rule`:`rules`]}),(0,K.jsxs)(`span`,{className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)]`,title:c.size===0?`no active agents`:Array.from(c.entries()).map(([e,t])=>`${e}: ${t.count}`).join(`
10
- `),children:[c.size,` `,c.size===1?`agent`:`agents`]}),(0,K.jsx)(`a`,{href:`/graph`,className:`text-[10px] font-mono uppercase tracking-wider text-sky-300 hover:text-sky-200`,title:`Open full /graph page`,children:`expand ↗`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[s.length===0?(0,K.jsx)(Os,{bursts:a,paused:!1,selectedId:n,onSelect:r,burstSeq:t}):(0,K.jsx)(`div`,{className:`absolute inset-0 grid gap-1 p-1`,style:{gridTemplateColumns:`repeat(${d}, minmax(0, 1fr))`,gridAutoRows:`1fr`},children:s.map(([e,t])=>(0,K.jsx)(Is,{sessionKey:e,bursts:t,activePanelCount:s.length,selectedId:n,onSelect:r},e))}),(0,K.jsx)(Fs,{className:`absolute bottom-2 left-2 z-10 max-w-[calc(100%-1rem)]`})]})]})}var zs=`ssg.sfx.enabled`;function Bs(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(zs)===`true`}catch{return!1}}function Vs(e){if(!(typeof window>`u`))try{window.localStorage.setItem(zs,String(e))}catch{}}function Hs(e,t,n,r,i,a,o=`sine`){try{let s=e.createOscillator(),c=e.createGain(),l=i/1e3;s.type=o,s.frequency.setValueAtTime(n,e.currentTime),s.frequency.exponentialRampToValueAtTime(Math.max(1,r),e.currentTime+l),c.gain.setValueAtTime(a,e.currentTime),c.gain.exponentialRampToValueAtTime(.001,e.currentTime+l),s.connect(c),c.connect(t),s.start(e.currentTime),s.stop(e.currentTime+l+.02)}catch{}}function Us(){let[e,t]=(0,_.useState)(Bs),n=(0,_.useRef)(null),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=()=>{let t=n.current;t&&(document.hidden?t.suspend().catch(()=>{}):e&&t.resume().catch(()=>{}))};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e]),{enabled:e,toggle:(0,_.useCallback)(()=>{t(e=>{let t=!e;if(Vs(t),t){if(!n.current)try{let e=new AudioContext,t=e.createGain();t.gain.value=.8,t.connect(e.destination),n.current=e,r.current=t}catch{}n.current?.resume().catch(()=>{})}else n.current?.suspend().catch(()=>{});return t})},[]),play:(0,_.useCallback)(t=>{if(!e)return;let i=n.current,a=r.current;if(!(!i||!a||i.state===`suspended`))switch(t){case`block`:Hs(i,a,110,55,150,.08);break;case`force`:Hs(i,a,80,40,200,.1),Hs(i,a,160,80,200,.05,`square`);break;case`milestone`:{Hs(i,a,660,880,100,.06);let e=i,t=a;setTimeout(()=>{e.state!==`suspended`&&Hs(e,t,880,1320,100,.05)},115);break}case`record`:Hs(i,a,880,1320,350,.07);break}},[e])}}var Ws=[`rules-changed`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`],Gs={critical:{border:`border-l-red-500/70`,iconBg:`bg-red-500/15`,iconFg:`text-red-400`,chipBg:`bg-red-500/10`,chipFg:`text-red-300`,label:`Critical`},warning:{border:`border-l-amber-400/70`,iconBg:`bg-amber-500/15`,iconFg:`text-amber-300`,chipBg:`bg-amber-500/10`,chipFg:`text-amber-200`,label:`Heads up`},info:{border:`border-l-sky-500/70`,iconBg:`bg-sky-500/15`,iconFg:`text-sky-300`,chipBg:`bg-sky-500/10`,chipFg:`text-sky-200`,label:`Tip`}};function Ks({severity:e}){return e===`critical`?(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,K.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,K.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}):e===`warning`?(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,K.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}):(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,K.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`12`}),(0,K.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`})]})}function qs({notification:e,onAction:t}){let[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(null),o=Gs[e.severity],s=async()=>{if(e.action&&!(e.action.confirm&&!confirm(e.action.confirm))){r(`loading`),a(null);try{await t(e),r(`done`)}catch(e){r(`error`),a(e instanceof Error?e.message:String(e))}}};return(0,K.jsxs)(`div`,{className:`hig-card border-l-2 ${o.border} flex items-start gap-3 px-3 py-2.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0 mt-0.5 inline-flex items-center justify-center w-6 h-6 rounded-full ${o.iconBg} ${o.iconFg}`,"aria-hidden":!0,children:(0,K.jsx)(Ks,{severity:e.severity})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-[9px] font-mono font-medium uppercase tracking-wider px-1.5 py-0.5 rounded ${o.chipBg} ${o.chipFg}`,children:o.label}),(0,K.jsx)(`h3`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-tight`,children:e.title})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:e.detail}),n===`error`&&i&&(0,K.jsxs)(`p`,{className:`mt-1.5 text-[11px] font-mono text-red-300`,children:[`Failed: `,i]}),n===`done`&&(0,K.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-emerald-300`,children:`✓ Done — refreshing…`})]}),(0,K.jsx)(`div`,{className:`shrink-0 self-center`,children:e.action?(0,K.jsx)(`button`,{type:`button`,onClick:s,disabled:n===`loading`||n===`done`,className:`inline-flex items-center gap-1 h-8 px-3 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-[var(--color-surface-2)] text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:bg-[var(--color-surface-3)] hover:border-[var(--color-line-2)] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:n===`loading`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`animate-spin`,children:`⟳`}),` working…`]}):n===`done`?(0,K.jsx)(K.Fragment,{children:`✓ done`}):e.action.label}):e.link?(0,K.jsxs)(`a`,{href:e.link.href,className:`inline-flex items-center gap-1 h-8 px-3 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-[var(--color-surface-2)] text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:bg-[var(--color-surface-3)] hover:border-[var(--color-line-2)] transition-colors whitespace-nowrap`,children:[e.link.label,` →`]}):null})]})}function Js({showEmptyState:e=!1,hideHeader:t=!1}={}){let n=ke(Ws),{data:r,refetch:i}=V(`/api/json/maintenance`,[n[`rules-changed`],n[`activity-updated`],n[`pending-changed`],n[`runtime-tick`],n[`limits-breach`]]),a=async e=>{if(!e.action)return;let t=await fetch(e.action.url,{method:e.action.method,headers:{Accept:`application/json`,"Content-Type":`application/json`,...B()}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(e||`HTTP ${t.status}`)}setTimeout(()=>i(),600)},o=r?.notifications??[];return o.length===0&&!e?null:(0,K.jsxs)(`section`,{"data-reveal":!0,children:[!t&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h2`,{className:`overline text-[11px]`,children:o.length===0?`maintenance · all clear`:`maintenance · ${o.length} item${o.length===1?``:`s`}`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] transition-colors cursor-pointer`,title:`Re-check now`,children:`refresh`})]}),o.length===0?(0,K.jsxs)(`div`,{className:`hig-card border-l-2 border-l-emerald-500/60 px-4 py-5 flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-8 h-8 rounded-full bg-emerald-500/15 text-emerald-300 shrink-0`,children:(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M20 6L9 17l-5-5`})})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-tight`,children:`Everything looks good`}),(0,K.jsx)(`p`,{className:`mt-1 text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:`No drift, no capacity warnings, no stalled daemons. We'll let you know if anything changes.`})]})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:o.map(e=>(0,K.jsx)(qs,{notification:e,onAction:a},e.id))})]})}function Ys(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}async function Xs(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:B()})}var Zs=e=>!0,Qs=e=>e.decision===`allow`,$s=e=>e.decision===`block`,ec=e=>e.decision===`ask`,tc=e=>e.decision===`force`,nc=e=>e.decision===`log`;function rc(){let e=new Date;return e.setHours(0,0,0,0),e.getTime()}function ic(){let e=ke([`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`]),t=Ee(),n=Oe(),r=De(),i=Us();(0,_.useEffect)(()=>{t&&(t.decision===`block`?i.play(`block`):t.decision===`force`&&i.play(`force`))},[n]);let[a,o]=(0,_.useState)(()=>rc());(0,_.useEffect)(()=>{let e=()=>{if(document.visibilityState!==`visible`)return;let e=rc();o(t=>e===t?t:e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{data:s}=V(`/api/state/counters?since_ms=${a}`,[e[`counters-updated`],a]),{data:c}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:l}=V(`/api/json/limits`,[e[`runtime-tick`]]),{data:u,refetch:d}=V(`/api/json/pending`,[e[`pending-changed`]]),{data:f}=V(`/api/json/blocked`,[e[`activity-updated`]]),p=Ua(),[m,h]=(0,_.useState)(!1),g=(0,_.useMemo)(()=>{let e=s?.allow??0,n=s?.block??0,r=s?.ask??0,i=s?.log??0,a=s?.force??0,o=e+n+r+i+a,c=t?.counters.total??0;return t&&c>=o&&t?{allow:t.counters.allow,block:t.counters.block,ask:t.counters.ask,log:t.counters.log,force:t.counters.force,shadow:t.counters.shadow,total:t.counters.total}:{allow:e,block:n,ask:r,log:i,force:a,shadow:0,total:o}},[t,s]),v=(0,_.useMemo)(()=>{if(r.length===0)return 0;let e=Date.now()-1e4;return r.filter(t=>t.ts_ms>=e).length/10},[r]),y=c?.history?.cpu_pct??[],b=c?.history?.memory_rss_mb??[],x=[],S=c?.latency,C=(0,_.useMemo)(()=>({"hero-metrics":()=>(0,K.jsx)(`div`,{className:`grid-bleed rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 h-full`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 h-full`,children:[(0,K.jsx)(Or,{label:`Total`,value:g.total,tone:`amber`,sub:t?Ys(t.duration_ns):void 0,burstRing:r,filter:Zs}),(0,K.jsx)(Or,{label:`Allow`,value:g.allow,tone:`green`,burstRing:r,filter:Qs}),(0,K.jsx)(Or,{label:`Block`,value:g.block,tone:`red`,burstRing:r,filter:$s}),(0,K.jsx)(Or,{label:`Ask`,value:g.ask,tone:`amber`,burstRing:r,filter:ec}),(0,K.jsx)(Or,{label:`Force`,value:g.force,tone:`blue`,burstRing:r,filter:tc}),(0,K.jsx)(Or,{label:`Log`,value:g.log,tone:`purple`,burstRing:r,filter:nc})]})}),graph:()=>(0,K.jsx)(Rs,{}),"latency-trace":()=>(0,K.jsx)(Qr,{latency:S,bursts:r,gaugeMaxMs:10,windowMs:3e4,trendWindowSec:60,gaugeSize:200}),throughput:()=>(0,K.jsxs)(q,{className:`h-full`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline`,children:`throughput · evals/s`}),(0,K.jsxs)(sr,{variant:`blue`,children:[v.toFixed(1),`/s`]})]}),(0,K.jsxs)(Y,{children:[(0,K.jsx)(br,{value:v,width:360,height:96,windowMs:6e4,className:`w-full`}),(0,K.jsx)(`p`,{className:`overline mt-2 text-center`,children:`60-second rolling window`})]})]}),"decision-mix":()=>(0,K.jsxs)(q,{className:`h-full`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline`,children:`decision mix`}),(0,K.jsx)(sr,{variant:`gray`,children:g.total.toLocaleString()})]}),(0,K.jsx)(Y,{children:(0,K.jsx)(ti,{counters:{allow:g.allow,block:g.block,ask:g.ask,log:g.log,force:g.force,shadow:g.shadow}})})]}),"telemetry-feed":()=>(0,K.jsxs)(q,{variant:`flush`,className:`h-full flex flex-col`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline`,children:`telemetry · live · newest first`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:[`hover to pause · scroll for history · `,r.length,` events buffered`]})]}),(0,K.jsx)(Y,{className:`p-0 flex-1 min-h-0`,children:(0,K.jsx)(wi,{variant:`decision`,bursts:r,windowSize:80,height:360,className:`border-0 rounded-none`})})]}),"system-pulse":()=>(0,K.jsx)(oi,{cpuPct:c?.cpu_pct??0,cpuSeries:y,cpuLimit:l?.config.cpuLimitPct,memMb:c?.memory_rss_mb??0,memSeries:b,memLimit:l?.config.memoryLimitMb,heapUsedMb:c?.heap_used_mb??0,heapTotalMb:c?.heap_total_mb??0,heapSeries:x,uptimeSec:(c?.uptime_ms??0)/1e3}),"pending-approvals":()=>(0,K.jsxs)(q,{className:`h-full`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline`,children:`pending approvals`}),(0,K.jsx)(sr,{variant:u&&u.length>0?`amber`:`gray`,children:u?.length??0})]}),(0,K.jsx)(Y,{children:u&&u.length>0?(0,K.jsx)(`ul`,{className:`space-y-2`,children:u.slice(0,5).map(e=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-2 border-b border-[var(--color-line-0)] last:border-b-0 py-1.5 text-[12px] font-mono`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`text-[var(--color-fg-1)] truncate`,children:[e.toolCall.tool,` · `,e.ruleId]}),(0,K.jsx)(`div`,{className:`text-[var(--color-fg-3)] text-[11px] truncate`,children:rr(e.toolCall.tool,JSON.stringify(e.toolCall.input??{}))})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,K.jsx)(X,{size:`sm`,variant:`primary`,onClick:()=>Xs(e.id,`allow`).then(d),children:`allow`}),(0,K.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>Xs(e.id,`block`).then(d),children:`block`})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] py-3 text-center`,children:`— no pending approvals —`})})]}),"recent-blocks":()=>(0,K.jsxs)(q,{className:`h-full`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline`,children:`recent blocks & forces`}),(0,K.jsx)(sr,{variant:f&&f.length>0?`red`:`gray`,children:f?.length??0})]}),(0,K.jsx)(Y,{children:f&&f.length>0?(0,K.jsx)(`ul`,{className:`space-y-1.5`,children:f.slice(0,6).map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 text-[12px] font-mono border-b border-[var(--color-line-0)] last:border-b-0 py-1.5`,children:[(0,K.jsx)(sr,{variant:e.decision===`force`?`amber`:`red`,children:e.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate flex-1`,children:rr(e.tool,e.input)}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate text-[11px] max-w-[120px]`,children:e.rule_id??`—`})]},`${e.timestamp}-${t}`))}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] py-3 text-center`,children:`— no recent blocks —`})})]})}),[g,t,r,S,v,c,y,b,x,l,u,f,d]),w=Tt({from:`first`,translateY:22,durationMs:640,staggerMs:80,maxStaggerMs:520});return(0,K.jsxs)(`div`,{ref:m?void 0:w,className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(ia,{manager:p,isEditing:m,onToggleEditing:h})}),(0,K.jsx)(`button`,{type:`button`,onClick:i.toggle,className:`chip cursor-pointer hover:border-sky-500/50 hover:text-sky-300 transition-colors shrink-0`,title:i.enabled?`Mute stream sounds`:`Enable stream sounds`,children:i.enabled?`SFX ON`:`SFX OFF`})]}),(0,K.jsx)(Js,{}),(0,K.jsx)(ra,{panels:p.activeLayout.panels,isEditing:m,renderers:C,onPanelsChange:p.updateActivePanels})]})}var ac=[{path:`/`,aliases:[`dashboard`,`home`,`main`,`top`],selector:`a[href="/"]`},{path:`/agents`,aliases:[`agents`,`agent`,`connected agents`],selector:`a[href="/agents"]`},{path:`/graph`,aliases:[`graph`,`graph view`,`visualisation`,`visualization`],selector:`a[href="/graph"]`},{path:`/rules`,aliases:[`rules`,`rule list`,`policies`],selector:`a[href="/rules"]`},{path:`/hub`,aliases:[`hub`,`rule hub`,`registry`,`marketplace`],selector:`a[href="/hub"]`},{path:`/approvals`,aliases:[`approvals`,`approval queue`,`pending`,`ask queue`,`approvals queue`],selector:`a[href="/approvals"]`},{path:`/audit`,aliases:[`audit`,`activity`,`audit log`,`history`],selector:`a[href="/audit"]`},{path:`/monitor`,aliases:[`monitor`,`live monitor`,`live stream`,`live`],selector:`a[href="/monitor"]`},{path:`/observability`,aliases:[`observability`,`metrics`,`telemetry`,`stats`],selector:`a[href="/observability"]`},{path:`/workspace`,aliases:[`workspace`,`monorepo`,`projects`],selector:`a[href="/workspace"]`},{path:`/setup`,aliases:[`setup`,`setup status`,`install`,`installation`],selector:`a[href="/setup"]`},{path:`/debug`,aliases:[`debug`,`diagnostics`,`troubleshoot`],selector:`a[href="/debug"]`},{path:`/profile`,aliases:[`profile`,`license`,`account`],selector:`a[href="/profile"]`},{path:`/support`,aliases:[`support`,`help`,`feedback`],selector:`a[href="/support"]`},{path:`/notifications`,aliases:[`notifications`,`alerts`,`inbox`],selector:`a[href="/notifications"]`},{path:`/try`,aliases:[`try`,`try it`,`simulator`,`sandbox`,`playground`],selector:`a[href="/try"]`},{path:`/guardrails`,aliases:[`guardrails`,`guardrail packs`,`packs`],selector:`a[href="/guardrails"]`}];function oc(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function sc(e){if(!e)return null;let t=e.toLowerCase().trim();for(let e of ac)for(let n of e.aliases)if(t===n)return e;for(let e of ac)for(let n of e.aliases)if(t.includes(n))return e;return null}function cc(e){let t=e.trim().toLowerCase();if(!t)return{kind:`unknown`,said:``,failed:!0};if(/\b(turn|switch|set|put)\s+(ssg|the system|everything)?\s*off\b/.test(t)||/\b(kill switch|panic|safe mode|stop ssg)\b/.test(t)||/\bssg\s+off\b/.test(t)||/^off$/.test(t))return{kind:`set-ssg-mode`,mode:`off`,said:`Switching SSG to OFF`,targetSelector:`.chip[title*="cycle"]`};if(/\b(audit\s+mode|set\s+audit|log[\s-]only|switch\s+to\s+audit|audit\s+only)\b/.test(t)||/\bssg\s+audit\b/.test(t)||/^audit$/.test(t))return{kind:`set-ssg-mode`,mode:`audit`,said:`Switching SSG to AUDIT`,targetSelector:`.chip[title*="cycle"]`};if(/\b(turn|switch|set|put)\s+(ssg|the system|everything)?\s*on\b/.test(t)||/\b(resume|re-enable|reenable|enforce)\b.*\b(ssg|rules)?\b/.test(t)||/\bssg\s+on\b/.test(t)||/^on$/.test(t))return{kind:`set-ssg-mode`,mode:`on`,said:`Resuming SSG enforcement`,targetSelector:`.chip[title*="cycle"]`};if(/\b(ask|approvals?)\b.*\b(dashboard|here|on screen|browser)\b/.test(t))return{kind:`set-ask-mode`,mode:`dashboard`,said:`Routing ASK prompts to the dashboard`,targetSelector:`.chip[title*="ASK"]`};if(/\b(ask|approvals?)\b.*\b(tty|terminal|native|ide|cli)\b/.test(t))return{kind:`set-ask-mode`,mode:`tty`,said:`Routing ASK prompts to the native terminal`,targetSelector:`.chip[title*="ASK"]`};if(/\b(newcomer|beginner|simple|simplified|easy)\s+(mode|ui|view)?\b/.test(t))return{kind:`set-ui-mode`,mode:`newcomer`,said:`Switching to Newcomer mode`,targetSelector:`button[title*="newcomer" i], button[title*="Newcomer"]`};if(/\b(pro|professional|advanced|expert|full)\s+(mode|ui|view)?\b/.test(t))return{kind:`set-ui-mode`,mode:`pro`,said:`Switching to Pro mode`,targetSelector:`button[title*="pro" i], button[title*="Pro"]`};if(/\b(refresh|reset)\b(?!.*reload)/.test(t))return{kind:`refresh`,said:`Resetting the page`};if(/\b(hard\s+reload|reload|force\s+reload|fresh\s+load)\b/.test(t))return{kind:`hard-reload`,said:`Hard-reloading the dashboard`};let n=t.match(/\b(?:show me|show|open|go to|take me to|switch to|jump to|navigate to|bring up|pull up)\s+(.+)$/);if(n){let e=n[1].replace(/[?!.]+$/,``).trim(),t=sc(e);return t?{kind:`navigate`,path:t.path,said:`Opening ${lc(t.path)}`,targetSelector:t.selector}:{kind:`unknown`,said:`I don't have a page called "${e}".`,failed:!0}}let r=sc(t);return r?{kind:`navigate`,path:r.path,said:`Opening ${lc(r.path)}`,targetSelector:r.selector}:{kind:`unknown`,said:`Didn't catch that. Try "go to rules", "audit mode", or "switch to newcomer".`,failed:!0}}function lc(e){return e===`/`?`Dashboard`:e.slice(1).replace(/\b\w/g,e=>e.toUpperCase())}function uc(e){e&&window.dispatchEvent(new CustomEvent(`ssg:voice-target`,{detail:{selector:e}}))}function dc(){window.dispatchEvent(new CustomEvent(`ssg:voice-page-morph`))}function fc({actions:e}){let t=(0,_.useMemo)(()=>!!oc(),[]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!0),f=(0,_.useRef)(null),p=(0,_.useCallback)(t=>{let n=cc(t);switch(s(n),n.kind){case`navigate`:uc(n.targetSelector),e.navigate(n.path),dc();break;case`set-ssg-mode`:uc(n.targetSelector),e.setSsgMode(n.mode);break;case`set-ask-mode`:uc(n.targetSelector),e.setAskMode(n.mode);break;case`set-ui-mode`:uc(n.targetSelector),e.setUiMode(n.mode);break;case`refresh`:e.refresh(),dc();break;case`hard-reload`:e.hardReload();break;case`unknown`:break}},[e]),m=(0,_.useCallback)(()=>{let e=f.current;if(e)try{e.stop()}catch{}r(!1)},[]),h=(0,_.useCallback)(()=>{let e=oc();if(!e)return;let t=new e;t.continuous=!1,t.interimResults=!0,t.lang=`en-US`,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r],a=i[0]?.transcript??``;i.isFinal?n+=a:t+=a}a(t||n),n&&p(n)},t.onend=()=>r(!1),t.onerror=()=>r(!1),f.current=t,a(``),s(null);try{t.start(),r(!0)}catch{r(!1)}},[p]);(0,_.useEffect)(()=>()=>m(),[m]);let g=e=>{e.preventDefault();let t=c.trim();t&&(a(t),p(t),l(``))};if(!u)return(0,K.jsx)(`button`,{type:`button`,className:`ssg-voice-dock ssg-voice-dock--collapsed`,onClick:()=>d(!0),title:`Talk to SigmaShake`,"aria-label":`Open voice dock`,children:(0,K.jsx)(pc,{})});let v=o?.kind===`unknown`;return(0,K.jsxs)(`div`,{className:`ssg-voice-dock ssg-voice-dock--open`+(n?` ssg-voice-dock--listening`:``)+(v?` ssg-voice-dock--failed`:``),role:`region`,"aria-label":`Voice dock`,children:[(0,K.jsxs)(`div`,{className:`ssg-voice-dock__row`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`ssg-voice-dock__mic`+(n?` ssg-voice-dock__mic--on`:``),onClick:n?m:h,disabled:!t,title:t?n?`Stop listening`:`Tap then speak — try "audit mode" or "go to rules"`:`Speech recognition isn't supported in this browser. Use the text box.`,children:[(0,K.jsx)(pc,{}),(0,K.jsx)(`span`,{children:n?`Listening…`:t?`Talk`:`Voice off`})]}),(0,K.jsx)(`form`,{className:`ssg-voice-dock__form`,onSubmit:g,children:(0,K.jsx)(`input`,{type:`text`,className:`ssg-voice-dock__input`,placeholder:`Type or say "go to audit"`,value:c,onChange:e=>l(e.target.value),spellCheck:!1})}),(0,K.jsx)(`button`,{type:`button`,className:`ssg-voice-dock__close`,onClick:()=>d(!1),title:`Hide voice dock`,"aria-label":`Hide voice dock`,children:`×`})]}),(i||o)&&(0,K.jsxs)(`div`,{className:`ssg-voice-dock__feedback`,children:[i&&(0,K.jsxs)(`div`,{className:`ssg-voice-dock__line ssg-voice-dock__line--heard`,children:[(0,K.jsx)(`span`,{className:`ssg-voice-dock__tag`,children:`Heard`}),(0,K.jsx)(`span`,{children:i})]}),o&&(0,K.jsxs)(`div`,{className:`ssg-voice-dock__line ssg-voice-dock__line--`+(v?`miss`:`did`),children:[(0,K.jsx)(`span`,{className:`ssg-voice-dock__tag`,children:v?`Hmm`:`Did`}),(0,K.jsx)(`span`,{children:o.said})]})]})]})}function pc(){return(0,K.jsxs)(`svg`,{className:`ssg-voice-dock__glyph`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:`6`,y:`2`,width:`4`,height:`8`,rx:`2`,fill:`currentColor`}),(0,K.jsx)(`path`,{d:`M4 8 v0.6 a4 4 0 0 0 8 0 V8`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,fill:`none`}),(0,K.jsx)(`path`,{d:`M8 13 v2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`})]})}function mc({val:e}){return e==null?(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] italic font-mono text-xs`,children:`null`}):typeof e==`boolean`?(0,K.jsx)(`span`,{className:`inline-block font-mono text-[10px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded-sm border ${e?`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`:`bg-red-500/8 text-red-300 border-red-500/25`}`,children:e.toString()}):typeof e==`number`?(0,K.jsx)(`span`,{className:`font-mono tabular-nums text-violet-300 text-xs`,children:e}):typeof e==`string`?e.length===0?(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] italic text-xs font-mono`,children:`empty string`}):e.length>200?(0,K.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 max-h-40 overflow-y-auto`,children:e}):(0,K.jsx)(`span`,{className:`font-mono text-xs text-[var(--color-fg-1)] break-all`,children:e}):(0,K.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 max-h-40 overflow-y-auto`,children:JSON.stringify(e,null,2)})}function hc({inputJson:e}){let t=[];try{let n=JSON.parse(e);n&&typeof n==`object`&&!Array.isArray(n)&&(t=Object.entries(n))}catch{return(0,K.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2`,children:e})}return t.length===0?(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-xs italic font-mono`,children:`no input fields`}):(0,K.jsx)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] overflow-hidden text-xs`,children:t.map(([e,t],n)=>(0,K.jsxs)(`div`,{className:`flex gap-0 ${n>0?`border-t border-[var(--color-line-0)]`:``}`,children:[(0,K.jsx)(`div`,{className:`w-40 shrink-0 px-3 py-2 bg-[var(--color-surface-0)] text-[var(--color-fg-3)] font-mono text-[11px] border-r border-[var(--color-line-0)] select-none`,children:e}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0 px-3 py-2 leading-relaxed`,children:(0,K.jsx)(mc,{val:t})})]},e))})}var gc={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},_c={allow:`Allowed`,block:`Blocked`,force:`Forced`,ask:`Held`,log:`Logged`},vc={allow:`border-l-emerald-500/60`,block:`border-l-red-500/60`,force:`border-l-amber-400/60`,ask:`border-l-sky-500/60`,log:`border-l-[var(--color-line-2)]`};function yc(e){return e==null?null:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}function bc({label:e,value:t,mono:n,children:r}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline mb-1`,children:e}),r??(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] text-xs ${n?`font-mono`:``} break-all`,children:t??`—`})]})}function xc({text:e}){let[t,n]=(0,_.useState)(!1);return(0,K.jsx)(`button`,{onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-2 py-1 transition-colors cursor-pointer`,children:t?`✓ copied`:`copy json`})}function Sc({row:e,defaultExpanded:t=!1}){let[n,r]=(0,_.useState)(t),i=(0,_.useRef)(null),a=(0,_.useRef)(!0),o=rr(e.tool,e.input),s=o&&o.length>0?o:e.input&&e.input!==`{}`&&e.input!==``?e.input:`—`,c=gc[e.decision]??`gray`,l=vc[e.decision]??`border-l-[var(--color-line-2)]`,u=nr(e.timestamp),d=yc(e.duration_ns),f=vi(e.tool,e.input);(0,_.useEffect)(()=>{let e=i.current;if(e){if(a.current){a.current=!1,n||(e.style.maxHeight=`0`,e.style.opacity=`0`);return}if(ot()){e.style.maxHeight=n?`none`:`0`,e.style.opacity=n?`1`:`0`;return}if(n){let t=e.scrollHeight;wt(e,{"max-height":[`0px`,`${t}px`],opacity:[0,1],translateY:[-6,0],duration:260,ease:`outCubic`,onComplete:()=>{e.style.maxHeight=`none`}})}else{let t=e.scrollHeight;wt(e,{"max-height":[`${t}px`,`0px`],opacity:[1,0],duration:180,ease:`outCubic`})}}},[n]);let p=(()=>{try{return JSON.stringify(JSON.parse(e.input),null,2)}catch{return e.input}})();return(0,K.jsxs)(`div`,{className:`border border-[var(--color-line-1)] border-l-2 ${l} rounded-sm bg-[var(--color-surface-1)] overflow-hidden transition-colors hover:border-[var(--color-line-2)] hover:border-l-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 cursor-pointer select-none group`,onClick:()=>r(e=>!e),role:`button`,"aria-expanded":n,children:[(0,K.jsx)(`svg`,{className:`shrink-0 w-3 text-[var(--color-fg-4)] group-hover:text-[var(--color-fg-2)] transition-all ${n?`rotate-90`:``}`,width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),(0,K.jsx)(`time`,{className:`shrink-0 font-mono text-[11px] text-[var(--color-fg-3)] w-14 tabular-nums`,title:u,dateTime:new Date(e.timestamp*1e3).toISOString(),children:tr(e.timestamp)}),(0,K.jsx)(sr,{variant:c,className:`shrink-0 w-20 justify-center`,children:_c[e.decision]??e.decision}),(0,K.jsxs)(`span`,{className:`flex-1 min-w-0 flex items-baseline gap-2`,title:`${f.headline} · ${e.tool}`,children:[(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--color-fg-0)] font-medium truncate`,children:f.headline}),!di(e.tool)&&s!==`—`&&(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)] font-mono truncate hidden sm:inline`,title:s,children:s})]}),d&&(0,K.jsx)(`span`,{className:`shrink-0 hidden md:inline w-12 text-right font-mono text-[10px] text-[var(--color-fg-4)] tabular-nums`,title:`Eval latency: ${d}`,children:d}),(0,K.jsx)(`span`,{className:`shrink-0 w-24 text-right text-[10px] text-[var(--color-fg-3)] truncate`,title:e.client?`Adapter: ${e.client}`:`Unidentified caller`,children:ui(e.client)})]}),(0,K.jsx)(`div`,{ref:i,className:`border-t border-[var(--color-line-0)] overflow-hidden`,style:{maxHeight:n?`none`:`0`,opacity:n?1:0},"aria-hidden":!n,children:n&&(0,K.jsxs)(`div`,{className:`px-3 py-3 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-x-6 gap-y-3`,children:[(0,K.jsx)(bc,{label:`When`,value:u}),(0,K.jsx)(bc,{label:`Decision`,children:(0,K.jsx)(sr,{variant:c,children:_c[e.decision]??e.decision})}),(0,K.jsx)(bc,{label:`Action`,children:(0,K.jsxs)(`span`,{className:`text-xs text-[var(--color-fg-1)]`,children:[f.headline,(0,K.jsxs)(`span`,{className:`ml-2 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`(`,e.tool,`)`]})]})}),e.client&&(0,K.jsx)(bc,{label:`AI agent`,value:ui(e.client)}),e.rule_id&&(0,K.jsx)(bc,{label:`Rule ID`,children:(0,K.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-xs text-[var(--color-brand)] hover:underline font-mono`,onClick:e=>e.stopPropagation(),children:e.rule_id})}),e.source_file&&(0,K.jsx)(bc,{label:`Source File`,value:e.source_file,mono:!0}),d&&(0,K.jsx)(bc,{label:`Latency`,value:d,mono:!0}),e.rules_evaluated!=null&&(0,K.jsx)(bc,{label:`Rules Evaluated`,value:`${e.rules_evaluated}`,mono:!0})]}),(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`overline mb-1`,children:`In plain English`}),(0,K.jsx)(`div`,{className:`text-xs font-medium text-[var(--color-fg-1)] mb-1`,children:f.headline}),(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] leading-relaxed`,children:f.detail})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline mb-2`,children:`Tool Input`}),(0,K.jsx)(hc,{inputJson:e.input})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[e.rule_id?(0,K.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-brand)]/70 hover:text-[var(--color-brand)] transition-colors`,onClick:e=>e.stopPropagation(),children:`→ view rule`}):(0,K.jsx)(`span`,{}),(0,K.jsx)(xc,{text:p})]})]})})]})}function Cc({className:e,children:t,...n}){return(0,K.jsx)(`pre`,{className:G(`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-3 py-2 text-[11px] leading-relaxed font-mono text-[var(--color-fg-1)] overflow-x-auto whitespace-pre-wrap break-all`,e),...n,children:t})}var wc={neutral:`text-[var(--color-fg-0)]`,green:`text-emerald-300`,red:`text-red-300`,amber:`text-amber-300`,blue:`text-sky-300`,purple:`text-violet-300`,gray:`text-[var(--color-fg-3)]`},Tc={neutral:`bg-[var(--color-fg-3)]`,green:`bg-emerald-500`,red:`bg-red-500`,amber:`bg-[var(--color-brand)]`,blue:`bg-sky-500`,purple:`bg-violet-500`,gray:`bg-[var(--color-line-2)]`},Ec=[{label:`User code`,color:`#451a03`},{label:`Runtime (bun:/node:)`,color:`#172554`},{label:`Native/other`,color:`#1f2937`},{label:`GC/idle`,color:`#450a0a`}],Dc={neutral:`#d0d0d0`,green:`#34d399`,red:`#f87171`,amber:`#fbbf24`,blue:`#38bdf8`,purple:`#a78bfa`,gray:`#6e7076`};function Oc({label:e,value:t,sub:n,tone:r=`neutral`,align:i=`left`,labelPlacement:a=`above`,labelClassName:o,valueClassName:s,subClassName:c,trend:l,trendColor:u}){let d=(0,K.jsx)(`div`,{className:G(a===`above`?`overline mb-1.5`:`mt-1 text-[11px] text-[var(--color-fg-3)]`,o),children:e}),f=(0,K.jsx)(`div`,{className:G(`font-mono font-medium tabular-nums`,i===`center`&&`text-center`,wc[r],s),children:t}),p=l&&l.length>1,m=u??Dc[r];return(0,K.jsxs)(K.Fragment,{children:[a===`above`&&d,p?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[f,(0,K.jsx)(pr,{data:l,width:48,height:18,color:m})]}):f,a===`below`&&d,n&&(0,K.jsx)(`div`,{className:G(`mt-1 text-[10px] font-mono text-[var(--color-fg-3)]`,i===`center`&&`text-center`,c),children:n})]})}function kc({className:e,contentClassName:t,label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f,...p}){return(0,K.jsx)(q,{className:e,...p,children:(0,K.jsx)(Y,{className:G(`py-3`,o===`center`&&`text-center`,t),children:(0,K.jsx)(Oc,{label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f})})})}function Ac({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)] p-3`,t.align===`center`&&`text-center`,e),children:(0,K.jsx)(Oc,{...t})})}function jc({pct:e,tone:t=`green`,markerPct:n,className:r,barClassName:i,markerTitle:a}){let o=Math.max(0,Math.min(100,e)),s=n===void 0?null:Math.max(0,Math.min(100,n));return(0,K.jsxs)(`div`,{className:G(`relative w-full overflow-hidden rounded-sm bg-[var(--color-surface-3)]`,r),children:[(0,K.jsx)(`div`,{className:G(`h-full rounded-sm transition-all duration-500`,Tc[t],i),style:{width:`${o}%`}}),s!==null&&(0,K.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-[var(--color-brand)]/70`,style:{left:`${s}%`},title:a})]})}function Mc({label:e,value:t,tone:n=`neutral`,breached:r=!1,breachLabel:i=`limit exceeded`,trendData:a,trendColor:o,threshold:s,maxValue:c,footer:l,className:u,valueClassName:d}){return(0,K.jsxs)(q,{className:u,children:[(0,K.jsxs)(J,{className:`py-2`,children:[(0,K.jsx)(`span`,{className:`overline`,children:e}),r&&(0,K.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300`,children:i})]}),(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`div`,{className:G(`text-2xl font-mono font-medium tabular-nums`,wc[n],d),children:t}),(a?.length??0)>1&&o&&(0,K.jsx)(pr,{data:a??[],width:80,height:28,color:o,threshold:s,maxValue:c})]}),l]})]})}function Nc({profile:e,children:t}){return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsxs)(`span`,{children:[`nodes:`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.nodes.length})]}),(0,K.jsxs)(`span`,{children:[`duration:`,` `,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[((e.endTime-e.startTime)/1e3).toFixed(0),`ms`]})]}),(0,K.jsxs)(`span`,{children:[`samples:`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.samples?.length??0})]})]}),(0,K.jsx)(`div`,{className:`flex gap-3 text-[10px] font-mono text-[var(--color-fg-3)]`,children:Ec.map(e=>(0,K.jsxs)(`span`,{className:`flex items-center`,children:[(0,K.jsx)(`span`,{className:`mr-1 inline-block h-2.5 w-2.5 rounded-[1px]`,style:{background:e.color}}),e.label]},e.label))}),t]})}function Pc({memory:e,formatValue:t}){return(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-3`,children:[{label:`RSS`,value:t(e.rss)},{label:`Heap Total`,value:t(e.heapTotal)},{label:`Heap Used`,value:t(e.heapUsed)},{label:`External`,value:t(e.external)}].map(e=>(0,K.jsx)(Ac,{align:`center`,label:e.label,value:e.value,valueClassName:`text-lg font-medium text-[var(--color-fg-0)]`},e.label))})}function Fc(e,t){let n=Array(t).fill(0);if(e.length===0)return n;let r=Date.now()-t*1e3;for(let i=e.length-1;i>=0;i--){let a=e[i];if(!a)continue;if(a.ts_ms<r)break;let o=Math.floor((a.ts_ms-r)/1e3);o>=0&&o<t&&n[o]++}return n}function Ic({bins:e=60,height:t=38,className:n}){let r=De(),i=(0,_.useRef)(null),a=(0,_.useRef)([]),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=i.current;if(!t)return;let n=t.getContext(`2d`);if(!n)return;let s=Math.min(window.devicePixelRatio??1,2),c=ot(),l=()=>{let i=Fc(r,e);if(a.current.length!==e)a.current=i.slice();else if(c)a.current=i;else for(let t=0;t<e;t++){let e=a.current[t]??0,n=i[t]??0;a.current[t]=e+(n-e)*.18}let u=t.clientWidth,d=t.clientHeight;(t.width!==u*s||t.height!==d*s)&&(t.width=u*s,t.height=d*s,n.scale(s,s)),n.clearRect(0,0,u,d);let f=Math.max(1,...a.current),p=u/e;for(let t=0;t<e;t++){let e=a.current[t]??0,r=e/f*d,i=t*p,o=e/f;n.fillStyle=`rgba(${Math.round(56+o*199)},${Math.round(189-o*100)},${Math.round(248-o*200)},${.4+o*.55})`,n.fillRect(i+.5,d-r,Math.max(1,p-1),r)}n.strokeStyle=`rgba(148, 163, 184, 0.1)`,n.lineWidth=1,n.beginPath(),n.moveTo(0,d-.5),n.lineTo(u,d-.5),n.stroke(),o.current=requestAnimationFrame(l)};return o.current=requestAnimationFrame(l),()=>{o.current!==null&&cancelAnimationFrame(o.current),o.current=null}},[r,e]),(0,K.jsxs)(`div`,{className:G(`relative w-full`,n),style:{height:t},children:[(0,K.jsx)(`canvas`,{ref:i,className:`block w-full h-full`,style:{width:`100%`,height:`100%`}}),(0,K.jsxs)(`span`,{className:`absolute top-1 left-2 text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)] pointer-events-none`,children:[`bursts/sec · `,e,`s window`]})]})}var Lc=8,Rc=6,zc=Math.PI*.75,Bc=Math.PI*2.25;function Vc({size:e=110,className:t}){let n=De(),r=(0,_.useRef)(null),i=(0,_.useRef)(0),a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=r.current;if(!t)return;let o=t.getContext(`2d`);if(!o)return;let s=Math.min(window.devicePixelRatio??1,2),c=ot(),l=()=>{let r=Date.now()-1500,u=0;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){if(t.ts_ms<r)break;u++}}let d=u/1.5,f=Math.min(1,d/Lc);c?i.current=f:i.current+=(f-i.current)*.16;let p=e,m=e;(t.width!==p*s||t.height!==m*s)&&(t.width=p*s,t.height=m*s,t.style.width=`${p}px`,t.style.height=`${m}px`,o.scale(s,s)),o.clearRect(0,0,p,m);let h=p/2,g=m/2+4,_=p/2-8;o.lineWidth=6,o.lineCap=`round`,o.strokeStyle=`rgba(148, 163, 184, 0.18)`,o.beginPath(),o.arc(h,g,_,zc,Bc),o.stroke();let v=zc+Rc/Lc*(Bc-zc);o.strokeStyle=`rgba(239, 68, 68, 0.45)`,o.beginPath(),o.arc(h,g,_,v,Bc),o.stroke();let y=zc+i.current*(Bc-zc),b=i.current*Lc>=Rc;o.strokeStyle=b?`rgba(239, 68, 68, 0.95)`:`rgba(56, 189, 248, 0.92)`,o.lineWidth=6,o.beginPath(),o.arc(h,g,_,zc,y),o.stroke();let x=h+Math.cos(y)*(_-2),S=g+Math.sin(y)*(_-2);o.strokeStyle=b?`#fca5a5`:`#e0e7ff`,o.lineWidth=2,o.beginPath(),o.moveTo(h,g),o.lineTo(x,S),o.stroke(),o.fillStyle=b?`#fca5a5`:`#e0e7ff`,o.beginPath(),o.arc(h,g,3,0,Math.PI*2),o.fill(),o.fillStyle=b?`#fca5a5`:`#e0e7ff`,o.font=`bold 20px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,o.textAlign=`center`,o.fillText(d.toFixed(1),h,g+_*.55),o.fillStyle=`rgba(148, 163, 184, 0.85)`,o.font=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,o.fillText(`eps`,h,g+_*.55+12),a.current=requestAnimationFrame(l)};return a.current=requestAnimationFrame(l),()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=null}},[n,e]),(0,K.jsx)(`canvas`,{ref:r,className:G(`block`,t),style:{width:e,height:e}})}var Hc={allow:`#22c55e`,block:`#ef4444`,force:`#a855f7`,ask:`#f59e0b`,log:`#60a5fa`,shadow:`#6b7280`},Uc=[`allow`,`block`,`force`,`ask`,`log`];function Wc({windowSec:e=30,height:t=14,className:n}){let r=De(),[i,a]=(0,_.useState)({}),o=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=ot(),n=()=>{let i=Date.now()-e*1e3,s={},c=0;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t){if(t.ts_ms<i)break;s[t.decision]=(s[t.decision]??0)+1,c++}}let l={};for(let e of Uc)l[e]=c===0?0:(s[e]??0)/c;if(t){a(l);return}a(e=>{let t={};for(let n of Uc){let r=e[n]??0;t[n]=r+((l[n]??0)-r)*.22}return t}),o.current=requestAnimationFrame(n)};return o.current=requestAnimationFrame(n),()=>{o.current!==null&&cancelAnimationFrame(o.current),o.current=null}},[r,e]);let s=Uc.map(e=>({key:e,color:Hc[e]??`#6b7280`,pct:Math.max(0,i[e]??0)})),c=s.reduce((e,t)=>e+t.pct,0)===0;return(0,K.jsxs)(`div`,{className:G(`w-full`,n),children:[(0,K.jsx)(`div`,{className:`flex w-full overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,style:{height:t},title:`decision mix · last ${e}s`,children:c?(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)]`,children:`— idle —`}):s.map(e=>(0,K.jsx)(`div`,{style:{width:`${e.pct*100}%`,background:e.color,transition:`width 240ms ease-out`},title:`${e.key} · ${(e.pct*100).toFixed(1)}%`},e.key))}),(0,K.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)]`,children:s.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:e.color}}),e.key,` · `,(e.pct*100).toFixed(0),`%`]},e.key))})]})}var Gc={centre:`#FF9500`,"cf-worker":`#5AC8FA`,bun:`#FFCC00`,elixir:`#AF52DE`,native:`#FF3B30`,unknown:`#8E8E93`},Kc={centre:`monorepo`,"cf-worker":`CF Worker`,bun:`Bun / TS`,elixir:`Elixir`,native:`Native`,unknown:`Other`};function qc({refreshKey:e=0}){let t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)([]),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=(0,_.useRef)(0),s=(0,_.useRef)(null),c=(0,_.useRef)({w:0,h:0}),l=(0,_.useRef)(!1),u=(0,_.useRef)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)({centre:0,"cf-worker":0,bun:0,elixir:0,native:0,unknown:0});(0,_.useEffect)(()=>{let e=!1;return m(!1),f(null),fetch(`/api/json/monorepo/graph`).then(async e=>{let t=e.headers.get(`content-type`)??``;if(!e.ok)throw Error(`HTTP ${e.status}`);if(!t.includes(`application/json`))throw Error(`expected JSON, got `+(t||`unknown`));return e.json()}).then(t=>{if(e)return;let i=n.current?.clientWidth??800,a=n.current?.clientHeight??420,s=i/2,c=a/2,l=Math.min(i,a)*.36,u=t.projects,d=[{id:t.centre.id,label:t.centre.label,type:`centre`,description:`Monorepo root — every sigmashake-* project lives here`,isCentre:!0,x:s,y:c,vx:0,vy:0,radius:0,phase:0},...u.map((e,t)=>{let n=t/Math.max(1,u.length)*Math.PI*2;return{id:e.id,label:e.label.replace(/^sigmashake-/,``),type:e.type,description:e.description||`${Kc[e.type]} project`,isCentre:!1,x:s+Math.cos(n)*l,y:c+Math.sin(n)*l,vx:0,vy:0,radius:l,phase:n}})];r.current=d,o.current=0,g(d.reduce((e,t)=>(e[t.type]=(e[t.type]??0)+1,e),{centre:0,"cf-worker":0,bun:0,elixir:0,native:0,unknown:0})),m(!0)}).catch(t=>{e||f(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[e]),(0,_.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>{l.current=e.matches};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,_.useEffect)(()=>{let e=t.current,s=n.current;if(!e||!s)return;let u=e.getContext(`2d`,{alpha:!0});if(!u)return;let d=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect,i=window.devicePixelRatio||1;c.current.w=t.width,c.current.h=t.height,e.width=Math.max(1,Math.floor(t.width*i)),e.height=Math.max(1,Math.floor(t.height*i)),e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,u.setTransform(i,0,0,i,0,0);let a=r.current;if(a.length>0){let e=t.width/2,n=t.height/2,r=Math.min(t.width,t.height)*.36;for(let t of a){if(t.isCentre){t.x=e,t.y=n;continue}t.radius=r}}}});d.observe(s);let f=0,p=performance.now(),m=[],h=(e,t)=>{let n=new Map;e.forEach((e,t)=>n.set(e.id,t));let r=[];for(let e of t){let t=n.get(e.from),i=n.get(e.to);t===void 0||i===void 0||r.push([t,i])}return r},g=e=>{let t=Math.min(.05,(e-p)/1e3);p=e;let n=r.current,{w:s,h:d}=c.current,h=s/2,_=d/2,v=i.current,y=l.current||v?0:.06;o.current+=y*t;let b=5.5,x=.86;for(let e=0;e<n.length;e++){let r=n[e];if(r.isCentre||r.id===v)continue;let i=0,a=0;for(let t=0;t<n.length;t++){if(e===t)continue;let o=n[t];if(o.isCentre)continue;let s=r.x-o.x,c=r.y-o.y,l=s*s+c*c+.01,u=Math.sqrt(l),d=1700/l;i+=s/u*d,a+=c/u*d}let s=r.phase+o.current,c=h+Math.cos(s)*r.radius,l=_+Math.sin(s)*r.radius;i+=(c-r.x)*b,a+=(l-r.y)*b;let u=r.x-h,d=r.y-_,f=Math.sqrt(u*u+d*d)||1,p=r.radius-f;i+=u/f*p*.6,a+=d/f*p*.6,r.vx=(r.vx+i*t)*x,r.vy=(r.vy+a*t)*x,r.x+=r.vx*t,r.y+=r.vy*t}u.clearRect(0,0,s,d);let S=u.createRadialGradient(h,_,0,h,_,Math.max(s,d)/1.4);S.addColorStop(0,`rgba(255, 149, 0, 0.06)`),S.addColorStop(1,`rgba(255, 149, 0, 0)`),u.fillStyle=S,u.fillRect(0,0,s,d),u.lineCap=`round`;for(let e=1;e<n.length;e++){let t=n[0],r=n[e];Jc(u,t,r,.1)}for(let[e,t]of m){let r=n[e],i=n[t];!r||!i||Jc(u,r,i,.24,`#5AC8FA`)}let C=a.current;for(let e of n){let t=Gc[e.type],n=C===e.id,r=v===e.id,i=e.isCentre?22:11,a=n||r?i+4:i;if(n||r||e.isCentre){let n=e.isCentre?a+14:a+8,r=u.createRadialGradient(e.x,e.y,a,e.x,e.y,n);r.addColorStop(0,t),r.addColorStop(1,`rgba(0,0,0,0)`),u.globalAlpha=e.isCentre?.22:.32,u.fillStyle=r,u.beginPath(),u.arc(e.x,e.y,n,0,Math.PI*2),u.fill(),u.globalAlpha=1}if(u.fillStyle=t,u.beginPath(),u.arc(e.x,e.y,a,0,Math.PI*2),u.fill(),u.lineWidth=e.isCentre?2:1.25,u.strokeStyle=`rgba(0,0,0,0.18)`,u.stroke(),u.font=e.isCentre?`600 12px ui-sans-serif, system-ui`:`500 10.5px ui-sans-serif, system-ui`,u.fillStyle=`rgba(60,60,67,0.85)`,u.textBaseline=`middle`,u.textAlign=`center`,e.isCentre)u.fillText(e.label,e.x,e.y+a+14);else{let t=e.x-h,n=e.y-_,r=Math.sqrt(t*t+n*n)||1,i=e.x+t/r*(a+12),o=e.y+n/r*(a+12);u.textAlign=t>=0?`left`:`right`,u.textBaseline=n>=0?`top`:`bottom`,u.fillText(e.label,i,o)}}u.textAlign=`start`,u.textBaseline=`alphabetic`,f=requestAnimationFrame(g)};f=requestAnimationFrame(g);let _=-1,v=``,y=setInterval(()=>{let e=r.current,t=window.__SSG_MONOREPO_EDGES__??``;e.length===_&&t===v||(_=e.length,v=t,m=h(e,t?JSON.parse(t):[]))},250);return()=>{cancelAnimationFrame(f),clearInterval(y),d.disconnect()}},[]),(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=t=>{let n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},o=(e,t)=>{let n=r.current;for(let r=n.length-1;r>=0;r--){let i=n[r],a=i.x-e,o=i.y-t,s=i.isCentre?26:14;if(a*a+o*o<=s*s)return i}return null},c=t=>{let{x:s,y:c}=n(t),l=i.current;if(l){let e=r.current.find(e=>e.id===l);if(e&&!e.isCentre){let t=e.x,n=e.y;e.x=s,e.y=c,e.vx=(s-t)*12,e.vy=(c-n)*12}return}let d=o(s,c);a.current=d?.id??null,e.style.cursor=d&&!d.isCentre?`grab`:`default`,d&&u.current?(u.current.style.display=`block`,u.current.style.left=`${s+14}px`,u.current.style.top=`${c+14}px`,u.current.innerHTML=`<strong>${Yc(d.id)}</strong><span class="mg-tooltip__kind">${Kc[d.type]}</span>`+(d.description?`<p>${Yc(d.description)}</p>`:``)):u.current&&(u.current.style.display=`none`)},l=t=>{let{x:r,y:a}=n(t),c=o(r,a);c&&!c.isCentre&&(i.current=c.id,e.setPointerCapture(t.pointerId),e.style.cursor=`grabbing`,s.current={x:r,y:a,downX:r,downY:a,downAt:performance.now()})},d=t=>{if(i.current)try{e.releasePointerCapture(t.pointerId)}catch{}i.current=null,e.style.cursor=`default`},f=()=>{a.current=null,u.current&&(u.current.style.display=`none`)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerdown`,l),e.addEventListener(`pointerup`,d),e.addEventListener(`pointercancel`,d),e.addEventListener(`pointerleave`,f),()=>{e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`pointerup`,d),e.removeEventListener(`pointercancel`,d),e.removeEventListener(`pointerleave`,f)}},[]),(0,_.useEffect)(()=>{p&&fetch(`/api/json/monorepo/graph`).then(e=>e.json()).then(e=>{window.__SSG_MONOREPO_EDGES__=JSON.stringify(e.serviceEdges??[])}).catch(()=>{window.__SSG_MONOREPO_EDGES__=`[]`})},[p]);let v=[`cf-worker`,`bun`,`elixir`,`native`,`unknown`];return(0,K.jsxs)(`div`,{className:`mg`,ref:n,children:[(0,K.jsx)(`canvas`,{ref:t,className:`mg__canvas`,"aria-label":`Monorepo dependency graph`}),(0,K.jsxs)(`div`,{className:`mg__overlay`,children:[(0,K.jsxs)(`div`,{className:`mg__title`,children:[(0,K.jsx)(`strong`,{children:`monorepo map`}),(0,K.jsx)(`span`,{className:`mg__hint`,children:`drag to pluck a project • hover for details`})]}),d&&(0,K.jsx)(`div`,{className:`mg__error`,children:d}),(0,K.jsx)(`ul`,{className:`mg__legend`,children:v.map(e=>h[e]>0?(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mg__swatch`,style:{background:Gc[e]}}),(0,K.jsx)(`span`,{children:Kc[e]}),(0,K.jsx)(`span`,{className:`mg__count`,children:h[e]})]},e):null)})]}),(0,K.jsx)(`div`,{ref:u,className:`mg-tooltip`})]})}function Jc(e,t,n,r,i=`#FF9500`){let a=n.x-t.x,o=n.y-t.y,s=(t.x+n.x)/2-o*.05,c=(t.y+n.y)/2+a*.05;e.globalAlpha=r,e.strokeStyle=i,e.lineWidth=1.25,e.beginPath(),e.moveTo(t.x,t.y),e.quadraticCurveTo(s,c,n.x,n.y),e.stroke(),e.globalAlpha=1}function Yc(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var Xc=3;function Zc(e){return e===null?`—`:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}var Qc=[`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`];function $c({info:e}){let t=e.tier===`pro`||e.tier===`enterprise`,n=e.status===`needs_reauth`,r=e.pct_used??0,i=r>=90?`bg-red-500`:r>=70?`bg-amber-500`:`bg-emerald-500`;return(0,K.jsxs)(q,{className:n?`border-l-2 border-l-amber-500/70`:t?`border-l-2 border-l-emerald-500/70`:`border-l-2 border-l-sky-500/70`,children:[(0,K.jsxs)(J,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`license`}),(0,K.jsx)(sr,{variant:t?`green`:n?`amber`:`blue`,children:e.tier_label}),e.fleet_enrolled&&(0,K.jsx)(sr,{variant:`gray`,children:`fleet`})]}),e.email&&(0,K.jsx)(`span`,{className:`text-xs text-[var(--color-fg-3)]`,children:e.email})]}),(0,K.jsxs)(Y,{className:`space-y-3`,children:[n&&e.detail&&(0,K.jsxs)(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200`,children:[e.detail,` — run `,(0,K.jsx)(`code`,{className:`font-mono`,children:`ssg auth login`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs text-[var(--color-fg-2)]`,children:[(0,K.jsx)(`span`,{children:`evals today`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(fr,{value:e.evals_today,curve:`spring`}),e.eval_daily_limit!==null&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:` / `}),e.eval_daily_limit.toLocaleString()]}),e.eval_daily_limit===null&&(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:` · unlimited`})]})]}),e.eval_daily_limit!==null&&(0,K.jsx)(`div`,{className:`mt-1 h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-2)]`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-700 ease-out ${i}`,style:{width:`${r}%`}})})]}),!t&&(0,K.jsxs)(`a`,{href:e.upgrade_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-[var(--color-brand)] hover:underline`,children:[`Upgrade to Pro · $`,e.pricing.pro_monthly_usd,`/mo →`]}),t&&e.retention_days>0&&(0,K.jsxs)(`div`,{className:`text-[10px] text-[var(--color-fg-3)] font-mono uppercase tracking-wider`,children:[`cloud retention: `,e.retention_days,` days`]})]})]})}function el(e){return new Date(e*1e3).toLocaleTimeString()}function tl(e,t=24){let n=(0,_.useRef)(null),[r,i]=(0,_.useState)([]);return(0,_.useEffect)(()=>{let r=n.current;if(n.current=e,r===null)return;let a=Math.max(0,e-r);i(e=>{let n=e.length>=t?e.slice(-(t-1)):e.slice();return n.push(a),n})},[e,t]),r}async function nl(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:B()})}async function rl(e,t){let n=await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t})});if(!n.ok)throw Error(`Toggle failed: ${n.status}`)}async function il(e,t){let n=await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t})});if(!n.ok)throw Error(`Toggle failed: ${n.status}`)}async function al(e,t){let n=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t,decision:`ask`})});if(!n.ok)throw Error(`Update decision failed: ${n.status}`)}async function ol(e,t){let n=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t,decision:`block`})});if(!n.ok)throw Error(`Update decision failed: ${n.status}`)}function sl({ruleId:e}){return e?(0,K.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e)}`,className:`text-[var(--color-brand)] hover:underline text-xs font-mono break-all`,title:`Go to rule: ${e}`,children:e}):(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}function cl({title:e,right:t}){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h2`,{className:`overline text-[11px]`,children:e}),t]})}function ll({children:e}){return(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:e})}function ul({item:e,onDisable:t,onChangeToAsk:n,onUndo:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(`idle`),[c,l]=(0,_.useState)(!1),u=rr(e.tool,e.input),d=e.rule_id&&e.source_file,f=e.decision===`force`?`force`:`block`,p=f===`force`?`amber`:`red`,m=async()=>{s(`loading`);try{await n(),s(`done-ask`)}catch{s(`error`)}},h=async()=>{s(`loading`);try{await t(),s(`done-disable`)}catch{s(`error`)}},g=async()=>{l(!0);try{await r(o===`done-disable`?`disable`:`ask`),s(`idle`)}catch{}finally{l(!1)}},v=o===`done-ask`||o===`done-disable`;return(0,K.jsx)(q,{className:`border-l-2 ${v?`border-l-[var(--color-line-1)]`:f===`force`?`border-l-amber-400/60`:`border-l-red-500/60`} ${v?`opacity-60`:``}`,children:(0,K.jsxs)(`div`,{className:`px-3 py-3`,children:[v&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-2.5 py-1.5 mb-3 text-[11px] font-mono ${o===`done-ask`?`bg-sky-500/5 border border-sky-500/25 text-sky-300`:`bg-amber-500/5 border border-amber-500/25 text-amber-300`}`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:o===`done-ask`?`✓ rule "${e.rule_id}" → ask · prompts next time`:`✓ rule "${e.rule_id}" disabled · no longer blocks`}),(0,K.jsx)(`button`,{onClick:g,disabled:c,className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-current/40 hover:bg-white/5 transition-colors cursor-pointer disabled:opacity-50 uppercase tracking-wider text-[10px]`,children:c?`…`:`↩ undo`})]}),o===`error`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-2.5 py-1.5 mb-3 text-[11px] font-mono bg-red-500/5 border border-red-500/25 text-red-300`,children:[(0,K.jsx)(`span`,{children:`failed to update rule — check server logs`}),(0,K.jsx)(`button`,{onClick:()=>s(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-current/40 hover:bg-white/5 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`retry`})]}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5 flex-wrap`,children:[(0,K.jsx)(sr,{variant:v?o===`done-ask`?`blue`:`gray`:p,children:v?o===`done-ask`?`ask`:`disabled`:f}),(0,K.jsx)(`code`,{className:`text-[var(--color-brand)] text-xs font-mono`,children:e.tool}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-xs`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] text-[11px] font-mono tabular-nums`,children:el(e.timestamp)}),e.repeat_count>1&&(0,K.jsxs)(sr,{variant:`gray`,children:[`×`,e.repeat_count]})]}),(0,K.jsx)(`div`,{className:`text-xs font-mono truncate cursor-pointer hover:text-[var(--color-fg-0)] transition-colors ${v?`text-[var(--color-fg-4)] line-through`:`text-[var(--color-fg-1)]`}`,title:u,onClick:()=>a(e=>!e),children:u})]}),d&&!v&&o!==`error`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pt-0.5`,children:[(0,K.jsxs)(`button`,{onClick:m,disabled:o===`loading`,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-sky-500/8 text-sky-300 border border-sky-500/25 hover:bg-sky-500/15 hover:border-sky-500/40 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:[o===`loading`?(0,K.jsx)(`span`,{className:`animate-spin`,children:`⟳`}):(0,K.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,K.jsx)(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),`ask instead`]}),(0,K.jsxs)(`button`,{onClick:h,disabled:o===`loading`,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-red-500/8 text-red-300 border border-red-500/25 hover:bg-red-500/15 hover:border-red-500/40 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:[o===`loading`?(0,K.jsx)(`span`,{className:`animate-spin`,children:`⟳`}):(0,K.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,K.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,K.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`disable rule`]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 mt-2 text-[11px] font-mono`,children:[e.rule_id&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`rule`}),(0,K.jsx)(sl,{ruleId:e.rule_id})]}),e.source_file&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`src`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:e.source_file})]}),e.rules_evaluated!==null&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`evals`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums`,children:e.rules_evaluated})]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`latency`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums`,children:Zc(e.duration_ns)})]}),(0,K.jsx)(`button`,{onClick:()=>a(e=>!e),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] transition-colors ml-auto cursor-pointer uppercase tracking-wider text-[10px]`,children:i?`▾ hide`:`▸ details`})]}),i&&(0,K.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(`div`,{className:`overline mb-2`,children:`full input`}),(0,K.jsx)(Cc,{children:(()=>{try{return JSON.stringify(JSON.parse(e.input),null,2)}catch{return e.input}})()})]})]})})}function dl(){let e=ke(Qc),t=[e[`counters-updated`],e[`activity-updated`],e[`pending-changed`]],{data:n}=V(`/api/state/counters`,t),{data:r,refetch:i}=V(`/api/json/pending`,t),{data:a,refetch:o}=V(`/api/json/blocked`,t),{data:s}=V(`/api/state/activity`,t),{data:c}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:l}=V(`/api/json/limits`,[e[`limits-breach`]]),{data:u}=V(`/api/json/license`,[e[`activity-updated`]]),[d,f]=(0,_.useState)(!1),p=a?.reduce((e,t)=>e+t.repeat_count,0)??0,m=n?.allow??0,h=(n?.block??0)+(n?.force??0),g=n?.force??0,v=n?.pending??0,y=n?.log??0,b=tl(m),x=tl(h),S=tl(g),C=tl(v),w=tl(y),T=[{label:`allow`,value:m,tone:`green`,trend:b},{label:`block`,value:h,tone:`red`,trend:x},{label:`force`,value:g,tone:`amber`,trend:S},{label:`pending`,value:v,tone:`blue`,trend:C},{label:`log`,value:y,tone:`gray`,trend:w}];return(0,K.jsxs)(`div`,{ref:Tt({from:`first`}),className:`space-y-8`,children:[(0,K.jsx)(Js,{}),(0,K.jsx)(`div`,{"data-reveal":!0,children:(0,K.jsx)(qc,{})}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-5 gap-2`,children:T.map(e=>(0,K.jsx)(kc,{align:`left`,label:e.label,value:(0,K.jsx)(fr,{value:e.value,curve:`spring`}),tone:e.tone,labelPlacement:`above`,contentClassName:`py-3`,valueClassName:`text-2xl font-medium`,trend:e.trend,"data-reveal":!0},e.label))}),(0,K.jsxs)(`div`,{"data-reveal":!0,className:`grid grid-cols-12 gap-2 items-stretch`,children:[(0,K.jsxs)(`div`,{className:`col-span-12 md:col-span-7 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 flex flex-col gap-2`,children:[(0,K.jsx)(Ic,{bins:60,height:42}),(0,K.jsx)(Wc,{windowSec:60,height:12})]}),(0,K.jsx)(`div`,{className:`col-span-12 md:col-span-5 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 flex items-center justify-center`,children:(0,K.jsx)(Vc,{size:130})})]}),u&&(0,K.jsx)(`div`,{"data-reveal":!0,children:(0,K.jsx)($c,{info:u})}),c&&(0,K.jsxs)(`div`,{"data-reveal":!0,className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(Mc,{label:`cpu`,value:c.cpu_pct==null?`—`:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fr,{value:c.cpu_pct,format:e=>Math.round(e).toString()}),`%`]}),tone:l?.breaches.cpu?`red`:(c.cpu_pct??0)>=60?`amber`:`green`,breached:l?.breaches.cpu??!1,trendData:c.history?.cpu_pct,trendColor:l?.breaches.cpu?`#f87171`:`#34d399`,threshold:l?.config.cpuLimitPct,maxValue:100,className:l?.breaches.cpu?`border-red-500/40`:``,footer:(0,K.jsx)(`a`,{href:`/monitor`,className:`mt-1 block text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`view details →`})}),(0,K.jsx)(Mc,{label:`memory rss`,value:c.memory_rss_mb==null?`—`:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fr,{value:c.memory_rss_mb,format:e=>Math.round(e).toString()}),(0,K.jsx)(`span`,{className:`ml-1 text-sm text-[var(--color-fg-3)]`,children:`MB`})]}),tone:l?.breaches.memory?`red`:`neutral`,breached:l?.breaches.memory??!1,trendData:c.history?.memory_rss_mb,trendColor:l?.breaches.memory?`#f87171`:`#38bdf8`,threshold:l?.config.memoryLimitMb,className:l?.breaches.memory?`border-red-500/40`:``,footer:(0,K.jsx)(`a`,{href:`/monitor`,className:`mt-1 block text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`view details →`})})]}),(0,K.jsxs)(`section`,{"data-reveal":!0,children:[(0,K.jsx)(cl,{title:`pending approvals`}),!r||r.length===0?(0,K.jsx)(ll,{children:`no pending approvals`}):(0,K.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,K.jsxs)(q,{className:`border-l-2 border-l-sky-500/50`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(X,{size:`sm`,variant:`primary`,onClick:async()=>{await nl(e.id,`allow`),i()},children:`approve`}),(0,K.jsx)(X,{size:`sm`,variant:`danger`,onClick:async()=>{await nl(e.id,`block`),i()},children:`deny`})]})]}),(0,K.jsxs)(Y,{className:`space-y-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`tool`}),(0,K.jsx)(`code`,{className:`text-[var(--color-brand)] font-mono`,children:e.toolCall.tool})]}),e.prompt&&(0,K.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,K.jsx)(`span`,{className:`overline pt-0.5`,children:`prompt`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.prompt})]}),(0,K.jsx)(Cc,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id))})]}),a&&a.length>0&&(0,K.jsxs)(`section`,{"data-reveal":!0,children:[(0,K.jsx)(cl,{title:`blocked actions`,right:(0,K.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[a.length,` active`,p>a.length?` · ${p} total hits`:``]})}),(0,K.jsx)(`div`,{className:`space-y-2`,children:(d?a:a.slice(0,Xc)).map(e=>(0,K.jsx)(ul,{item:e,onDisable:async()=>{await rl(e.rule_id,e.source_file),o()},onChangeToAsk:async()=>{await al(e.rule_id,e.source_file),o()},onUndo:async t=>{t===`disable`?await il(e.rule_id,e.source_file):await ol(e.rule_id,e.source_file),o()}},`${e.decision}:${e.rule_id??`none`}:${e.tool}:${e.timestamp}:${e.input}`))}),a.length>Xc&&(0,K.jsx)(`div`,{className:`mt-3 flex justify-center`,children:(0,K.jsx)(X,{size:`sm`,variant:`secondary`,onClick:()=>f(e=>!e),children:d?`↑ show less`:`↓ show ${a.length-Xc} more`})})]}),(0,K.jsxs)(`section`,{"data-reveal":!0,children:[(0,K.jsx)(cl,{title:`recent audit log`,right:s&&s.length>0?(0,K.jsx)(`a`,{href:`/audit`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors`,children:`view all →`}):void 0}),!s||s.length===0?(0,K.jsx)(ll,{children:`no audit entries yet`}):(0,K.jsx)(`div`,{className:`space-y-1.5`,children:s.slice(0,15).map(e=>(0,K.jsx)(Sc,{row:e},e.id))})]})]})}function fl({checked:e,onChange:t,disabled:n,size:r=`md`,tone:i=`brand`,label:a}){return(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a,disabled:n,onClick:()=>t(!e),className:`ss-toggle ${r===`sm`?`ss-toggle--sm`:``} ${i===`danger`?`ss-toggle--danger`:``}`,children:(0,K.jsx)(`span`,{className:`ss-toggle-thumb`,"aria-hidden":`true`})})}var pl=new Map;async function ml(e){let t=pl.get(e);if(t)return t.status===`ok`?t.data:t.status===`error`?null:t.promise;let n=(async()=>{try{let t=await fetch(`/api/json/rule-explain?ruleId=${encodeURIComponent(e)}`,{headers:{Accept:`application/json`}});if(!t.ok)return pl.set(e,{status:`error`,error:`HTTP ${t.status}`}),null;let n=await t.json();return pl.set(e,{status:`ok`,data:n}),n}catch(t){return pl.set(e,{status:`error`,error:String(t)}),null}})();return pl.set(e,{status:`loading`,promise:n}),n}var hl=220,gl=90;function _l({ruleId:e,children:t,className:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),u.current=null,d.current=null},p=(0,_.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.left;n+320>window.innerWidth-12&&(n=Math.max(12,window.innerWidth-320-12));let r=t.bottom+8;r+200>window.innerHeight-12&&(r=Math.max(12,t.top-200-8)),c({top:r,left:n})},[]),m=(0,_.useCallback)(()=>{f(),u.current=setTimeout(()=>{p(),i(!0),ml(e).then(e=>{e&&o(e)});let t=pl.get(e);t&&t.status===`ok`&&o(t.data)},hl)},[e,p]),h=(0,_.useCallback)(()=>{f(),d.current=setTimeout(()=>{i(!1)},gl)},[]);return(0,_.useEffect)(()=>{if(!r)return;let e=()=>p(),t=()=>p(),n=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,t),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,t),window.removeEventListener(`keydown`,n)}},[r,p]),(0,_.useEffect)(()=>()=>f(),[]),(0,K.jsxs)(`span`,{ref:l,className:`ss-rule-trigger${n?` `+n:``}`,onMouseEnter:m,onMouseLeave:h,onFocus:m,onBlur:h,tabIndex:0,"aria-describedby":r?`rule-popover-${e}`:void 0,children:[t,r&&s&&(0,K.jsx)(`span`,{id:`rule-popover-${e}`,role:`tooltip`,className:`ss-rule-popover`,style:{top:s.top,left:s.left},onMouseEnter:()=>f(),onMouseLeave:h,children:a?(0,K.jsx)(vl,{data:a}):(0,K.jsx)(`span`,{className:`ss-rule-popover__loading`,children:`loading rule…`})})]})}function vl({data:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`ss-rule-popover__head`,children:[(0,K.jsx)(`code`,{className:`ss-rule-popover__id`,children:e.ruleId}),(0,K.jsx)(`span`,{className:`ss-rule-popover__pill ss-rule-popover__pill--${e.decision}`,children:e.decision}),(0,K.jsx)(`span`,{className:`ss-rule-popover__state ss-rule-popover__state--${e.enabled?`on`:`off`}`,children:e.enabled?`ON`:`OFF`})]}),(0,K.jsx)(`strong`,{className:`ss-rule-popover__headline`,children:e.headline}),(0,K.jsx)(`span`,{className:`ss-rule-popover__summary`,children:e.summary}),e.conditions.length>1&&(0,K.jsxs)(`span`,{className:`ss-rule-popover__section`,children:[(0,K.jsx)(`span`,{className:`ss-rule-popover__label`,children:`Matches when`}),(0,K.jsx)(`ul`,{className:`ss-rule-popover__list`,children:e.conditions.map((e,t)=>(0,K.jsx)(`li`,{children:e},t))})]}),e.hints.length>0&&(0,K.jsx)(`span`,{className:`ss-rule-popover__hints`,children:e.hints.map((e,t)=>(0,K.jsx)(`span`,{className:`ss-rule-popover__hint`,children:e},t))}),(0,K.jsx)(`span`,{className:`ss-rule-popover__foot`,children:(0,K.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.ruleId)}`,className:`ss-rule-popover__link`,children:`Open in Rules →`})})]})}function yl({open:e,onClose:t,title:n,subtitle:r,children:i,footer:a,size:o=`md`}){let s=(0,_.useRef)(null),c=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement;let n=document.body.style.overflow;document.body.style.overflow=`hidden`;let r=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,r),s.current?.focus(),()=>{document.removeEventListener(`keydown`,r),document.body.style.overflow=n,c.current?.focus?.()}},[e,t]),e?(0,K.jsx)(`div`,{className:`ss-sheet-backdrop`,onClick:e=>{e.target===e.currentTarget&&t()},role:`presentation`,children:(0,K.jsxs)(`div`,{ref:s,className:`ss-sheet ss-sheet--${o}`,role:`dialog`,"aria-modal":`true`,"aria-label":n??`Detail`,tabIndex:-1,children:[(0,K.jsx)(`button`,{className:`ss-sheet-handle`,onClick:t,"aria-label":`Close`,type:`button`}),(0,K.jsxs)(`div`,{className:`ss-sheet-head`,children:[(0,K.jsxs)(`div`,{className:`ss-sheet-head-text`,children:[n&&(0,K.jsx)(`h2`,{className:`ss-sheet-title`,children:n}),r&&(0,K.jsx)(`p`,{className:`ss-sheet-subtitle`,children:r})]}),(0,K.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`ss-sheet-close`,children:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,K.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]}),(0,K.jsx)(`div`,{className:`ss-sheet-body`,children:i}),a&&(0,K.jsx)(`div`,{className:`ss-sheet-footer`,children:a})]})}):null}function bl(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function xl({open:e,onClose:t,onSaved:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(`error`),[w,T]=(0,_.useState)(50),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(``),A=(0,_.useRef)(null);(0,_.useEffect)(()=>{f(bl()!==void 0)},[]),(0,_.useEffect)(()=>{fetch(`/api/rules/dictate/templates`).then(e=>e.json()).then(e=>i(e.templates??[])).catch(()=>void 0)},[]),(0,_.useEffect)(()=>{e?(o(``),c(``),m(null),k(``),y({}),x(``),C(`error`),T(50)):M()},[e]);function j(){let e=bl();if(!e)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=`en-US`,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i&&(i.isFinal?t+=i[0].transcript:n+=i[0].transcript)}t&&o(e=>(e?`${e} ${t}`:t).trim()),c(n)},t.onend=()=>u(!1),t.onerror=()=>u(!1),t.start(),A.current=t,u(!0)}function M(){if(A.current){try{A.current.stop()}catch{}A.current=null}u(!1)}async function N(e){let t=e.trim();if(!t){m(null);return}g(!0);try{let e=await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({transcript:t})})).json();m(e),e.matched&&e.slots&&y({...e.slots}),e.args?(x(e.args.name),C(e.args.severity),T(e.args.priority)):e.modifiers?.severity&&C(e.modifiers.severity)}finally{g(!1)}}async function ee(){if(p?.templateId){g(!0);try{m(await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({templateId:p.templateId,slots:v,severity:S,priority:w,name:b})})).json())}finally{g(!1)}}}async function te(e=!1){if(p?.args){D(!0),k(``);try{let r={args:{...p.args,name:b||p.args.name,severity:S,priority:w},overwrite:e},i=await(await fetch(`/api/rules/dictate/save`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify(r)})).json();i.ok?(n?.(),t()):i.error===`exists`&&!e?window.confirm(`A rule named "${r.args.name}" already exists. Overwrite it?`)&&await te(!0):k(i.error??`save failed`)}catch(e){k(e instanceof Error?e.message:String(e))}finally{D(!1)}}}let P=p?.templateId?r.find(e=>e.id===p.templateId):void 0;return(0,K.jsx)(yl,{open:e,onClose:t,title:`Dictate a Rule`,subtitle:`Speak or type — SSG matches a template, deterministic, no inference cost`,size:`lg`,footer:p?.args?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[O?(0,K.jsx)(`span`,{className:`text-[11px] font-mono text-red-300 mr-auto`,children:O}):(0,K.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mr-auto`,children:[`will write .sigmashake/rules/`,b||p.args.name,`.rules`]}),(0,K.jsx)(X,{variant:`secondary`,onClick:t,disabled:E,children:`Cancel`}),(0,K.jsx)(X,{variant:`primary`,onClick:()=>te(!1),disabled:E,children:E?`Saving…`:`Save Rule`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mr-auto`,children:`dictate or pick a template to begin`}),(0,K.jsx)(X,{variant:`secondary`,onClick:t,children:`Close`})]}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(Sl,{transcript:a,interim:s,listening:l,voiceSupported:d,onChange:o,onToggleMic:l?M:j,onSubmit:()=>N(a),matching:h}),!p&&r.length>0&&(0,K.jsx)(Cl,{templates:r,onPick:e=>{o(e.example),N(e.example)}}),p&&!p.matched&&(0,K.jsx)(wl,{onTryAgain:()=>{o(``),m(null)},templates:r,onPick:e=>{o(e.example),N(e.example)}}),p?.matched&&P&&(0,K.jsx)(Tl,{template:P,args:p.args,preview:p.preview,previewError:p.previewError,missingSlots:p.missingSlots??[],editedSlots:v,editedName:b,editedSeverity:S,editedPriority:w,onSlotChange:(e,t)=>y(n=>({...n,[e]:t})),onNameChange:x,onSeverityChange:C,onPriorityChange:T,onApply:ee,applying:h,alternatives:p.alternatives.map(e=>r.find(t=>t.id===e)).filter(e=>!!e),onSwitchTemplate:e=>{y({}),m({...p,templateId:e.id,args:void 0,preview:void 0}),setTimeout(()=>ee(),0)}})]})})}function Sl({transcript:e,interim:t,listening:n,voiceSupported:r,onChange:i,onToggleMic:a,onSubmit:o,matching:s}){return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`what should the rule do?`}),r?(0,K.jsx)(`button`,{type:`button`,onClick:a,className:`ml-auto px-2 py-1 text-[11px] font-mono uppercase tracking-wider rounded-sm border cursor-pointer transition-colors ${n?`border-red-400 text-red-300 bg-red-500/10`:`border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:bg-[var(--color-surface-2)]`}`,"aria-pressed":n,children:n?`● recording — click to stop`:`🎙 dictate`}):(0,K.jsx)(`span`,{className:`ml-auto text-[10px] font-mono text-[var(--color-fg-4)]`,children:`voice unavailable in this browser`})]}),(0,K.jsx)(`textarea`,{rows:3,value:e+(t?` ${t}`:``),onChange:e=>i(e.target.value),placeholder:`e.g. "block any command containing dangerous-cmd" or "ask before editing the migrations folder"`,className:`w-full font-mono text-[13px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm p-3 text-[var(--color-fg-0)] placeholder:text-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-brand)]`}),(0,K.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,K.jsx)(X,{variant:`primary`,size:`sm`,onClick:o,disabled:s||!e.trim(),children:s?`Matching…`:`Match Template`})})]})}function Cl({templates:e,onPick:t}){return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`or pick a template`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`text-left p-3 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] hover:bg-[var(--color-surface-2)] cursor-pointer transition-colors`,children:[(0,K.jsx)(`div`,{className:`font-mono text-[12px] text-[var(--color-fg-0)] mb-1`,children:e.name}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)] mb-1`,children:e.description}),(0,K.jsxs)(`div`,{className:`font-mono text-[10px] text-[var(--color-fg-4)] italic`,children:[`"`,e.example,`"`]})]},e.id))})]})}function wl({onTryAgain:e,templates:t,onPick:n}){return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/5 p-3`,children:[(0,K.jsx)(`div`,{className:`font-mono text-[12px] text-amber-300 mb-1`,children:`no template matched`}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`The deterministic matcher could not recognise the intent in your dictation. Try one of the templates below — they show the phrasing the matcher understands.`})]}),(0,K.jsx)(`button`,{type:`button`,onClick:e,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline cursor-pointer`,children:`← clear and try again`}),(0,K.jsx)(Cl,{templates:t,onPick:n})]})}function Tl({template:e,args:t,preview:n,previewError:r,missingSlots:i,editedSlots:a,editedName:o,editedSeverity:s,editedPriority:c,onSlotChange:l,onNameChange:u,onSeverityChange:d,onPriorityChange:f,onApply:p,applying:m,alternatives:h,onSwitchTemplate:g}){return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-sm border border-emerald-500/40 bg-emerald-500/5 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-emerald-300`,children:`matched`}),(0,K.jsx)(`span`,{className:`font-mono text-[12px] text-[var(--color-fg-0)]`,children:e.name})]}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1`,children:e.description})]}),h.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[11px] font-mono`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`also matches:`}),h.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:bg-[var(--color-surface-2)] cursor-pointer`,children:e.name},e.id))]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`slots`}),e.slots.map(e=>{let t=a[e.name]??``,n=i.includes(e.name);return(0,K.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,K.jsxs)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:[e.label,e.required&&(0,K.jsx)(`span`,{className:`text-red-300 ml-1`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:t,onChange:t=>l(e.name,t.target.value),placeholder:e.placeholder,className:`font-mono text-[12px] bg-[var(--color-surface-1)] border rounded-sm px-2 py-1 text-[var(--color-fg-0)] placeholder:text-[var(--color-fg-4)] focus:outline-none ${n?`border-red-400 focus:border-red-300`:`border-[var(--color-line-1)] focus:border-[var(--color-brand)]`}`})]},e.name)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,K.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`rule name`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>u(e.target.value),placeholder:`kebab-case-id`,className:`font-mono text-[12px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[var(--color-fg-0)] focus:outline-none focus:border-[var(--color-brand)]`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,K.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`severity`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[`error`,`warning`,`info`].map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`px-2 py-0.5 rounded-sm border cursor-pointer transition-colors ${s===e?`border-[var(--color-brand)] text-[var(--color-fg-0)] bg-[var(--color-surface-2)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-[var(--color-surface-2)]`}`,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,K.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`priority`}),(0,K.jsx)(`input`,{type:`number`,value:c,min:0,max:100,onChange:e=>f(Math.max(0,Math.min(100,Number(e.target.value)||0))),className:`font-mono text-[12px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[var(--color-fg-0)] focus:outline-none focus:border-[var(--color-brand)] w-24`})]}),(0,K.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,K.jsx)(X,{variant:`secondary`,size:`sm`,onClick:p,disabled:m,children:m?`Rebuilding…`:`Apply edits`})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`generated .rules preview`}),i.length>0&&(0,K.jsx)(`div`,{className:`text-[11px] font-mono text-amber-300`,children:`fill the required slots above to see the rule`}),r&&(0,K.jsxs)(`div`,{className:`text-[11px] font-mono text-red-300`,children:[`preview error: `,r]}),n&&(0,K.jsx)(`pre`,{className:`font-mono text-[12px] bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3 text-[var(--color-fg-0)] overflow-x-auto whitespace-pre`,children:n}),t&&(0,K.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`decision=`,t.decision,` · target=`,t.target,` · field=`,t.field,` `,`· op=`,t.operator]})]})]})}var El=[`rules-changed`],Dl=[`block`,`ask`,`log`,`allow`,`force`,`shadow`],Ol={block:`text-red-300`,deny:`text-red-300`,ask:`text-sky-300`,allow:`text-emerald-300`,log:`text-[var(--color-fg-3)]`,force:`text-amber-300`,shadow:`text-violet-300`},kl=[{value:`today`,label:`today`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`all`,label:`all`}];async function Al(e,t){await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t})})}async function jl(e,t,n){await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({ruleId:e,file:t,decision:n})})}async function Ml(e,t){return fetch(`/api/rules/bulk-set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({targets:e,enabled:t})}).then(e=>e.json())}async function Nl(e,t){return fetch(`/api/rules/bulk-update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({targets:e,decision:t})}).then(e=>e.json())}async function Pl(e){return fetch(`/api/rules/bulk-delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({targets:e})}).then(e=>e.json())}async function Q(e,t={}){return fetch(`/api/rules/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify(t)}).then(e=>e.json())}function Fl(e){if(!e)return`never`;let t=Date.now()/1e3-e;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Il({rule:e,file:t,onToggle:n}){let[r,i]=(0,_.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider ${e.enabled?`text-[var(--color-fg-1)]`:`text-[var(--color-fg-4)]`}`,children:e.enabled?`on`:`off`}),(0,K.jsx)(fl,{size:`sm`,checked:e.enabled,disabled:r,label:`${e.enabled?`Disable`:`Enable`} rule ${e.id}`,onChange:async()=>{i(!0);try{await n()}finally{i(!1)}}})]})}function Ll(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/json/rule-write-enforcement`,{headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json();!e&&typeof r.enforced==`boolean`&&t(r.enforced)}catch{}})(),()=>{e=!0}},[]);async function o(e){r(!0);try{let n=await fetch(`/api/json/rule-write-enforcement`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({enforced:e})});if(n.ok){let e=await n.json();typeof e.enforced==`boolean`&&t(e.enforced)}}finally{r(!1),a(!1)}}if(e===null)return null;let s=!e;return(0,K.jsx)(q,{className:s?`border-amber-500/40 bg-amber-500/5`:`border-[var(--color-line-1)]`,children:(0,K.jsx)(Y,{className:`px-3 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`rule-write protection`}),(0,K.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider ${s?`text-amber-300`:`text-emerald-300`}`,children:s?`disabled`:`enforced`})]}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1 leading-snug`,children:s?`Agents can currently Write/Edit .rules files. Turn this back on when you finish authoring.`:`Agents cannot Write/Edit/MultiEdit any .sigmashake/rules/**/*.rules file. Disable only when curating rulesets.`})]}),(0,K.jsx)(`div`,{className:`shrink-0`,children:i?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{onClick:()=>o(!1),disabled:n,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:`disable`}),(0,K.jsx)(`button`,{onClick:()=>a(!1),disabled:n,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`cancel`})]}):(0,K.jsx)(`button`,{onClick:()=>{e?a(!0):o(!0)},disabled:n,className:`text-[11px] font-mono uppercase tracking-wider border rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-50 ${s?`bg-emerald-500/10 border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20`:`bg-[var(--color-surface-1)] border-[var(--color-line-1)] text-[var(--color-fg-1)] hover:bg-[var(--color-surface-2)]`}`,children:s?`enable`:`disable`})})]})})})}function Rl({perf:e}){if(!e)return null;let t=e.totalRules>0?e.activeRules/e.totalRules*100:0,n=e.avgEvalMs>50?`text-amber-300`:e.avgEvalMs>100?`text-red-300`:`text-emerald-300`;return(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{className:`px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-4 flex-wrap`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`installed`}),(0,K.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:e.totalRules})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`active`}),(0,K.jsxs)(`div`,{className:`font-mono text-sm text-emerald-300 tabular-nums`,children:[e.activeRules,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[11px]`,children:[`(`,t.toFixed(0),`%)`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`avg eval`}),(0,K.jsxs)(`div`,{className:`font-mono text-sm tabular-nums ${n}`,children:[e.avgEvalMs.toFixed(1),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`p95`}),(0,K.jsxs)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:[e.p95EvalMs.toFixed(1),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`per-rule`}),(0,K.jsxs)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:[`~`,e.perRuleMs.toFixed(3),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`evals today`}),(0,K.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:e.evalsToday.toLocaleString()})]}),(0,K.jsxs)(`div`,{className:`ml-auto text-right`,children:[(0,K.jsx)(`div`,{className:`overline text-[10px]`,children:`all-time evals`}),(0,K.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-2)] tabular-nums`,children:e.evalsAllTime.toLocaleString()})]})]}),e.avgEvalMs>50&&(0,K.jsx)(`p`,{className:`mt-2 text-[11px] text-amber-300/80`,children:`⚡ avg eval > 50ms — consider trimming or disabling low-value rules.`})]})})}function zl({totalRules:e,activeRules:t,onChanged:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);async function s(e){i(e);try{e===`disable`?await Q(`disable-all`):e===`enable`?await Q(`enable-all`):await Q(`uninstall-all`,{confirm:`UNINSTALL_ALL_RULES`}),n()}finally{i(null),o(null)}}return(0,K.jsx)(q,{className:`border-[var(--color-line-1)]`,children:(0,K.jsx)(Y,{className:`px-3 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`rule firewall`}),(0,K.jsxs)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:[t,`/`,e,` active`]})]}),(0,K.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1 leading-snug`,children:[`Master switches across every installed ruleset. Disable / enable are reversible; uninstall wipes `,(0,K.jsx)(`code`,{children:`~/.sigmashake/rules/`}),`.`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[a===`disable`?(0,K.jsx)(Bl,{onConfirm:()=>void s(`disable`),onCancel:()=>o(null),tone:`amber`,label:`disable ${t} rules`,disabled:r!==null}):(0,K.jsx)(`button`,{onClick:()=>o(`disable`),disabled:r!==null||t===0,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`disable`?`disabling…`:`disable all`}),a===`enable`?(0,K.jsx)(Bl,{onConfirm:()=>void s(`enable`),onCancel:()=>o(null),tone:`emerald`,label:`enable ${e-t} rules`,disabled:r!==null}):(0,K.jsx)(`button`,{onClick:()=>o(`enable`),disabled:r!==null||t===e,className:`text-[11px] font-mono uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`enable`?`enabling…`:`enable all`}),a===`uninstall`?(0,K.jsx)(Bl,{onConfirm:()=>void s(`uninstall`),onCancel:()=>o(null),tone:`red`,label:`UNINSTALL ${e} rules`,disabled:r!==null}):(0,K.jsx)(`button`,{onClick:()=>o(`uninstall`),disabled:r!==null||e===0,className:`text-[11px] font-mono uppercase tracking-wider bg-red-500/10 border border-red-500/40 text-red-200 hover:bg-red-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`uninstall`?`uninstalling…`:`uninstall all`})]})]})})})}function Bl({onConfirm:e,onCancel:t,tone:n,label:r,disabled:i}){let a={amber:`bg-amber-500/10 border-amber-500/40 text-amber-200 hover:bg-amber-500/20`,emerald:`bg-emerald-500/10 border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20`,red:`bg-red-500/10 border-red-500/40 text-red-200 hover:bg-red-500/20`}[n];return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsxs)(`button`,{onClick:e,disabled:i,className:`text-[11px] font-mono uppercase tracking-wider border rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50 ${a}`,children:[`confirm: `,r]}),(0,K.jsx)(`button`,{onClick:t,disabled:i,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`cancel`})]})}function Vl({selected:e,onClear:t,onApply:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`block`),[s,c]=(0,_.useState)(!1);if(e.length===0)return null;async function l(e,t){i(e);try{await n(e,t)}finally{i(null),c(!1)}}return(0,K.jsx)(`div`,{className:`sticky top-0 z-20 -mx-1 px-1`,children:(0,K.jsx)(q,{className:`border-sky-500/40 bg-sky-500/5 backdrop-blur`,children:(0,K.jsx)(Y,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-sky-200`,children:[e.length,` selected`]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`button`,{onClick:()=>void l(`enable`),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`enable`?`…`:`enable`}),(0,K.jsx)(`button`,{onClick:()=>void l(`disable`),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`disable`?`…`:`disable`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),disabled:r!==null,className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50 ${Ol[a]??`text-[var(--color-fg-2)]`}`,children:Dl.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),(0,K.jsx)(`button`,{onClick:()=>void l(`decision`,a),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-sky-500/10 border border-sky-500/40 text-sky-200 hover:bg-sky-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`decision`?`…`:`set decision`})]}),s?(0,K.jsx)(Bl,{onConfirm:()=>void l(`delete`),onCancel:()=>c(!1),tone:`red`,label:`delete ${e.length}`,disabled:r!==null}):(0,K.jsx)(`button`,{onClick:()=>c(!0),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-red-500/10 border border-red-500/40 text-red-200 hover:bg-red-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:`delete…`}),(0,K.jsx)(`button`,{onClick:t,disabled:r!==null,className:`ml-auto text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`clear`})]})})})})}function Hl({ruleId:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),fetch(`/api/json/rule-audit?ruleId=${encodeURIComponent(e)}&limit=25`).then(e=>e.json()).then(e=>{t||n(e)}).catch(()=>{}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),r?(0,K.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-[var(--color-fg-3)]`,children:`loading audit…`}):!t||t.rows.length===0?(0,K.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no audit entries for this rule`}):(0,K.jsxs)(`div`,{className:`mt-2 border border-[var(--color-line-0)] rounded-sm overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`bg-[var(--color-surface-0)] px-2 py-1 flex items-center gap-2`,children:(0,K.jsxs)(`span`,{className:`overline text-[10px]`,children:[`audit log — last `,t.rows.length,` of `,t.total]})}),(0,K.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)] max-h-64 overflow-y-auto`,children:t.rows.map(e=>(0,K.jsxs)(`div`,{className:`px-2 py-1.5 flex items-center gap-3 text-[11px] font-mono`,children:[(0,K.jsx)(`span`,{className:`uppercase tracking-wider w-14 shrink-0 ${Ol[e.decision]??`text-[var(--color-fg-2)]`}`,children:e.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] w-20 shrink-0 truncate`,children:e.tool}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] flex-1 min-w-0 truncate`,children:e.input}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0`,children:e.duration_ns?`${Math.round(e.duration_ns/1e6)}ms`:`–`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums shrink-0 w-16 text-right`,children:Fl(e.timestamp)})]},e.id))})]})}function Ul(){let[e,t]=(0,_.useState)(!1);return(0,K.jsx)(q,{children:(0,K.jsxs)(`details`,{open:e,onToggle:e=>t(e.target.open),children:[(0,K.jsxs)(`summary`,{className:`px-3 py-2 cursor-pointer list-none select-none flex items-center gap-2 hover:bg-[var(--color-surface-2)]/70`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`ai-native config`}),(0,K.jsx)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`curl recipes — every UI action is also a JSON endpoint`}),(0,K.jsx)(`svg`,{className:`ml-auto text-[var(--color-fg-3)]`,width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,K.jsx)(`polyline`,{points:e?`6 15 12 9 18 15`:`6 9 12 15 18 9`})})]}),(0,K.jsxs)(Y,{className:`py-2`,children:[(0,K.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mb-2 leading-snug`,children:[`Point an agent at `,(0,K.jsx)(`code`,{children:`http://127.0.0.1:7901`}),`. Every bulk action below is one POST — no UI scraping required.`]}),(0,K.jsx)(`pre`,{className:`text-[10px] font-mono text-[var(--color-fg-2)] bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm p-2 overflow-x-auto whitespace-pre`,children:`# list rules + stats
8
+ `+e.stack}}var ye=Object.prototype.hasOwnProperty,be=t.unstable_scheduleCallback,xe=t.unstable_cancelCallback,Se=t.unstable_shouldYield,Ce=t.unstable_requestPaint,we=t.unstable_now,Te=t.unstable_getCurrentPriorityLevel,Ee=t.unstable_ImmediatePriority,De=t.unstable_UserBlockingPriority,Oe=t.unstable_NormalPriority,ke=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,je=t.log,Me=t.unstable_setDisableYieldValue,Ne=null,Pe=null;function B(e){if(typeof je==`function`&&Me(e),Pe&&typeof Pe.setStrictMode==`function`)try{Pe.setStrictMode(Ne,e)}catch{}}var Fe=Math.clz32?Math.clz32:Re,Ie=Math.log,Le=Math.LN2;function Re(e){return e>>>=0,e===0?32:31-(Ie(e)/Le|0)|0}var ze=256,Be=262144,Ve=4194304;function He(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ue(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=He(n))):i=He(o):i=He(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=He(n))):i=He(o)):i=He(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function We(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ge(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ke(){var e=Ve;return Ve<<=1,!(Ve&62914560)&&(Ve=4194304),e}function qe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Je(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ye(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Fe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Xe(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Xe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Fe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ze(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Fe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Qe(e,t){var n=t&-t;return n=n&42?1:$e(n),(n&(e.suspendedLanes|t))===0?n:0}function $e(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function et(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function tt(){var e=F.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function nt(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var rt=Math.random().toString(36).slice(2),it=`__reactFiber$`+rt,at=`__reactProps$`+rt,ot=`__reactContainer$`+rt,st=`__reactEvents$`+rt,ct=`__reactListeners$`+rt,lt=`__reactHandles$`+rt,ut=`__reactResources$`+rt,dt=`__reactMarker$`+rt;function ft(e){delete e[it],delete e[at],delete e[st],delete e[ct],delete e[lt]}function pt(e){var t=e[it];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ot]||n[it]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[it])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function mt(e){if(e=e[it]||e[ot]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ht(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function gt(e){var t=e[ut];return t||=e[ut]={hoistableStyles:new Map,hoistableScripts:new Map},t}function _t(e){e[dt]=!0}var vt=new Set,yt={};function bt(e,t){xt(e,t),xt(e+`Capture`,t)}function xt(e,t){for(yt[e]=t,e=0;e<t.length;e++)vt.add(t[e])}var St=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Ct={},wt={};function Tt(e){return ye.call(wt,e)?!0:ye.call(Ct,e)?!1:St.test(e)?wt[e]=!0:(Ct[e]=!0,!1)}function Et(e,t,n){if(Tt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Dt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Ot(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function kt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function At(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function jt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Mt(e){if(!e._valueTracker){var t=At(e)?`checked`:`value`;e._valueTracker=jt(e,t,``+e[t])}}function V(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=At(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Nt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Pt=/[\n"\\]/g;function Ft(e){return e.replace(Pt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function It(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+kt(t)):e.value!==``+kt(t)&&(e.value=``+kt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Rt(e,o,kt(n)):Rt(e,o,kt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+kt(s):e.removeAttribute(`name`)}function Lt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Mt(e);return}n=n==null?``:``+kt(n),t=t==null?n:``+kt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Mt(e)}function Rt(e,t,n){t===`number`&&Nt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function H(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+kt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function zt(e,t,n){if(t!=null&&(t=``+kt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+kt(n)}function Bt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(te(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=kt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Mt(e)}function Vt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ht=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ut(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Ht.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Wt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Ut(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ut(e,o,t[o])}function Gt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Kt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),qt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jt(e){return qt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Yt(){}var Xt=null;function Zt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qt=null,$t=null;function en(e){var t=mt(e);if(t&&(e=t.stateNode)){var n=e[at]||null;a:switch(e=t.stateNode,t.type){case`input`:if(It(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ft(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[at]||null;if(!a)throw Error(i(90));It(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&V(r)}break a;case`textarea`:zt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&H(e,!!n.multiple,t,!1)}}}var tn=!1;function nn(e,t,n){if(tn)return e(t,n);tn=!0;try{return e(t)}finally{if(tn=!1,(Qt!==null||$t!==null)&&(vu(),Qt&&(t=Qt,e=$t,$t=Qt=null,en(t),e)))for(t=0;t<e.length;t++)en(e[t])}}function rn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[at]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var an=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),on=!1;if(an)try{var sn={};Object.defineProperty(sn,`passive`,{get:function(){on=!0}}),window.addEventListener(`test`,sn,sn),window.removeEventListener(`test`,sn,sn)}catch{on=!1}var cn=null,ln=null,un=null;function dn(){if(un)return un;var e,t=ln,n=t.length,r,i=`value`in cn?cn.value:cn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return un=i.slice(e,1<r?1-r:void 0)}function fn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function pn(){return!0}function mn(){return!1}function hn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?pn:mn,this.isPropagationStopped=mn,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=pn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=pn)},persist:function(){},isPersistent:pn}),t}var gn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_n=hn(gn),vn=h({},gn,{view:0,detail:0}),yn=hn(vn),bn,xn,Sn,Cn=h({},vn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Pn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Sn&&(Sn&&e.type===`mousemove`?(bn=e.screenX-Sn.screenX,xn=e.screenY-Sn.screenY):xn=bn=0,Sn=e),bn)},movementY:function(e){return`movementY`in e?e.movementY:xn}}),wn=hn(Cn),Tn=hn(h({},Cn,{dataTransfer:0})),En=hn(h({},vn,{relatedTarget:0})),Dn=hn(h({},gn,{animationName:0,elapsedTime:0,pseudoElement:0})),On=hn(h({},gn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),kn=hn(h({},gn,{data:0})),An={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},jn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Mn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Nn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Mn[e])?!!t[e]:!1}function Pn(){return Nn}var Fn=hn(h({},vn,{key:function(e){if(e.key){var t=An[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=fn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?jn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Pn,charCode:function(e){return e.type===`keypress`?fn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?fn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),In=hn(h({},Cn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Ln=hn(h({},vn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Pn})),Rn=hn(h({},gn,{propertyName:0,elapsedTime:0,pseudoElement:0})),zn=hn(h({},Cn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Bn=hn(h({},gn,{newState:0,oldState:0})),Vn=[9,13,27,32],Hn=an&&`CompositionEvent`in window,Un=null;an&&`documentMode`in document&&(Un=document.documentMode);var Wn=an&&`TextEvent`in window&&!Un,Gn=an&&(!Hn||Un&&8<Un&&11>=Un),Kn=` `,qn=!1;function Jn(e,t){switch(e){case`keyup`:return Vn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Yn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Xn=!1;function Zn(e,t){switch(e){case`compositionend`:return Yn(t);case`keypress`:return t.which===32?(qn=!0,Kn):null;case`textInput`:return e=t.data,e===Kn&&qn?null:e;default:return null}}function Qn(e,t){if(Xn)return e===`compositionend`||!Hn&&Jn(e,t)?(e=dn(),un=ln=cn=null,Xn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Gn&&t.locale!==`ko`?null:t.data;default:return null}}var $n={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function er(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!$n[e.type]:t===`textarea`}function tr(e,t,n,r){Qt?$t?$t.push(r):$t=[r]:Qt=r,t=Td(t,`onChange`),0<t.length&&(n=new _n(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var U=null,nr=null;function rr(e){vd(e,0)}function ir(e){if(V(ht(e)))return e}function ar(e,t){if(e===`change`)return t}var or=!1;if(an){var sr;if(an){var cr=`oninput`in document;if(!cr){var lr=document.createElement(`div`);lr.setAttribute(`oninput`,`return;`),cr=typeof lr.oninput==`function`}sr=cr}else sr=!1;or=sr&&(!document.documentMode||9<document.documentMode)}function ur(){U&&(U.detachEvent(`onpropertychange`,dr),nr=U=null)}function dr(e){if(e.propertyName===`value`&&ir(nr)){var t=[];tr(t,nr,e,Zt(e)),nn(rr,t)}}function W(e,t,n){e===`focusin`?(ur(),U=t,nr=n,U.attachEvent(`onpropertychange`,dr)):e===`focusout`&&ur()}function fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return ir(nr)}function pr(e,t){if(e===`click`)return ir(t)}function mr(e,t){if(e===`input`||e===`change`)return ir(t)}function hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var gr=typeof Object.is==`function`?Object.is:hr;function _r(e,t){if(gr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ye.call(t,i)||!gr(e[i],t[i]))return!1}return!0}function vr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function G(e,t){var n=vr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=vr(n)}}function yr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?yr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function br(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Nt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Nt(e.document)}return t}function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Sr=an&&`documentMode`in document&&11>=document.documentMode,Cr=null,wr=null,Tr=null,Er=!1;function Dr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Er||Cr==null||Cr!==Nt(r)||(r=Cr,`selectionStart`in r&&xr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Tr&&_r(Tr,r)||(Tr=r,r=Td(wr,`onSelect`),0<r.length&&(t=new _n(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Cr)))}function Or(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var kr={animationend:Or(`Animation`,`AnimationEnd`),animationiteration:Or(`Animation`,`AnimationIteration`),animationstart:Or(`Animation`,`AnimationStart`),transitionrun:Or(`Transition`,`TransitionRun`),transitionstart:Or(`Transition`,`TransitionStart`),transitioncancel:Or(`Transition`,`TransitionCancel`),transitionend:Or(`Transition`,`TransitionEnd`)},Ar={},jr={};an&&(jr=document.createElement(`div`).style,`AnimationEvent`in window||(delete kr.animationend.animation,delete kr.animationiteration.animation,delete kr.animationstart.animation),`TransitionEvent`in window||delete kr.transitionend.transition);function Mr(e){if(Ar[e])return Ar[e];if(!kr[e])return e;var t=kr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in jr)return Ar[e]=t[n];return e}var Nr=Mr(`animationend`),Pr=Mr(`animationiteration`),Fr=Mr(`animationstart`),Ir=Mr(`transitionrun`),Lr=Mr(`transitionstart`),Rr=Mr(`transitioncancel`),zr=Mr(`transitionend`),Br=new Map,Vr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Vr.push(`scrollEnd`);function K(e,t){Br.set(e,t),bt(t,[e])}var Hr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ur=[],Wr=0,Gr=0;function Kr(){for(var e=Wr,t=Gr=Wr=0;t<e;){var n=Ur[t];Ur[t++]=null;var r=Ur[t];Ur[t++]=null;var i=Ur[t];Ur[t++]=null;var a=Ur[t];if(Ur[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Xr(n,i,a)}}function qr(e,t,n,r){Ur[Wr++]=e,Ur[Wr++]=t,Ur[Wr++]=n,Ur[Wr++]=r,Gr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Jr(e,t,n,r){return qr(e,t,n,r),Zr(e)}function Yr(e,t){return qr(e,null,null,t),Zr(e)}function Xr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Fe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Zr(e){if(50<lu)throw lu=0,uu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Qr={};function $r(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ei(e,t,n,r){return new $r(e,t,n,r)}function ti(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ni(e,t){var n=e.alternate;return n===null?(n=ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ri(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ii(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ti(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,ae.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=ei(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ai(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=ei(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=ei(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=ei(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ei(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ai(e,t,n,r){return e=ei(7,e,r,t),e.lanes=n,e}function oi(e,t,n){return e=ei(6,e,null,t),e.lanes=n,e}function si(e){var t=ei(18,null,null,0);return t.stateNode=e,t}function ci(e,t,n){return t=ei(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var li=new WeakMap;function ui(e,t){if(typeof e==`object`&&e){var n=li.get(e);return n===void 0?(t={value:e,source:t,stack:ve(t)},li.set(e,t),t):n}return{value:e,source:t,stack:ve(t)}}var di=[],fi=0,pi=null,mi=0,hi=[],gi=0,_i=null,vi=1,yi=``;function bi(e,t){di[fi++]=mi,di[fi++]=pi,pi=e,mi=t}function xi(e,t,n){hi[gi++]=vi,hi[gi++]=yi,hi[gi++]=_i,_i=e;var r=vi;e=yi;var i=32-Fe(r)-1;r&=~(1<<i),n+=1;var a=32-Fe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,vi=1<<32-Fe(t)+i|n<<i|r,yi=a+e}else vi=1<<a|n<<i|r,yi=e}function Si(e){e.return!==null&&(bi(e,1),xi(e,1,0))}function Ci(e){for(;e===pi;)pi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null;for(;e===_i;)_i=hi[--gi],hi[gi]=null,yi=hi[--gi],hi[gi]=null,vi=hi[--gi],hi[gi]=null}function wi(e,t){hi[gi++]=vi,hi[gi++]=yi,hi[gi++]=_i,vi=t.id,yi=t.overflow,_i=e}var Ti=null,Ei=null,Di=!1,Oi=null,ki=!1,Ai=Error(i(519));function ji(e){throw Li(ui(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ai}function Mi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[it]=e,t[at]=r,n){case`dialog`:$(`cancel`,t),$(`close`,t);break;case`iframe`:case`object`:case`embed`:$(`load`,t);break;case`video`:case`audio`:for(n=0;n<gd.length;n++)$(gd[n],t);break;case`source`:$(`error`,t);break;case`img`:case`image`:case`link`:$(`error`,t),$(`load`,t);break;case`details`:$(`toggle`,t);break;case`input`:$(`invalid`,t),Lt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),Bt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&($(`beforetoggle`,t),$(`toggle`,t)),r.onScroll!=null&&$(`scroll`,t),r.onScrollEnd!=null&&$(`scrollend`,t),r.onClick!=null&&(t.onclick=Yt),t=!0):t=!1,t||ji(e,!0)}function Ni(e){for(Ti=e.return;Ti;)switch(Ti.tag){case 5:case 31:case 13:ki=!1;return;case 27:case 3:ki=!0;return;default:Ti=Ti.return}}function Pi(e){if(e!==Ti)return!1;if(!Di)return Ni(e),Di=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&Ei&&ji(e),Ni(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ei=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ei=uf(e)}else t===27?(t=Ei,Zd(e.type)?(e=lf,lf=null,Ei=e):Ei=t):Ei=Ti?cf(e.stateNode.nextSibling):null;return!0}function Fi(){Ei=Ti=null,Di=!1}function Ii(){var e=Oi;return e!==null&&(Yl===null?Yl=e:Yl.push.apply(Yl,e),Oi=null),e}function Li(e){Oi===null?Oi=[e]:Oi.push(e)}var Ri=I(null),q=null,zi=null;function J(e,t,n){R(Ri,t._currentValue),t._currentValue=n}function Y(e){e._currentValue=Ri.current,L(Ri)}function X(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Bi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),X(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),X(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Vi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;gr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===se.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Bi(t,e,n,r),t.flags|=262144}function Hi(e){for(e=e.firstContext;e!==null;){if(!gr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ui(e){q=e,zi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Wi(e){return Ki(q,e)}function Gi(e,t){return q===null&&Ui(e),Ki(e,t)}function Ki(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},zi===null){if(e===null)throw Error(i(308));zi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else zi=zi.next=t;return n}var qi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ji=t.unstable_scheduleCallback,Yi=t.unstable_NormalPriority,Xi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Zi(){return{controller:new qi,data:new Map,refCount:0}}function Qi(e){e.refCount--,e.refCount===0&&Ji(Yi,function(){e.controller.abort()})}var $i=null,ea=0,ta=0,na=null;function ra(e,t){if($i===null){var n=$i=[];ea=0,ta=ud(),na={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ea++,t.then(ia,ia),t}function ia(){if(--ea===0&&$i!==null){na!==null&&(na.status=`fulfilled`);var e=$i;$i=null,ta=0,na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function aa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var oa=P.S;P.S=function(e,t){Ql=we(),typeof t==`object`&&t&&typeof t.then==`function`&&ra(e,t),oa!==null&&oa(e,t)};var sa=I(null);function ca(){var e=sa.current;return e===null?Pl.pooledCache:e}function la(e,t){t===null?R(sa,sa.current):R(sa,t.pool)}function ua(){var e=ca();return e===null?null:{parent:Xi._currentValue,pool:e}}var da=Error(i(460)),fa=Error(i(474)),pa=Error(i(542)),ma={then:function(){}};function ha(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ga(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Yt,Yt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e;default:if(typeof t.status==`string`)t.then(Yt,Yt);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ba(e),e}throw va=t,da}}function _a(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(va=e,da):e}}var va=null;function ya(){if(va===null)throw Error(i(459));var e=va;return va=null,e}function ba(e){if(e===da||e===pa)throw Error(i(483))}var xa=null,Sa=0;function Ca(e){var t=Sa;return Sa+=1,xa===null&&(xa=[]),ga(xa,e,t)}function wa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ta(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ea(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=ni(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=oi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&_a(i)===t.type)?(t=a(t,n.props),wa(t,n),t.return=e,t):(t=ii(n.type,n.key,n.props,null,e.mode,r),wa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ci(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ai(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=oi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ii(t.type,t.key,t.props,null,e.mode,n),wa(n,t),n.return=e,n;case v:return t=ci(t,e.mode,n),t.return=e,t;case O:return t=_a(t),f(e,t,n)}if(te(t)||M(t))return t=ai(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ca(t),n);if(t.$$typeof===C)return f(e,Gi(e,t),n);Ta(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=_a(n),p(e,t,n,r)}if(te(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ca(n),r);if(n.$$typeof===C)return p(e,t,Gi(e,n),r);Ta(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=_a(r),m(e,t,n,r,i)}if(te(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ca(r),i);if(r.$$typeof===C)return m(e,t,n,Gi(t,r),i);Ta(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Di&&bi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Di&&bi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Di&&bi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Di&&bi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Di&&bi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Di&&bi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&_a(l)===r.type){n(e,r.sibling),c=a(r,o.props),wa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ai(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ii(o.type,o.key,o.props,null,e.mode,c),wa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ci(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=_a(o),b(e,r,o,c)}if(te(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ca(o),c);if(o.$$typeof===C)return b(e,r,Gi(e,o),c);Ta(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=oi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Sa=0;var i=b(e,t,n,r);return xa=null,i}catch(t){if(t===da||t===pa)throw t;var a=ei(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Da=Ea(!0),Oa=Ea(!1),ka=!1;function Aa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ja(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ma(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Na(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Zr(e),Xr(e,null,n),t}return qr(e,r,t,n),Zr(e)}function Pa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}function Fa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ia=!1;function La(){if(Ia){var e=na;if(e!==null)throw e}}function Ra(e,t,n,r){Ia=!1;var i=e.updateQueue;ka=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Fl&f)===f:(r&f)===f){f!==0&&f===ta&&(Ia=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:ka=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Ul|=o,e.lanes=o,e.memoizedState=d}}function za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ba(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)za(n[e],t)}var Va=I(null),Ha=I(0);function Ua(e,t){e=Vl,R(Ha,e),R(Va,t),Vl=e|t.baseLanes}function Wa(){R(Ha,Vl),R(Va,Va.current)}function Ga(){Vl=Ha.current,L(Va),L(Ha)}var Ka=I(null),qa=null;function Ja(e){var t=e.alternate;R($a,$a.current&1),R(Ka,e),qa===null&&(t===null||Va.current!==null||t.memoizedState!==null)&&(qa=e)}function Ya(e){R($a,$a.current),R(Ka,e),qa===null&&(qa=e)}function Xa(e){e.tag===22?(R($a,$a.current),R(Ka,e),qa===null&&(qa=e)):Za(e)}function Za(){R($a,$a.current),R(Ka,Ka.current)}function Qa(e){L(Ka),qa===e&&(qa=null),L($a)}var $a=I(0);function eo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var to=0,Z=null,no=null,ro=null,io=!1,ao=!1,oo=!1,so=0,co=0,lo=null,uo=0;function fo(){throw Error(i(321))}function po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!gr(e[n],t[n]))return!1;return!0}function mo(e,t,n,r,i,a){return to=a,Z=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?js:Ms,oo=!1,a=n(r,i),oo=!1,ao&&(a=go(t,n,r,i)),ho(e),a}function ho(e){P.H=As;var t=no!==null&&no.next!==null;if(to=0,ro=no=Z=null,io=!1,co=0,lo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Hi(e)&&(Ys=!0))}function go(e,t,n,r){Z=e;var a=0;do{if(ao&&(lo=null),co=0,ao=!1,25<=a)throw Error(i(301));if(a+=1,ro=no=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(no===null?null:no.memoizedState)!==e&&(Z.flags|=1024),t}function vo(){var e=so!==0;return so=0,e}function yo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function bo(e){if(io){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}io=!1}to=0,ro=no=Z=null,ao=!1,co=so=0,lo=null}function xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ro===null?Z.memoizedState=ro=e:ro=ro.next=e,ro}function So(){if(no===null){var e=Z.alternate;e=e===null?null:e.memoizedState}else e=no.next;var t=ro===null?Z.memoizedState:ro.next;if(t!==null)ro=t,no=e;else{if(e===null)throw Z.alternate===null?Error(i(467)):Error(i(310));no=e,e={memoizedState:no.memoizedState,baseState:no.baseState,baseQueue:no.baseQueue,queue:no.queue,next:null},ro===null?Z.memoizedState=ro=e:ro=ro.next=e}return ro}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=co;return co+=1,lo===null&&(lo=[]),e=ga(lo,e,t),t=Z,(ro===null?t.memoizedState:ro.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===C)return Wi(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=Z.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Z.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),Z.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),no,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(to&f)===f:(Fl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ta&&(d=!0);else if((to&p)===p){u=u.next,p===ta&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Z.lanes|=p,Ul|=p;f=u.action,oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Z.lanes|=f,Ul|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!gr(o,e.memoizedState)&&(Ys=!0,d&&(n=na,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);gr(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=Z,a=So(),o=Di;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!gr((no||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ro!==null&&ro.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||to&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Z.updateQueue,t===null?(t=Co(),Z.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!gr(e,n)}catch{return!0}}function Io(e){var t=Yr(e,2);t!==null&&pu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){B(!0);try{n()}finally{B(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,no,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(Di){var n=Pl.formState;if(n!==null){a:{var r=Z;if(Di){if(Ei){b:{for(var i=Ei,a=ki;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ei=cf(i.nextSibling),r=i.data===`F!`;break a}}ji(r)}r=!1}r&&(t=n[0])}}return n=xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,Z,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,Z,!1,r.queue),r=xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,Z,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),no,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===da?pa:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Z.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=no;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Z.updateQueue,t===null&&(t=Co(),Z.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=xo();Z.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;no!==null&&r!==null&&po(r,no.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(Z.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){Z.flags|=4;var t=Z.updateQueue;if(t===null)t=Co(),Z.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&po(t,r[1]))return r[0];if(r=e(),oo){B(!0);try{e()}finally{B(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||to&1073741824&&!(Fl&261930)?e.memoizedState=t:(e.memoizedState=n,e=fu(),Z.lanes|=e,Ul|=e,n)}function ps(e,t,n,r){return gr(n,t)?n:Va.current===null?!(to&42)||to&1073741824&&!(Fl&261930)?(Ys=!0,e.memoizedState=n):(e=fu(),Z.lanes|=e,Ul|=e,t):(e=fs(e,n,r),gr(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,Es(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,aa(c,r),du(e)):Ts(e,t,r,du(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},du())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,ne,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:ne},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},du())}function ys(){return Wi(Qf)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=du();e=Ma(n);var r=Na(t,e,n);r!==null&&(pu(r,t,n),Pa(r,t,n)),t={cache:Zi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=du();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Jr(e,t,n,r),n!==null&&(pu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,du())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,gr(s,o))return qr(e,t,i,0),Pl===null&&Kr(),!1}catch{}if(n=Jr(e,t,i,r),n!==null)return pu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Jr(e,n,r,2),t!==null&&pu(t,e,2)}function Ds(e){var t=e.alternate;return e===Z||t!==null&&t===Z}function Os(e,t){ao=io=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}var As={readContext:Wi,use:To,useCallback:fo,useContext:fo,useEffect:fo,useImperativeHandle:fo,useLayoutEffect:fo,useInsertionEffect:fo,useMemo:fo,useReducer:fo,useRef:fo,useState:fo,useDebugValue:fo,useDeferredValue:fo,useTransition:fo,useSyncExternalStore:fo,useId:fo,useHostTransitionStatus:fo,useFormState:fo,useActionState:fo,useOptimistic:fo,useMemoCache:fo,useCacheRefresh:fo};As.useEffectEvent=fo;var js={readContext:Wi,use:To,useCallback:function(e,t){return xo().memoizedState=[e,t===void 0?null:t],e},useContext:Wi,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=xo();t=t===void 0?null:t;var r=e();if(oo){B(!0);try{e()}finally{B(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=xo();if(n!==void 0){var i=n(t);if(oo){B(!0);try{n(t)}finally{B(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,Z,e),[r.memoizedState,e]},useRef:function(e){var t=xo();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,Z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(xo(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,Z,e.queue,!0,!1),xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Z,a=xo();if(Di){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Fl&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=xo(),t=Pl.identifierPrefix;if(Di){var n=yi,r=vi;n=(r&~(1<<32-Fe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=so++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=uo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,Z,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return xo().memoizedState=Ss.bind(null,Z)},useEffectEvent:function(e){var t=xo(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),no.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Wi,use:To,useCallback:us,useContext:Wi,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return no===null?fs(n,e,t):ps(n,no.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return no===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=du(),i=Ma(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(pu(t,e,r),Pa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=du(),r=Ma(n);r.tag=2,t!=null&&(r.callback=t),t=Na(e,r,n),t!==null&&(pu(t,e,n),Pa(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!_r(n,r)||!_r(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Hr(e)}function Bs(e){console.error(e)}function Vs(e){Hr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=Ma(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=Ma(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(tu===null?tu=new Set([this]):tu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Vi(t,n,a,!0),n=Ka.current,n!==null){switch(n.tag){case 31:case 13:return qa===null?Tu():n.alternate===null&&Hl===0&&(Hl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Wu(e,r,a)),!1;case 22:return n.flags|=65536,r===ma?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Wu(e,r,a)),!1}throw Error(i(435,n.tag))}return Wu(e,r,a),Tu(),!1}if(Di)return t=Ka.current,t===null?(r!==Ai&&(t=Error(i(423),{cause:r}),Li(ui(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ui(r,n),a=Ws(e.stateNode,r,a),Fa(e,a),Hl!==4&&(Hl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ai&&(e=Error(i(422),{cause:r}),Li(ui(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ui(o,n),Jl===null?Jl=[o]:Jl.push(o),Hl!==4&&(Hl=2),t===null)return!0;r=ui(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Fa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(tu===null||!tu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Fa(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?Oa(t,null,n,r):Da(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ui(t),r=mo(e,t,n,o,a,i),s=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Di&&s&&Si(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ti(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?_r:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=ni(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(_r(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&la(t,a===null?null:a.cachePool),a===null?Wa():Ua(t,a),Xa(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&la(t,null),Wa(),Za(t)):(la(t,a.cachePool),Ua(t,a),Za(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=ca();return a=a===null?null:{parent:Xi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&la(t,null),Wa(),Xa(t),e!==null&&Vi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Da(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,Qa(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Di){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Ya(t),(e=Ei)?(e=rf(e,ki),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:vi,overflow:yi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,Ti=t,Ei=null)):e=null,e===null)throw ji(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ya(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Vi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Qe(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Yr(e,s),pu(r,e,s),Js;Tu(),t=ic(e,t,n)}else e=o.treeContext,Ei=cf(s.nextSibling),Ti=t,Di=!0,Oi=null,ki=!1,e!==null&&wi(t,e),t=rc(t,r),t.flags|=4096;return t}return e=ni(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Ui(t),n=mo(e,t,n,r,void 0,i),r=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Di&&r&&Si(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Ui(t),t.updateQueue=null,n=go(t,r,n,i),ho(e),r=vo(),e!==null&&!Ys?(yo(e,t,a),xc(e,t,a)):(Di&&r&&Si(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Ui(t),t.stateNode===null){var a=Qr,o=n.contextType;typeof o==`object`&&o&&(a=Wi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Aa(t),o=n.contextType,a.context=typeof o==`object`&&o?Wi(o):Qr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),Ra(t,r,a,i),La(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Qr,typeof u==`object`&&u&&(o=Wi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),ka=!1;var f=t.memoizedState;a.state=f,Ra(t,r,a,i),La(),l=t.memoizedState,s||f!==l||ka?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=ka||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ja(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Qr,typeof l==`object`&&l&&(c=Wi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),ka=!1,f=t.memoizedState,a.state=f,Ra(t,r,a,i),La();var p=t.memoizedState;o!==d||f!==p||ka||e!==null&&e.dependencies!==null&&Hi(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=ka||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Hi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Da(t,e.child,null,i),t.child=Da(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return Fi(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:ua()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Kl),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:($a.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Di){if(a?Ja(t):Za(t),(e=Ei)?(e=rf(e,ki),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:vi,overflow:yi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,Ti=t,Ei=null)):e=null,e===null)throw ji(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Za(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ai(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(Ja(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ja(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Za(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ai(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Da(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Za(t),t.child=e.child,t.flags|=128,t=null);else if(Ja(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Li({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Vi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Qe(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Yr(e,r),pu(s,e,r),Js;af(c)||Tu(),t=_c(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ei=cf(c.nextSibling),Ti=t,Di=!0,Oi=null,ki=!1,e!==null&&wi(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Za(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ni(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ai(c,a,n,null),c.flags|=2):c=ni(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=ua():(l=Xi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(Ja(t),n=e.child,e=n.sibling,n=ni(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=ei(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Da(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),X(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=$a.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,R($a,o),Xs(e,t,r,n),r=Di?mi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&eo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&eo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Vi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=ni(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ni(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Hi(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:ce(t,t.stateNode.containerInfo),J(t,Xi,e.memoizedState.cache),Fi();break;case 27:case 5:ue(t);break;case 4:ce(t,t.stateNode.containerInfo);break;case 10:J(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ya(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ja(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(Ja(t),t.flags|=128,null);Ja(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Vi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),R($a,$a.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:J(t,Xi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,Di&&t.flags&1048576&&xi(t,mi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=_a(t.elementType),t.type=e,typeof e==`function`)ti(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=ee(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(ce(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ja(e,t),Ra(t,r,null,n);var s=t.memoizedState;if(r=s.cache,J(t,Xi,r),r!==o.cache&&Bi(t,[Xi],n,!0),La(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=ui(Error(i(424)),t),Li(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ei=cf(e.firstChild),Ti=t,Di=!0,Oi=null,ki=!0,n=Oa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Fi(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Di||(n=t.type,e=t.pendingProps,r=Bd(oe.current).createElement(n),r[it]=t,r[at]=e,Pd(r,n,e),_t(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ue(t),e===null&&Di&&(r=t.stateNode=ff(t.type,t.pendingProps,oe.current),Ti=t,ki=!0,a=Ei,Zd(t.type)?(lf=a,Ei=cf(r.firstChild)):Ei=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Di&&((a=r=Ei)&&(r=tf(r,t.type,t.pendingProps,ki),r===null?a=!1:(t.stateNode=r,Ti=t,Ei=cf(r.firstChild),ki=!1,a=!0)),a||ji(t)),ue(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=mo(e,t,_o,null,null,n),Qf._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&Di&&((e=n=Ei)&&(n=nf(n,t.pendingProps,ki),n===null?e=!1:(t.stateNode=n,Ti=t,Ei=null,e=!0)),e||ji(t)),null;case 13:return mc(e,t,n);case 4:return ce(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Da(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,J(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Ui(t),a=Wi(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Ui(t),r=Wi(Xi),e===null?(a=ca(),a===null&&(a=Pl,o=Zi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Aa(t),J(t,Xi,a)):((e.lanes&n)!==0&&(ja(e,t),Ra(t,null,null,n),La()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,J(t,Xi,r),r!==a.cache&&Bi(t,[Xi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),J(t,Xi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Su())e.flags|=8192;else throw va=ma,fa}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(Su())e.flags|=8192;else throw va=ma,fa}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ke(),e.lanes|=t,ql|=t)}function kc(e,t){if(!Di)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(Ci(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Y(Xi),le(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Pi(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ii())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(de(t),n=oe.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=ae.current,Pi(t)?Mi(t,e):(e=ff(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(de(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=ae.current,Pi(t))Mi(t,o);else{var s=Bd(oe.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[it]=t,o[at]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=oe.current,Pi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ti,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[it]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||ji(t,!0)}else e=Bd(e).createTextNode(r),e[it]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Pi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[it]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Qa(t),t):(Qa(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Pi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[it]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Qa(t),t):(Qa(t),null)}return Qa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return le(),e===null&&xd(t.stateNode.containerInfo),Ac(t),null;case 10:return Y(t.type),Ac(t),null;case 19:if(L($a),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Hl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=eo(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ri(n,e),n=n.sibling;return R($a,$a.current&1|2),Di&&bi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&we()>$l&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=eo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Di)return Ac(t),null}else 2*we()-r.renderingStartTime>$l&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=we(),e.sibling=null,n=$a.current,R($a,a?n&1|2:n&1),Di&&bi(t,r.treeForkCount),e);case 22:case 23:return Qa(t),Ga(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&L(sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Y(Xi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(Ci(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Y(Xi),le(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return de(t),null;case 31:if(t.memoizedState!==null){if(Qa(t),t.alternate===null)throw Error(i(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Qa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L($a),null;case 4:return le(),null;case 10:return Y(t.type),null;case 22:case 23:return Qa(t),Ga(),e!==null&&L(sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Y(Xi),null;case 25:return null;default:return null}}function Nc(e,t){switch(Ci(t),t.tag){case 3:Y(Xi),le();break;case 26:case 27:case 5:de(t);break;case 4:le();break;case 31:t.memoizedState!==null&&Qa(t);break;case 13:Qa(t);break;case 19:L($a);break;case 10:Y(t.type);break;case 22:case 23:Qa(t),Ga(),e!==null&&L(sa);break;case 24:Y(Xi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Uu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Uu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Uu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ba(t,n)}catch(t){Uu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Uu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Uu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Uu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Uu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Uu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[at]=t}catch(t){Uu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Yt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[it]=e,t[at]=n}catch(t){Uu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,Rd=sp,e=br(e),xr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Uu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Uu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Uu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ba(e,t)}catch(e){Uu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qu.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ft(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Pe&&typeof Pe.onCommitFiberUnmount==`function`)try{Pe.onCommitFiberUnmount(Ne,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;Zd(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),pf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Uu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Uu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Uu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Uu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ju.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[dt]||o[it]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[it]=e,_t(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[it]=e,_t(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Vt(a,``)}catch(t){Uu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Uu(e,e.return,t)}}break;case 3:if(Bf=null,a=ul,ul=gf(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Uu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=gf(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Zl=we()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Uu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Uu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Uu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Vt(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Uu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:pf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Uu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)za(c[i],s)}catch(e){Uu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Qi(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Qi(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Uu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Gf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=gf(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Qi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Wi(Xi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Wi(Xi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Q=null,Fl=0,Il=0,Ll=null,Rl=!1,zl=!1,Bl=!1,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=null,Yl=null,Xl=!1,Zl=0,Ql=0,$l=1/0,eu=null,tu=null,nu=0,ru=null,iu=null,au=0,ou=0,su=null,cu=null,lu=0,uu=null;function du(){return Nl&2&&Fl!==0?Fl&-Fl:P.T===null?tt():ud()}function fu(){if(Kl===0)if(!(Fl&536870912)||Di){var e=Be;Be<<=1,!(Be&3932160)&&(Be=262144),Kl=e}else Kl=536870912;return e=Ka.current,e!==null&&(e.flags|=32),Kl}function pu(e,t,n){(e===Pl&&(Il===2||Il===9)||e.cancelPendingCommit!==null)&&(bu(e,0),_u(e,Fl,Kl,!1)),Je(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Wl|=n),Hl===4&&_u(e,Fl,Kl,!1)),nd(e))}function mu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||We(e,t),a=r?Ou(e,t):Eu(e,t,!0),o=r;do{if(a===0){zl&&!r&&_u(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!gu(n)){a=Eu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Jl;var l=c.current.memoizedState.isDehydrated;if(l&&(bu(c,s).flags|=256),s=Eu(c,s,!1),s!==2){if(Bl&&!l){c.errorRecoveryDisabledLanes|=o,Wl|=o,a=4;break a}o=Yl,Yl=a,o!==null&&(Yl===null?Yl=o:Yl.push.apply(Yl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){bu(e,0),_u(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:_u(r,t,Kl,!Rl);break a;case 2:Yl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Zl+300-we(),10<a)){if(_u(r,t,Kl,!Rl),Ue(r,0,!0)!==0)break a;au=t,r.timeoutHandle=Kd(hu.bind(null,r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,`Throttled`,-0,0),a);break a}hu(r,n,Yl,eu,Xl,t,Kl,Wl,ql,Rl,o,null,-0,0)}}break}while(1);nd(e)}function hu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Yt},Tl(t,a,d);var m=(a&62914560)===a?Zl-we():(a&4194048)===a?Ql-we():0;if(m=qf(d,m),m!==null){au=a,e.cancelPendingCommit=m(Fu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),_u(e,a,o,!l);return}}Fu(e,t,a,n,r,i,o,s,c)}function gu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!gr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function _u(e,t,n,r){t&=~Gl,t&=~Wl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Fe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Xe(e,n,t)}function vu(){return Nl&6?!0:(rd(0,!1),!1)}function yu(){if(Q!==null){if(Il===0)var e=Q.return;else e=Q,zi=q=null,bo(e),xa=null,Sa=0,e=Q;for(;e!==null;)Nc(e.alternate,e),e=e.return;Q=null}}function bu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),au=0,yu(),Pl=e,Q=n=ni(e.current,null),Fl=t,Il=0,Ll=null,Rl=!1,zl=We(e,t),Bl=!1,ql=Kl=Gl=Wl=Ul=Hl=0,Yl=Jl=null,Xl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Fe(r),a=1<<i;t|=e[i],r&=~a}return Vl=t,Kr(),n}function xu(e,t){Z=null,P.H=As,t===da||t===pa?(t=ya(),Il=3):t===fa?(t=ya(),Il=4):Il=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ll=t,Q===null&&(Hl=1,Hs(e,ui(t,e.current)))}function Su(){var e=Ka.current;return e===null?!0:(Fl&4194048)===Fl?qa===null:(Fl&62914560)===Fl||Fl&536870912?e===qa:!1}function Cu(){var e=P.H;return P.H=As,e===null?As:e}function wu(){var e=P.A;return P.A=jl,e}function Tu(){Hl=4,Rl||(Fl&4194048)!==Fl&&Ka.current!==null||(zl=!0),!(Ul&134217727)&&!(Wl&134217727)||Pl===null||_u(Pl,Fl,Kl,!1)}function Eu(e,t,n){var r=Nl;Nl|=2;var i=Cu(),a=wu();(Pl!==e||Fl!==t)&&(eu=null,bu(e,t)),t=!1;var o=Hl;a:do try{if(Il!==0&&Q!==null){var s=Q,c=Ll;switch(Il){case 8:yu(),o=6;break a;case 3:case 2:case 9:case 6:Ka.current===null&&(t=!0);var l=Il;if(Il=0,Ll=null,Mu(e,s,c,l),n&&zl){o=0;break a}break;default:l=Il,Il=0,Ll=null,Mu(e,s,c,l)}}Du(),o=Hl;break}catch(t){xu(e,t)}while(1);return t&&e.shellSuspendCounter++,zi=q=null,Nl=r,P.H=i,P.A=a,Q===null&&(Pl=null,Fl=0,Kr()),o}function Du(){for(;Q!==null;)Au(Q)}function Ou(e,t){var n=Nl;Nl|=2;var r=Cu(),a=wu();Pl!==e||Fl!==t?(eu=null,$l=we()+500,bu(e,t)):zl=We(e,t);a:do try{if(Il!==0&&Q!==null){t=Q;var o=Ll;b:switch(Il){case 1:Il=0,Ll=null,Mu(e,t,o,1);break;case 2:case 9:if(ha(o)){Il=0,Ll=null,ju(t);break}t=function(){Il!==2&&Il!==9||Pl!==e||(Il=7),nd(e)},o.then(t,t);break a;case 3:Il=7;break a;case 4:Il=5;break a;case 7:ha(o)?(Il=0,Ll=null,ju(t)):(Il=0,Ll=null,Mu(e,t,o,7));break;case 5:var s=null;switch(Q.tag){case 26:s=Q.memoizedState;case 5:case 27:var c=Q;if(s?Wf(s):c.stateNode.complete){Il=0,Ll=null;var l=c.sibling;if(l!==null)Q=l;else{var u=c.return;u===null?Q=null:(Q=u,Nu(u))}break b}}Il=0,Ll=null,Mu(e,t,o,5);break;case 6:Il=0,Ll=null,Mu(e,t,o,6);break;case 8:yu(),Hl=6;break a;default:throw Error(i(462))}}ku();break}catch(t){xu(e,t)}while(1);return zi=q=null,P.H=r,P.A=a,Nl=n,Q===null?(Pl=null,Fl=0,Kr(),Hl):0}function ku(){for(;Q!==null&&!Se();)Au(Q)}function Au(e){var t=wc(e.alternate,e,Vl);e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function ju(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Fl);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Fl);break;case 5:bo(t);default:Nc(n,t),t=Q=ri(t,Vl),t=wc(n,t,Vl)}e.memoizedProps=e.pendingProps,t===null?Nu(e):Q=t}function Mu(e,t,n,r){zi=q=null,bo(t),xa=null,Sa=0;var i=t.return;try{if(qs(e,i,t,n,Fl)){Hl=1,Hs(e,ui(n,e.current)),Q=null;return}}catch(t){if(i!==null)throw Q=i,t;Hl=1,Hs(e,ui(n,e.current)),Q=null;return}t.flags&32768?(Di||r===1?e=!0:zl||Fl&536870912?e=!1:(Rl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ka.current,r!==null&&r.tag===13&&(r.flags|=16384))),Pu(t,e)):Nu(t)}function Nu(e){var t=e;do{if(t.flags&32768){Pu(t,Rl);return}e=t.return;var n=jc(t.alternate,t,Vl);if(n!==null){Q=n;return}if(t=t.sibling,t!==null){Q=t;return}Q=t=e}while(t!==null);Hl===0&&(Hl=5)}function Pu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Q=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Q=e;return}Q=e=n}while(e!==null);Hl=6,Q=null}function Fu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Bu();while(nu!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Gr,Ye(e,n,o,s,c,l),e===Pl&&(Q=Pl=null,Fl=0),iu=t,ru=e,au=n,ou=o,su=a,cu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Yu(Oe,function(){return Vu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,F.p=a,P.T=r}}nu=1,Iu(),Lu(),Ru()}}function Iu(){if(nu===1){nu=0;var e=ru,t=iu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=zd,o=br(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&yr(s.ownerDocument.documentElement,s)){if(c!==null&&xr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=G(s,h),v=G(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{Nl=i,F.p=r,P.T=n}}e.current=t,nu=2}}function Lu(){if(nu===2){nu=0;var e=ru,t=iu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,F.p=r,P.T=n}}nu=3}}function Ru(){if(nu===4||nu===3){nu=0,Ce();var e=ru,t=iu,n=au,r=cu;t.subtreeFlags&10256||t.flags&10256?nu=5:(nu=0,iu=ru=null,zu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(tu=null),et(n),t=t.stateNode,Pe&&typeof Pe.onCommitFiberRoot==`function`)try{Pe.onCommitFiberRoot(Ne,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}au&3&&Bu(),nd(e),i=e.pendingLanes,n&261930&&i&42?e===uu?lu++:(lu=0,uu=e):lu=0,rd(0,!1)}}function zu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Qi(t)))}function Bu(){return Iu(),Lu(),Ru(),Vu()}function Vu(){if(nu!==5)return!1;var e=ru,t=ou;ou=0;var n=et(au),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=su,su=null;var o=ru,s=au;if(nu=0,iu=ru=null,au=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,rd(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot==`function`)try{Pe.onPostCommitFiberRoot(Ne,o)}catch{}return!0}finally{F.p=a,P.T=r,zu(e,t)}}function Hu(e,t,n){t=ui(n,t),t=Ws(e.stateNode,t,2),e=Na(e,t,2),e!==null&&(Je(e,2),nd(e))}function Uu(e,t,n){if(e.tag===3)Hu(e,e,n);else for(;t!==null;){if(t.tag===3){Hu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(tu===null||!tu.has(r))){e=ui(n,e),n=Gs(2),r=Na(t,n,2),r!==null&&(Ks(n,r,t,e),Je(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Bl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Fl&n)===n&&(Hl===4||Hl===3&&(Fl&62914560)===Fl&&300>we()-Zl?!(Nl&2)&&bu(e,0):Gl|=n,ql===Fl&&(ql=0)),nd(e)}function Ku(e,t){t===0&&(t=Ke()),e=Yr(e,t),e!==null&&(Je(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return be(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Fe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=Fl,a=Ue(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||We(r,a)||(n=!0,cd(r,a));r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=we(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}nu!==0&&nu!==5||rd(e,!1),td!==0&&(td=0)}function od(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Fe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ge(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Fl,n=Ue(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Il===2||Il===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&xe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||We(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&xe(r),et(n)){case 2:case 8:n=De;break;case 32:n=Oe;break;case 268435456:n=Ae;break;default:n=Oe}return r=sd.bind(null,e),n=be(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&xe(r),e.callbackPriority=2,e.callbackNode=null,2}function sd(e,t){if(nu!==0&&nu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Bu()&&e.callbackNode!==n)return null;var r=Fl;return r=Ue(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(mu(e,r,t),od(e,we()),e.callbackNode!=null&&e.callbackNode===n?sd.bind(null,e):null)}function cd(e,t){if(Bu())return null;mu(e,t,!0)}function ld(){Yd(function(){Nl&6?be(Ee,id):ad()})}function ud(){if(td===0){var e=ta;e===0&&(e=ze,ze<<=1,!(ze&261888)&&(ze=256)),td=e}return td}function dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Jt(``+e)}function fd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function pd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=dd((i[at]||null).action),o=r.submitter;o&&(t=(t=o[at]||null)?dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new _n(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(td!==0){var e=o?fd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?fd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var md=0;md<Vr.length;md++){var hd=Vr[md];K(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}K(Nr,`onAnimationEnd`),K(Pr,`onAnimationIteration`),K(Fr,`onAnimationStart`),K(`dblclick`,`onDoubleClick`),K(`focusin`,`onFocus`),K(`focusout`,`onBlur`),K(Ir,`onTransitionRun`),K(Lr,`onTransitionStart`),K(Rr,`onTransitionCancel`),K(zr,`onTransitionEnd`),xt(`onMouseEnter`,[`mouseout`,`mouseover`]),xt(`onMouseLeave`,[`mouseout`,`mouseover`]),xt(`onPointerEnter`,[`pointerout`,`pointerover`]),xt(`onPointerLeave`,[`pointerout`,`pointerover`]),bt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),bt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),bt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),bt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),bt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),bt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var gd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),_d=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(gd));function vd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[st];n===void 0&&(n=t[st]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,vt.forEach(function(t){t!==`selectionchange`&&(_d.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!on||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=pt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}nn(function(){var r=a,i=Zt(n),s=[];a:{var c=Br.get(e);if(c!==void 0){var l=_n,u=e;switch(e){case`keypress`:if(fn(n)===0)break a;case`keydown`:case`keyup`:l=Fn;break;case`focusin`:u=`focus`,l=En;break;case`focusout`:u=`blur`,l=En;break;case`beforeblur`:case`afterblur`:l=En;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=wn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Tn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Ln;break;case Nr:case Pr:case Fr:l=Dn;break;case zr:l=Rn;break;case`scroll`:case`scrollend`:l=yn;break;case`wheel`:l=zn;break;case`copy`:case`cut`:case`paste`:l=On;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=In;break;case`toggle`:case`beforetoggle`:l=Bn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=rn(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Xt&&(u=n.relatedTarget||n.fromElement)&&(pt(u)||u[ot]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?pt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=wn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=In,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ht(l),h=u==null?c:ht(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,pt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(s,c,l,d,!1),u!==null&&f!==null&&Dd(s,f,u,d,!0)}}a:{if(c=r?ht(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=ar;else if(er(c))if(or)v=mr;else{v=fr;var y=W}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Gt(r.elementType)&&(v=ar):v=pr;if(v&&=v(e,r)){tr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Rt(c,`number`,c.value)}switch(y=r?ht(r):window,e){case`focusin`:(er(y)||y.contentEditable===`true`)&&(Cr=y,wr=r,Tr=null);break;case`focusout`:Tr=wr=Cr=null;break;case`mousedown`:Er=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Er=!1,Dr(s,n,i);break;case`selectionchange`:if(Sr)break;case`keydown`:case`keyup`:Dr(s,n,i)}var b;if(Hn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Xn?Jn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Gn&&n.locale!==`ko`&&(Xn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Xn&&(b=dn()):(cn=i,ln=`value`in cn?cn.value:cn.textContent,Xn=!0)),y=Td(r,x),0<y.length&&(x=new kn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Yn(n),b!==null&&(x.data=b)))),(b=Wn?Zn(e,n):Qn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new kn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),pd(s,e,r,n,i)}vd(s,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=rn(e,n),i!=null&&r.unshift(wd(e,i,a)),i=rn(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=rn(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=rn(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
9
+ `).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Vt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Vt(e,``+r);break;case`className`:Dt(e,`class`,r);break;case`tabIndex`:Dt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Dt(e,n,r);break;case`style`:Wt(e,r,o);break;case`data`:if(t!==`object`){Dt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Jt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Jt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Yt);break;case`onScroll`:r!=null&&$(`scroll`,e);break;case`onScrollEnd`:r!=null&&$(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Jt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),Et(e,`popover`,r);break;case`xlinkActuate`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ot(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ot(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ot(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ot(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Et(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Kt.get(n)||n,Et(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Wt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Vt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Vt(e,``+r);break;case`onScroll`:r!=null&&$(`scroll`,e);break;case`onScrollEnd`:r!=null&&$(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Yt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!yt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[at]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Et(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}Lt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&H(e,!!r,n,!0):H(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}Bt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)$(gd[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(Gt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}It(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?H(e,!!n,n?[]:``,!1):H(e,!!n,t,!0)):H(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}zt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(Gt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[dt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),ft(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[dt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ft(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=vu();return e||t}function yf(e){var t=mt(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Ft(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ft(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ft(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ft(n.imageSizes)+`"]`)):i+=`[href="`+Ft(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ft(r)+`"][href="`+Ft(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),_t(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=gt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);_t(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=gt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),_t(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=gt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),_t(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=oe.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=gt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=gt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=gt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Ft(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),_t(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Ft(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ft(n.href)+`"]`);if(r)return t.instance=r,_t(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),_t(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,_t(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),_t(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,_t(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),_t(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[dt]||a[it]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,_t(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),_t(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=qe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qe(0),this.hiddenUpdates=qe(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ei(3,null,null,t),e.current=a,a.stateNode=e,t=Zi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Aa(a),e}function tp(e){return e?(e=Qr,e):Qr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ma(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Na(e,r,t),n!==null&&(pu(n,e,t),Pa(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Yr(e,67108864);t!==null&&pu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=du();t=$e(t);var n=Yr(e,t);n!==null&&pu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=mt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=He(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Fe(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Nl&6)&&($l=we()+500,rd(0,!1))}}break;case 31:case 13:s=Yr(a,2),s!==null&&pu(s,a,2),vu(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Zt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=pt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Te()){case Ee:return 2;case De:return 8;case Oe:case ke:return 32;case Ae:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=mt(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=pt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,nt(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,nt(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Xt=r,n.target.dispatchEvent(r),Xt=null}else return t=mt(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=mt(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[at]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[at]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,du(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),vu(),t[ot]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=tt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.4`)throw Error(i(527,Lp,`19.2.4`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Ne=zp.inject(Rp),Pe=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[ot]=t.current,xd(e),new Fp(t)}})),g=c(o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=`ssg:ui:font-scale:v1`,y=[{label:`S`,value:.9},{label:`M`,value:1},{label:`L`,value:1.15},{label:`XL`,value:1.3}],b=1;function x(e){if(typeof e!=`number`||!Number.isFinite(e))return b;let t=y.find(t=>Math.abs(t.value-e)<.001);return t?t.value:b}function S(){if(typeof localStorage>`u`)return b;try{let e=localStorage.getItem(v);return e===null?b:x(parseFloat(e))}catch{return b}}function C(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(v,String(e))}catch{}}function w(e){typeof document>`u`||(document.documentElement.style.setProperty(`--ssg-font-scale`,String(e)),document.documentElement.style.fontSize=`${16*e}px`)}function T(){let[e,t]=(0,_.useState)(()=>{let e=S();return w(e),e});return(0,_.useEffect)(()=>{w(e)},[e]),{scale:e,setScale:(0,_.useCallback)(e=>{t(e),C(e),w(e)},[])}}var E=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),D=o(((e,t)=>{t.exports=E()}))();function O(){let{scale:e,setScale:t}=T();return(0,D.jsx)(`div`,{role:`radiogroup`,"aria-label":`Font size`,className:`hig-segmented`,style:{height:`24px`},children:y.map(n=>{let r=Math.abs(n.value-e)<.001;return(0,D.jsx)(`button`,{role:`radio`,"aria-checked":r,"aria-selected":r,onClick:()=>t(n.value),title:`Font size: ${n.label} (${Math.round(n.value*100)}%)`,className:r?`selected`:``,style:{height:`20px`,padding:`0 8px`,fontSize:`11px`},children:n.label},n.label)})})}var k=`ssg:ui:theme:v1`,A=[{label:`System (Auto)`,value:`default`},{label:`Apple Light`,value:`apple-light`},{label:`Apple Dark`,value:`apple-dark`},{label:`Light (Legacy)`,value:`light`},{label:`Dracula`,value:`dracula`},{label:`Gruvbox Dark`,value:`gruvbox-dark`},{label:`Gruvbox Light`,value:`gruvbox-light`},{label:`Tokyo Night`,value:`tokyo-night`},{label:`Catppuccin Mocha`,value:`catppuccin-mocha`},{label:`Nord`,value:`nord`},{label:`One Dark Pro`,value:`one-dark-pro`}],j=new Set([`light`,`gruvbox-light`,`apple-light`]),M=new Set([`apple-dark`,`dracula`,`gruvbox-dark`,`tokyo-night`,`catppuccin-mocha`,`nord`,`one-dark-pro`]),N=`default`;function ee(e){return typeof e==`string`&&A.some(t=>t.value===e)}function te(){if(typeof localStorage>`u`)return N;try{let e=localStorage.getItem(k);return ee(e)?e:N}catch{return N}}function P(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(k,e)}catch{}}function F(e){typeof document>`u`||(e===N?(document.documentElement.removeAttribute(`data-theme`),document.documentElement.style.colorScheme=`light dark`):(document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=j.has(e)?`light`:M.has(e)?`dark`:`light dark`))}function ne(){let[e,t]=(0,_.useState)(()=>{let e=te();return F(e),e});return(0,_.useEffect)(()=>{F(e)},[e]),{theme:e,setTheme:(0,_.useCallback)(e=>{t(e),P(e),F(e)},[])}}function re(){let{theme:e,setTheme:t}=ne();return(0,D.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),"aria-label":`Color theme`,title:`Color theme`,className:`hig-input cursor-pointer`,style:{height:`24px`,paddingRight:`22px`,minWidth:`90px`},children:A.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))})}var ie=`ssg:ui:mode:v1`,I=`ssg:ui:mode:seeded`,L=`ssg:ui-mode-change`,R=new Set([`professional`,`enterprise`,`agent-dev`]);function ae(){try{let e=localStorage.getItem(ie);if(e===`newcomer`||e===`pro`)return e}catch{}return null}function z(e){try{localStorage.setItem(ie,e)}catch{}}async function oe(){if(ae()===null){try{if(localStorage.getItem(I))return;localStorage.setItem(I,`1`)}catch{return}try{let e=await fetch(`/api/json/wizard-state`);if(!e.ok){z(`newcomer`);return}let t=await e.json(),n=R.has(t.profile??``)?`pro`:`newcomer`;z(n),window.dispatchEvent(new CustomEvent(L,{detail:n}))}catch{z(`newcomer`)}}}function se(){let[e,t]=(0,_.useState)(()=>ae()??`newcomer`);return(0,_.useEffect)(()=>{oe().then(()=>{let n=ae();n&&n!==e&&t(n)});let n=e=>{let n=e.detail;(n===`newcomer`||n===`pro`)&&t(n)};return window.addEventListener(L,n),()=>window.removeEventListener(L,n)},[e]),{mode:e,setMode:(0,_.useCallback)(e=>{t(e),z(e),window.dispatchEvent(new CustomEvent(L,{detail:e}))},[])}}function ce(){let{mode:e,setMode:t}=se(),n=e===`newcomer`;return(0,D.jsxs)(`div`,{role:`radiogroup`,"aria-label":`UI mode`,className:`hig-segmented`,style:{height:`24px`},title:n?`Switch to advanced view`:`Switch to simple view`,children:[(0,D.jsx)(`button`,{role:`radio`,"aria-checked":n,"aria-selected":n,onClick:()=>t(`newcomer`),className:n?`selected`:``,style:{height:`20px`,padding:`0 10px`,fontSize:`11.5px`},children:`Simple`}),(0,D.jsx)(`button`,{role:`radio`,"aria-checked":!n,"aria-selected":!n,onClick:()=>t(`pro`),className:n?``:`selected`,style:{height:`20px`,padding:`0 10px`,fontSize:`11.5px`},children:`Advanced`})]})}var le=`SSG_AUDIO`,ue=`SSG_AUDIO_VOLUME`,de=12,fe=null,pe=null,me=!1,he=.18,ge=[],_e=!1;function ve(){if(typeof localStorage>`u`)return{enabled:!1,volume:.18};let e=localStorage.getItem(le)===`1`,t=localStorage.getItem(ue);return{enabled:e,volume:t?Math.max(0,Math.min(1,parseFloat(t))):.18}}function ye(){typeof localStorage>`u`||(localStorage.setItem(le,me?`1`:`0`),localStorage.setItem(ue,he.toString()))}function be(){if(typeof window>`u`)return null;if(fe)return fe;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;try{fe=new e,pe=fe.createGain(),pe.gain.value=he,pe.connect(fe.destination),typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{fe&&(document.visibilityState===`hidden`?fe.suspend():fe.resume())})}catch{fe=null,pe=null}return fe}function xe(){if(_e)return;_e=!0;let{enabled:e,volume:t}=ve();me=e,he=t}function Se(){return xe(),me}function Ce(e){if(xe(),me=e,ye(),e){let e=be();e&&e.state===`suspended`&&e.resume()}}function we(){return xe(),he}function Te(e){xe(),he=Math.max(0,Math.min(1,e)),ye(),pe&&(pe.gain.value=he)}function Ee(e){for(;ge.length>0&&e-ge[0]>1e3;)ge.shift();return ge.length>=de?!1:(ge.push(e),!0)}var De={allow:{type:`sine`,freq:660,durationMs:90,peak:.6},block:{type:`square`,freq:110,durationMs:130,peak:1},force:{type:`sawtooth`,freq:220,freqSweep:440,durationMs:170,peak:.8},ask:{type:`triangle`,freq:880,durationMs:110,peak:.55},log:{type:`sine`,freq:1320,durationMs:30,peak:.35},shadow:{type:`sine`,freq:220,durationMs:60,peak:.18}};function Oe(e){if(xe(),!me||typeof document<`u`&&document.visibilityState===`hidden`)return;let t=be();if(!t||!pe)return;t.state===`suspended`&&t.resume().catch(()=>{});let n=t.currentTime;if(!Ee(performance.now()))return;let r=De[e],i=t.createOscillator();i.type=r.type,i.frequency.value=r.freq,r.freqSweep!==void 0&&(i.frequency.setValueAtTime(r.freq,n),i.frequency.exponentialRampToValueAtTime(Math.max(1,r.freqSweep),n+r.durationMs/1e3));let a=t.createGain();a.gain.setValueAtTime(0,n),a.gain.linearRampToValueAtTime(r.peak,n+.005),a.gain.exponentialRampToValueAtTime(1e-4,n+r.durationMs/1e3),i.connect(a),a.connect(pe),i.start(n),i.stop(n+r.durationMs/1e3+.05),i.onended=()=>{try{i.disconnect(),a.disconnect()}catch{}}}function ke(){let[e,t]=(0,_.useState)(()=>Se()),[n,r]=(0,_.useState)(()=>we()),[i,a]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{Ce(e)},[e]),(0,_.useEffect)(()=>{Te(n)},[n]),(0,D.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,D.jsxs)(`button`,{onClick:()=>t(e=>!e),onContextMenu:e=>{e.preventDefault(),a(e=>!e)},className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors`,style:e?{color:`var(--color-decision-allow)`}:void 0,title:e?`Decision chimes on · click to mute · right-click for volume`:`Decision chimes off · click to enable`,children:[(0,D.jsx)(`span`,{className:`status-dot ${e?`bg-[var(--color-decision-allow)]`:`bg-[var(--color-fg-4)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Audio `,e?`on`:`off`]})]}),i&&(0,D.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 flex items-center gap-2 px-3 py-2 hig-card hig-card-padded shadow-[var(--hig-shadow-2)]`,onMouseLeave:()=>a(!1),children:[(0,D.jsx)(`span`,{className:`overline`,children:`Volume`}),(0,D.jsx)(`input`,{type:`range`,min:0,max:1,step:.02,value:n,onChange:e=>r(parseFloat(e.target.value)),className:`w-24`,style:{accentColor:`var(--color-accent)`}}),(0,D.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-[var(--color-fg-2)] w-8 text-right`,children:Math.round(n*100)})]})]})}var Ae=500,je=200,Me=3e3,Ne=1e3,Pe=3e4,B=Object.freeze({counters:Object.freeze({}),latestBurst:null,burstRing:Object.freeze([]),burstSeq:0,lifecycleRing:Object.freeze([]),connectionSeq:0,connected:!1,reconnectAttempts:0,lastErrorAt:null,reconnectDelayMs:Ne}),Fe=new Set,Ie={},Le=[],Re=[],ze=[],Be=!1,Ve=!1,He=null,Ue=null,We=null,Ge=!1,Ke=typeof localStorage<`u`&&localStorage.getItem(`DEBUG_SSE`)===`1`;function qe(e,t){Ke&&(t?console.debug(`[ssg-sse] ${e}`,t):console.debug(`[ssg-sse] ${e}`))}function Je(){Ge||(Ge=!0,queueMicrotask(Ye))}function Ye(){Ge=!1;let e=Object.keys(Ie),t=Le,n=Re,r=ze,i=Be,a=He!==null||Ue!==null||We!==null;if(e.length===0&&t.length===0&&n.length===0&&r.length===0&&!i&&!a)return;let o=B.counters;if(e.length>0){let t={...B.counters};for(let n of e)t[n]=(t[n]??0)+(Ie[n]??0);o=Object.freeze(t),Ie={}}let s=B.burstRing,c=B.latestBurst,l=B.burstSeq;if(t.length>0){let e=B.burstRing.length+t.length>Ae?[...B.burstRing,...t].slice(-Ae):[...B.burstRing,...t];s=Object.freeze(e),c=t[t.length-1]??c,l=B.burstSeq+t.length,Le=[]}if(n.length>0){let e=new Map;for(let t of n)e.set(t.tool_use_id,t);let t=!1,r=s.map(n=>{if(!n.tool_use_id)return n;let r=e.get(n.tool_use_id);if(!r)return n;t=!0;let i=n.output_tokens??0,a=n.complete_ts_ms??0,o=Math.max(i,r.output_tokens),s=Math.max(a,r.ts_ms),c=Math.max(n.complete_duration_ms??0,r.duration_ms??0);return{...n,output_tokens:o,complete_ts_ms:s,...c>0?{complete_duration_ms:c}:{}}});t&&(s=Object.freeze(r),l=B.burstSeq+1),Re=[]}let u=B.lifecycleRing;if(r.length>0){let e=B.lifecycleRing.length+r.length>je?[...B.lifecycleRing,...r].slice(-je):[...B.lifecycleRing,...r];u=Object.freeze(e),ze=[]}let d=B.connected,f=B.connectionSeq;i&&(d=Ve,f=B.connectionSeq+1,Be=!1);let p=B.reconnectAttempts,m=B.lastErrorAt,h=B.reconnectDelayMs;He!==null&&(p=He,He=null),Ue!==null&&(m=Ue,Ue=null),We!==null&&(h=We,We=null),B=Object.freeze({counters:o,latestBurst:c,burstRing:s,burstSeq:l,lifecycleRing:u,connectionSeq:f,connected:d,reconnectAttempts:p,lastErrorAt:m,reconnectDelayMs:h});for(let e of Fe)e()}var Xe=null,Ze=0,Qe=new Set,$e=new Map,et=null,tt=Ne,nt=null;function rt(e,t){if(e===`eval-burst`){try{let e=JSON.parse(t.data);Array.isArray(e?.bursts)&&(Le.push(...e.bursts),Je())}catch{}return}if(e===`eval-burst-complete`){try{let e=JSON.parse(t.data);if(e&&typeof e.tool_use_id==`string`&&e.tool_use_id.length>0&&typeof e.output_tokens==`number`&&Number.isFinite(e.output_tokens)&&typeof e.ts_ms==`number`&&Number.isFinite(e.ts_ms)){let t={ts_ms:e.ts_ms,tool_use_id:e.tool_use_id,output_tokens:Math.max(0,e.output_tokens),...typeof e.duration_ms==`number`&&Number.isFinite(e.duration_ms)?{duration_ms:e.duration_ms}:{}};Re.push(t),Je()}}catch{}return}if(e===`session-lifecycle`){try{let e=JSON.parse(t.data);Array.isArray(e?.events)&&e.events.length>0&&(ze.push(...e.events),Je())}catch{}return}Ie[e]=(Ie[e]??0)+1,Je()}function it(e){if(!Xe||$e.has(e))return;let t=t=>rt(e,t);Xe.addEventListener(e,t),$e.set(e,t)}var at=0,ot=0,st=2e3;function ct(){if(Xe)return;qe(`opening EventSource`,{url:`/api/events`}),ot=Date.now();let e=new EventSource(`/api/events`);Xe=e,$e.clear();for(let e of Qe)it(e);e.onopen=()=>{let e=B.lastErrorAt!==null;tt=Ne,at=0,He=0,We=Ne,Be=!0,Ve=!0,Je(),e&&yt(`reconnect`),qe(`connected`)},e.onerror=()=>{e.close(),Xe=null,$e.clear(),Be=!0,Ve=!1,Ue=Date.now(),Je(),at===0&&Date.now()-ot<st?qe(`first-open interrupted (page-load race) — reconnect in ${tt}ms`):console.warn(`[ssg-sse] EventSource error — reconnect in ${tt}ms (attempt ${at+1})`),Ze>0&&(et=setTimeout(()=>{et=null,Ze>0&&ct()},tt),at++,He=at,tt=Math.min(tt*2,Pe),We=tt,Je())}}function lt(){et&&=(clearTimeout(et),null),Xe?.close(),Xe=null,$e.clear(),tt=Ne,at=0,He=0,We=Ne,Be=!0,Ve=!1,Je()}typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ze!==0&&(Xe||(et&&=(clearTimeout(et),null),qe(`visibilitychange → reconnecting`),ct()))});function ut(){for(let e of Qe)e!==`eval-burst`&&(Ie[e]=(Ie[e]??0)+1);Je()}function dt(e){return Fe.add(e),()=>{Fe.delete(e)}}function ft(){return B}var pt=2e3,mt=1e4,ht=1440*60*1e3,gt=500,_t=0,vt=null;function yt(e){let t=Date.now();if(t-_t<mt){qe(`hydrate skipped (cooldown)`,{reason:e});return}if(vt)return;let n=t-ht,r=B.burstRing[B.burstRing.length-1],i=B.burstRing.length>0&&r!==void 0?r.ts_ms+1:n,a=e===`reconnect`?Math.max(i,n):n,o=t;if(a>=o)return;_t=t;let s=new AbortController;vt=s,qe(`hydrate start`,{reason:e,since:a,until:o,ringLen:B.burstRing.length}),(async()=>{let t=a,n=0;try{for(;n<pt&&t<o&&!s.signal.aborted;){let r=Math.min(gt,pt-n),i=await fetch(`/api/json/graph/backfill?since_ms=${t}&until_ms=${o}&limit=${r}`,{signal:s.signal,credentials:`same-origin`});if(!i.ok)break;let a=await i.json();if(!Array.isArray(a.bursts)||a.bursts.length===0||(Le.push(...a.bursts),Je(),n+=a.bursts.length,qe(`hydrate page`,{reason:e,page:n,count:a.bursts.length}),a.bursts.length<r))break;let c=a.bursts[a.bursts.length-1];if(c===void 0)break;t=c.ts_ms+1}qe(`hydrate done`,{reason:e,fetched:n})}catch(t){t.name!==`AbortError`&&console.warn(`[ssg-sse] ring hydration failed (${e})`,t)}finally{vt=null}})()}function bt(e){for(let t of e)Qe.add(t),it(t);return Ze++,Ze===1&&(yt(`initial`),ct(),nt=setInterval(ut,Me)),()=>{Ze--,Ze===0&&(lt(),nt&&=(clearInterval(nt),null))}}var xt=Me;function St(){(0,_.useEffect)(()=>bt([]),[]);let e=(0,_.useSyncExternalStore)(dt,ft),[,t]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(e.connected||e.lastErrorAt===null)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.connected,e.lastErrorAt]);let n=Ct(e),r=n===`reconnecting`&&e.lastErrorAt!==null?Math.max(0,Math.ceil((e.lastErrorAt+e.reconnectDelayMs-Date.now())/1e3)):null,i=Math.round(xt/1e3);if(n===`connected`)return(0,D.jsxs)(`div`,{className:`chip`,title:`Telemetry Live — SSE connected`,"data-testid":`sse-status-chip`,"data-state":`connected`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-[var(--color-decision-allow)]`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`Live`})]});let a=n===`reconnecting`,o=a?{color:`var(--color-hig-orange)`,background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`}:{color:`var(--color-hig-red)`,background:`color-mix(in oklab, var(--color-hig-red) 14%, transparent)`},s=a?`bg-[var(--color-hig-orange)]`:`bg-[var(--color-hig-red)]`,c=a?r===null?`Reconnecting`:`Reconnect ${r}s`:`Offline`,l=`Live paused · ${i}s poll`;return(0,D.jsxs)(`div`,{className:`chip`,style:o,title:a?`Live stream down — reconnect in ${r??`…`}s (attempt ${e.reconnectAttempts}). Dashboard is polling every ${i}s until SSE recovers.`:`Live stream disconnected. Dashboard is polling every ${i}s — data still updates, just at a coarser cadence.`,"data-testid":`sse-status-chip`,"data-state":n,role:`status`,"aria-live":`polite`,children:[(0,D.jsx)(`span`,{className:`status-dot ${s} pulse-soft`}),(0,D.jsx)(`span`,{className:`hidden md:inline`,children:l}),(0,D.jsx)(`span`,{className:`md:hidden`,children:c})]})}function Ct(e){return e.connected?`connected`:e.reconnectAttempts>0||e.lastErrorAt!==null?`reconnecting`:`disconnected`}var wt=[{path:`/`,aliases:[`dashboard`,`home`,`main`,`top`],selector:`a[href="/"]`},{path:`/agents`,aliases:[`agents`,`agent`,`connected agents`],selector:`a[href="/agents"]`},{path:`/graph`,aliases:[`graph`,`graph view`,`visualisation`,`visualization`],selector:`a[href="/graph"]`},{path:`/rules`,aliases:[`rules`,`rule list`,`policies`],selector:`a[href="/rules"]`},{path:`/hub`,aliases:[`hub`,`rule hub`,`registry`,`marketplace`],selector:`a[href="/hub"]`},{path:`/approvals`,aliases:[`approvals`,`approval queue`,`pending`,`ask queue`,`approvals queue`],selector:`a[href="/approvals"]`},{path:`/audit`,aliases:[`audit`,`activity`,`audit log`,`history`],selector:`a[href="/audit"]`},{path:`/monitor`,aliases:[`monitor`,`live monitor`,`live stream`,`live`],selector:`a[href="/monitor"]`},{path:`/observability`,aliases:[`observability`,`metrics`,`telemetry`,`stats`],selector:`a[href="/observability"]`},{path:`/workspace`,aliases:[`workspace`,`monorepo`,`projects`],selector:`a[href="/workspace"]`},{path:`/setup`,aliases:[`setup`,`setup status`,`install`,`installation`],selector:`a[href="/setup"]`},{path:`/debug`,aliases:[`debug`,`diagnostics`,`troubleshoot`],selector:`a[href="/debug"]`},{path:`/profile`,aliases:[`profile`,`license`,`account`],selector:`a[href="/profile"]`},{path:`/support`,aliases:[`support`,`help`,`feedback`],selector:`a[href="/support"]`},{path:`/notifications`,aliases:[`notifications`,`alerts`,`inbox`],selector:`a[href="/notifications"]`},{path:`/try`,aliases:[`try`,`try it`,`simulator`,`sandbox`,`playground`],selector:`a[href="/try"]`},{path:`/guardrails`,aliases:[`guardrails`,`guardrail packs`,`packs`],selector:`a[href="/guardrails"]`}];function Tt(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Et(e){if(!e)return null;let t=e.toLowerCase().trim();for(let e of wt)for(let n of e.aliases)if(t===n)return e;for(let e of wt)for(let n of e.aliases)if(t.includes(n))return e;return null}function Dt(e){let t=e.trim().toLowerCase();if(!t)return{kind:`unknown`,said:``,failed:!0};if(/\b(turn|switch|set|put)\s+(ssg|the system|everything)?\s*off\b/.test(t)||/\b(kill switch|panic|safe mode|stop ssg)\b/.test(t)||/\bssg\s+off\b/.test(t)||/^off$/.test(t))return{kind:`set-ssg-mode`,mode:`off`,said:`Switching SSG to OFF`,targetSelector:`.chip[title*="cycle"]`};if(/\b(audit\s+mode|set\s+audit|log[\s-]only|switch\s+to\s+audit|audit\s+only)\b/.test(t)||/\bssg\s+audit\b/.test(t)||/^audit$/.test(t))return{kind:`set-ssg-mode`,mode:`audit`,said:`Switching SSG to AUDIT`,targetSelector:`.chip[title*="cycle"]`};if(/\b(turn|switch|set|put)\s+(ssg|the system|everything)?\s*on\b/.test(t)||/\b(resume|re-enable|reenable|enforce)\b.*\b(ssg|rules)?\b/.test(t)||/\bssg\s+on\b/.test(t)||/^on$/.test(t))return{kind:`set-ssg-mode`,mode:`on`,said:`Resuming SSG enforcement`,targetSelector:`.chip[title*="cycle"]`};if(/\b(ask|approvals?)\b.*\b(dashboard|here|on screen|browser)\b/.test(t))return{kind:`set-ask-mode`,mode:`dashboard`,said:`Routing ASK prompts to the dashboard`,targetSelector:`.chip[title*="ASK"]`};if(/\b(ask|approvals?)\b.*\b(tty|terminal|native|ide|cli)\b/.test(t))return{kind:`set-ask-mode`,mode:`tty`,said:`Routing ASK prompts to the native terminal`,targetSelector:`.chip[title*="ASK"]`};if(/\b(newcomer|beginner|simple|simplified|easy)\s+(mode|ui|view)?\b/.test(t))return{kind:`set-ui-mode`,mode:`newcomer`,said:`Switching to Newcomer mode`,targetSelector:`button[title*="newcomer" i], button[title*="Newcomer"]`};if(/\b(pro|professional|advanced|expert|full)\s+(mode|ui|view)?\b/.test(t))return{kind:`set-ui-mode`,mode:`pro`,said:`Switching to Pro mode`,targetSelector:`button[title*="pro" i], button[title*="Pro"]`};if(/\b(refresh|reset)\b(?!.*reload)/.test(t))return{kind:`refresh`,said:`Resetting the page`};if(/\b(hard\s+reload|reload|force\s+reload|fresh\s+load)\b/.test(t))return{kind:`hard-reload`,said:`Hard-reloading the dashboard`};let n=t.match(/\b(?:show me|show|open|go to|take me to|switch to|jump to|navigate to|bring up|pull up)\s+(.+)$/);if(n){let e=n[1]?.replace(/[?!.]+$/,``).trim(),t=Et(e);return t?{kind:`navigate`,path:t.path,said:`Opening ${Ot(t.path)}`,targetSelector:t.selector}:{kind:`unknown`,said:`I don't have a page called "${e}".`,failed:!0}}let r=Et(t);return r?{kind:`navigate`,path:r.path,said:`Opening ${Ot(r.path)}`,targetSelector:r.selector}:{kind:`unknown`,said:`Didn't catch that. Try "go to rules", "audit mode", or "switch to newcomer".`,failed:!0}}function Ot(e){return e===`/`?`Dashboard`:e.slice(1).replace(/\b\w/g,e=>e.toUpperCase())}function kt(e){e&&window.dispatchEvent(new CustomEvent(`ssg:voice-target`,{detail:{selector:e}}))}function At(){window.dispatchEvent(new CustomEvent(`ssg:voice-page-morph`))}function jt({actions:e}){let t=(0,_.useMemo)(()=>!!Tt(),[]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!0),f=(0,_.useRef)(null),p=(0,_.useCallback)(t=>{let n=Dt(t);switch(s(n),n.kind){case`navigate`:kt(n.targetSelector),e.navigate(n.path),At();break;case`set-ssg-mode`:kt(n.targetSelector),e.setSsgMode(n.mode);break;case`set-ask-mode`:kt(n.targetSelector),e.setAskMode(n.mode);break;case`set-ui-mode`:kt(n.targetSelector),e.setUiMode(n.mode);break;case`refresh`:e.refresh(),At();break;case`hard-reload`:e.hardReload();break;case`unknown`:break}},[e]),m=(0,_.useCallback)(()=>{let e=f.current;if(e)try{e.stop()}catch{}r(!1)},[]),h=(0,_.useCallback)(()=>{let e=Tt();if(!e)return;let t=new e;t.continuous=!1,t.interimResults=!0,t.lang=`en-US`,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r],a=i[0]?.transcript??``;i.isFinal?n+=a:t+=a}a(t||n),n&&p(n)},t.onend=()=>r(!1),t.onerror=()=>r(!1),f.current=t,a(``),s(null);try{t.start(),r(!0)}catch{r(!1)}},[p]);(0,_.useEffect)(()=>()=>m(),[m]);let g=e=>{e.preventDefault();let t=c.trim();t&&(a(t),p(t),l(``))};if(!u)return(0,D.jsx)(`button`,{type:`button`,className:`ssg-voice-dock ssg-voice-dock--collapsed`,onClick:()=>d(!0),title:`Talk to SigmaShake`,"aria-label":`Open voice dock`,children:(0,D.jsx)(Mt,{})});let v=o?.kind===`unknown`;return(0,D.jsxs)(`div`,{className:`ssg-voice-dock ssg-voice-dock--open`+(n?` ssg-voice-dock--listening`:``)+(v?` ssg-voice-dock--failed`:``),role:`region`,"aria-label":`Voice dock`,children:[(0,D.jsxs)(`div`,{className:`ssg-voice-dock__row`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`ssg-voice-dock__mic${n?` ssg-voice-dock__mic--on`:``}`,onClick:n?m:h,disabled:!t,title:t?n?`Stop listening`:`Tap then speak — try "audit mode" or "go to rules"`:`Speech recognition isn't supported in this browser. Use the text box.`,children:[(0,D.jsx)(Mt,{}),(0,D.jsx)(`span`,{children:n?`Listening…`:t?`Talk`:`Voice off`})]}),(0,D.jsx)(`form`,{className:`ssg-voice-dock__form`,onSubmit:g,children:(0,D.jsx)(`input`,{type:`text`,className:`ssg-voice-dock__input`,placeholder:`Type or say "go to audit"`,value:c,onChange:e=>l(e.target.value),spellCheck:!1})}),(0,D.jsx)(`button`,{type:`button`,className:`ssg-voice-dock__close`,onClick:()=>d(!1),title:`Hide voice dock`,"aria-label":`Hide voice dock`,children:`×`})]}),(i||o)&&(0,D.jsxs)(`div`,{className:`ssg-voice-dock__feedback`,children:[i&&(0,D.jsxs)(`div`,{className:`ssg-voice-dock__line ssg-voice-dock__line--heard`,children:[(0,D.jsx)(`span`,{className:`ssg-voice-dock__tag`,children:`Heard`}),(0,D.jsx)(`span`,{children:i})]}),o&&(0,D.jsxs)(`div`,{className:`ssg-voice-dock__line ssg-voice-dock__line--`+(v?`miss`:`did`),children:[(0,D.jsx)(`span`,{className:`ssg-voice-dock__tag`,children:v?`Hmm`:`Did`}),(0,D.jsx)(`span`,{children:o.said})]})]})]})}function Mt(){return(0,D.jsxs)(`svg`,{className:`ssg-voice-dock__glyph`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,D.jsx)(`rect`,{x:`6`,y:`2`,width:`4`,height:`8`,rx:`2`,fill:`currentColor`}),(0,D.jsx)(`path`,{d:`M4 8 v0.6 a4 4 0 0 0 8 0 V8`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,fill:`none`}),(0,D.jsx)(`path`,{d:`M8 13 v2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`})]})}function V(e,t=[]){let[n,r]=(0,_.useState)({data:null,loading:!0,error:null}),[i,a]=(0,_.useState)(0),o=(0,_.useRef)(null),s=(0,_.useCallback)(()=>{a(e=>e+1)},[]);return(0,_.useEffect)(()=>{let t=new AbortController;return o.current=t,r(e=>({...e,loading:!0,error:null})),fetch(e,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t.signal.aborted||r({data:e,loading:!1,error:null})}).catch(e=>{if(t.signal.aborted)return;let n=e instanceof Error?e.message:String(e);r(e=>({...e,loading:!1,error:n}))}),()=>{t.abort()}},[e]),{...n,refetch:s}}function Nt(e){let t=(0,_.useSyncExternalStore)(dt,ft);e.join(`,`),(0,_.useEffect)(()=>bt(e),[e]);let n=(0,_.useRef)({});return(0,_.useMemo)(()=>{let r={},i=!1;for(let a of e){let e=t.counters[a]??0;r[a]=e,n.current[a]!==e&&(i=!0)}return!i&&Object.keys(n.current).length===e.length?n.current:(n.current=r,r)},[t,e.length,e])}var Pt=`ssg-dashboard-tabs`,Ft=2e3,It=6e3;function Lt(){return`tab-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Rt(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(!0),i=(0,_.useRef)(Lt()),a=(0,_.useRef)(new Map);return(0,_.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(Pt);function n(){let e=Date.now();for(let[t,n]of a.current.entries())e-n>It&&a.current.delete(t);let n=a.current.size;t(n),r([...a.current.keys(),i.current].sort()[0]===i.current)}function o(e){let t=e.data;!t||t.id===i.current||(t.type===`leave`?a.current.delete(t.id):a.current.set(t.id,Date.now()),n())}e.addEventListener(`message`,o),e.postMessage({type:`join`,id:i.current});let s=setInterval(()=>{e.postMessage({type:`heartbeat`,id:i.current}),n()},Ft),c=()=>{e.postMessage({type:`leave`,id:i.current})};return window.addEventListener(`beforeunload`,c),()=>{clearInterval(s),e.postMessage({type:`leave`,id:i.current}),e.removeEventListener(`message`,o),e.close(),window.removeEventListener(`beforeunload`,c)}},[]),{otherTabCount:e,isLeader:n}}function H(){let e=document.querySelector(`meta[name="ssg-csrf"]`)?.content??``;return e?{"X-SigmaShake-Token":e}:{}}function zt(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}function Bt(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.enabled!==i.enabled||n.toolGroups.length!==i.toolGroups.length||n.toolGroups.some((e,t)=>e!==i.toolGroups[t]))return!1}return!0}function Vt(e,t){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(`project`),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)({}),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(0),C=(0,_.useRef)(null);(0,_.useEffect)(()=>{let n=`${e}:${u}:${x}`,i=C.current!==n;C.current=n;let o=!1,c=setTimeout(()=>{i&&(s(!0),l(null));let n=new URLSearchParams({agent:e,projectDir:t,scope:u});fetch(`/api/json/adapters/toggles?${n.toString()}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(o)return;r(t.catalog);let n=t.resolved[e]??{hooks:{},mcp:{}};a(n),i&&(p({...n.hooks}),h(Object.fromEntries(Object.entries(n.mcp).map(([e,t])=>[e,{...t,toolGroups:[...t.toolGroups]}]))),s(!1))}).catch(e=>{o||i&&(l(e instanceof Error?e.message:String(e)),s(!1))})},i?0:250);return()=>{o=!0,clearTimeout(c)}},[e,t,u,x]);let w=(0,_.useCallback)(()=>S(e=>e+1),[]);return{catalog:n,loading:o,fetchError:c,scope:u,setScope:d,hooks:f,mcp:m,setHook:(0,_.useCallback)((e,t)=>{p(n=>({...n,[e]:t}))},[]),setMcpEnabled:(0,_.useCallback)((e,t)=>{h(n=>({...n,[e]:{...n[e]??{enabled:!0,toolGroups:[`core`]},enabled:t}}))},[]),setMcpToolGroups:(0,_.useCallback)((e,t)=>{h(n=>({...n,[e]:{...n[e]??{enabled:!0,toolGroups:[`core`]},toolGroups:t}}))},[]),hasChanges:i!==null&&(!zt(f,i.hooks)||!Bt(m,i.mcp)),saving:g,saveError:y,refetch:w,save:(0,_.useCallback)(async()=>{v(!0),b(null);try{let n=await(await fetch(`/api/json/adapters/toggles`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({agent:e,scope:u,projectDir:t,changes:{hooks:f,mcp:m}})})).json();if(!n.ok)b(n.error??`Save failed`);else{let e=n.resolved??{hooks:f,mcp:m};a(e),p({...e.hooks}),h(Object.fromEntries(Object.entries(e.mcp).map(([e,t])=>[e,{...t,toolGroups:[...t.toolGroups]}])))}}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e,u,t,f,m]),saveAndInstall:(0,_.useCallback)(async(t,n)=>{v(!0),b(null);try{let r=await(await fetch(`/api/json/adapters/toggles`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({agent:e,scope:u,projectDir:t,changes:{hooks:f,mcp:m}})})).json();if(!r.ok){b(r.error??`Save failed`),n?.(!1);return}a(r.resolved??{hooks:f,mcp:m});let i=await(await fetch(`/api/json/adapters/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({adapter:e,projectDir:t})})).json();i.ok?n?.(!0):(b(i.error??`Install failed`),n?.(!1))}catch(e){b(e instanceof Error?e.message:String(e)),n?.(!1)}finally{v(!1)}},[e,u,f,m])}}function Ht({checked:e,onChange:t,disabled:n,size:r=`md`,tone:i=`brand`,label:a}){return(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a,disabled:n,onClick:()=>t(!e),className:`ss-toggle ${r===`sm`?`ss-toggle--sm`:``} ${i===`danger`?`ss-toggle--danger`:``}`,children:(0,D.jsx)(`span`,{className:`ss-toggle-thumb`,"aria-hidden":`true`})})}function Ut({groups:e,selected:t,onChange:n,disabled:r}){let i=(0,_.useRef)(null);function a(e){if(t.includes(e)){let r=t.filter(t=>t!==e);if(r.length>0)n(r);else{i.current&&(i.current.textContent=``,requestAnimationFrame(()=>{i.current&&(i.current.textContent=`At least one tool group must remain enabled.`)}));let t=document.getElementById(`chip-${e}`);t&&(t.classList.remove(`chip--shake-deny`),t.offsetWidth,t.classList.add(`chip--shake-deny`),t.addEventListener(`animationend`,()=>t.classList.remove(`chip--shake-deny`),{once:!0}))}}else n([...t,e])}return(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[e.map(e=>{let n=t.includes(e.id);return(0,D.jsx)(`button`,{id:`chip-${e.id}`,type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a(e.id),className:`chip${n?` chip--active`:``}`,children:e.label},e.id)}),(0,D.jsx)(`span`,{ref:i,className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`})]})}function Wt(){return(0,D.jsx)(`div`,{className:`flex flex-col gap-0.5 mb-4`,children:[0,1,2,3].map(e=>(0,D.jsx)(`div`,{className:`shimmer agent-toggles-skeleton-row`},e))})}function Gt({agentId:e,projectDir:t,onApplied:n}){let{catalog:r,loading:i,fetchError:a,scope:o,setScope:s,hooks:c,mcp:l,setHook:u,setMcpEnabled:d,setMcpToolGroups:f,hasChanges:p,saving:m,saveError:h,saveAndInstall:g,refetch:_}=Vt(e,t);if(i)return(0,D.jsx)(Wt,{});if(a)return(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-hig-red)] font-sans`,children:a}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--ghost`,onClick:()=>_(),children:`Retry`})]});if(!r)return null;let v=r.hookApplicability[e]??[],y=r.mcpApplicability[e]??[],b=v.length>0,x=y.length>0;if(!b&&!x)return(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-sans py-1`,children:`No configurable hooks or MCP servers for this agent yet.`});let S=r.hooks.filter(e=>v.includes(e.id)),C=r.mcp.filter(e=>y.includes(e.id)),w=p?S.filter(e=>(c[e.id]??!0)!==!0).length+C.filter(e=>{let t=l[e.id]??{enabled:!0,toolGroups:[`core`]};return!t.enabled||t.toolGroups.join()!==`core`}).length:0;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`Scope`}),(0,D.jsx)(`div`,{className:`ss-segment`,role:`tablist`,"aria-label":`Toggle scope`,children:[`project`,`global`].map(e=>(0,D.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e,className:`ss-segment-item`,onClick:()=>s(e),children:e===`project`?`This project`:`Global`},e))}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1.5`,children:o===`project`?`Saves to .sigmashake/agent-toggles.json in this project.`:`Saves to ~/.sigmashake/agent-toggles.json (applies to all projects).`})]}),b&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`Claude Code lifecycle hooks`}),(0,D.jsx)(`div`,{className:`ss-list`,style:{margin:0},children:S.map(e=>{let t=c[e.id]??!0;return(0,D.jsxs)(`div`,{className:`ss-list-row`,style:{gap:12,cursor:`pointer`},onClick:()=>u(e.id,!t),children:[(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`span`,{className:`block text-[12.5px] font-medium text-[var(--color-fg-1)] mb-0.5`,children:e.label}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] m-0`,children:e.description})]}),(0,D.jsx)(Ht,{checked:t,onChange:t=>u(e.id,t),disabled:m,label:e.label,size:`sm`})]},e.id)})})]}),x&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`MCP servers`}),(0,D.jsx)(`div`,{className:`ss-list`,style:{margin:0},children:C.map(e=>{let t=l[e.id]??{enabled:!0,toolGroups:[`core`]},n=!t.enabled;return(0,D.jsxs)(`div`,{style:{padding:`10px 14px`,borderBottom:`1px solid var(--color-line-0)`},children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,D.jsx)(`span`,{className:`block text-[12.5px] font-medium text-[var(--color-fg-1)] mb-0.5`,children:e.label})}),(0,D.jsx)(Ht,{checked:t.enabled,onChange:t=>d(e.id,t),disabled:m,label:e.label,size:`sm`,tone:n?`danger`:`brand`})]}),n&&(0,D.jsxs)(`p`,{className:`ss-list-row-warning`,children:[`Disconnecting will remove `,e.id,` from this agent. Hooks remain unchanged.`]}),t.enabled&&(0,D.jsxs)(`div`,{className:`mt-2`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mb-0.5`,children:`Tool groups`}),(0,D.jsx)(Ut,{groups:e.toolGroups,selected:t.toolGroups,onChange:t=>f(e.id,t),disabled:m})]})]},e.id)})})]}),p&&w>0&&(0,D.jsxs)(`p`,{className:`agent-toggles-pending`,children:[w,` change`,w===1?``:`s`,` pending — click Apply to save.`]}),h&&(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-hig-red)] font-sans m-0`,children:h}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--ghost`,onClick:()=>void g(t,e=>n?.(e)),children:`Retry`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,disabled:m||!p||!t.trim(),onClick:()=>void g(t,e=>n?.(e)),title:t.trim()?p?`Save toggle choices and re-run ssg init to update config files.`:`No changes to apply.`:`Pick a project directory above before applying.`,style:{height:34,padding:`0 16px`,fontSize:12.5,display:`inline-flex`,alignItems:`center`,gap:6},children:[m&&(0,D.jsx)(`span`,{className:`ss-spinner`,"aria-hidden":`true`}),m?`Applying…`:`Apply`]}),!p&&!m&&(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`no changes`})]})]})}function Kt({open:e,onClose:t,title:n,subtitle:r,children:i,footer:a,size:o=`md`}){let s=(0,_.useRef)(null),c=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement;let n=document.body.style.overflow;document.body.style.overflow=`hidden`;let r=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,r),s.current?.focus(),()=>{document.removeEventListener(`keydown`,r),document.body.style.overflow=n,c.current?.focus?.()}},[e,t]),e?(0,D.jsx)(`div`,{className:`ss-sheet-backdrop`,onClick:e=>{e.target===e.currentTarget&&t()},role:`presentation`,children:(0,D.jsxs)(`div`,{ref:s,className:`ss-sheet ss-sheet--${o}`,role:`dialog`,"aria-modal":`true`,"aria-label":n??`Detail`,tabIndex:-1,children:[(0,D.jsx)(`button`,{className:`ss-sheet-handle`,onClick:t,"aria-label":`Close`,type:`button`}),(0,D.jsxs)(`div`,{className:`ss-sheet-head`,children:[(0,D.jsxs)(`div`,{className:`ss-sheet-head-text`,children:[n&&(0,D.jsx)(`h2`,{className:`ss-sheet-title`,children:n}),r&&(0,D.jsx)(`p`,{className:`ss-sheet-subtitle`,children:r})]}),(0,D.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`ss-sheet-close`,children:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,D.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]}),(0,D.jsx)(`div`,{className:`ss-sheet-body`,children:i}),a&&(0,D.jsx)(`div`,{className:`ss-sheet-footer`,children:a})]})}):null}var qt=`http://www.w3.org/2000/svg`;function Jt({markup:e,size:t=22}){let n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=n.current;if(!t)return;for(;t.firstChild;)t.removeChild(t.firstChild);let r=`<svg xmlns="${qt}">${e}</svg>`,i=new DOMParser().parseFromString(r,`image/svg+xml`).documentElement;for(let e of Array.from(i.childNodes))t.appendChild(t.ownerDocument.importNode(e,!0))},[e]),(0,D.jsx)(`svg`,{ref:n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,width:t,height:t,"aria-hidden":`true`})}function Yt({a:e,size:t=40}){return(0,D.jsx)(`div`,{className:`agent-card-icon shrink-0`,style:{width:t,height:t,color:e.accent,background:`color-mix(in oklab, ${e.accent} 16%, var(--color-surface-2))`,borderColor:`color-mix(in oklab, ${e.accent} 38%, var(--color-line-1))`},children:(0,D.jsx)(Jt,{markup:e.glyph,size:Math.round(t*.55)})})}function Xt({a:e}){return e.active?(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 16%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 38%, transparent)`},children:`Active`}):e.detected?(0,D.jsxs)(`span`,{className:`agent-badge agent-badge--detected`,children:[(0,D.jsx)(`span`,{className:`agent-badge-dot`}),`Detected`]}):e.recommended?(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 12%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 30%, transparent)`},children:`Recommended`}):null}function Zt(){return(0,D.jsx)(`svg`,{className:`ss-list-row-chevron`,viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M5 3l5 5-5 5`})})}function Qt({text:e}){let[t,n]=(0,_.useState)(!1);return(0,D.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`ss-btn ss-btn--secondary`,style:{height:32,padding:`0 12px`,fontSize:12},"aria-label":t?`Copied`:`Copy`,children:t?`Copied ✓`:`Copy`})}function $t(e,t){return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}function en({agentId:e,projectDir:t}){let[n,r]=(0,_.useState)(!1);return(0,D.jsxs)(`div`,{style:{border:`1px solid var(--color-line-1)`,borderRadius:10,overflow:`hidden`,marginBottom:16},children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,width:`100%`,padding:`10px 14px`,background:`var(--color-surface-2)`,border:`none`,cursor:`pointer`,textAlign:`left`,gap:8},children:[(0,D.jsx)(`span`,{style:{fontSize:12.5,fontWeight:500,color:`var(--color-fg-1)`},children:`Configure hooks & MCP`}),(0,D.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--color-fg-3)`,transform:n?`rotate(90deg)`:`rotate(0deg)`,transition:`transform 0.15s`,flexShrink:0},"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M5 3l5 5-5 5`})})]}),(0,D.jsx)(`div`,{className:`agent-toggles-body`,"data-open":n?`true`:`false`,style:{borderTop:n?`1px solid var(--color-line-1)`:`none`},children:(0,D.jsx)(`div`,{style:{padding:`14px 14px 16px`},children:(0,D.jsx)(Gt,{agentId:e,projectDir:t})})})]})}function tn({agent:e,ctx:t,onClose:n,onInstalled:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),C=`ssg init --client=${e.id}`;async function w(){b(!0),S(null);try{let e=await(await fetch(`/api/json/pick-dir`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()}})).json();e.ok?a(e.path):e.reason===`user_cancelled`||(e.reason===`no_display`?S(`No graphical session — type the path manually instead.`):e.reason===`no_picker_found`?S("Folder picker not available. Install `zenity` (Linux), or type the path manually."):S(e.error||`Folder picker failed.`))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}(0,_.useEffect)(()=>{let e=!1;return fetch(`/api/json/adapters/recent`).then(e=>e.json()).then(t=>{e||(s(t.recents??[]),!i&&t.recents&&t.recents.length>0&&a(t.recents[0]?.path))}).catch(()=>{}),()=>{e=!0}},[i]);async function T(){if(i.trim()){l(!0),h(null),v(!1);try{let t=await(await fetch(`/api/json/adapters/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({adapter:e.id,projectDir:i})})).json();h(t),t.ok&&(r(),fetch(`/api/json/adapters/recent`).then(e=>e.json()).then(e=>s(e.recents??[])).catch(()=>{}))}catch(t){h({ok:!1,exitCode:-1,adapter:e.id,projectDir:i,stdout:``,stderr:``,error:t instanceof Error?t.message:String(t)})}finally{l(!1)}}}async function E(e){d(!0),p(null);try{let t=await(await fetch(`/api/json/adapters/active`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({adapter:e})})).json();t.ok?r():p(t.error??`Failed to pin adapter.`)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}let O=c||!i.trim(),k=c?`Connecting…`:i.trim()?`Connect this project`:`Pick a project directory`,A=u?`Saving…`:e.pinned?`Pinned ✓`:`Set as my agent`,j=u||e.pinned;return(0,D.jsxs)(Kt,{open:!0,onClose:n,title:e.displayName,subtitle:e.vendor,size:`md`,footer:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:O,onClick:()=>void T(),title:"Run `ssg init --client` in the chosen project directory.",children:k}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,disabled:j,onClick:()=>void E(e.id),style:{"--tone":e.accent},title:e.pinned?`Already pinned as your default agent.`:`Pin ${e.displayName} as the default — overrides auto-detection across SSG.`,children:A})]}),children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-4 mb-4`,children:[(0,D.jsx)(Yt,{a:e,size:56}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1.5`,children:[(0,D.jsx)(Xt,{a:e}),e.pinned&&(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 14%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 36%, transparent)`},title:`You pinned this agent as your default.`,children:`Pinned`}),e.healthy&&!e.active&&(0,D.jsx)(`span`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`healthy`})]}),(0,D.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-1)] leading-relaxed`,children:e.tagline}),e.pinned&&(0,D.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>void E(null),className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] mt-2 cursor-pointer hover:underline`,children:u?`unpinning…`:`unpin & return to auto-detect`}),f&&(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-hig-red)] mt-2`,children:f})]})]}),(0,D.jsx)(`p`,{className:`ss-list-section-title`,children:`Install target`}),(0,D.jsxs)(`div`,{className:`ss-list mb-4`,children:[(0,D.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},onClick:e=>e.preventDefault(),children:(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[12.5px] font-medium text-[var(--color-fg-1)]`,children:`Project directory`}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-0.5 truncate`,children:i.trim()?$t(i,t.home):`Type a path or pick from below.`})]})}),(0,D.jsxs)(`div`,{style:{padding:`10px 14px`,borderTop:`1px solid var(--color-line-0)`},children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),spellCheck:!1,placeholder:`Click Browse… or paste a path`,className:`flex-1 h-9 px-3 rounded-md text-[12px] font-mono`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-1)`,outline:`none`}}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:y,className:`ss-btn ss-btn--secondary`,style:{height:36,padding:`0 14px`,fontSize:12},title:`Open the system folder picker.`,children:y?`Opening…`:`Browse…`})]}),x&&(0,D.jsx)(`p`,{className:`text-[11px] font-mono mt-2`,style:{color:`var(--color-hig-red)`},children:x}),o.length>0&&(0,D.jsxs)(`div`,{className:`mt-3`,children:[(0,D.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`Recent`}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>a(e.path),className:`text-[11px] font-mono px-2 py-1 rounded-md cursor-pointer`,style:{background:i===e.path?`color-mix(in oklab, var(--color-brand) 14%, var(--color-surface-2))`:`var(--color-surface-2)`,border:`1px solid ${i===e.path?`color-mix(in oklab, var(--color-brand) 38%, var(--color-line-1))`:`var(--color-line-1)`}`,color:i===e.path?`var(--color-brand)`:`var(--color-fg-1)`},title:e.path,children:$t(e.path,t.home)},e.path))})]})]})]}),(0,D.jsx)(`p`,{className:`ss-list-section-title`,children:`Or run from terminal`}),(0,D.jsxs)(`div`,{className:`ss-list mb-4 p-3 flex items-center gap-2`,style:{padding:`12px 14px`},children:[(0,D.jsxs)(`code`,{className:`flex-1 text-[12px] font-mono text-[var(--color-brand)] overflow-x-auto whitespace-nowrap`,children:[`$ `,C]}),(0,D.jsx)(Qt,{text:C})]}),(0,D.jsx)(en,{agentId:e.id,projectDir:i}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{className:`ss-list-section-title`,children:m.ok?`Setup complete`:`Setup failed`}),(0,D.jsx)(nn,{result:m}),(m.stdout||m.stderr||m.error)&&(0,D.jsxs)(`div`,{className:`mt-3`,children:[(0,D.jsx)(`button`,{type:`button`,className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] cursor-pointer`,onClick:()=>v(e=>!e),children:g?`▾ Hide full log`:`▸ Show full log`}),g&&(0,D.jsx)(`pre`,{className:`text-[11px] font-mono rounded-md p-3 mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-2)`},children:m.error?`${m.error}${m.detail?`\n${m.detail}`:``}`:[m.stdout,m.stderr].filter(Boolean).join(`
10
+ `)||`Exit code: ${m.exitCode}`})]})]})]})}function nn({result:e}){return(0,D.jsx)(`ul`,{className:`ss-install-checklist`,children:(e.steps&&e.steps.length>0?e.steps:[{label:e.ok?`Setup complete`:`Setup failed`,status:e.ok?`ok`:`error`,detail:e.error??void 0}]).map((e,t)=>(0,D.jsxs)(`li`,{className:`ss-install-step ss-install-step--${e.status}`,children:[(0,D.jsx)(`span`,{className:`ss-install-step__icon`,"aria-hidden":`true`,children:e.status===`ok`?`✓`:e.status===`error`?`✗`:`–`}),(0,D.jsxs)(`div`,{className:`ss-install-step__body`,children:[(0,D.jsx)(`span`,{className:`ss-install-step__label`,children:e.label}),e.detail&&(0,D.jsx)(`span`,{className:`ss-install-step__detail`,children:e.detail})]})]},t))})}function rn({a:e,onOpen:t}){return(0,D.jsxs)(`button`,{type:`button`,className:`ss-list-row`,onClick:t,"aria-label":`Open ${e.displayName} details`,children:[(0,D.jsx)(Yt,{a:e,size:34}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`text-[13.5px] font-semibold text-[var(--color-fg-0)] truncate`,children:e.displayName}),(0,D.jsx)(Xt,{a:e}),e.pinned&&!e.active&&(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 12%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 30%, transparent)`},children:`Pinned`})]}),(0,D.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-0.5`,children:e.vendor})]}),(0,D.jsx)(Zt,{})]})}function an(){let{data:e,refetch:t}=V(`/api/json/adapters`),[n,r]=(0,_.useState)(`all`),[i,a]=(0,_.useState)(null),o=(0,_.useMemo)(()=>e?n===`detected`?e.adapters.filter(e=>e.detected):n===`available`?e.adapters.filter(e=>!e.detected):e.adapters:[],[e,n]);if(!e)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading adapters…`});let s=e.adapters.find(e=>e.active),c=e.adapters.filter(e=>e.detected).length,l=i?e.adapters.find(e=>e.id===i):null;return(0,D.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,D.jsxs)(`section`,{className:`rounded-2xl p-5 relative overflow-hidden`,style:{border:`1px solid var(--color-line-1)`,background:s?`linear-gradient(180deg, color-mix(in oklab, ${s.accent} 14%, transparent) 0%, transparent 70%), var(--color-surface-1)`:`var(--color-surface-1)`,boxShadow:s?`0 0 0 1px color-mix(in oklab, ${s.accent} 30%, transparent), 0 18px 40px color-mix(in oklab, ${s.accent} 14%, transparent)`:void 0},children:[(0,D.jsx)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:12},children:`Connected agent`}),s?(0,D.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,D.jsx)(Yt,{a:s,size:56}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`h2`,{className:`text-[18px] font-semibold text-[var(--color-fg-0)] tracking-tight`,children:s.displayName}),(0,D.jsx)(Xt,{a:s}),s.pinned?(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:s.accent,background:`color-mix(in oklab, ${s.accent} 14%, transparent)`,borderColor:`color-mix(in oklab, ${s.accent} 36%, transparent)`},title:`You pinned this agent as your default — auto-detection is overridden.`,children:`Pinned`}):(0,D.jsx)(`span`,{className:`agent-badge`,style:{color:`var(--color-fg-3)`,background:`var(--color-surface-2)`,borderColor:`var(--color-line-1)`},title:`SSG auto-detected this agent from process env and filesystem markers.`,children:`Auto-detected`})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-0.5`,children:s.vendor}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-2 leading-relaxed`,children:s.pinned?`Pinned as your default agent — SSG will treat every tool call as ${s.displayName} regardless of auto-detection.`:s.id===`generic`?`No specific AI client detected — falling back to the generic adapter. Pick the agent you actually use and hit "Set as my agent" to override.`:s.healthy?`Auto-detected from process environment. If this isn't the agent you actually use, tap any other row and hit "Set as my agent" to pin it.`:`Forced via SSG_CLIENT — adapter is in use but its config dir is missing or incomplete.`}),s.pinned&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>{fetch(`/api/json/adapters/active`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({adapter:null})}).then(()=>t())},className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] mt-3 cursor-pointer hover:underline`,children:`↺ reset to auto-detect`})]})]}):(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-2)]`,children:`No active adapter resolved.`})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:0},children:[`All supported agents · `,e.adapters.length]}),(0,D.jsx)(`div`,{className:`ss-segment`,role:`tablist`,"aria-label":`Filter`,children:[`all`,`detected`,`available`].map(e=>(0,D.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,className:`ss-segment-item`,onClick:()=>r(e),children:e===`all`?`All`:e===`detected`?`Detected${c>0?` · ${c}`:``}`:`Available`},e))})]}),o.length>0?(0,D.jsx)(`div`,{className:`ss-list`,children:o.map(e=>(0,D.jsx)(rn,{a:e,onOpen:()=>a(e.id)},e.id))}):(0,D.jsx)(`div`,{className:`rounded-2xl p-8 text-center`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] font-mono`,children:`no agents match this filter`})}),(0,D.jsx)(`div`,{className:`rounded-xl p-4`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:[`SSG picks the active adapter at runtime — either from`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`SSG_CLIENT`}),` or by auto-detecting your tool. Tap any agent to wire it into a project from the dashboard, or copy the`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg init`}),` command and run it yourself.`]})}),(0,D.jsx)(on,{ctx:e.context,adapters:e.adapters}),(0,D.jsx)(cn,{}),l&&(0,D.jsx)(tn,{agent:l,ctx:e.context,onClose:()=>a(null),onInstalled:()=>t()})]})}function on({ctx:e,adapters:t}){let{data:n}=V(`/api/json/adapters/recent`),r=t.find(e=>e.active)??null,i=t.filter(e=>e.detected);return(0,D.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid var(--color-line-1)`,background:`var(--color-surface-1)`},children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,D.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight text-[var(--color-fg-0)]`,children:`How SigmaShake is connected`}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Overview`})]}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] leading-relaxed mb-4`,children:`Each AI agent on your machine has its own config file. SigmaShake adds a small hook to those files so it sees every tool call before it runs.`}),(0,D.jsxs)(`ul`,{className:`space-y-2`,children:[(0,D.jsx)(sn,{label:`Daemon`,status:`on`,detail:`Running — watching tool calls in real time.`}),(0,D.jsx)(sn,{label:`Active AI agent`,status:r?`on`:`off`,detail:r?`${r.displayName} (${r.vendor})`:`Nothing detected yet — install an adapter below.`}),(0,D.jsx)(sn,{label:`Wired-in agents`,status:i.length>0?`on`:`off`,detail:i.length>0?i.map(e=>e.displayName).join(`, `):`No agents wired in yet.`})]}),n?.recents&&n.recents.length>0&&(0,D.jsxs)(`div`,{className:`mt-5`,children:[(0,D.jsxs)(`p`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:[`Projects connected (`,n.recents.length,`)`]}),(0,D.jsx)(`ul`,{className:`space-y-1.5`,children:n.recents.map(t=>(0,D.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-3 py-2 text-[12px]`,style:{background:`var(--color-surface-2)`,border:`0.5px solid var(--color-line-1)`},children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:`var(--color-hig-green)`}}),(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-1)] truncate flex-1 min-w-0`,children:$t(t.path,e.home)}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] shrink-0`,children:new Date(t.lastUsed).toLocaleDateString(void 0,{month:`short`,day:`numeric`})})]},t.path))})]})]})}function sn({label:e,status:t,detail:n}){return(0,D.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-3 py-2`,style:{background:`var(--color-surface-2)`,border:`0.5px solid var(--color-line-1)`},children:[(0,D.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:t===`on`?`var(--color-hig-green)`:`var(--color-fg-4)`,boxShadow:t===`on`?`0 0 0 3px color-mix(in oklab, var(--color-hig-green) 22%, transparent)`:void 0}}),(0,D.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--color-fg-0)] w-32 shrink-0`,children:e}),(0,D.jsx)(`span`,{className:`text-[12px] text-[var(--color-fg-2)] flex-1 min-w-0 truncate`,children:n})]})}function cn(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null);async function c(){a(!0),s(null);try{s(await(await fetch(`/api/json/uninstall-everything`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({keepData:n})})).json())}catch(e){s({ok:!1,error:`Could not reach SigmaShake`,detail:e instanceof Error?e.message:String(e)})}finally{a(!1)}}return(0,D.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid color-mix(in oklab, var(--color-hig-red) 28%, var(--color-line-1))`,background:`linear-gradient(180deg, color-mix(in oklab, var(--color-hig-red) 6%, transparent) 0%, transparent 100%), var(--color-surface-1)`},children:[(0,D.jsx)(`div`,{className:`flex items-baseline justify-between gap-3 flex-wrap`,children:(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight text-[var(--color-fg-0)]`,children:`Uninstall SigmaShake`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] leading-relaxed mt-1`,children:[`Removes the SigmaShake hook from every AI-agent config file on this machine and stops the daemon.`,` `,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`The `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg`}),` binary itself stays installed — remove it with your package manager.`]})]})]})}),!e&&!o&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors`,style:{color:`var(--color-hig-red)`,border:`1px solid color-mix(in oklab, var(--color-hig-red) 40%, transparent)`,background:`color-mix(in oklab, var(--color-hig-red) 8%, transparent)`},children:`Uninstall SigmaShake everywhere…`}),e&&!o&&(0,D.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,D.jsxs)(`label`,{className:`flex items-start gap-2 text-[12px] text-[var(--color-fg-1)] cursor-pointer`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),className:`mt-0.5`}),(0,D.jsxs)(`span`,{children:[`Keep my activity history and license`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`(~/.sigmashake/). Uncheck to wipe everything.`})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>void c(),disabled:i,className:`text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,style:{color:`white`,background:`var(--color-hig-red)`},children:i?`Uninstalling…`:`Yes — uninstall everywhere`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(!1),disabled:i,className:`text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors`,style:{color:`var(--color-fg-1)`,background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`},children:`Cancel`})]})]}),o&&(0,D.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`rounded-lg px-4 py-3`,style:{border:`1px solid ${o.ok?`color-mix(in oklab, var(--color-hig-green) 38%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 38%, transparent)`}`,background:o.ok?`color-mix(in oklab, var(--color-hig-green) 6%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 6%, transparent)`},children:[(0,D.jsx)(`p`,{className:`text-[13px] font-semibold`,style:{color:o.ok?`var(--color-hig-green)`:`var(--color-hig-red)`},children:o.ok?`SigmaShake has been removed from this machine`:`Uninstall failed`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:o.ok?(0,D.jsxs)(D.Fragment,{children:[`Hooks were stripped from every AI-agent config file. The daemon has stopped.`,o.packageManagerHint&&(0,D.jsxs)(D.Fragment,{children:[` `,`To also remove the`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg`}),` `,`binary, run:`,(0,D.jsx)(`code`,{className:`block mt-2 px-2 py-1.5 rounded bg-[var(--color-surface-2)] text-[var(--color-brand)] text-[11.5px] font-mono`,children:o.packageManagerHint})]})]}):(0,D.jsxs)(D.Fragment,{children:[o.error??`Unknown error.`,` `,o.detail&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:o.detail})]})})]}),(o.stdout||o.stderr)&&(0,D.jsxs)(`details`,{children:[(0,D.jsx)(`summary`,{className:`text-[11px] text-[var(--color-fg-3)] cursor-pointer hover:text-[var(--color-fg-1)]`,children:`Show full log`}),(0,D.jsx)(`pre`,{className:`text-[11px] font-mono rounded-md p-3 mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-2)`},children:[o.stdout,o.stderr].filter(Boolean).join(`
11
+ `)})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{s(null),t(!1)},className:`text-[11.5px] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`↺ Close`})]})]})}function ln(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ln(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function un(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ln(e))&&(r&&(r+=` `),r+=t);return r}var dn=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,fn=un,pn=(e,t)=>n=>{if(t?.variants==null)return fn(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=dn(t)||dn(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return fn(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},mn=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},hn=(e,t)=>({classGroupId:e,validator:t}),gn=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),_n=`-`,vn=[],yn=`arbitrary..`,bn=e=>{let t=Cn(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Sn(e);let n=e.split(_n);return xn(n,n[0]===``&&n.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?mn(i,t):t:i||vn}return n[e]||vn}}},xn=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=xn(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(_n):e.slice(t).join(_n),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Sn=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?yn+r:void 0})(),Cn=e=>{let{theme:t,classGroups:n}=e;return wn(n,t)},wn=(e,t)=>{let n=gn();for(let r in e){let i=e[r];Tn(i,n,r,t)}return n},Tn=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];En(i,t,n,r)}},En=(e,t,n,r)=>{if(typeof e==`string`){Dn(e,t,n);return}if(typeof e==`function`){On(e,t,n,r);return}kn(e,t,n,r)},Dn=(e,t,n)=>{let r=e===``?t:An(t,e);r.classGroupId=n},On=(e,t,n,r)=>{if(jn(e)){Tn(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(hn(n,e))},kn=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Tn(o,An(t,a),n,r)}},An=(e,t)=>{let n=e,r=t.split(_n),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=gn(),n.nextPart.set(t,i)),n=i}return n},jn=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Mn=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Nn=`!`,Pn=`:`,Fn=[],In=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Ln=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Pn){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Nn)?(c=s.slice(0,-1),l=!0):s.startsWith(Nn)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return In(t,l,c,u)};if(t){let e=t+Pn,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):In(Fn,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Rn=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},zn=e=>({cache:Mn(e.cacheSize),parseClassName:Ln(e),sortModifiers:Rn(e),...bn(e)}),Bn=/\s+/,Vn=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(Bn),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+Nn:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},Hn=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Un(n))&&(i&&(i+=` `),i+=r);return i},Un=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Un(e[r]))&&(n&&(n+=` `),n+=t);return n},Wn=(e,...t)=>{let n,r,i,a,o=o=>(n=zn(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Vn(e,n);return i(e,a),a};return a=o,(...e)=>a(Hn(...e))},Gn=[],Kn=e=>{let t=t=>t[e]||Gn;return t.isThemeGetter=!0,t},qn=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jn=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Yn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Qn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$n=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,er=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tr=e=>Yn.test(e),U=e=>!!e&&!Number.isNaN(Number(e)),nr=e=>!!e&&Number.isInteger(Number(e)),rr=e=>e.endsWith(`%`)&&U(e.slice(0,-1)),ir=e=>Xn.test(e),ar=()=>!0,or=e=>Zn.test(e)&&!Qn.test(e),sr=()=>!1,cr=e=>$n.test(e),lr=e=>er.test(e),ur=e=>!W(e)&&!G(e),dr=e=>Er(e,Ar,sr),W=e=>qn.test(e),fr=e=>Er(e,jr,or),pr=e=>Er(e,Mr,U),mr=e=>Er(e,Pr,ar),hr=e=>Er(e,Nr,sr),gr=e=>Er(e,Or,sr),_r=e=>Er(e,kr,lr),vr=e=>Er(e,Fr,cr),G=e=>Jn.test(e),yr=e=>Dr(e,jr),br=e=>Dr(e,Nr),xr=e=>Dr(e,Or),Sr=e=>Dr(e,Ar),Cr=e=>Dr(e,kr),wr=e=>Dr(e,Fr,!0),Tr=e=>Dr(e,Pr,!0),Er=(e,t,n)=>{let r=qn.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Dr=(e,t,n=!1)=>{let r=Jn.exec(e);return r?r[1]?t(r[1]):n:!1},Or=e=>e===`position`||e===`percentage`,kr=e=>e===`image`||e===`url`,Ar=e=>e===`length`||e===`size`||e===`bg-size`,jr=e=>e===`length`,Mr=e=>e===`number`,Nr=e=>e===`family-name`,Pr=e=>e===`number`||e===`weight`,Fr=e=>e===`shadow`,Ir=Wn(()=>{let e=Kn(`color`),t=Kn(`font`),n=Kn(`text`),r=Kn(`font-weight`),i=Kn(`tracking`),a=Kn(`leading`),o=Kn(`breakpoint`),s=Kn(`container`),c=Kn(`spacing`),l=Kn(`radius`),u=Kn(`shadow`),d=Kn(`inset-shadow`),f=Kn(`text-shadow`),p=Kn(`drop-shadow`),m=Kn(`blur`),h=Kn(`perspective`),g=Kn(`aspect`),_=Kn(`ease`),v=Kn(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),G,W],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[G,W,c],T=()=>[tr,`full`,`auto`,...w()],E=()=>[nr,`none`,`subgrid`,G,W],D=()=>[`auto`,{span:[`full`,nr,G,W]},nr,G,W],O=()=>[nr,`auto`,G,W],k=()=>[`auto`,`min`,`max`,`fr`,G,W],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[tr,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[tr,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[tr,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,G,W],F=()=>[...b(),xr,gr,{position:[G,W]}],ne=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],re=()=>[`auto`,`cover`,`contain`,Sr,dr,{size:[G,W]}],ie=()=>[rr,yr,fr],I=()=>[``,`none`,`full`,l,G,W],L=()=>[``,U,yr,fr],R=()=>[`solid`,`dashed`,`dotted`,`double`],ae=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],z=()=>[U,rr,xr,gr],oe=()=>[``,`none`,m,G,W],se=()=>[`none`,U,G,W],ce=()=>[`none`,U,G,W],le=()=>[U,G,W],ue=()=>[tr,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ir],breakpoint:[ir],color:[ar],container:[ir],"drop-shadow":[ir],ease:[`in`,`out`,`in-out`],font:[ur],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ir],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ir],shadow:[ir],spacing:[`px`,U],text:[ir],"text-shadow":[ir],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,tr,W,G,g]}],container:[`container`],columns:[{columns:[U,W,G,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[nr,`auto`,G,W]}],basis:[{basis:[tr,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[U,tr,`auto`,`initial`,`none`,W]}],grow:[{grow:[``,U,G,W]}],shrink:[{shrink:[``,U,G,W]}],order:[{order:[nr,`first`,`last`,`none`,G,W]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,yr,fr]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Tr,mr]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,rr,W]}],"font-family":[{font:[br,hr,t]}],"font-features":[{"font-features":[W]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,G,W]}],"line-clamp":[{"line-clamp":[U,`none`,G,pr]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,G,W]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,G,W]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...R(),`wavy`]}],"text-decoration-thickness":[{decoration:[U,`from-font`,`auto`,G,fr]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[U,`auto`,G,W]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,G,W]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,G,W]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:re()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},nr,G,W],radial:[``,G,W],conic:[nr,G,W]},Cr,_r]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:I()}],"rounded-s":[{"rounded-s":I()}],"rounded-e":[{"rounded-e":I()}],"rounded-t":[{"rounded-t":I()}],"rounded-r":[{"rounded-r":I()}],"rounded-b":[{"rounded-b":I()}],"rounded-l":[{"rounded-l":I()}],"rounded-ss":[{"rounded-ss":I()}],"rounded-se":[{"rounded-se":I()}],"rounded-ee":[{"rounded-ee":I()}],"rounded-es":[{"rounded-es":I()}],"rounded-tl":[{"rounded-tl":I()}],"rounded-tr":[{"rounded-tr":I()}],"rounded-br":[{"rounded-br":I()}],"rounded-bl":[{"rounded-bl":I()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":L()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...R(),`hidden`,`none`]}],"divide-style":[{divide:[...R(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...R(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[U,G,W]}],"outline-w":[{outline:[``,U,yr,fr]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,wr,vr]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,wr,vr]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:L()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[U,fr]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,wr,vr]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[U,G,W]}],"mix-blend":[{"mix-blend":[...ae(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ae()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[U]}],"mask-image-linear-from-pos":[{"mask-linear-from":z()}],"mask-image-linear-to-pos":[{"mask-linear-to":z()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":z()}],"mask-image-t-to-pos":[{"mask-t-to":z()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":z()}],"mask-image-r-to-pos":[{"mask-r-to":z()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":z()}],"mask-image-b-to-pos":[{"mask-b-to":z()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":z()}],"mask-image-l-to-pos":[{"mask-l-to":z()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":z()}],"mask-image-x-to-pos":[{"mask-x-to":z()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":z()}],"mask-image-y-to-pos":[{"mask-y-to":z()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[G,W]}],"mask-image-radial-from-pos":[{"mask-radial-from":z()}],"mask-image-radial-to-pos":[{"mask-radial-to":z()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[U]}],"mask-image-conic-from-pos":[{"mask-conic-from":z()}],"mask-image-conic-to-pos":[{"mask-conic-to":z()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,G,W]}],filter:[{filter:[``,`none`,G,W]}],blur:[{blur:oe()}],brightness:[{brightness:[U,G,W]}],contrast:[{contrast:[U,G,W]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,wr,vr]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,U,G,W]}],"hue-rotate":[{"hue-rotate":[U,G,W]}],invert:[{invert:[``,U,G,W]}],saturate:[{saturate:[U,G,W]}],sepia:[{sepia:[``,U,G,W]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,G,W]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[U,G,W]}],"backdrop-contrast":[{"backdrop-contrast":[U,G,W]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,U,G,W]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[U,G,W]}],"backdrop-invert":[{"backdrop-invert":[``,U,G,W]}],"backdrop-opacity":[{"backdrop-opacity":[U,G,W]}],"backdrop-saturate":[{"backdrop-saturate":[U,G,W]}],"backdrop-sepia":[{"backdrop-sepia":[``,U,G,W]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,G,W]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[U,`initial`,G,W]}],ease:[{ease:[`linear`,`initial`,_,G,W]}],delay:[{delay:[U,G,W]}],animate:[{animate:[`none`,v,G,W]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,G,W]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":[`scale-3d`],skew:[{skew:le()}],"skew-x":[{"skew-x":le()}],"skew-y":[{"skew-y":le()}],transform:[{transform:[G,W,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,G,W]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,G,W]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[U,yr,fr,pr]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Lr(...e){return Ir(un(e))}function Rr(e){let t=Math.max(0,Math.floor((Date.now()-e*1e3)/1e3));if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:`${Math.floor(i/30)}mo ago`}function zr(e){return new Date(e*1e3).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Br(e,t){try{let e=JSON.parse(t);if(!e||typeof e!=`object`)return t;for(let t of[`command`,`CommandLine`,`Input`,`query`,`Task`,`Prompt`])if(typeof e[t]==`string`&&e[t].length>0)return e[t];for(let t of[`file_path`,`path`,`TargetFile`,`AbsolutePath`,`SearchPath`,`DirectoryPath`,`Url`,`ImageName`])if(typeof e[t]==`string`&&e[t].length>0)return e[t];for(let t of Object.values(e))if(typeof t==`string`&&t.length>0)return t;return``}catch{return t}}var Vr=pn(`inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-[10px] font-mono font-medium leading-none tracking-wide uppercase border whitespace-nowrap`,{variants:{variant:{green:`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`,red:`bg-red-500/8 text-red-300 border-red-500/25`,amber:`bg-amber-500/10 text-amber-300 border-amber-500/30`,blue:`bg-sky-500/8 text-sky-300 border-sky-500/25`,gray:`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`,purple:`bg-violet-500/8 text-violet-300 border-violet-500/25`,outline:`bg-transparent text-[var(--color-fg-3)] border-[var(--color-line-1)]`}},defaultVariants:{variant:`outline`}});function K({className:e,variant:t,...n}){return(0,D.jsx)(`span`,{className:Lr(Vr({variant:t,className:e})),...n})}var Hr=e=>e,Ur=e=>({in:t=>t**e,out:t=>1-(1-t)**e,inOut:t=>t<.5?(2*t)**e/2:1-(-2*t+2)**e/2}),Wr=Ur(2),Gr=Ur(3),Kr=Ur(4),qr=Ur(5),Jr={in:e=>1-Math.cos(e*Math.PI/2),out:e=>Math.sin(e*Math.PI/2),inOut:e=>-(Math.cos(Math.PI*e)-1)/2},Yr={in:e=>e===0?0:2**(10*e-10),out:e=>e===1?1:1-2**(-10*e),inOut:e=>e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2},Xr={in:e=>1-Math.sqrt(1-e**2),out:e=>Math.sqrt(1-(e-1)**2),inOut:e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2};function Zr(e=1.70158){let t=e;return e=>e*e*((t+1)*e-t)}function Qr(e=1.70158){let t=e;return e=>{let n=e-1;return n*n*((t+1)*n+t)+1}}function $r(e=1.70158){let t=e*1.525;return e=>e<.5?(2*e)**2*((t+1)*2*e-t)/2:((2*e-2)**2*((t+1)*(e*2-2)+t)+2)/2}function ei(e=1,t=.3){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>e===0?0:e===1?1:n*2**(-10*e)*Math.sin((e-i)*(Math.PI*2)/r)+1}function ti(e=1,t=.3){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>e===0?0:e===1?1:-(n*2**(10*(e-1))*Math.sin((e-1-i)*(Math.PI*2)/r))}function ni(e=1,t=.45){let n=Math.max(e,1),r=Math.max(t,.08),i=r/(Math.PI*2)*Math.asin(1/n);return e=>{if(e===0)return 0;if(e===1)return 1;let t=e*2;return t<1?-.5*(n*2**(10*(t-1))*Math.sin((t-1-i)*(Math.PI*2)/r)):n*2**(-10*(t-1))*Math.sin((t-1-i)*(Math.PI*2)/r)*.5+1}}var ri=7.5625,ii=2.75,ai=e=>{if(e<1/ii)return ri*e*e;if(e<2/ii){let t=e-1.5/ii;return ri*t*t+.75}if(e<2.5/ii){let t=e-2.25/ii;return ri*t*t+.9375}let t=e-2.625/ii;return ri*t*t+.984375},oi=e=>1-ai(1-e),si=e=>e<.5?(1-ai(1-2*e))/2:(1+ai(2*e-1))/2;function ci(e){let t=Math.max(1,Math.floor(e));return e=>e>=1?1:e<=0?0:Math.floor(e*t)/t}function li(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<1e-5)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;n<r;){let i=u(t);if(Math.abs(i-e)<1e-5)return t;e>i?n=t:r=t,t=(n+r)/2}return t};return e=>e<=0?0:e>=1?1:d(p(e))}function ui(e={}){let t=Math.max(1,e.stiffness??100),n=Math.max(0,e.damping??10),r=Math.max(.01,e.mass??1),i=e.velocity??0,a=Math.sqrt(t/r),o=n/(2*Math.sqrt(t*r)),s;if(o<1){let e=a*Math.sqrt(1-o*o),t=(o*a+-i)/e;s=n=>1-Math.exp(-o*a*n)*(1*Math.cos(e*n)+t*Math.sin(e*n))}else if(o===1){let e=a+-i;s=t=>1-Math.exp(-a*t)*(1+e*t)}else{let e=Math.sqrt(o*o-1),t=-a*(o-e),n=-a*(o+e),r=(n- -i)/(n-t),c=1-r;s=e=>1-(r*Math.exp(t*e)+c*Math.exp(n*e))}let c=400;for(let e=16;e<=4e3;e+=16){let t=s(e/1e3);if(Math.abs(1-t)<.005){let t=s((e-16)/1e3);if(Math.abs(1-t)<.005){c=e;break}}c=e}let l=c/1e3;return{duration:c,fn:e=>s(Math.max(0,Math.min(1,e))*l)}}var di={linear:Hr,inQuad:Wr.in,outQuad:Wr.out,inOutQuad:Wr.inOut,inCubic:Gr.in,outCubic:Gr.out,inOutCubic:Gr.inOut,inQuart:Kr.in,outQuart:Kr.out,inOutQuart:Kr.inOut,inQuint:qr.in,outQuint:qr.out,inOutQuint:qr.inOut,inSine:Jr.in,outSine:Jr.out,inOutSine:Jr.inOut,inExpo:Yr.in,outExpo:Yr.out,inOutExpo:Yr.inOut,inCirc:Xr.in,outCirc:Xr.out,inOutCirc:Xr.inOut,inBack:Zr(),outBack:Qr(),inOutBack:$r(),inElastic:ti(),outElastic:ei(),inOutElastic:ni(),inBounce:oi,outBounce:ai,inOutBounce:si};function fi(e){if(typeof e==`function`)return e;if(e===void 0)return di.outCubic;let t=di[e];if(t)return t;let n=e.match(/^(\w+)\(([^)]*)\)$/);if(n){let e=n[1],t=n[2]?.split(`,`).map(e=>parseFloat(e.trim())).filter(e=>!Number.isNaN(e));switch(e){case`outElastic`:return ei(t[0],t[1]);case`inElastic`:return ti(t[0],t[1]);case`inOutElastic`:return ni(t[0],t[1]);case`outBack`:return Qr(t[0]);case`inBack`:return Zr(t[0]);case`inOutBack`:return $r(t[0]);case`steps`:return ci(t[0]??4);case`cubicBezier`:return t.length>=4?li(t[0],t[1],t[2],t[3]):di.outCubic;default:return di.outCubic}}return di.outCubic}function pi(e,t){if(t<=1||e===void 0||e===`first`)return 0;if(e===`last`)return t-1;if(e===`center`)return(t-1)/2;let n=Math.floor(e);return n<0?0:n>t-1?t-1:n}function mi(e,t={}){let n=t.start??0,r=t.direction===`reverse`;return(i,a)=>{if(a<=0)return n;let o=pi(t.from,a),s=Math.abs(i-o),c=Math.max(o,a-1-o),l=c===0?0:s/c,u=r?1-l:l,d;if(Array.isArray(e)){let[t,n]=e;d=t+u*(n-t)}else d=(r?c-s:s)*e;return n+d}}var hi=new Set([`duration`,`delay`,`ease`,`loop`,`alternate`,`onBegin`,`onUpdate`,`onComplete`]);function gi(e){if(typeof e==`number`||typeof e==`string`)return e;if(Array.isArray(e)&&e.length===2){let[t,n]=e;if((typeof t==`number`||typeof t==`string`)&&(typeof n==`number`||typeof n==`string`))return[t,n]}return null}function _i(e){return e?typeof e==`string`?typeof document>`u`?[]:Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:`length`in e?Array.from(e):[]:[]}function vi(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var yi=/^(-?\d*\.?\d+)([a-z%]*)$/i;function bi(e){if(typeof e==`number`)return{value:e,unit:``};let t=e.trim().match(yi);return t?{value:parseFloat(t[1]),unit:t[2]??``}:{value:0,unit:``}}function xi(e){return e.unit===``?`${e.value}`:`${e.value}${e.unit}`}var Si=new Set([`translate`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`]),Ci=new WeakMap;function wi(e){let t=Ci.get(e);return t||(t={values:{}},Ci.set(e,t)),t}function Ti(e){let t=[];for(let[n,r]of Object.entries(e.values)){let e=r.unit||(n.startsWith(`rotate`)||n.startsWith(`skew`)?`deg`:n.startsWith(`translate`)?`px`:``);t.push(`${n}(${r.value}${e})`)}return t.join(` `)}function Ei(e,t,n){if(Si.has(t)){let r=wi(e);r.values[t]=n,e.style.transform=Ti(r);return}if(t===`opacity`){e.style.opacity=`${n.value}`;return}e.style.setProperty(t,xi(n))}function Di(e,t){return Si.has(t)?wi(e).values[t]||{value:t.startsWith(`scale`)?1:0,unit:``}:bi(e.style.getPropertyValue(t)||(typeof window<`u`?window.getComputedStyle(e).getPropertyValue(t):``)||(t===`opacity`?`1`:`0`))}function Oi(e,t,n){return e+(t-e)*n}function ki(e,t,n){return e===void 0?0:typeof e==`number`?e:e(t,n)}function Ai(e){if(e&&typeof e==`object`&&`spring`in e){let t=ui(e.spring);return{ease:t.fn,duration:t.duration}}return{ease:fi(e),duration:null}}var ji=0,Mi=new Set;function Ni(e){for(let t of Mi){if(t.done||e<t.start)continue;let{target:n,options:r}=t,i=e-t.start,a=Math.max(1,n.duration),o=r.loop??!1,s=r.alternate===!0,c=o===!0?1/0:typeof o==`number`?Math.max(1,o):1,l=Math.floor(i/a),u=(i-l*a)/a,d=s&&l%2==1?1-u:u;if(l>=c){for(let e of n.props)Ei(n.el,e.name,Pi(e.from,e.to,s&&c%2==0?0:1));r.onUpdate?.(1,n.el,n.index),r.onComplete?.(n.el,n.index),t.done=!0;continue}for(let e of n.props){let t=e.ease(Math.max(0,Math.min(1,d)));n.el!==null&&Ei(n.el,e.name,Pi(e.from,e.to,t))}n.el!==null&&r.onUpdate?.(d,n.el,n.index)}for(let e of[...Mi])e.done&&Mi.delete(e);if(Mi.size===0){ji=0;return}ji=requestAnimationFrame(Ni)}function Pi(e,t,n){let r=e.unit||t.unit;return{value:Oi(e.value,t.value,n),unit:r}}function Fi(){ji===0&&(typeof requestAnimationFrame>`u`||(ji=requestAnimationFrame(Ni)))}function Ii(e,t){let n=_i(e),r=n.length,i=Object.keys(t).filter(e=>!hi.has(e)),a=vi(),{ease:o,duration:s}=Ai(t.ease),c=t.duration??s??400,l=[],u=[],d=typeof performance<`u`?performance.now():Date.now(),f=(e,n)=>{let a=[];for(let n of i){let r=t[n];if(r===void 0)continue;let i=gi(r);if(i===null)continue;let s,c;Array.isArray(i)?(s=bi(i[0]),c=bi(i[1])):(s=Di(e,n),c=bi(i)),a.push({name:n,from:s,to:c,ease:o})}return{el:e,index:n,props:a,duration:c,delay:ki(t.delay,n,r)}};if(n.length===0)return{cancel:()=>{},finished:Promise.resolve(),get done(){return!0}};let p=!1;for(let e=0;e<n.length;e++){let r=n[e],i=f(r,e),o=d+i.delay;if(t.onBegin?.(r,e),a){for(let e of i.props)Ei(r,e.name,e.to);t.onUpdate?.(1,r,e),t.onComplete?.(r,e),u.push(Promise.resolve());continue}for(let e of i.props)Ei(r,e.name,e.from);let s={target:i,start:o,options:t,done:!1};l.push(s),Mi.add(s),u.push(new Promise(e=>{let n=t.onComplete,r=(t,r)=>{try{n?.(t,r)}finally{e()}};s.options={...t,onComplete:r}}))}return Fi(),{cancel(){if(!p){p=!0;for(let e of l)e.done=!0,Mi.delete(e)}},finished:Promise.all(u).then(()=>void 0),get done(){return p||l.every(e=>e.done)}}}var Li=pn(`hig-button relative overflow-hidden focus-visible:outline-none disabled:pointer-events-none disabled:opacity-45`,{variants:{variant:{primary:`hig-button-primary`,secondary:``,ghost:`hig-button-plain`,danger:`hig-button-destructive`},size:{sm:`hig-button-small`,md:``,icon:`!w-7 !h-7 !min-w-0 !p-0`}},defaultVariants:{variant:`primary`,size:`md`}});function Ri(e,t){if(vi())return;let n=e.getBoundingClientRect(),r=Math.hypot(n.width,n.height),i=document.createElement(`span`);i.style.position=`absolute`,i.style.left=`${t.clientX-n.left-r/2}px`,i.style.top=`${t.clientY-n.top-r/2}px`,i.style.width=`${r}px`,i.style.height=`${r}px`,i.style.borderRadius=`50%`,i.style.pointerEvents=`none`,i.style.background=`currentColor`,i.style.opacity=`0.22`,i.style.transform=`scale(0)`,i.style.mixBlendMode=`screen`,e.appendChild(i),Ii(i,{scale:[0,1],opacity:[.22,0],duration:540,ease:`outExpo`,onComplete:()=>{i.remove()}})}var q=_.forwardRef(({className:e,variant:t,size:n,onMouseDown:r,onClick:i,...a},o)=>(0,D.jsx)(`button`,{ref:o,className:Lr(Li({variant:t,size:n,className:e})),onMouseDown:e=>{Ri(e.currentTarget,e),r?.(e)},onClick:i,...a}));q.displayName=`Button`;var zi=pn(`hig-card flex flex-col min-h-0 overflow-hidden`,{variants:{variant:{default:``,interactive:`hover:border-[var(--color-line-2)] hover:shadow-[var(--hig-shadow-2)] transition-all cursor-pointer`,flush:`bg-transparent border-[var(--color-line-0)] shadow-none`}},defaultVariants:{variant:`default`}});function J({className:e,variant:t,...n}){return(0,D.jsx)(`div`,{className:Lr(zi({variant:t,className:e})),...n})}function Y({className:e,...t}){return(0,D.jsx)(`div`,{className:Lr(`flex items-center justify-between gap-2 px-4 pt-3 pb-2 shrink-0`,e),...t})}function X({className:e,...t}){return(0,D.jsx)(`div`,{className:Lr(`px-4 py-3 flex-1 min-h-0 overflow-auto`,e),...t})}function Bi({className:e,children:t,...n}){return(0,D.jsx)(`pre`,{className:Lr(`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-3 py-2 text-[11px] leading-relaxed font-mono text-[var(--color-fg-1)] overflow-x-auto whitespace-pre-wrap break-all`,e),...n,children:t})}var Vi=new Map;async function Hi(e){let t=Vi.get(e);if(t)return t.status===`ok`?t.data:t.status===`error`?null:t.promise;let n=(async()=>{try{let t=await fetch(`/api/json/rule-explain?ruleId=${encodeURIComponent(e)}`,{headers:{Accept:`application/json`}});if(!t.ok)return Vi.set(e,{status:`error`,error:`HTTP ${t.status}`}),null;let n=await t.json();return Vi.set(e,{status:`ok`,data:n}),n}catch(t){return Vi.set(e,{status:`error`,error:String(t)}),null}})();return Vi.set(e,{status:`loading`,promise:n}),n}var Ui=220,Wi=90;function Gi({ruleId:e,children:t,className:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),f=()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),u.current=null,d.current=null},p=(0,_.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.left;n+320>window.innerWidth-12&&(n=Math.max(12,window.innerWidth-320-12));let r=t.bottom+8;r+200>window.innerHeight-12&&(r=Math.max(12,t.top-200-8)),c({top:r,left:n})},[]),m=(0,_.useCallback)(()=>{f(),u.current=setTimeout(()=>{p(),i(!0),Hi(e).then(e=>{e&&o(e)});let t=Vi.get(e);t&&t.status===`ok`&&o(t.data)},Ui)},[e,p,f]),h=(0,_.useCallback)(()=>{f(),d.current=setTimeout(()=>{i(!1)},Wi)},[f]);return(0,_.useEffect)(()=>{if(!r)return;let e=()=>p(),t=()=>p(),n=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,t),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,t),window.removeEventListener(`keydown`,n)}},[r,p]),(0,_.useEffect)(()=>()=>f(),[f]),(0,D.jsxs)(`span`,{ref:l,className:`ss-rule-trigger${n?` ${n}`:``}`,onMouseEnter:m,onMouseLeave:h,onFocus:m,onBlur:h,"aria-describedby":r?`rule-popover-${e}`:void 0,children:[t,r&&s&&(0,D.jsx)(`span`,{id:`rule-popover-${e}`,role:`tooltip`,className:`ss-rule-popover`,style:{top:s.top,left:s.left},onMouseEnter:()=>f(),onMouseLeave:h,children:a?(0,D.jsx)(Ki,{data:a}):(0,D.jsx)(`span`,{className:`ss-rule-popover__loading`,children:`loading rule…`})})]})}function Ki({data:e}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`ss-rule-popover__head`,children:[(0,D.jsx)(`code`,{className:`ss-rule-popover__id`,children:e.ruleId}),(0,D.jsx)(`span`,{className:`ss-rule-popover__pill ss-rule-popover__pill--${e.decision}`,children:e.decision}),(0,D.jsx)(`span`,{className:`ss-rule-popover__state ss-rule-popover__state--${e.enabled?`on`:`off`}`,children:e.enabled?`ON`:`OFF`})]}),(0,D.jsx)(`strong`,{className:`ss-rule-popover__headline`,children:e.headline}),(0,D.jsx)(`span`,{className:`ss-rule-popover__summary`,children:e.summary}),e.conditions.length>1&&(0,D.jsxs)(`span`,{className:`ss-rule-popover__section`,children:[(0,D.jsx)(`span`,{className:`ss-rule-popover__label`,children:`Matches when`}),(0,D.jsx)(`ul`,{className:`ss-rule-popover__list`,children:e.conditions.map((e,t)=>(0,D.jsx)(`li`,{children:e},t))})]}),e.hints.length>0&&(0,D.jsx)(`span`,{className:`ss-rule-popover__hints`,children:e.hints.map((e,t)=>(0,D.jsx)(`span`,{className:`ss-rule-popover__hint`,children:e},t))}),(0,D.jsx)(`span`,{className:`ss-rule-popover__foot`,children:(0,D.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.ruleId)}`,className:`ss-rule-popover__link`,children:`Open in Rules →`})})]})}var qi={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},Ji=[`all`,`allow`,`block`,`force`,`log`],Yi={allow:`text-emerald-300`,block:`text-red-300`,force:`text-amber-300`,log:`text-[var(--color-fg-3)]`};function Xi(e){return new Date(e*1e3).toLocaleString()}function Zi(e,t){if(!t)return``;let n=t-e;return n<60?`${n}s`:`${Math.round(n/60)}m`}async function Qi(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:H()})}async function $i(e,t){try{return await(await fetch(`/api/rules/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({ruleId:e,enabled:t})})).json()}catch(e){return{error:String(e)}}}function ea(e){try{let t=JSON.parse(e).input;return t&&typeof t==`object`?Br(``,JSON.stringify(t)):Br(``,e)}catch{return e.slice(0,80)}}function ta(e){try{let t=JSON.parse(e);return t.input===void 0?JSON.stringify(JSON.parse(e),null,2):JSON.stringify(t.input,null,2)}catch{return e}}function na({label:e,value:t,tone:n}){return(0,D.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,D.jsx)(`span`,{className:`font-mono text-sm tabular-nums ${n??`text-[var(--color-fg-0)]`}`,children:t}),(0,D.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e})]})}function ra(e,t){let n=Math.floor(Date.now()/1e3),r=n-86400,i=new Map;for(let t of e){if(t.decision!==`ask`||t.created_at<r||!t.rule_id)continue;let e=i.get(t.rule_id);e?(e.count+=1,t.created_at>e.lastSeen&&(e.lastSeen=t.created_at)):i.set(t.rule_id,{ruleId:t.rule_id,ruleMessage:t.rule_message||t.rule_id,count:1,lastSeen:t.created_at})}for(let e of t){if(!e.ruleId)continue;let t=i.get(e.ruleId);t?(t.count+=1,t.lastSeen=n):i.set(e.ruleId,{ruleId:e.ruleId,ruleMessage:e.ruleMessage||e.ruleId,count:1,lastSeen:n})}return Array.from(i.values()).filter(e=>e.count>=3).sort((e,t)=>t.count-e.count||t.lastSeen-e.lastSeen).slice(0,5)}function ia(e){let t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function aa({ruleId:e,ruleMessage:t,onDismiss:n,onUndo:r}){let[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>(o.current=setTimeout(n,6e3),()=>{o.current&&clearTimeout(o.current)}),[n]),(0,D.jsxs)(`div`,{className:`fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2.5 rounded-full border border-[var(--color-line-2)] bg-[var(--color-surface-1)] backdrop-blur-md shadow-lg`,children:[(0,D.jsxs)(`span`,{className:`text-xs text-[var(--color-fg-1)]`,children:[`Silenced`,` `,(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-0)]`,children:t})]}),(0,D.jsx)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0),await r(),n()},className:`text-[11px] font-mono uppercase tracking-wider px-2.5 py-1 rounded-full border border-[var(--color-brand)]/40 text-[var(--color-brand)] hover:bg-[var(--color-brand)]/10 cursor-pointer disabled:opacity-50`,"aria-label":`Undo silencing ${e}`,children:`undo`}),(0,D.jsx)(`button`,{type:`button`,onClick:n,className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,"aria-label":`Dismiss`,children:(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,D.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,D.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]})}function oa({target:e,onClose:t,onConfirm:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null);return(0,_.useEffect)(()=>{o(null)},[]),e?(0,D.jsxs)(Kt,{open:!!e,onClose:t,size:`sm`,title:`Silence this rule?`,subtitle:`It won't ask for approval again until you re-enable it on the Rules page.`,footer:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:r,onClick:t,children:`Cancel`}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,style:{"--tone":`#ff6f6f`},disabled:r,onClick:async()=>{i(!0),o(null);let r=await n(e);if(i(!1),!r.ok){o(r.message??`Could not silence rule.`);return}t()},children:r?`Silencing…`:`Disable rule`})]}),children:[(0,D.jsxs)(`div`,{className:`ss-list`,children:[(0,D.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},children:(0,D.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,D.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-1`,children:`rule`}),(0,D.jsx)(`div`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,D.jsx)(Gi,{ruleId:e.ruleId,children:(0,D.jsx)(`code`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] block mt-1 break-all`,children:e.ruleId})})]})}),(0,D.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},children:(0,D.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,D.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-1`,children:`recent activity`}),(0,D.jsxs)(`div`,{className:`text-sm text-[var(--color-fg-1)]`,children:[`Triggered`,` `,(0,D.jsx)(`strong`,{className:`text-[var(--color-fg-0)] tabular-nums`,children:e.fireCount}),` `,e.fireCount===1?`time`:`times`,` in the last 24 hours.`]})]})})]}),(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-3 leading-relaxed`,children:[`Disabling a rule is fully reversible — head to`,` `,(0,D.jsx)(`a`,{href:`/rules`,className:`text-[var(--color-brand)] hover:underline`,children:`Rules`}),` `,`to switch it back on.`]}),a&&(0,D.jsx)(`p`,{className:`mt-3 text-xs text-red-300`,role:`alert`,children:a})]}):null}function sa(){let e=Nt([`pending-changed`,`rules-changed`]),{data:t,refetch:n}=V(`/api/json/pending`,[e[`pending-changed`]]),{data:r}=V(`/api/json/approvals`,[e[`pending-changed`]]),[i,a]=(0,_.useState)(`all`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(new Set),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),m=(0,_.useMemo)(()=>ra(r??[],t??[]),[r,t]),h=(0,_.useMemo)(()=>{let e=new Map;for(let t of m)e.set(t.ruleId,t.count);return e},[m]),g=Math.floor(Date.now()/1e3),v=(r??[]).filter(e=>e.created_at>=g-86400).length,y=(r??[]).reduce((e,t)=>(e[t.decision]=(e[t.decision]??0)+1,e),{}),b=(r??[]).filter(e=>{if(i!==`all`&&e.decision!==i)return!1;if(o){let t=o.toLowerCase(),n=ea(e.input).toLowerCase();if(!e.tool.toLowerCase().includes(t)&&!e.rule_id.toLowerCase().includes(t)&&!(e.rule_message??``).toLowerCase().includes(t)&&!n.includes(t))return!1}return!0});function x(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function S(e){let t=await $i(e.ruleId,!1);return t.error||t.ok===!1?{ok:!1,message:t.error??`Server rejected the request.`}:(e.pendingId&&await Qi(e.pendingId,`block`),p({ruleId:e.ruleId,ruleMessage:e.ruleMessage}),n(),{ok:!0})}async function C(e){await $i(e,!0),n()}return(0,D.jsxs)(`div`,{className:`space-y-6`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`overline text-[11px]`,children:`approvals`}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:`approve or deny pending tool calls · review past decisions · silence noisy rules`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5 px-3 py-2.5 rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)]/60`,children:[(0,D.jsx)(na,{label:`pending`,value:t?.length??0,tone:`text-amber-300`}),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),[`allow`,`block`,`force`,`log`].map(e=>(0,D.jsx)(na,{label:e,value:y[e]??0,tone:Yi[e]},e)),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),(0,D.jsx)(na,{label:`last 24h`,value:v})]}),m.length>0&&(0,D.jsxs)(`section`,{className:`ss-noisy-card`,"aria-label":`Noisy rules`,children:[(0,D.jsxs)(`div`,{className:`ss-noisy-card-head`,children:[(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 9v4`}),(0,D.jsx)(`path`,{d:`M12 17h.01`}),(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`})]}),`asking too often · last 24h`]}),m.map(e=>(0,D.jsxs)(`div`,{className:`ss-noisy-row`,children:[(0,D.jsx)(`span`,{className:`ss-noisy-count`,"aria-label":`${e.count} fires`,children:e.count}),(0,D.jsxs)(`div`,{className:`ss-noisy-text`,children:[(0,D.jsx)(`span`,{className:`ss-noisy-title`,children:e.ruleMessage}),(0,D.jsxs)(`span`,{className:`ss-noisy-sub`,children:[(0,D.jsx)(Gi,{ruleId:e.ruleId,children:(0,D.jsx)(`code`,{className:`font-mono`,children:e.ruleId})}),(0,D.jsx)(`span`,{style:{margin:`0 6px`},children:`·`}),`last fired `,ia(e.lastSeen)]})]}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger`,onClick:()=>d({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:e.count}),"aria-label":`Silence rule ${e.ruleId}`,children:[(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,D.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,D.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Silence`]})]},e.ruleId))]}),t&&t.length>0&&(0,D.jsxs)(`section`,{children:[(0,D.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,D.jsxs)(`h2`,{className:`overline text-[11px]`,children:[`pending · `,t.length]})}),(0,D.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=h.get(e.ruleId)??0;return(0,D.jsxs)(J,{className:`border-l-2 border-l-amber-400/60`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,D.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,D.jsx)(q,{size:`sm`,variant:`primary`,onClick:async()=>{await Qi(e.id,`allow`),n()},children:`approve`}),(0,D.jsx)(q,{size:`sm`,variant:`danger`,onClick:async()=>{await Qi(e.id,`block`),n()},children:`deny`}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger`,onClick:()=>d({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:t||1,pendingId:e.id}),"aria-label":`Disable rule ${e.ruleId}`,children:[(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,D.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,D.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Disable rule`]})]})]}),(0,D.jsxs)(X,{className:`space-y-2 text-xs`,children:[(0,D.jsxs)(`div`,{className:`flex gap-3 flex-wrap items-center`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`tool`}),(0,D.jsx)(`code`,{className:`text-[var(--color-brand)] font-mono`,children:e.toolCall.tool}),(0,D.jsx)(`span`,{className:`overline ml-2`,children:`rule`}),(0,D.jsx)(Gi,{ruleId:e.ruleId,children:(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-2)]`,children:e.ruleId})}),t>=3&&(0,D.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded-full`,style:{background:`color-mix(in oklab, #ffa657 14%, transparent)`,color:`#ffb27d`,border:`1px solid color-mix(in oklab, #ffa657 28%, transparent)`},title:`Fired ${t} times in the last 24h`,children:[`asks often · `,t,`×`]})]}),e.prompt&&(0,D.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,D.jsx)(`span`,{className:`overline pt-0.5 shrink-0`,children:`why`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.prompt})]}),(0,D.jsx)(Bi,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id)})})]}),(0,D.jsxs)(`section`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-3 gap-3 flex-wrap`,children:[(0,D.jsx)(`h2`,{className:`overline text-[11px]`,children:`history`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`div`,{className:`flex gap-0.5 rounded-sm border border-[var(--color-line-1)] p-0.5 bg-[var(--color-surface-1)]`,children:Ji.map(e=>(0,D.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${i===e?`bg-[var(--color-brand)]/10 text-[var(--color-brand)] border border-[var(--color-brand)]/30`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-transparent`}`,children:e},e))}),(0,D.jsx)(`input`,{type:`text`,placeholder:`search tool, rule, command…`,value:o,onChange:e=>s(e.target.value),className:`text-xs font-mono bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2.5 py-1 text-[var(--color-fg-1)] placeholder-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-brand)]/50 w-48`})]})]}),!r||r.length===0?(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no approval history yet`}):b.length===0?(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no results match your filter`}):(0,D.jsx)(J,{children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:b.map(e=>{let t=c.has(e.id),n=ea(e.input),r=Zi(e.created_at,e.resolved_at);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`button`,{onClick:()=>x(e.id),className:`w-full text-left px-3 py-2 hover:bg-[var(--color-surface-2)]/60 transition-colors cursor-pointer flex items-start gap-3`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-[10px] w-2.5 shrink-0 mt-1`,children:t?`▼`:`▶`}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-nowrap tabular-nums`,children:Xi(e.resolved_at??e.created_at)}),(0,D.jsx)(K,{variant:qi[e.decision]??`gray`,children:e.decision}),(0,D.jsx)(`code`,{className:`text-xs text-[var(--color-brand)] font-mono`,children:e.tool}),r&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] ml-auto`,children:[`Δ`,r]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,D.jsx)(`span`,{className:`text-xs text-[var(--color-fg-2)] truncate flex-1 min-w-0`,children:e.rule_message||e.rule_id||`—`}),n&&(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)] font-mono truncate flex-1 min-w-0 hidden md:block`,children:n})]})]})]}),t&&(0,D.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-2 bg-[var(--color-surface-0)]`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs font-mono items-center`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`rule`}),` `,e.rule_id?(0,D.jsx)(Gi,{ruleId:e.rule_id,children:(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.rule_id})}):(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:`—`})]}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`created`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:Xi(e.created_at)})]}),e.resolved_at&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`resolved`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:Xi(e.resolved_at)})]}),e.rule_id&&(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger ml-auto`,onClick:()=>d({ruleId:e.rule_id,ruleMessage:e.rule_message||e.rule_id,fireCount:h.get(e.rule_id)??1}),"aria-label":`Silence rule ${e.rule_id}`,children:[(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,D.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,D.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Silence rule`]})]}),e.prompt&&(0,D.jsxs)(`div`,{className:`text-xs flex gap-2 items-start`,children:[(0,D.jsx)(`span`,{className:`overline pt-0.5 shrink-0`,children:`why`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.prompt})]}),(0,D.jsx)(Bi,{children:ta(e.input)})]})]},e.id)})})})]}),(0,D.jsx)(oa,{target:u,onClose:()=>d(null),onConfirm:S}),f&&(0,D.jsx)(aa,{ruleId:f.ruleId,ruleMessage:f.ruleMessage,onDismiss:()=>p(null),onUndo:()=>C(f.ruleId)})]})}function ca(e){return e==null?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function la(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d ${n%24}h`}function ua(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),g=async()=>{let e=await(await fetch(`/api/json/audit-config`)).json();t(e),a(String(e.config.maxRows)),s(String(e.config.absoluteMaxRows)),l(String(e.config.minRetentionHours)),d(e.config.maxBytes==null?``:String(Math.round(e.config.maxBytes/(1024*1024))))};(0,_.useEffect)(()=>{g()},[g]);let v=(0,_.useMemo)(()=>!e?.usage.oldestTimestampSec||!e?.usage.newestTimestampSec?null:e.usage.newestTimestampSec-e.usage.oldestTimestampSec,[e]),y=async()=>{if(!e)return;p(!0),h(null);let t={},n=Number(i);Number.isFinite(n)&&n!==e.config.maxRows&&(t.maxRows=n);let r=Number(o);Number.isFinite(r)&&r!==e.config.absoluteMaxRows&&(t.absoluteMaxRows=r);let a=Number(c);if(Number.isFinite(a)&&a!==e.config.minRetentionHours&&(t.minRetentionHours=a),u.trim()===``)e.config.maxBytes!=null&&(t.maxBytes=null);else{let n=Number(u);if(Number.isFinite(n)){let r=Math.round(n*1024*1024);r!==e.config.maxBytes&&(t.maxBytes=r)}}if(Object.keys(t).length===0){h({kind:`ok`,text:`No changes.`}),p(!1);return}try{let e=await fetch(`/api/json/audit-config`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!e.ok){let t=await e.json();throw Error(t.error??`HTTP ${e.status}`)}await g(),h({kind:`ok`,text:`Saved. New budget applies within ~60 seconds.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}},b=async()=>{if(e){p(!0),h(null);try{let t=await fetch(`/api/json/audit-config`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e.defaults)});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await g(),h({kind:`ok`,text:`Reset to defaults.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}}};if(!e)return(0,D.jsx)(D.Fragment,{});let x=`w-32 bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50`,S=`text-[10.5px] uppercase tracking-wider text-[var(--color-fg-4)]`,C=`text-[10.5px] font-mono text-[var(--color-fg-4)] tabular-nums`;return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,D.jsxs)(`button`,{onClick:()=>r(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 hover:bg-white/[0.02] cursor-pointer`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11.5px]`,children:[(0,D.jsx)(`span`,{className:`font-medium text-[var(--color-fg-1)]`,children:`Storage budget`}),(0,D.jsxs)(`span`,{className:C,children:[e.usage.rows.toLocaleString(),` rows`,e.usage.bytes!=null&&` · ${ca(e.usage.bytes)}`,v!=null&&` · spans ${la(v)}`]})]}),(0,D.jsx)(`span`,{className:C,children:n?`▾`:`▸`})]}),n&&(0,D.jsxs)(`div`,{className:`border-t border-[var(--color-line-1)] px-3 py-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:S,children:`Soft row cap`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`number`,value:i,min:e.limits.maxRows.min,max:e.limits.maxRows.max,onChange:e=>a(e.target.value),className:x}),(0,D.jsx)(`span`,{className:C,children:`rows`})]}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Above this, old rows are rotated — but never within the retention window.`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:S,children:`Hard ceiling`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`number`,value:o,min:e.limits.absoluteMaxRows.min,max:e.limits.absoluteMaxRows.max,onChange:e=>s(e.target.value),className:x}),(0,D.jsx)(`span`,{className:C,children:`rows`})]}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Pruned regardless of age once exceeded. Protects against runaway disk growth.`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:S,children:`Retention floor`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`number`,value:c,step:`0.5`,min:e.limits.minRetentionHours.min,max:e.limits.minRetentionHours.max,onChange:e=>l(e.target.value),className:x}),(0,D.jsx)(`span`,{className:C,children:`hours`})]}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Rows newer than this are never deleted by the soft cap. Set 0 to disable the floor.`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:S,children:`Size cap (optional)`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`number`,value:u,placeholder:`off`,min:1,onChange:e=>d(e.target.value),className:x}),(0,D.jsx)(`span`,{className:C,children:`MB`})]}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Bytes-based eviction. Leave blank to disable. Honors the retention floor like the soft cap.`})]})]}),m&&(0,D.jsx)(`p`,{className:`text-[11px] font-mono ${m.kind===`err`?`text-rose-300`:`text-emerald-300`}`,children:m.text}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,D.jsx)(`button`,{onClick:y,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:text-[var(--color-fg-0)] bg-[var(--color-surface-2)] hover:bg-[var(--color-surface-3)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:f?`saving…`:`save`}),(0,D.jsx)(`button`,{onClick:b,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:`reset to defaults`})]})]})]})}var da={"http-json":`HTTP webhook (generic JSON)`,"splunk-hec":`Splunk HEC`,datadog:`Datadog logs`,"file-jsonl":`Local JSONL file`};function fa(e){if(!e)return`never`;let t=Date.now()/1e3-e;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function pa(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=async()=>{t(await(await fetch(`/api/json/audit-sinks`)).json())};(0,_.useEffect)(()=>{y()},[y]);let b=(0,_.useMemo)(()=>e?new Map(e.status.map(e=>[e.sink_id,e])):new Map,[e]),x=t=>{if(!e)return;let n=`${t}-${Date.now().toString(36).slice(-4)}`,r={id:n,name:da[t],type:t,enabled:!1,endpoint:t===`file-jsonl`?void 0:``,path:t===`file-jsonl`?`~/.sigmashake/audit-export.jsonl`:void 0,auth:{type:`none`},batch:{maxEvents:100,maxBytes:1e6,intervalMs:3e4},retry:{maxAttempts:5,baseMs:1e3,maxMs:6e4},filter:{},payload:{template:e.starterTemplates[t]}};a(n),s(r),l(!1),d(JSON.stringify(r,null,2)),h(null),v(null)},S=e=>{a(e.id),s(JSON.parse(JSON.stringify(e))),l(!1),d(JSON.stringify(e,null,2)),h(null),v(null)},C=()=>{a(null),s(null),l(!1),d(``),h(null),v(null)},w=()=>{if(c)try{return JSON.parse(u)}catch{return null}return o},T=async()=>{let e=w();if(!e){h({kind:`err`,text:`JSON is invalid`});return}p(!0),h(null);try{let t=await fetch(`/api/json/audit-sinks`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await y(),h({kind:`ok`,text:`Saved.`}),C()}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}},E=async e=>{if(confirm(`Delete sink "${e}"? Forwarded events stay; new events won't be sent here.`)){p(!0);try{let t=await fetch(`/api/json/audit-sinks?id=${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await y(),h({kind:`ok`,text:`Deleted.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}}},O=async()=>{let e=w();if(!e){h({kind:`err`,text:`JSON is invalid`});return}p(!0),v(null);try{let t=await(await fetch(`/api/json/audit-sinks/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).json();v({...t.result,rendered:t.rendered})}catch(e){v({ok:!1,status:0,error:e instanceof Error?e.message:String(e)})}finally{p(!1)}},k=async e=>{p(!0);try{let t=await fetch(`/api/json/audit-sinks`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...e,enabled:!e.enabled})});if(!t.ok)throw Error(`HTTP ${t.status}`);await y()}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}};if(!e)return(0,D.jsx)(D.Fragment,{});let A=`text-[10.5px] font-mono text-[var(--color-fg-4)] tabular-nums`,j=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50`,M=`text-[10.5px] uppercase tracking-wider text-[var(--color-fg-4)]`,N=`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`;return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,D.jsxs)(`button`,{onClick:()=>r(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 hover:bg-white/[0.02] cursor-pointer`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11.5px]`,children:[(0,D.jsx)(`span`,{className:`font-medium text-[var(--color-fg-1)]`,children:`Centralized logging`}),(0,D.jsx)(`span`,{className:A,children:e.sinks.length===0?`no destinations`:`${e.sinks.filter(e=>e.enabled).length} of ${e.sinks.length} active`})]}),(0,D.jsx)(`span`,{className:A,children:n?`▾`:`▸`})]}),n&&(0,D.jsxs)(`div`,{className:`border-t border-[var(--color-line-1)] px-3 py-3 space-y-3`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] leading-relaxed`,children:`Forward every audit event to your SIEM or log lake. Each destination has its own filter + payload template — edit the JSON directly to map fields to whatever shape your destination expects.`}),e.sinks.length>0&&(0,D.jsx)(`div`,{className:`space-y-1.5`,children:e.sinks.map(e=>{let t=b.get(e.id);return(0,D.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)]`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e.enabled?t?.last_status===`ok`?`bg-emerald-400`:t?.last_status===`dead-lettered`?`bg-rose-400`:`bg-amber-400`:`bg-[var(--color-fg-4)]`}`}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11.5px] font-mono`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.name}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:da[e.type]})]}),(0,D.jsxs)(`div`,{className:`${A} truncate`,children:[e.endpoint??e.path??``,t&&(0,D.jsxs)(D.Fragment,{children:[` · `,`sent: `,t.last_status??`—`,` · last:`,` `,fa(t.last_sent_at),t.dropped_count>0&&(0,D.jsxs)(`span`,{className:`text-rose-300`,children:[` · `,`dropped: `,t.dropped_count]})]})]}),t?.last_error&&(0,D.jsx)(`div`,{className:`text-[10.5px] font-mono text-rose-300 truncate`,children:t.last_error})]}),(0,D.jsx)(`button`,{onClick:()=>k(e),disabled:f,className:N,children:e.enabled?`disable`:`enable`}),(0,D.jsx)(`button`,{onClick:()=>S(e),disabled:f,className:N,children:`edit`}),(0,D.jsx)(`button`,{onClick:()=>E(e.id),disabled:f,className:`${N} hover:!text-rose-300`,children:`delete`})]},e.id)})}),i===null&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:A,children:`add destination:`}),(e.sinkTypes??[]).map(e=>(0,D.jsxs)(`button`,{onClick:()=>x(e),className:N,children:[`+ `,da[e]]},e))]}),i!==null&&o&&(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-brand)]/30 bg-[var(--color-surface-0)] p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`text-[11.5px] font-medium text-[var(--color-fg-1)]`,children:[i,` · `,da[o.type]]}),(0,D.jsx)(`button`,{onClick:()=>l(e=>!e),className:N,children:c?`form view`:`raw JSON`})]}),!c&&(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Display name`}),(0,D.jsx)(`input`,{type:`text`,value:o.name,onChange:e=>s({...o,name:e.target.value}),className:`${j} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Endpoint URL`}),(0,D.jsx)(`input`,{type:`text`,value:o.endpoint??``,placeholder:`https://…`,onChange:e=>s({...o,endpoint:e.target.value}),className:`${j} w-full`})]}),o.type===`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`File path`}),(0,D.jsx)(`input`,{type:`text`,value:o.path??``,onChange:e=>s({...o,path:e.target.value}),className:`${j} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Auth`}),(0,D.jsxs)(`select`,{value:o.auth.type,onChange:e=>{let t=e.target.value,n=t===`bearer`?{type:`bearer`,token:``}:t===`basic`?{type:`basic`,username:``,password:``}:t===`header`?{type:`header`,name:``,value:``}:{type:`none`};s({...o,auth:n})},className:`${j} w-full cursor-pointer`,children:[(0,D.jsx)(`option`,{value:`none`,children:`none`}),(0,D.jsx)(`option`,{value:`bearer`,children:`bearer token`}),(0,D.jsx)(`option`,{value:`basic`,children:`basic auth`}),(0,D.jsx)(`option`,{value:`header`,children:`custom header`})]})]}),o.auth.type===`bearer`&&(0,D.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,D.jsx)(`label`,{className:M,children:`Token`}),(0,D.jsx)(`input`,{type:`password`,value:o.auth.token,onChange:e=>s({...o,auth:{type:`bearer`,token:e.target.value}}),className:`${j} w-full`})]}),o.auth.type===`basic`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Username`}),(0,D.jsx)(`input`,{type:`text`,value:o.auth.username,onChange:e=>o.auth.type===`basic`&&s({...o,auth:{...o.auth,username:e.target.value}}),className:`${j} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Password`}),(0,D.jsx)(`input`,{type:`password`,value:o.auth.password,onChange:e=>o.auth.type===`basic`&&s({...o,auth:{...o.auth,password:e.target.value}}),className:`${j} w-full`})]})]}),o.auth.type===`header`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Header name`}),(0,D.jsx)(`input`,{type:`text`,value:o.auth.name,onChange:e=>o.auth.type===`header`&&s({...o,auth:{...o.auth,name:e.target.value}}),className:`${j} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:M,children:`Header value`}),(0,D.jsx)(`input`,{type:`password`,value:o.auth.value,onChange:e=>o.auth.type===`header`&&s({...o,auth:{...o.auth,value:e.target.value}}),className:`${j} w-full`})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,D.jsxs)(`label`,{className:M,children:[`Payload template (JSON; `,`{{field}}`,` placeholders)`]}),(0,D.jsx)(`textarea`,{value:JSON.stringify(o.payload.template??{},null,2),rows:10,onChange:e=>{try{let t=JSON.parse(e.target.value);s({...o,payload:{...o.payload,template:t}}),h(null)}catch{h({kind:`err`,text:`Template is not valid JSON`})}},className:`${j} w-full leading-snug`})]})]}),c&&(0,D.jsx)(`textarea`,{value:u,rows:20,onChange:e=>d(e.target.value),className:`${j} w-full leading-snug`}),g&&(0,D.jsxs)(`div`,{className:`rounded-sm border px-3 py-2 text-[11px] font-mono ${g.ok?`border-emerald-400/40 text-emerald-200 bg-emerald-400/5`:`border-rose-400/40 text-rose-200 bg-rose-400/5`}`,children:[(0,D.jsxs)(`div`,{children:[g.ok?`✓ delivered`:`✗ failed`,` (HTTP`,` `,g.status,`)`,g.error&&(0,D.jsx)(`span`,{className:`ml-2 text-rose-200`,children:g.error})]}),g.rendered!=null&&(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-[var(--color-fg-4)]`,children:`payload sent`}),(0,D.jsx)(`pre`,{className:`mt-1 text-[10px] whitespace-pre-wrap break-all bg-black/30 rounded-sm px-2 py-1 max-h-48 overflow-y-auto`,children:JSON.stringify(g.rendered,null,2)})]})]}),m&&(0,D.jsx)(`p`,{className:`text-[11px] font-mono ${m.kind===`err`?`text-rose-300`:`text-emerald-300`}`,children:m.text}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{onClick:T,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:text-[var(--color-fg-0)] bg-[var(--color-surface-2)] hover:bg-[var(--color-surface-3)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:f?`saving…`:`save`}),(0,D.jsx)(`button`,{onClick:O,disabled:f,className:N,children:`send test event`}),(0,D.jsx)(`button`,{onClick:C,disabled:f,className:N,children:`cancel`})]})]})]})]})}var ma={__daemon:`SigmaShake itself`,bash:`Run a terminal command`,shell:`Run a terminal command`,run_command:`Run a terminal command`,exec:`Run a terminal command`,run_shell_command:`Run a terminal command`,read:`Read a file`,read_file:`Read a file`,view_file:`Read a file`,cat:`Read a file`,view:`Read a file`,write:`Save changes to a file`,write_to_file:`Save changes to a file`,create_file:`Create a new file`,edit:`Edit an existing file`,multiedit:`Edit several spots in a file`,patch:`Edit an existing file`,apply_patch:`Edit an existing file`,replace:`Edit an existing file`,grep:`Search the codebase`,ripgrep:`Search the codebase`,search:`Search the codebase`,search_codebase:`Search the codebase`,glob:`Find files by name`,find:`Find files by name`,list_files:`List files in a folder`,ls:`List files in a folder`,webfetch:`Read a webpage`,fetch:`Read a webpage`,websearch:`Search the web`,search_web:`Search the web`,browser_action:`Use a web browser`,agent:`Ask a helper AI to investigate`,spawn:`Ask a helper AI to investigate`,task:`Update its to-do list`,todowrite:`Update its to-do list`,todo_write:`Update its to-do list`,notebookedit:`Edit a Jupyter notebook`,notebook_edit:`Edit a Jupyter notebook`};function ha(e){return e?ma[e.toLowerCase()]||`Use the ${e.replace(/^_+/,``)} tool`:`Take an action`}function ga(e){return e?{"claude-code":`Claude Code`,claudecode:`Claude Code`,cursor:`Cursor`,copilot:`GitHub Copilot`,codex:`OpenAI Codex`,gemini:`Gemini`,antigravity:`Antigravity`,pi:`Pi`,generic:`AI agent`,daemon:`SigmaShake`}[e.toLowerCase()]??e:`AI agent`}function _a(e){return e?e.startsWith(`__`):!1}function va(e){for(let t of[`file_path`,`path`,`TargetFile`,`AbsolutePath`,`filename`,`file`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function ya(e){for(let t of[`command`,`CommandLine`,`cmd`,`Input`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function ba(e){for(let t of[`query`,`pattern`,`Query`,`q`,`search`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function xa(e){for(let t of[`url`,`URL`,`Url`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Sa(e){let t=e.replace(/[\\/]+$/,``),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`\\`),i=Math.max(n,r);return i>=0?t.slice(i+1):t}function Ca(e){let t=e.trim(),n=(t.split(/[|;&]/)[0]?.trim()??t).split(/\s+/),r=n[0]?.toLowerCase()??``,i=n[1]?.toLowerCase()??``,a=(e,t)=>({headline:e,detail:t});if(r===`rm`)return a(`Delete files`,`Deleting files from disk: \`${t}\``);if(r===`mkdir`)return a(`Create a folder`,`Creating a new folder: \`${t}\``);if(r===`mv`)return a(`Move or rename a file`,`Moving or renaming: \`${t}\``);if(r===`cp`)return a(`Copy a file`,`Copying files: \`${t}\``);if(r===`cat`||r===`head`||r===`tail`||r===`less`)return a(`Show file contents`,`Printing file contents: \`${t}\``);if(r===`ls`||r===`tree`||r===`find`)return a(`List files`,`Listing files: \`${t}\``);if(r===`cd`||r===`pwd`)return a(`Check the working folder`,`Checking or changing the current folder: \`${t}\``);if(r===`echo`||r===`printf`)return a(`Print a message`,`Printing a message: \`${t}\``);if(r===`curl`||r===`wget`)return a(`Download from the internet`,`Downloading something from the internet: \`${t}\``);if(r===`kill`||r===`pkill`)return a(`Stop a running program`,`Stopping a running program: \`${t}\``);if(r===`git`)return new Set([`status`,`log`,`diff`,`show`,`branch`,`remote`,`blame`,`config`]).has(i)?a(`Check git history`,`Reading git information (\`git ${i}\`) — no changes are made.`):i===`add`||i===`restore`||i===`reset`?a(`Stage or unstage changes`,`Preparing changes for commit (\`git ${i}\`).`):i===`commit`?a(`Save a checkpoint`,`Saving a snapshot of your changes to git history.`):i===`push`?a(`Send code to the remote`,`Uploading your commits to the remote git repository (e.g. GitHub).`):i===`pull`||i===`fetch`?a(`Get latest from the remote`,`Downloading the newest commits from the remote repository.`):i===`checkout`||i===`switch`?a(`Switch git branch`,`Switching which version of the code is loaded (\`git ${i}\`).`):i===`merge`||i===`rebase`?a(`Combine git branches`,`Combining changes from another branch (\`git ${i}\`).`):a(`Use git`,`Running a git command: \`${t}\``);if(r===`npm`||r===`bun`||r===`pnpm`||r===`yarn`){if(i===`install`||i===`i`||i===`add`)return a(`Install packages`,`Downloading project dependencies from the internet (\`${r} ${i}\`).`);if(i===`run`)return a(`Run a project script`,`Running a project script: \`${t}\``);if(i===`test`)return a(`Run automated tests`,`Running the project's automated tests.`);if(i===`build`)return a(`Build the project`,`Compiling the project for release.`)}return r===`pip`||r===`pip3`||r===`uv`?a(`Install Python packages`,`Installing Python packages: \`${t}\``):r===`pytest`||r===`jest`||r===`vitest`||r===`mocha`||r===`bun`&&i===`test`?a(`Run automated tests`,`Running automated tests: \`${t}\``):r===`docker`||r===`podman`?a(`Use Docker`,`Running a container command: \`${t}\``):r===`ssh`||r===`scp`||r===`rsync`?a(`Talk to another machine`,`Connecting to another computer over the network: \`${t}\``):a(`Run a terminal command`,`Running in the terminal: \`${t}\``)}function wa(e,t){let n=e??``,r=n.toLowerCase(),i=ha(n),a=null;try{let e=JSON.parse(t);e&&typeof e==`object`&&!Array.isArray(e)&&(a=e)}catch{}if(r===`__daemon`){let e=a?.event,t=a?.detail;return typeof e==`string`&&e.length>0?{headline:`SigmaShake itself`,detail:`SigmaShake ${e===`start`?`started`:e===`stop`?`stopped`:e}${typeof t==`string`&&t.length>0?` — ${t}`:``}.`}:{headline:`SigmaShake itself`,detail:`A SigmaShake lifecycle event.`}}if(!a)return{headline:i,detail:`${i}.`};if(r===`bash`||r===`shell`||r===`run_command`||r===`exec`||r===`run_shell_command`){let e=ya(a);return e?Ca(e):{headline:i,detail:`Running a terminal command.`}}if(r===`read`||r===`read_file`||r===`view_file`||r===`cat`||r===`view`){let e=va(a);return e?{headline:i,detail:`Reading the file \`${Sa(e)}\` so it can understand the current code. No changes are made.`}:{headline:i,detail:`Reading a file. No changes are made.`}}if(r===`write`||r===`write_to_file`||r===`create_file`){let e=va(a);return e?{headline:`Save changes to a file`,detail:`Creating or overwriting the file \`${Sa(e)}\`. This will replace anything that was there before.`}:{headline:i,detail:`Creating or overwriting a file.`}}if(r===`edit`||r===`multiedit`||r===`patch`||r===`apply_patch`||r===`replace`){let e=va(a);return e?{headline:i,detail:`Editing the file \`${Sa(e)}\` — changing specific parts of it without rewriting the whole thing.`}:{headline:i,detail:`Editing a file in place.`}}if(r===`grep`||r===`ripgrep`||r===`search`||r===`search_codebase`){let e=ba(a);return e?{headline:i,detail:`Searching the project for the text "${e}".`}:{headline:i,detail:`Searching the project for matching text.`}}if(r===`glob`||r===`find`||r===`list_files`||r===`ls`){let e=ba(a)??va(a);return e?{headline:i,detail:`Looking for files matching "${e}".`}:{headline:i,detail:`Looking for files in the project.`}}if(r===`webfetch`||r===`fetch`||r===`browser_action`){let e=xa(a);return e?{headline:i,detail:`Reading a webpage from the internet: ${e}`}:{headline:i,detail:`Reading a webpage from the internet.`}}if(r===`websearch`||r===`search_web`){let e=ba(a);return e?{headline:i,detail:`Searching the web for "${e}".`}:{headline:i,detail:`Searching the web.`}}return r===`agent`||r===`spawn`?{headline:i,detail:`Asking a separate helper AI to investigate something on its own, then report back. Helps keep this conversation focused.`}:r===`task`||r===`todowrite`||r===`todo_write`?{headline:i,detail:`Updating its internal to-do list so it can keep track of progress on a multi-step task.`}:{headline:i,detail:`${i}.`}}function Ta({val:e}){return e==null?(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] italic font-mono text-xs`,children:`null`}):typeof e==`boolean`?(0,D.jsx)(`span`,{className:`inline-block font-mono text-[10px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded-sm border ${e?`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`:`bg-red-500/8 text-red-300 border-red-500/25`}`,children:e.toString()}):typeof e==`number`?(0,D.jsx)(`span`,{className:`font-mono tabular-nums text-violet-300 text-xs`,children:e}):typeof e==`string`?e.length===0?(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] italic text-xs font-mono`,children:`empty string`}):e.length>200?(0,D.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 max-h-40 overflow-y-auto`,children:e}):(0,D.jsx)(`span`,{className:`font-mono text-xs text-[var(--color-fg-1)] break-all`,children:e}):(0,D.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 max-h-40 overflow-y-auto`,children:JSON.stringify(e,null,2)})}function Ea({inputJson:e}){let t=[];try{let n=JSON.parse(e);n&&typeof n==`object`&&!Array.isArray(n)&&(t=Object.entries(n))}catch{return(0,D.jsx)(`pre`,{className:`text-[11px] font-mono text-[var(--color-fg-1)] whitespace-pre-wrap break-all bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2`,children:e})}return t.length===0?(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-xs italic font-mono`,children:`no input fields`}):(0,D.jsx)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] overflow-hidden text-xs`,children:t.map(([e,t],n)=>(0,D.jsxs)(`div`,{className:`flex gap-0 ${n>0?`border-t border-[var(--color-line-0)]`:``}`,children:[(0,D.jsx)(`div`,{className:`w-40 shrink-0 px-3 py-2 bg-[var(--color-surface-0)] text-[var(--color-fg-3)] font-mono text-[11px] border-r border-[var(--color-line-0)] select-none`,children:e}),(0,D.jsx)(`div`,{className:`flex-1 min-w-0 px-3 py-2 leading-relaxed`,children:(0,D.jsx)(Ta,{val:t})})]},e))})}var Da={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},Oa={allow:`Allowed`,block:`Blocked`,force:`Forced`,ask:`Held`,log:`Logged`},ka={allow:`border-l-emerald-500/60`,block:`border-l-red-500/60`,force:`border-l-amber-400/60`,ask:`border-l-sky-500/60`,log:`border-l-[var(--color-line-2)]`};function Aa(e){return e==null?null:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}function ja({label:e,value:t,mono:n,children:r}){return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline mb-1`,children:e}),r??(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] text-xs ${n?`font-mono`:``} break-all`,children:t??`—`})]})}function Ma({text:e}){let[t,n]=(0,_.useState)(!1);return(0,D.jsx)(`button`,{onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-2 py-1 transition-colors cursor-pointer`,children:t?`✓ copied`:`copy json`})}function Na({row:e,defaultExpanded:t=!1}){let[n,r]=(0,_.useState)(t),i=(0,_.useRef)(null),a=(0,_.useRef)(!0),o=Br(e.tool,e.input),s=o&&o.length>0?o:e.input&&e.input!==`{}`&&e.input!==``?e.input:`—`,c=Da[e.decision]??`gray`,l=ka[e.decision]??`border-l-[var(--color-line-2)]`,u=zr(e.timestamp),d=Aa(e.duration_ns),f=wa(e.tool,e.input);(0,_.useEffect)(()=>{let e=i.current;if(e){if(a.current){a.current=!1,n||(e.style.maxHeight=`0`,e.style.opacity=`0`);return}if(vi()){e.style.maxHeight=n?`none`:`0`,e.style.opacity=n?`1`:`0`;return}if(n){let t=e.scrollHeight;Ii(e,{"max-height":[`0px`,`${t}px`],opacity:[0,1],translateY:[-6,0],duration:260,ease:`outCubic`,onComplete:()=>{e.style.maxHeight=`none`}})}else{let t=e.scrollHeight;Ii(e,{"max-height":[`${t}px`,`0px`],opacity:[1,0],duration:180,ease:`outCubic`})}}},[n]);let p=(()=>{try{return JSON.stringify(JSON.parse(e.input),null,2)}catch{return e.input}})();return(0,D.jsxs)(`div`,{className:`border border-[var(--color-line-1)] border-l-2 ${l} rounded-sm bg-[var(--color-surface-1)] overflow-hidden transition-colors hover:border-[var(--color-line-2)] hover:border-l-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 cursor-pointer select-none group`,onClick:()=>r(e=>!e),role:`button`,"aria-expanded":n,children:[(0,D.jsx)(`svg`,{className:`shrink-0 w-3 text-[var(--color-fg-4)] group-hover:text-[var(--color-fg-2)] transition-all ${n?`rotate-90`:``}`,width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),(0,D.jsx)(`time`,{className:`shrink-0 font-mono text-[11px] text-[var(--color-fg-3)] w-14 tabular-nums`,title:u,dateTime:new Date(e.timestamp*1e3).toISOString(),children:Rr(e.timestamp)}),(0,D.jsx)(K,{variant:c,className:`shrink-0 w-20 justify-center`,children:Oa[e.decision]??e.decision}),(0,D.jsxs)(`span`,{className:`flex-1 min-w-0 flex items-baseline gap-2`,title:`${f.headline} · ${e.tool}`,children:[(0,D.jsx)(`span`,{className:`text-[12px] text-[var(--color-fg-0)] font-medium truncate`,children:f.headline}),!_a(e.tool)&&s!==`—`&&(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)] font-mono truncate hidden sm:inline`,title:s,children:s})]}),d&&(0,D.jsx)(`span`,{className:`shrink-0 hidden md:inline w-12 text-right font-mono text-[10px] text-[var(--color-fg-4)] tabular-nums`,title:`Eval latency: ${d}`,children:d}),(0,D.jsx)(`span`,{className:`shrink-0 w-24 text-right text-[10px] text-[var(--color-fg-3)] truncate`,title:e.client?`Adapter: ${e.client}`:`Unidentified caller`,children:ga(e.client)})]}),(0,D.jsx)(`div`,{ref:i,className:`border-t border-[var(--color-line-0)] overflow-hidden`,style:{maxHeight:n?`none`:`0`,opacity:n?1:0},"aria-hidden":!n,children:n&&(0,D.jsxs)(`div`,{className:`px-3 py-3 space-y-4`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-x-6 gap-y-3`,children:[(0,D.jsx)(ja,{label:`When`,value:u}),(0,D.jsx)(ja,{label:`Decision`,children:(0,D.jsx)(K,{variant:c,children:Oa[e.decision]??e.decision})}),(0,D.jsx)(ja,{label:`Action`,children:(0,D.jsxs)(`span`,{className:`text-xs text-[var(--color-fg-1)]`,children:[f.headline,(0,D.jsxs)(`span`,{className:`ml-2 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`(`,e.tool,`)`]})]})}),e.client&&(0,D.jsx)(ja,{label:`AI agent`,value:ga(e.client)}),e.rule_id&&(0,D.jsx)(ja,{label:`Rule ID`,children:(0,D.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-xs text-[var(--color-brand)] hover:underline font-mono`,onClick:e=>e.stopPropagation(),children:e.rule_id})}),e.source_file&&(0,D.jsx)(ja,{label:`Source File`,value:e.source_file,mono:!0}),d&&(0,D.jsx)(ja,{label:`Latency`,value:d,mono:!0}),e.rules_evaluated!=null&&(0,D.jsx)(ja,{label:`Rules Evaluated`,value:`${e.rules_evaluated}`,mono:!0})]}),(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-3 py-2.5`,children:[(0,D.jsx)(`div`,{className:`overline mb-1`,children:`In plain English`}),(0,D.jsx)(`div`,{className:`text-xs font-medium text-[var(--color-fg-1)] mb-1`,children:f.headline}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] leading-relaxed`,children:f.detail})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline mb-2`,children:`Tool Input`}),(0,D.jsx)(Ea,{inputJson:e.input})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[e.rule_id?(0,D.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-brand)]/70 hover:text-[var(--color-brand)] transition-colors`,onClick:e=>e.stopPropagation(),children:`→ view rule`}):(0,D.jsx)(`span`,{}),(0,D.jsx)(Ma,{text:p})]})]})})]})}var Pa=[``,`allow`,`block`,`force`,`ask`,`log`],Fa=[``,`claude-code`,`gemini`,`antigravity`,`cursor`,`copilot`,`codex`,`pi`,`generic`],Ia=[50,100,250,500],La=100;function Ra(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(La),[u,d]=(0,_.useState)(0),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null);Nt([`activity-updated`]),(0,_.useEffect)(()=>{let t=!1,r=new URLSearchParams;return e&&r.set(`decision`,e),n&&r.set(`tool`,n),i&&r.set(`client`,i),r.set(`limit`,String(c)),r.set(`offset`,String(u)),r.set(`envelope`,`1`),h(!0),v(null),fetch(`/api/state/activity?${r.toString()}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t||(p(e),h(!1))}).catch(e=>{t||(v(e instanceof Error?e.message:String(e)),h(!1))}),()=>{t=!0}},[e,n,i,c,u]);let y=e=>t=>{e(t.target.value),d(0)},b=(0,_.useMemo)(()=>{if(!f)return[];let e=o.trim().toLowerCase();return e?f.rows.filter(t=>t.tool.toLowerCase().includes(e)||t.decision.toLowerCase().includes(e)||(t.rule_id??``).toLowerCase().includes(e)||(t.client??``).toLowerCase().includes(e)||(t.source_file??``).toLowerCase().includes(e)||t.input.toLowerCase().includes(e)):f.rows},[f,o]),x=f?.total??0,S=Math.floor(u/c)+1,C=Math.max(1,Math.ceil(x/c)),w=x===0?0:u+1,T=Math.min(u+(f?.rows.length??0),x),E=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50 cursor-pointer`,O=`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-3 py-1.5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`;return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`What your AI tried to do`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`Every move your AI agent made — and what SigmaShake decided.`,f&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums ml-1.5`,children:[`· `,x.toLocaleString(),` action`,x===1?``:`s`,` on record`]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`select`,{id:`audit-filter-decision`,value:e,onChange:y(t),className:E,children:Pa.map(e=>(0,D.jsx)(`option`,{value:e,children:e===``?`All decisions`:e===`allow`?`Allowed`:e===`block`?`Blocked`:e===`force`?`Forced`:e===`ask`?`Held`:`Logged`},e))}),(0,D.jsx)(`select`,{id:`audit-filter-client`,value:i,onChange:y(a),className:E,children:Fa.map(e=>(0,D.jsx)(`option`,{value:e,children:e===``?`All AI agents`:e===`claude-code`?`Claude Code`:e===`copilot`?`GitHub Copilot`:e===`codex`?`OpenAI Codex`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,D.jsx)(`input`,{id:`audit-filter-tool`,type:`text`,placeholder:`Filter by tool…`,value:n,onChange:y(r),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] rounded-sm px-2.5 py-1.5 w-36 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)]`}),(0,D.jsx)(`select`,{id:`audit-page-size`,value:c,onChange:e=>{l(Number(e.target.value)),d(0)},className:E,title:`Rows per page`,children:Ia.map(e=>(0,D.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]})]}),(0,D.jsx)(ua,{}),(0,D.jsx)(pa,{}),(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsxs)(`svg`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] pointer-events-none`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,D.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,D.jsx)(`input`,{id:`audit-search`,type:`text`,placeholder:`Search within this page…`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm pl-9 pr-10 py-2.5 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] transition-colors`}),o&&(0,D.jsx)(`button`,{onClick:()=>s(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] transition-colors cursor-pointer`,title:`Clear search`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,D.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),f&&f.rows.length>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-[10px] uppercase tracking-widest text-[var(--color-fg-4)] select-none`,children:[(0,D.jsx)(`span`,{className:`w-3`}),(0,D.jsx)(`span`,{className:`w-14`,children:`When`}),(0,D.jsx)(`span`,{className:`w-20`,children:`Decision`}),(0,D.jsx)(`span`,{className:`flex-1 min-w-0`,children:`Action`}),(0,D.jsx)(`span`,{className:`hidden md:inline w-12 text-right`,children:`Time`}),(0,D.jsx)(`span`,{className:`w-24 text-right`,children:`AI agent`})]}),g&&(0,D.jsxs)(`p`,{className:`text-sm text-red-300 font-mono`,children:[`failed to load audit log: `,g]}),m&&!f&&(0,D.jsx)(`div`,{className:`space-y-1.5`,children:Array.from({length:10}).map((e,t)=>(0,D.jsx)(`div`,{className:`h-9 bg-[var(--color-surface-1)] rounded-sm border border-[var(--color-line-0)] border-l-2 border-l-[var(--color-line-2)] shimmer`},t))}),!m&&!g&&b.length===0&&(0,D.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] py-16 flex flex-col items-center justify-center text-center`,children:[(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)]`,children:o?`No actions on this page match your search.`:x===0?`Nothing yet — connect an AI agent and its actions will show up here.`:`No rows on this page match the filter.`}),o&&(0,D.jsx)(`button`,{onClick:()=>s(``),className:`mt-3 text-[11.5px] text-[var(--color-brand)] hover:underline cursor-pointer`,children:`Clear search`})]}),b.length>0&&(0,D.jsx)(`div`,{className:`space-y-1.5`,children:b.map(e=>(0,D.jsx)(Na,{row:e},e.id))}),f&&x>c&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2`,children:[(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:[`showing `,w.toLocaleString(),`–`,T.toLocaleString(),` `,`of `,x.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{onClick:()=>d(0),disabled:u===0,className:O,children:`⟪ first`}),(0,D.jsx)(`button`,{onClick:()=>d(Math.max(0,u-c)),disabled:u===0,className:O,children:`‹ prev`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`page `,S,` / `,C]}),(0,D.jsx)(`button`,{onClick:()=>d(f.nextOffset==null?u:f.nextOffset),disabled:f.nextOffset==null,className:O,children:`next ›`}),(0,D.jsx)(`button`,{onClick:()=>d((C-1)*c),disabled:f.nextOffset==null,className:O,children:`last ⟫`})]})]})]})}var za=Object.freeze([`eval-burst`,`eval-burst-complete`,`counters-updated`]);function Ba(){(0,_.useEffect)(()=>bt(za),[])}function Va(){return Ba(),(0,_.useSyncExternalStore)(dt,ft).latestBurst}function Ha(){return Ba(),(0,_.useSyncExternalStore)(dt,ft).burstRing}function Ua(){return Ba(),(0,_.useSyncExternalStore)(dt,ft).burstSeq}function Wa(e){return`${e.client}:${e.agent_id??`solo`}`}var Ga=Object.freeze({allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`}),Ka=5*6e4,qa=1200,Ja=30*6e4,Ya=1.4;function Xa(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 6;let n=6+Math.log2(1+t/50)*Ya;return n<4?4:n>16?16:n}function Za(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 0;let n=Math.log2(1+t/50)*Ya/10;return n<=0?0:n>=1?1:n}function Qa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function $a(e,t){if(t<=0)return e;let n=e.startsWith(`#`)?e.slice(1):e;if(n.length!==6)return e;let r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);if(Number.isNaN(r)||Number.isNaN(i)||Number.isNaN(a))return e;let o=Math.max(r,i,a);if(o===0)return e;let s=t>1?1:t,c=(255-o)*s,l=Math.round(r+r/o*c),u=Math.round(i+i/o*c),d=Math.round(a+a/o*c),f=e=>(e<0?0:e>255?255:e).toString(16).padStart(2,`0`);return`#${f(l)}${f(u)}${f(d)}`}var eo=new Set([`compact`,`end`,`stop`,`subagent-stop`,`close`]),to=Object.freeze([`session-lifecycle`]);function Z(e){(0,_.useEffect)(()=>bt(to),[]);let t=(0,_.useSyncExternalStore)(dt,ft),[n,r]=(0,_.useState)(new Map),i=(0,_.useRef)(0);(0,_.useEffect)(()=>{let e=t.lifecycleRing;if(e.length<=i.current)return;let n=e.slice(i.current);i.current=e.length,no(n,r)},[t.lifecycleRing]);let a=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{!e||e===a.current||(a.current=e,no(e,r))},[e]),{closedAt:n,isBurstActive(e,t){let r=n.get(e);return r===void 0||t>r}}}function no(e,t){let n=e.filter(e=>eo.has(e.event));n.length!==0&&t(e=>{let t=!1,r=new Map(e);for(let e of n){let n=r.get(e.session_key);(n===void 0||e.ts_ms>n)&&(r.set(e.session_key,e.ts_ms),t=!0)}return t?r:e})}var ro=1440*60*1e3,io=1800*1e3,ao=3e3;function oo(e,t){if(e.length===0)return t.slice();if(t.length===0)return e.slice();let n=new Set,r=[],i=0,a=0;for(;i<e.length&&a<t.length;){let o=e[i]?.ts_ms<=t[a]?.ts_ms?e[i++]:t[a++],s=so(o);n.has(s)||(n.add(s),r.push(o))}for(;i<e.length;i++){let t=e[i],a=so(t);n.has(a)||(n.add(a),r.push(t))}for(;a<t.length;a++){let e=t[a],i=so(e);n.has(i)||(n.add(i),r.push(e))}return r}function so(e){return e.audit_id??`${e.ts_ms}:${e.tool}:${e.client}`}function co(e,t){if(e.length===0)return t.slice();if(t.length===0)return e.slice();let n=new Set,r=[];for(let i of[...e,...t]){let e=`${i.session_key}:${i.ts_ms}:${i.event}`;n.has(e)||(n.add(e),r.push(i))}return r}function lo(e,t,n,r=200,i=Ja,a=12){let o=new Map,s=new Map;for(let r of e){if(r.ts_ms>n)break;let e=Wa(r);if(!t(e,r.ts_ms))continue;let i=o.get(e);i?i.push(r):o.set(e,[r]);let a=s.get(e);(a===void 0||r.ts_ms>a)&&s.set(e,r.ts_ms)}let c=n-i,l=[];for(let[e,t]of s)t<c&&l.push(e);for(let e of l)o.delete(e),s.delete(e);if(o.size>a){let e=new Set(Array.from(s.entries()).sort((e,t)=>t[1]-e[1]).slice(0,a).map(([e])=>e));for(let t of[...o.keys()])e.has(t)||o.delete(t)}let u=[];for(let e of o.values()){let t=e.length>r?e.slice(-r):e;u.push(...t)}return u.sort((e,t)=>e.ts_ms-t.ts_ms),u}function uo(e={}){let t=e.windowMs??12e4,n=Ha(),[r,i]=(0,_.useState)(()=>({mode:`live`,playhead_ms:Date.now(),window_ms:t})),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{p.current=n.length>0||a.length>0},[n,a]),(0,_.useEffect)(()=>{if(r.mode!==`live`)return;let e=()=>{if(!p.current)return;let e=Date.now();i(t=>t.mode===`live`?t.playhead_ms===e?t:{...t,playhead_ms:e}:t)};e();let t=setInterval(e,500);return()=>clearInterval(t)},[r.mode]);let m=(0,_.useMemo)(()=>oo(a,n),[a,n]),{isBurstActive:h}=Z(s),g=(0,_.useMemo)(()=>lo(m,h,r.playhead_ms),[m,h,r.playhead_ms]),v=m.length>0?m[0]?.ts_ms:r.playhead_ms,y=m.length>0?m[m.length-1]?.ts_ms:r.playhead_ms,b=(0,_.useCallback)(async e=>{if(f.current)return;let t=v,n=Math.min(t,(d.current??Date.now())-e);if(n>=t)return;let r=new AbortController;f.current=r,u(!0);try{let e=await fetch(`/api/json/graph/backfill?since_ms=${n}&until_ms=${t}&limit=500`,{signal:r.signal,credentials:`same-origin`});if(!e.ok)throw Error(`backfill ${e.status}`);let i=await e.json();Array.isArray(i.bursts)&&i.bursts.length>0&&o(e=>{let t=oo(e,i.bursts);return t.length>ao?t.slice(-ao):t}),Array.isArray(i.lifecycle)&&i.lifecycle.length>0&&c(e=>co(e,i.lifecycle)),d.current=n}catch(e){e.name!==`AbortError`&&console.warn(`[graph] backfill failed`,e)}finally{f.current=null,u(!1)}},[v]);(0,_.useEffect)(()=>{r.playhead_ms-v<r.window_ms*.5&&b(Ka)},[r.playhead_ms,r.window_ms,v,b]);let x=(0,_.useRef)(!1);(0,_.useEffect)(()=>{x.current||(x.current=!0,b(io))},[b]),(0,_.useEffect)(()=>()=>{f.current?.abort(),f.current=null},[]);let S=(0,_.useCallback)(e=>{i(t=>e===`live`?{...t,mode:`live`}:{...t,mode:e})},[]),C=(0,_.useCallback)(e=>{i(t=>({...t,mode:t.mode===`live`?`scrubbing`:t.mode,playhead_ms:e}))},[]),w=(0,_.useCallback)(e=>{i(t=>({...t,window_ms:Math.max(1e3,e)}))},[]),T=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now()}))},[]),E=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now(),window_ms:ro})),b(ro)},[b]);return{snapshot:(0,_.useMemo)(()=>({bursts:g,playback:r,oldest_known_ms:v,newest_known_ms:y,loading_backfill:l}),[g,r,v,y,l]),allBursts:m,setMode:S,setPlayhead:C,setWindow:w,jumpToLive:T,requestBackfill:b,jumpTo24h:E}}function fo(e){let t=e|0;return()=>{t=t+1831565813|0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var po={"claude-code":`C`,"claude-code-ide":`C`,cursor:`>`,copilot:`H`,codex:`X`,pi:`P`,gemini:`G`,antigravity:`A`};function mo(e){return po[e.toLowerCase()]??`.`}function ho(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)|0;return(t>>>0)%360}function go(e,t,n){for(let[r,i]of t){let{x:t,y:a,n:o}=i,s=50+Math.min(o,12)*7,c=ho(r),l=n.get(r),u;l&&Math.abs(l.x-t)<2&&Math.abs(l.y-a)<2&&l.r===s?u=l.grad:(u=e.createRadialGradient(t,a,0,t,a,s),u.addColorStop(0,`hsla(${c},80%,55%,0.10)`),u.addColorStop(1,`hsla(${c},80%,55%,0)`),n.set(r,{grad:u,x:t,y:a,r:s})),e.fillStyle=u,e.beginPath(),e.arc(t,a,s,0,Math.PI*2),e.fill()}for(let e of n.keys())t.has(e)||n.delete(e)}function _o(e,t,n,r,i,a,o){let s=8+a*r,c=Math.max(0,1-r)*o;c<=0||(e.save(),e.globalAlpha=c,e.fillStyle=i,e.beginPath(),e.arc(t,n,s,0,Math.PI*2),e.fill(),e.restore())}var vo=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,yo=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,bo=new Map,xo=256;function So(e,t){let n=bo.get(t);if(n!==void 0)return n;let r=e.measureText(t).width;if(bo.size>=xo){let e=bo.keys().next().value;e!==void 0&&bo.delete(e)}return bo.set(t,r),r}function Co(e,t,n,r,i,a,o){let s=(r.split(`:`)[0]??r).slice(0,18),c=mo(s),l=ho(r),u=Ga[o]??`#6b7280`;e.save(),e.textAlign=`center`;let d=`[${c}] ${s}`,f=`${i.length>14?i.slice(0,14):i} · ${a}`;e.font=yo;let p=So(e,d);e.font=vo;let m=So(e,f),h=Math.max(p,m)+10;e.globalAlpha=.82,e.fillStyle=`hsla(${l},25%,5%,0.92)`,e.fillRect(t-h/2,n-2,h,28),e.globalAlpha=.92,e.fillStyle=`hsla(${l},78%,70%,1)`,e.font=yo,e.fillText(d,t,n+10),e.globalAlpha=.72,e.fillStyle=u,e.font=vo,e.fillText(f,t,n+21),e.restore()}var wo=`bold 13px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,To=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;function Eo(e){if((!Number.isFinite(e)||e<0)&&(e=0),e<6e4)return`${(e/1e3).toFixed(3)}s`;if(e<36e5)return`${Math.floor(e/6e4)}:${(e%6e4/1e3).toFixed(3).padStart(6,`0`)}`;let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),r=(e%6e4/1e3).toFixed(1).padStart(4,`0`);return`${t}:${String(n).padStart(2,`0`)}:${r}`}function Do(e,t,n,r,i){e.save(),e.textAlign=`center`,e.font=To,e.globalAlpha=.7,e.fillStyle=`hsla(${i},78%,72%,0.55)`,e.fillText(`uptime`,t,n),e.font=wo,e.globalAlpha=.96,e.fillStyle=`hsla(${i},78%,82%,1)`,e.fillText(Eo(r),t,n+13),e.restore()}function Oo(e,t,n,r){e.save(),e.textAlign=`right`,e.font=To,e.fillStyle=`rgba(148, 163, 184, 0.55)`,e.globalAlpha=.85,e.fillText(`LIVE`,t,n),e.font=`bold 16px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,e.fillStyle=`#e0e7ff`,e.globalAlpha=.92,e.fillText(Eo(r),t,n+16),e.restore()}function ko(e,t,n,r,i,a,o){let s=r-t,c=i-n;if(Math.sqrt(s*s+c*c)<24)return;let l=Math.atan2(c,s),u=3.5,d=r-Math.cos(l)*9,f=i-Math.sin(l)*9;e.save(),e.globalAlpha=o*.85,e.fillStyle=a,e.translate(d,f),e.rotate(l),e.beginPath(),e.moveTo(0,0),e.lineTo(-6,-u),e.lineTo(-6,u),e.closePath(),e.fill(),e.restore()}var Ao={Read:`▣`,Write:`✎`,Edit:`✎`,MultiEdit:`✎`,NotebookEdit:`✎`,NotebookRead:`▣`,Glob:`✦`,Grep:`✦`,LS:`⊞`,Find:`✦`,ToolSearch:`⊕`,Bash:`$`,Skill:`◈`,WebFetch:`⌬`,WebSearch:`⌬`,Agent:`◇`,Task:`⌘`,TaskCreate:`⌘`,TaskUpdate:`⌘`,TaskList:`⌘`,TaskGet:`⌘`,TaskOutput:`⌘`,TaskStop:`⌘`,TodoWrite:`✓`,TodoRead:`✓`,AskUserQuestion:`?`,EnterPlanMode:`◐`,ExitPlanMode:`◑`,EnterWorktree:`⎇`,ExitWorktree:`⎇`,PushNotification:`⏰`,ScheduleWakeup:`⏰`,CronCreate:`⏰`,CronList:`⏰`,CronDelete:`⏰`,RemoteTrigger:`↗`,Monitor:`◉`};function jo(e){if(!e)return`·`;let t=e.lastIndexOf(`__`);return Ao[t>=0?e.slice(t+2):e]??Ao[e]??`·`}var Mo=2*Math.PI/6e4,No=2.3999632297286535,Po=16,Fo=22,Io=.4,Lo=14,Ro=8,zo=24;function Bo(e,t,n){let r=new Map;for(let t of e){if(t.exitingAt!=null)continue;let e=r.get(t.session);e?e.push(t):r.set(t.session,[t])}if(r.size===0)return;for(let e of r.values())e.sort((e,t)=>e.ts_ms-t.ts_ms);let i=Math.min(t,n)-zo,a=Array.from(r.keys()).sort(),o=a.length,s=0;for(let e of r.values())e.length>s&&(s=e.length);let c=Math.max(1,Math.min(Fo,(i-Po)/Math.max(1,s-1))),l=Po,u=Po+c,d=(l*l+u*u-Lo*Lo)/(2*l*u),f=Math.max(Io,Math.acos(Math.min(1,Math.max(-1,d))));if(o<=Ro)for(let e=0;e<o;e++){let t=a[e];if(t===void 0)continue;let n=r.get(t);if(!n)continue;let i=e*2*Math.PI/o;for(let e=0;e<n.length;e++){let t=n[e];t&&(t.slotPhi=i+e*f,t.slotR=Po+e*c)}}else{let e=[];for(let t of r.values())for(let n of t)e.push(n);e.sort((e,t)=>e.ts_ms-t.ts_ms);let t=Math.max(1,Math.min(Fo,(i-Po)/Math.max(1,e.length-1)));for(let n=0;n<e.length;n++){let r=e[n];r&&(r.slotPhi=n*No,r.slotR=Po+n*t)}}}function Vo(e,t,n,r){for(let i of e)i.exitingAt??(i.slotR==null||i.slotPhi==null||(i.x=t+i.slotR*Math.cos(i.slotPhi+r),i.y=n+i.slotR*Math.sin(i.slotPhi+r)))}function Ho(e){let t=new Map;for(let n of e){let e=t.get(n.session);e?(e.x+=n.x,e.y+=n.y,e.n+=1):t.set(n.session,{x:n.x,y:n.y,n:1})}for(let e of t.values())e.x/=e.n,e.y/=e.n;return t}function Uo(e,t){let n=[],r=new Map;for(let t of e){let e=r.get(t.session);e?e.push(t):r.set(t.session,[t])}for(let e of r.values()){e.sort((e,t)=>e.ts_ms-t.ts_ms);for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];!i||!a||a.ts_ms-i.ts_ms<=t&&n.push({source:i.id,target:a.id,kind:`session`})}}return n}var Wo=new Set,Go=0,Ko=0;function qo(){for(let e of Wo)e();Wo.size>0&&(Go=requestAnimationFrame(qo))}function Jo(e){let t=Ko++;return Wo.add(e),Wo.size===1&&(Go=requestAnimationFrame(qo)),[()=>{Wo.delete(e),Wo.size===0&&(cancelAnimationFrame(Go),Go=0)},t]}var Yo=820,Xo=e=>Math.min(1,e),Zo=620,Qo=e=>1-(1-e)**3,$o=ui({stiffness:120,damping:22,mass:1}),es=1800;function ts(e){return e<=2?Math.min(window.devicePixelRatio,2):e<=4?Math.min(window.devicePixelRatio,1.5):Math.min(window.devicePixelRatio,1)}function ns(e){return e<=2?1:e<=4?2:3}function rs(e){return e<=2?24:e<=4?12:6}function is(e){return e<=4}var as=!1,os=!1;function ss(){if(os||typeof window>`u`)return;os=!0;let e=navigator;typeof e.getBattery==`function`&&e.getBattery().then(e=>{let t=()=>{as=!e.charging&&e.level<.2};t(),e.addEventListener(`chargingchange`,t),e.addEventListener(`levelchange`,t)}).catch(()=>{})}function cs(){return typeof window>`u`?!1:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||navigator.connection?.saveData?!0:as}var ls=typeof window<`u`&&new URLSearchParams(window.location.search).get(`fullrate`)===`1`,us=typeof window<`u`&&new URLSearchParams(window.location.search).get(`rotate`)!==`0`,ds=typeof window<`u`&&new URLSearchParams(window.location.search).get(`probe`)===`1`;function fs(e,t,n,r){let i=new Map;for(let t of e)i.set(t.id,t);let a=new Set,o=[];for(let e=0;e<t.length;e++){let s=t[e],c=s.audit_id??`${s.ts_ms}:${s.tool}:${e}`;a.add(c);let l=i.get(c);if(l)l.burst=s,l.exitingAt=void 0,o.push(l);else{let t=fo(s.ts_ms^e),i=n*.6+(t()-.5)*60,a=r/2+(t()-.5)*40,l=Wa(s);o.push({id:c,burst:s,ts_ms:s.ts_ms,session:l,x:i,y:a,vx:0,vy:0,age:0,tx:i,ty:a})}}let s=performance.now();for(let t of e)a.has(t.id)||(t.exitingAt??=s,s-t.exitingAt<1200&&o.push(t));return o}function ps(e){let{bursts:t,paused:n,selectedId:r,onSelect:i,burstSeq:a,compact:o=!1,activePanelCount:s=1,labelDensity:c=`normal`,onFrameTime:l}=e,u=(0,_.useRef)(l);u.current=l;let d=(0,_.useRef)(c);d.current=c;let f=(0,_.useRef)(null),p=(0,_.useRef)([]),m=(0,_.useRef)([]),h=(0,_.useRef)(null),g=(0,_.useRef)(null),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(0),x=(0,_.useRef)(new Map),S=(0,_.useRef)(new Set),C=(0,_.useRef)(new Set),w=(0,_.useRef)(new Set),[T,E]=(0,_.useState)({w:0,h:0}),O=(0,_.useRef)(0),k=(0,_.useRef)(0),A=(0,_.useRef)(null),j=(0,_.useRef)(Date.now()),M=(0,_.useRef)(new Map),N=(0,_.useRef)({frame:0,cache:null});(0,_.useLayoutEffect)(()=>{let e=f.current?.parentElement;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&E({w:Math.max(40,t.width),h:Math.max(40,t.height)});let n=new ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t.contentRect;e<=0||n<=0||E({w:Math.max(40,e),h:Math.max(40,n)})}});return n.observe(e),()=>n.disconnect()},[]),(0,_.useEffect)(()=>{if(T.w<=0||T.h<=0)return;N.current.frame=0;let e=new Map;for(let t of p.current)e.set(t.id,t);p.current=fs(p.current,t,T.w,T.h),Bo(p.current,T.w/2,T.h/2);let n=us&&!vi()?performance.now()*Mo:0;for(let t of p.current){if(t.slotR==null||t.slotPhi==null)continue;let r=T.w/2+t.slotR*Math.cos(t.slotPhi+n),i=T.h/2+t.slotR*Math.sin(t.slotPhi+n),a=!e.has(t.id),o=Math.hypot(t.x-r,t.y-i);(a||o>40)&&(t.x=r,t.y=i,t.vx=0,t.vy=0)}if(m.current=Uo(p.current,1/0),!vi())for(let t=0;t<p.current.length;t++){let n=p.current[t];!n||e.has(n.id)||Oe(n.burst.decision)}let r=p.current.reduce((e,t)=>t.ts_ms>e?t.ts_ms:e,0);y.current=Math.max(performance.now()+Yo,performance.now()+qa,r+1500),v.current=performance.now()},[t,T.w,T.h]),(0,_.useEffect)(()=>{let e=f.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;ss();let i=performance.now(),a=0,c=0,l=0,g=.1,[_,E]=Jo(()=>{let f=performance.now();if(!ls&&cs()){if(a^=1,a===1)return}else a!==0&&(a=0);if(!ls){let e=ns(s);if(e>1&&(k.current=(k.current+1)%e,k.current!==0))return}let _=performance.now(),E=_<y.current,D=_-v.current<200,O=_-b.current>500,ee=vi(),te=us&&!ee;if(!te&&!E&&!D&&!O)return;b.current=_;let P=f,F=Math.min(50,P-i);i=P;let ne=p.current,re=m.current,ie=te?performance.now()*Mo:0;Vo(ne,T.w/2,T.h/2,ie);for(let e of ne)e.age<1&&(e.age=Math.min(1,e.age+F/Yo));let I=typeof window<`u`?ts(s):1,L=T.w,R=T.h;(e.width!==L*I||e.height!==R*I)&&(e.width=L*I,e.height=R*I,e.style.width=`${L}px`,e.style.height=`${R}px`,t.scale(I,I)),t.fillStyle=`#0a0a0f`,t.fillRect(0,0,L,R);let ae=`${L}x${R}`,z=A.current?.key===ae?A.current.grad:null;if(z||(z=t.createRadialGradient(L/2,R/2,0,L/2,R/2,Math.max(L,R)/1.2),z.addColorStop(0,`rgba(56, 189, 248, 0.06)`),z.addColorStop(1,`rgba(0, 0, 0, 0)`),A.current={key:ae,grad:z}),t.fillStyle=z,t.fillRect(0,0,L,R),!o){let e=N.current;(e.frame++%6==0||e.cache===null)&&(e.cache=Ho(ne));let n=e.cache;if(go(t,n,M.current),!ee){let e=new Map,r=new Map;for(let t of ne)t.exitingAt??(r.set(t.session,(r.get(t.session)??0)+1),e.set(t.session,t));let i=new Map;for(let e of ne){if(e.exitingAt!=null)continue;let t=i.get(e.session);(t===void 0||e.ts_ms<t)&&i.set(e.session,e.ts_ms)}let a=Date.now();for(let[o,s]of n){let n=e.get(o),c=r.get(o)??0;if(!n||c===0)continue;let l=50+Math.min(s.n,12)*7;Co(t,s.x,s.y-l-34,o,n.burst.tool,c,n.burst.decision);let u=i.get(o);if(u!==void 0){let e=Math.max(0,a-u);Do(t,s.x,s.y+l+12,e,ho(o))}}}}let oe=e=>e.exitingAt==null?1:Math.max(0,1-(P-e.exitingAt)/qa),se=rs(s),ce=is(s)&&!ee,le=S.current;if(le.clear(),n)for(let e of ne)le.add(e.id);else{let e=0;for(let t=ne.length-1;t>=0&&e<se;t--){let n=ne[t];!n||n.exitingAt!=null||(le.add(n.id),e++)}}let ue=x.current;ue.clear();for(let e of ne)ue.set(e.id,e);t.lineWidth=2,t.lineCap=`round`,t.lineJoin=`round`;for(let e=0;e<re.length;e++){let n=re[e],r=ue.get(n.source),i=ue.get(n.target);if(!r||!i||le.has(r.id)||le.has(i.id))continue;let a=Math.max(oe(r),oe(i));a<=0||(t.globalAlpha=a,t.strokeStyle=`${Ga[i.burst.decision]??`#6b7280`}aa`,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(i.x,i.y),t.stroke())}t.globalAlpha=1;let de=d.current===`large`,fe=de?`10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`8px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;for(let e=0;e<re.length;e++){let n=re[e],r=ue.get(n.source),i=ue.get(n.target);if(!r||!i||!le.has(r.id)&&!le.has(i.id))continue;let a=Ga[i.burst.decision]??`#6b7280`,o=Math.max(oe(r),oe(i));if(o<=0)continue;let s=Xo(i.age),c=r.x+(i.x-r.x)*s,l=r.y+(i.y-r.y)*s;if(t.globalAlpha=o,t.strokeStyle=`${a}aa`,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(c,l),t.stroke(),t.globalAlpha=1,ce){let n=Math.min(s,(P/es+e*.618033)%1),u=r.x+(i.x-r.x)*n,d=r.y+(i.y-r.y)*n;t.save(),t.globalAlpha=o*Math.sin(n*Math.PI)*.9,t.fillStyle=a,t.beginPath(),t.arc(u,d,2.5,0,Math.PI*2),t.fill(),t.restore(),ko(t,r.x,r.y,c,l,a,o)}let u=i.ts_ms-r.ts_ms,d=u<1e3?`${u}ms`:u<6e4?`${(u/1e3).toFixed(1)}s`:`${Math.floor(u/6e4)}m${Math.floor(u%6e4/1e3)}s`,f=(r.x+c)/2,p=(r.y+l)/2;t.save(),t.globalAlpha=o*.65*s,t.font=fe,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(`${e+1} · ${d}`,f,p-(de?8:7)),t.restore()}t.globalAlpha=1;let pe=C.current;pe.clear();let me=w.current;me.clear();let he=d.current===`large`?10:5;{let e=0;for(let t=ne.length-1;t>=0;t--){let r=ne[t];!r||r.exitingAt!=null||(!n&&e<3&&pe.add(r.id),e<he&&me.add(r.id),e++)}}let ge=r,_e=h.current;for(let e of ne){let r=oe(e);if(r<=0)continue;t.globalAlpha=r;let i=Math.min(1,e.age),a=Xo(i);e.displayedRadius=o?4:Xa(e.burst);let s=e.displayedRadius,c=o?s*a:(s+2*Math.min(1,e.age))*a,l=Ga[e.burst.decision]??`#6b7280`,u=$a(l,Za(e.burst));if((e.id===ge||e.id===_e)&&(t.beginPath(),t.arc(e.x,e.y,c+6,0,Math.PI*2),t.fillStyle=`${u}33`,t.fill()),ce&&(e.burst.decision===`allow`?_o(t,e.x,e.y,i,`#22c55e`,14,.3):e.burst.decision===`ask`&&_o(t,e.x,e.y,i,`#f59e0b`,14,.45)),ce&&(e.burst.decision===`block`||e.burst.decision===`force`)){let n=i*Yo;if(n<Zo){let r=n/Zo,i=c+16*Qo(r),a=Math.max(0,1-r)*.75;t.beginPath(),t.arc(e.x,e.y,i,0,Math.PI*2),t.strokeStyle=u+Math.floor(a*255).toString(16).padStart(2,`0`),t.lineWidth=1.5,t.stroke()}}if(!ee&&pe.has(e.id)&&(t.beginPath(),t.arc(e.x,e.y,c+2,0,Math.PI*2),t.fillStyle=`${u}33`,t.fill()),t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.fillStyle=u,t.fill(),t.strokeStyle=l,t.lineWidth=1.5,t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.stroke(),me.has(e.id)&&(n||le.has(e.id))){let n=d.current===`large`;t.font=n?`11px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.textAlign=`center`,t.fillStyle=`${u}cc`,t.fillText(mo(e.burst.client),e.x,e.y-c-(n?4:3));let i=n?16:12,a=e.burst.tool.length>i?e.burst.tool.slice(0,i):e.burst.tool,o=jo(e.burst.tool),s=o===`·`?a:`${o} ${a}`;t.fillStyle=`${u}88`,t.fillText(s,e.x,e.y+c+(n?13:11));let l=e.burst.input_tokens??0,f=e.burst.output_tokens??0;(l>0||f>0)&&(t.globalAlpha=r*(le.has(e.id)?.8:.35),t.font=n?`10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`:`8px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.fillText(`↓${Qa(l)} ↑${Qa(f)}`,e.x,e.y+c+(n?25:21)),t.globalAlpha=r),t.textAlign=`left`}(e.id===ge||e.id===_e)&&(t.font=`11px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,t.fillStyle=`#e0e7ff`,t.fillText(e.burst.tool,e.x+c+6,e.y+3))}if(t.globalAlpha=1,ce&&ne.length>0){let e=null;for(let t=ne.length-1;t>=0;t--)if(ne[t].exitingAt==null){e=ne[t];break}let n=e?Date.now()-e.ts_ms:1/0,r=5e3;if(e&&n<=r){let i=Math.max(0,1-n/r),a=1100,o=P%a/a,s=14+$o.fn(o)*8,c=Math.max(0,1-o)*.85*i,l=Math.floor(c*255).toString(16).padStart(2,`0`);t.beginPath(),t.arc(e.x,e.y,s,0,Math.PI*2),t.strokeStyle=`#38bdf8${l}`,t.lineWidth=2,t.stroke();let u=P%800/800*Math.PI*2,d=100/360*Math.PI*2,f=.85*i,p=Math.floor(f*255).toString(16).padStart(2,`0`);t.save(),t.beginPath(),t.arc(e.x,e.y,22,u,u+d),t.strokeStyle=`#38bdf8${p}`,t.lineWidth=2.5,t.lineCap=`round`,t.stroke(),t.restore()}}if(!o&&L>220&&Oo(t,L-12,12,Date.now()-j.current),ds){let t,n=0;for(let e of ne)e.exitingAt??(n++,t||=e);e.dataset.probeCount=String(n),e.dataset.probeX0=(t?.x??0).toFixed(2),e.dataset.probeY0=(t?.y??0).toFixed(2)}c=c===0?F:c*(1-g)+F*g;let ve=u.current;ve&&P-l>250&&(l=P,ve(c))});return O.current=E,k.current=E,_},[n,r,T.w,T.h,o,s]);function ee(e,t){let n=f.current;if(!n)return null;let r=n.getBoundingClientRect(),i=e-r.left,a=t-r.top,o=null,s=200;for(let e of p.current){let t=e.x-i,n=e.y-a,r=t*t+n*n;r<s&&(s=r,o=e.id)}return o}return(0,D.jsxs)(`div`,{className:`relative w-full h-full rounded-sm border border-[var(--color-line-1)] overflow-hidden bg-black`,children:[(0,D.jsx)(`canvas`,{ref:f,className:`block w-full h-full cursor-crosshair`,onMouseMove:e=>{let t=ee(e.clientX,e.clientY);h.current=t;let n=g.current;if(!n)return;if(!t){n.style.display=`none`;return}let r=p.current.find(e=>e.id===t);if(!r){n.style.display=`none`;return}let i=r.burst,a=Ga[i.decision]??`#6b7280`,o;if(i.complete_duration_ms!=null&&i.complete_duration_ms>0){let e=i.complete_duration_ms;o=e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(0)}ms`}else{let e=i.duration_ns/1e6;o=e<1?`${(e*1e3).toFixed(0)}µs`:`${e.toFixed(1)}ms`}let s=[];i.input_tokens!=null&&s.push(`↓${Qa(i.input_tokens)}`),i.output_tokens!=null&&s.push(`↑${Qa(i.output_tokens)}`);let c=i.input_preview?` · "${i.input_preview.length>45?`${i.input_preview.slice(0,45)}…`:i.input_preview}"`:``,l=s.length>0?` · ${s.join(` `)}`:``;n.textContent=`${i.decision} ${i.tool} · ${o}${l}${c}`,n.style.borderColor=a,n.style.color=a;let u=Math.min(e.clientX+14,window.innerWidth-420),d=Math.max(8,e.clientY-36);n.style.left=`${u}px`,n.style.top=`${d}px`,n.style.display=`block`},onMouseLeave:()=>{h.current=null,g.current&&(g.current.style.display=`none`)},onClick:e=>{i(ee(e.clientX,e.clientY),{x:e.clientX,y:e.clientY})}}),t.length===0&&(0,D.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none px-4 text-center`,children:[(0,D.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`graph · idle`}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[260px]`,children:[`Each dot = one tool call an AI agent made.`,(0,D.jsx)(`br`,{}),`Color = the ssg rule decision · line = same agent's sequence.`]})]}),(0,D.jsx)(`div`,{ref:g,style:{display:`none`,position:`fixed`,zIndex:45,fontSize:`11px`,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,padding:`4px 10px`,background:`rgba(10, 10, 15, 0.92)`,border:`1px solid`,borderRadius:`4px`,pointerEvents:`none`,whiteSpace:`nowrap`,maxWidth:`500px`,overflow:`hidden`,textOverflow:`ellipsis`}})]})}var ms=3e4,hs=6e4,gs=5e3;function _s(e,t){let n=t?e.filter(e=>Wa(e)===t):e,r=Date.now(),i=n.length>0?n[n.length-1]:null;if(!i||r-i.ts_ms>gs||!i)return{idle:!0,client:``,tool:``,ruleId:null,decision:``,evalsPerSec:`0.0`,allowPct:0,agents:0,topRules:[]};let a=n.filter(e=>r-e.ts_ms<=ms),o=a.filter(e=>e.decision===`allow`).length,s=a.length>0?Math.round(o/a.length*100):0,c=(a.length/(ms/1e3)).toFixed(1),l=new Set(a.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size,u=n.filter(e=>r-e.ts_ms<=hs&&e.rule_id),d=new Map;for(let e of u){let t=e.rule_id;t&&d.set(t,(d.get(t)??0)+1)}let f=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,4).map(([e])=>e);return{idle:!1,client:i.client,tool:i.tool,ruleId:i.rule_id,decision:i.decision,evalsPerSec:c,allowPct:s,agents:l,topRules:f}}var vs={allow:`ALLOW`,block:`BLOCK`,ask:`ASK`,log:`LOG`,force:`FORCE`,shadow:`SHADOW`},ys={allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`};function bs({className:e,sessionKey:t}){let n=Ha(),r=Ua(),i=(0,_.useRef)(-1),a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>{if(i.current===r&&a.current)return a.current;i.current=r;let e=_s(n,t);return a.current=e,e},[n,r,t]),s=o.decision?ys[o.decision]??`#6b7280`:`#6b7280`,c=o.decision?vs[o.decision]??o.decision:``,l=o.client?mo(o.client):``;return o.idle?(0,D.jsxs)(`div`,{className:Lr(`pointer-events-none select-none`,`flex items-center justify-center gap-2`,`px-4 py-2 rounded-sm`,`bg-[#0a0a0f]/95`,`border border-[var(--color-line-1,#242424)]`,`font-mono text-[11px] text-[var(--color-fg-4,#5a6071)]`,e),children:[(0,D.jsx)(`span`,{className:`status-dot bg-[var(--color-fg-4)] pulse-soft`}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider`,children:`waiting for activity`})]}):(0,D.jsxs)(`div`,{className:Lr(`pointer-events-none select-none`,`flex flex-col gap-1 px-4 py-2.5 rounded-sm`,`bg-[#0a0a0f]/96`,`border border-[var(--color-line-1,#242424)]`,`font-mono`,!t&&`min-w-[280px] max-w-[460px]`,e),children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest text-[var(--color-fg-4,#5a6071)]`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),(0,D.jsx)(`span`,{children:`now evaluating`}),(0,D.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[o.evalsPerSec,`/s · `,o.allowPct,`% allow · `,o.agents,` `,o.agents===1?`agent`:`agents`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px] text-[var(--color-fg-0,#f5f5f5)] tracking-tight`,children:[(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)] text-[11px] tabular-nums`,children:[`[`,l,`]`]}),(0,D.jsx)(`span`,{className:`text-sky-300`,children:o.client}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-white font-semibold`,children:o.tool}),o.ruleId&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`->`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] text-[12px]`,children:o.ruleId})]}),(0,D.jsx)(`span`,{className:`ml-auto text-[13px] font-bold tabular-nums`,style:{color:s},children:c})]}),o.topRules.length>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider text-[9px]`,children:`rules`}),o.topRules.map(e=>(0,D.jsx)(`span`,{className:`px-1 py-0.5 rounded-sm bg-[var(--color-surface-2,#121212)] text-[var(--color-fg-3)]`,children:e},e))]})]})}var xs=(0,_.memo)(function({sessionKey:e,bursts:t,activePanelCount:n,selectedId:r,onSelect:i}){let a=t.length>0?t[t.length-1]?.ts_ms??0:0,o=e.indexOf(`:`),s=o>=0?e.slice(0,o):e,c=o>=0?e.slice(o+1):``,l=c!==``&&c!==`solo`,u=t[t.length-1],d=u?Ga[u.decision]??`#6b7280`:`#6b7280`,f=(0,_.useMemo)(()=>t.length>24?t.slice(t.length-24):t,[t]);return(0,D.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 rounded-sm border border-[var(--color-line-1)] bg-black/30 overflow-hidden`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-[var(--color-line-1)] text-[10px] font-mono shrink-0`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:d},title:u?`latest decision: ${u.decision}`:``}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider truncate`,children:s}),l&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate`,children:c})]}),(0,D.jsxs)(`span`,{className:`ml-auto text-[var(--color-fg-4)] tabular-nums shrink-0`,children:[t.length,`n`]})]}),(0,D.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,D.jsx)(ps,{bursts:f,paused:!1,selectedId:r,onSelect:i,burstSeq:a,compact:!0,activePanelCount:n})})]})});function Ss(e){return e<=1?1:e<=4?2:3}function Cs(){let e=Ha(),t=Ua(),[n,r]=(0,_.useState)(null),{isBurstActive:i}=Z(),a=(0,_.useMemo)(()=>lo(e,i,Date.now()),[e,i]),o=(0,_.useRef)(new Map),s=(0,_.useMemo)(()=>{let e=new Map;for(let t of a){let n=Wa(t),r=e.get(n);r?r.push(t):e.set(n,[t])}let t=o.current;for(let[n,r]of e){let i=t.get(n);i&&i.length===r.length&&i[i.length-1]===r[r.length-1]&&e.set(n,i)}return o.current=e,Array.from(e.entries()).sort((e,t)=>{let n=e[1][e[1].length-1]?.ts_ms??0;return(t[1][t[1].length-1]?.ts_ms??0)-n})},[a]),c=(0,_.useMemo)(()=>{let e=new Map;for(let t of a){let n=`${t.client}:${t.agent_id??`solo`}`,r=e.get(n);r?r.count+=1:e.set(n,{client:t.client,count:1})}return e},[a]),l=(0,_.useMemo)(()=>{let e={allow:0,block:0,ask:0,other:0};for(let t of a)t.decision===`allow`?e.allow++:t.decision===`block`||t.decision===`force`?e.block++:t.decision===`ask`?e.ask++:e.other++;return e},[a]),u=(0,_.useMemo)(()=>{let e=new Set,t=0;for(let n of a)n.rule_id&&(e.add(n.rule_id),t+=1);return{distinct:e.size,matched:t,topRule:e.values().next().value}},[a]),d=Ss(s.length);return(0,D.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,D.jsxs)(`header`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-line-1)]`,children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`graph · live`}),(0,D.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),a.length]}),(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-mono`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Ga.allow}}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.allow}),(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ml-1`,style:{background:Ga.block}}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.block}),(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ml-1`,style:{background:Ga.ask}}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:l.ask})]}),(0,D.jsx)(`span`,{className:`flex-1`}),(0,D.jsxs)(`span`,{className:`chip text-violet-300 border-violet-500/30`,title:`${u.matched} tool calls matched ${u.distinct} ssg ${u.distinct===1?`rule`:`rules`} in active sessions`,children:[u.distinct,` `,u.distinct===1?`rule`:`rules`]}),(0,D.jsxs)(`span`,{className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)]`,title:c.size===0?`no active agents`:Array.from(c.entries()).map(([e,t])=>`${e}: ${t.count}`).join(`
12
+ `),children:[c.size,` `,c.size===1?`agent`:`agents`]}),(0,D.jsx)(`a`,{href:`/graph`,className:`text-[10px] font-mono uppercase tracking-wider text-sky-300 hover:text-sky-200`,title:`Open full /graph page`,children:`expand ↗`})]}),(0,D.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[s.length===0?(0,D.jsx)(ps,{bursts:a,paused:!1,selectedId:n,onSelect:r,burstSeq:t}):(0,D.jsx)(`div`,{className:`absolute inset-0 grid gap-1 p-1`,style:{gridTemplateColumns:`repeat(${d}, minmax(0, 1fr))`,gridAutoRows:`1fr`},children:s.map(([e,t])=>(0,D.jsx)(xs,{sessionKey:e,bursts:t,activePanelCount:s.length,selectedId:n,onSelect:r},e))}),(0,D.jsx)(bs,{className:`absolute bottom-2 left-2 z-10 max-w-[calc(100%-1rem)]`})]})]})}function ws(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function Ts(e){return{id:e.id,x:e.x,y:e.y,w:e.w,h:e.h}}function Es(e,t){let n=[Ts(e)],r=t.map(Ts);r.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y);for(let e of r){for(;;){let t=!1;for(let r of n)if(ws(e,r)){let n=r.y+r.h;n>e.y&&(e.y=n,t=!0)}if(!t)break}n.push(e)}return n}function Ds(e){if(e.length===0)return[];let t=[...e].map(Ts).sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y),n=[];for(let e of t){let t=!0;for(;t;){t=!1;for(let r of n)ws(e,r)&&(e.y=r.y+r.h,t=!0)}n.push(e)}return n}function Os(e,t,n){let r=e.findIndex(e=>e.id===t);if(r===-1)return{panels:e.map(Ts)};let i=Es({id:e[r]?.id,x:n.x,y:n.y,w:n.w,h:n.h},e.filter((e,t)=>t!==r)),a=new Map(i.map(e=>[e.id,e]));return{panels:Ds(e.map(e=>a.get(e.id)).filter(Boolean))}}var ks=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),As=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),js=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Ms=e=>{let t=js(e);return t.charAt(0).toUpperCase()+t.slice(1)},Ns={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ps=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Fs=(0,_.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,_.createElement)(`svg`,{ref:c,...Ns,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ks(`lucide`,i),...!a&&!Ps(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Is=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(Fs,{ref:i,iconNode:t,className:ks(`lucide-${As(Ms(e))}`,`lucide-${e}`,n),...r}));return n.displayName=Ms(e),n},Ls=Is(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Rs=Is(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),zs=Is(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),Bs=Is(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Vs=Is(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Hs=Is(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Us=Is(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Ws=Is(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Gs=Is(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ks=[`hero-metrics`,`graph`,`latency-trace`,`throughput`,`decision-mix`,`telemetry-feed`,`system-pulse`,`pending-approvals`,`recent-blocks`],qs={"hero-metrics":`Hero metrics`,graph:`Graph intelligence`,"latency-trace":`Latency trace`,throughput:`Throughput`,"decision-mix":`Decision mix`,"telemetry-feed":`Telemetry feed`,"system-pulse":`System pulse`,"pending-approvals":`Pending approvals`,"recent-blocks":`Recent blocks`},Js={"hero-metrics":{minW:6,minH:2,defaultW:12,defaultH:2},graph:{minW:4,minH:3,defaultW:8,defaultH:5},"latency-trace":{minW:4,minH:3,defaultW:8,defaultH:4},throughput:{minW:2,minH:2,defaultW:4,defaultH:2},"decision-mix":{minW:2,minH:2,defaultW:4,defaultH:2},"telemetry-feed":{minW:6,minH:3,defaultW:12,defaultH:4},"system-pulse":{minW:4,minH:3,defaultW:12,defaultH:3},"pending-approvals":{minW:3,minH:2,defaultW:6,defaultH:3},"recent-blocks":{minW:3,minH:2,defaultW:6,defaultH:3}};function Ys({panel:e,isEditing:t,children:n,drag:r}){let i=(0,_.useRef)(null),a={gridColumn:`${e.x+1} / span ${e.w}`,gridRow:`${e.y+1} / span ${e.h}`};return(0,D.jsxs)(`div`,{ref:i,className:`grid-panel ${t?`grid-panel--edit`:``}`,style:a,role:t?`region`:void 0,"aria-label":t?qs[e.id]:void 0,tabIndex:t?0:void 0,onKeyDown:t?t=>r.onPanelKeyDown(t,e.id):void 0,"data-panel-id":e.id,children:[t&&(0,D.jsx)(`button`,{type:`button`,className:`grid-panel__drag-handle`,title:`Drag ${qs[e.id]} (or Arrow keys)`,"aria-label":`Drag ${qs[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onDragPointerDown(t,e.id,n)},children:(0,D.jsx)(zs,{size:12,strokeWidth:2})}),(0,D.jsx)(`div`,{className:`grid-panel__content`,"data-reveal":t?void 0:``,children:n}),t&&(0,D.jsx)(`button`,{type:`button`,className:`grid-panel__resize-handle`,title:`Resize ${qs[e.id]} (or Shift+Arrow keys)`,"aria-label":`Resize ${qs[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onResizePointerDown(t,e.id,n)},children:(0,D.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":!0,children:[(0,D.jsx)(`path`,{d:`M10 0 L10 10 L0 10 Z`,fill:`currentColor`,fillOpacity:`0.4`}),(0,D.jsx)(`path`,{d:`M3 10 L10 3 M6 10 L10 6 M9 10 L10 9`,stroke:`currentColor`,strokeWidth:`0.8`,fill:`none`})]})})]})}var Xs=(0,_.memo)(Ys);function Zs(e){let t=getComputedStyle(e),n=e.getBoundingClientRect(),r=parseFloat(t.rowGap||t.gap||`0`)||0,i=r*11;return{cellWidthPx:(n.width-i)/12+r,cellHeightPx:72+r}}function Qs(e){let t=(0,_.useRef)(null),n=(0,_.useRef)(e);n.current=e;let r=(0,_.useCallback)(()=>{let e=t.current;if(e){e.element.style.transform=``,e.element.style.width=``,e.element.style.height=``,e.element.style.zIndex=``,e.element.classList.remove(`grid-panel--dragging`),e.element.classList.remove(`grid-panel--resizing`);try{e.element.releasePointerCapture(e.pointerId)}catch{}t.current=null}},[]);(0,_.useEffect)(()=>{function e(e){let n=t.current;if(!n||e.pointerId!==n.pointerId)return;let r=e.clientX-n.startPointerX,i=e.clientY-n.startPointerY;if(n.mode===`drag`)n.element.style.transform=`translate3d(${r}px, ${i}px, 0)`;else{let e=Js[n.startPanel.id],t=e.minW*n.cellWidthPx-n.cellWidthPx+40,a=e.minH*n.cellHeightPx-n.cellHeightPx+40,o=Math.max(t,n.startRectW+r),s=Math.max(a,n.startRectH+i);n.element.style.width=`${o}px`,n.element.style.height=`${s}px`}}function i(e,t,n){let r=Js[e.startPanel.id];if(e.mode===`drag`){let r=Math.round(t/e.cellWidthPx),i=Math.round(n/e.cellHeightPx),a=e.startPanel.x+r,o=e.startPanel.y+i;return a<0&&(a=0),a+e.startPanel.w>12&&(a=12-e.startPanel.w),o<0&&(o=0),{id:e.id,x:a,y:o,w:e.startPanel.w,h:e.startPanel.h}}let i=Math.round(t/e.cellWidthPx),a=Math.round(n/e.cellHeightPx),o=e.startPanel.w+i,s=e.startPanel.h+a;return o<r.minW&&(o=r.minW),s<r.minH&&(s=r.minH),e.startPanel.x+o>12&&(o=12-e.startPanel.x),{id:e.id,x:e.startPanel.x,y:e.startPanel.y,w:o,h:s}}function a(e){let a=t.current;if(!a||e.pointerId!==a.pointerId)return;let o=i(a,e.clientX-a.startPointerX,e.clientY-a.startPointerY);r(),o.x===a.startPanel.x&&o.y===a.startPanel.y&&o.w===a.startPanel.w&&o.h===a.startPanel.h||n.current.onCommit(o)}function o(e){let n=t.current;!n||e.pointerId!==n.pointerId||r()}function s(e){e.key===`Escape`&&t.current&&r()}function c(){document.visibilityState===`hidden`&&t.current&&r()}return document.addEventListener(`pointermove`,e),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,o),document.addEventListener(`keydown`,s),document.addEventListener(`visibilitychange`,c),()=>{document.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,o),document.removeEventListener(`keydown`,s),document.removeEventListener(`visibilitychange`,c),t.current&&r()}},[r]);let i=(0,_.useCallback)((e,r,i,a)=>{if(!n.current.enabled||t.current)return;let o=n.current.getPanel(r),s=n.current.gridRef.current;if(!o||!s)return;e.preventDefault(),e.stopPropagation();let{cellWidthPx:c,cellHeightPx:l}=Zs(s),u=i.getBoundingClientRect();t.current={id:r,mode:a,startPointerX:e.clientX,startPointerY:e.clientY,startPanel:o,element:i,cellWidthPx:c,cellHeightPx:l,pointerId:e.pointerId,startRectW:u.width,startRectH:u.height},i.classList.add(a===`drag`?`grid-panel--dragging`:`grid-panel--resizing`),i.style.zIndex=`10`;try{i.setPointerCapture(e.pointerId)}catch{}},[]);return{onDragPointerDown:(0,_.useCallback)((e,t,n)=>i(e,t,n,`drag`),[i]),onResizePointerDown:(0,_.useCallback)((e,t,n)=>i(e,t,n,`resize`),[i]),onPanelKeyDown:(0,_.useCallback)((e,t)=>{if(!n.current.enabled)return;let r=n.current.getPanel(t);if(!r)return;let i=e.shiftKey,a=0,o=0;switch(e.key){case`ArrowLeft`:a=-1;break;case`ArrowRight`:a=1;break;case`ArrowUp`:o=-1;break;case`ArrowDown`:o=1;break;default:return}e.preventDefault(),e.stopPropagation();let s=Js[t];if(i){let e=r.w+a,i=r.h+o;if(e<s.minW&&(e=s.minW),i<s.minH&&(i=s.minH),r.x+e>12&&(e=12-r.x),e===r.w&&i===r.h)return;n.current.onCommit({id:t,x:r.x,y:r.y,w:e,h:i})}else{let e=r.x+a,i=r.y+o;if(e<0&&(e=0),e+r.w>12&&(e=12-r.w),i<0&&(i=0),e===r.x&&i===r.y)return;n.current.onCommit({id:t,x:e,y:i,w:r.w,h:r.h})}},[]),isGesturing:(0,_.useCallback)(()=>t.current!==null,[])}}function $s({panels:e,isEditing:t,renderers:n,onPanelsChange:r}){let i=(0,_.useRef)(null),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n);return t},[e]),s=Qs({gridRef:i,getPanel:(0,_.useCallback)(e=>o.get(e),[o]),onCommit:(0,_.useCallback)(e=>{let t=a.current,{panels:n}=Os(t,e.id,{x:e.x,y:e.y,w:e.w,h:e.h});r(n)},[r]),enabled:t});return(0,D.jsx)(`div`,{ref:i,className:`grid-layout ${t?`grid-layout--editing`:``}`,"aria-live":t?`polite`:void 0,children:e.map(e=>(0,D.jsx)(Xs,{panel:e,isEditing:t,drag:s,children:n[e.id]()},e.id))})}function ec({manager:e,isEditing:t,onToggleEditing:n}){let{config:r,activeLayout:i,canAddUserLayout:a,saveError:o,selectLayout:s,saveAs:c,renameActive:l,deleteLayout:u,resetActive:d,exportConfig:f,importConfig:p}=e,[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(i.name),[T,E]=(0,_.useState)(!1),[O,k]=(0,_.useState)(!1),A=(0,_.useRef)(null);(0,_.useEffect)(()=>{w(i.name)},[i.name]),(0,_.useEffect)(()=>{o&&h(o)},[o]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]);function j(){y.trim()&&(c(y.trim()),b(``),v(!1),h(`Saved "${y.trim()}"`))}function M(){C.trim()&&(l(C.trim()),S(!1),h(`Renamed`))}function N(){let e=i.name;u(i.id),k(!1),h(`Deleted "${e}"`)}function ee(){d(),E(!1),h(`Reset to default`)}function te(){let e=f(),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=new Date().toISOString().slice(0,10),i=document.createElement(`a`);i.href=n,i.download=`ssg-layout-${r}.json`,i.click(),URL.revokeObjectURL(n),h(`Layout exported`)}function P(e){let t=e.target.files?.[0];e.target.value=``,t&&t.text().then(e=>{h(p(e).message)}).catch(()=>h(`Import failed: could not read file`))}return(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,D.jsx)(`span`,{className:`overline shrink-0`,children:`layout`}),(0,D.jsxs)(`select`,{value:r.activeLayoutId,onChange:e=>s(e.target.value),className:`bg-[var(--color-surface-2)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[11px] font-mono text-[var(--color-fg-1)] hover:border-[var(--color-line-2)] focus:outline-none focus:ring-1 focus:ring-[var(--color-brand)] cursor-pointer`,"aria-label":`Select layout`,children:[(0,D.jsx)(`optgroup`,{label:`Built-in`,children:r.layouts.filter(e=>e.builtIn).map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))}),r.layouts.some(e=>!e.builtIn)&&(0,D.jsx)(`optgroup`,{label:`Your layouts`,children:r.layouts.filter(e=>!e.builtIn).map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),i.builtIn&&(0,D.jsx)(`span`,{className:`chip text-[var(--color-fg-3)]`,title:`Built-in preset`,children:`built-in`})]}),(0,D.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>v(!0),disabled:!a,title:a?`Save the current arrangement as a new preset`:`Layout limit reached — delete one first`,children:[(0,D.jsx)(Hs,{size:11,strokeWidth:2.25}),`Save as`]}),!i.builtIn&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>{w(i.name),S(!0)},children:[(0,D.jsx)(Bs,{size:11,strokeWidth:2.25}),`Rename`]}),(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>k(!0),children:[(0,D.jsx)(Us,{size:11,strokeWidth:2.25}),`Delete`]})]}),(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),title:`Replace the current layout with the Default preset`,children:[(0,D.jsx)(Vs,{size:11,strokeWidth:2.25}),`Reset`]}),(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:te,title:`Download current layouts as JSON`,children:[(0,D.jsx)(Rs,{size:11,strokeWidth:2.25}),`Export`]}),(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>A.current?.click(),title:`Load layouts from a JSON file`,children:[(0,D.jsx)(Ws,{size:11,strokeWidth:2.25}),`Import`]}),(0,D.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,onChange:P,className:`hidden`,"aria-hidden":!0}),(0,D.jsxs)(q,{variant:`primary`,size:`sm`,onClick:()=>n(!1),children:[(0,D.jsx)(Ls,{size:11,strokeWidth:2.5}),`Done`]})]}):(0,D.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>n(!0),children:[(0,D.jsx)(Bs,{size:11,strokeWidth:2.25}),`Edit layout`]})}),g&&(0,D.jsx)(tc,{title:`Save layout as`,value:y,placeholder:`My dashboard`,onChange:b,onConfirm:j,onCancel:()=>{v(!1),b(``)},confirmLabel:`Save`}),x&&(0,D.jsx)(tc,{title:`Rename layout`,value:C,placeholder:i.name,onChange:w,onConfirm:M,onCancel:()=>S(!1),confirmLabel:`Rename`}),T&&(0,D.jsx)(nc,{title:`Reset this layout?`,body:`The current arrangement will be replaced with the Default preset. Saved layouts are not affected.`,confirmLabel:`Reset`,onConfirm:ee,onCancel:()=>E(!1),destructive:!1}),O&&(0,D.jsx)(nc,{title:`Delete "${i.name}"?`,body:`This layout will be removed. You can always recreate it via Save as.`,confirmLabel:`Delete`,onConfirm:N,onCancel:()=>k(!1),destructive:!0}),m&&(0,D.jsx)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 -translate-x-1/2 z-50 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-3)] px-3 py-2 text-[11px] font-mono text-[var(--color-fg-1)] shadow-lg`,children:m})]})}function tc({title:e,value:t,placeholder:n,onChange:r,onConfirm:i,onCancel:a,confirmLabel:o}){return(0,D.jsx)(`div`,{role:`dialog`,"aria-modal":!0,"aria-label":e,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:a,children:(0,D.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`w-80 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-2)] p-4`,children:[(0,D.jsx)(`div`,{className:`overline mb-2`,children:e}),(0,D.jsx)(`input`,{value:t,onChange:e=>r(e.target.value),placeholder:n,onKeyDown:e=>{e.key===`Enter`&&i(),e.key===`Escape`&&a()},className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5 text-[13px] font-mono text-[var(--color-fg-1)] focus:outline-none focus:border-[var(--color-brand)]`}),(0,D.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:a,children:[(0,D.jsx)(Gs,{size:11,strokeWidth:2.25}),`Cancel`]}),(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:i,children:o})]})]})})}function nc({title:e,body:t,confirmLabel:n,destructive:r,onConfirm:i,onCancel:a}){return(0,D.jsx)(`div`,{role:`dialog`,"aria-modal":!0,"aria-label":e,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:a,children:(0,D.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`w-96 rounded-sm border border-[var(--color-line-2)] bg-[var(--color-surface-2)] p-4`,children:[(0,D.jsx)(`div`,{className:`overline mb-2`,children:e}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:t}),(0,D.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,D.jsx)(q,{variant:r?`danger`:`primary`,size:`sm`,onClick:i,children:n})]})]})})}var rc={default:`builtin-default`,focusLatency:`builtin-focus-latency`,focusApprovals:`builtin-focus-approvals`,compact:`builtin-compact`},ic={id:rc.default,name:`Default`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`graph`,x:0,y:2,w:8,h:5},{id:`latency-trace`,x:8,y:2,w:4,h:3},{id:`throughput`,x:8,y:5,w:2,h:2},{id:`decision-mix`,x:10,y:5,w:2,h:2},{id:`telemetry-feed`,x:0,y:7,w:12,h:3},{id:`system-pulse`,x:0,y:10,w:12,h:3},{id:`pending-approvals`,x:0,y:13,w:6,h:3},{id:`recent-blocks`,x:6,y:13,w:6,h:3}]},ac={id:rc.focusLatency,name:`Focus · Latency`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`latency-trace`,x:0,y:2,w:8,h:5},{id:`graph`,x:8,y:2,w:4,h:5},{id:`throughput`,x:0,y:7,w:6,h:2},{id:`decision-mix`,x:6,y:7,w:6,h:2},{id:`system-pulse`,x:0,y:9,w:12,h:3},{id:`telemetry-feed`,x:0,y:12,w:12,h:3},{id:`pending-approvals`,x:0,y:15,w:6,h:2},{id:`recent-blocks`,x:6,y:15,w:6,h:2}]},oc={id:rc.focusApprovals,name:`Focus · Approvals`,builtIn:!0,panels:[{id:`pending-approvals`,x:0,y:0,w:8,h:4},{id:`graph`,x:8,y:0,w:4,h:4},{id:`recent-blocks`,x:0,y:4,w:12,h:3},{id:`hero-metrics`,x:0,y:7,w:12,h:2},{id:`latency-trace`,x:0,y:9,w:6,h:3},{id:`telemetry-feed`,x:6,y:9,w:6,h:3},{id:`system-pulse`,x:0,y:12,w:12,h:3},{id:`throughput`,x:0,y:15,w:6,h:2},{id:`decision-mix`,x:6,y:15,w:6,h:2}]},sc={id:rc.compact,name:`Compact`,builtIn:!0,panels:[{id:`hero-metrics`,x:0,y:0,w:12,h:2},{id:`graph`,x:0,y:2,w:8,h:3},{id:`latency-trace`,x:8,y:2,w:4,h:3},{id:`system-pulse`,x:0,y:5,w:12,h:3},{id:`throughput`,x:0,y:8,w:4,h:2},{id:`decision-mix`,x:4,y:8,w:4,h:2},{id:`telemetry-feed`,x:0,y:10,w:12,h:3},{id:`pending-approvals`,x:0,y:13,w:6,h:2},{id:`recent-blocks`,x:6,y:13,w:6,h:2}]},cc=Object.freeze([ic,ac,oc,sc]);function lc(){return cc.map(e=>({...e,panels:e.panels.map(e=>({...e}))}))}function uc(){return{version:1,activeLayoutId:rc.default,layouts:lc()}}function dc(e){return Object.values(rc).includes(e)}var fc=new Set(Ks),pc=new Set(cc.map(e=>e.id));function mc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hc(e,t,n,r){if(typeof e!=`number`||!Number.isFinite(e))return r;let i=Math.floor(e);return i<t?t:i>n?n:i}function gc(e,t){let n=(typeof e==`string`?e:``).replace(/[\u0000-\u001F\u007F]/g,``).trim();return n.length===0?t:n.slice(0,40)}function _c(e){let t=e.find(e=>e.id===`system-pulse`);if(!t||t.h>=3)return e;let n=3-t.h,r=t.y+t.h;return e.map(e=>e.id===`system-pulse`?{...e,h:3}:e.y>=r?{...e,y:e.y+n}:e)}function vc(e){for(let t=0;t<e.length;t++){let n=e[t];for(let r=t+1;r<e.length;r++){let t=e[r];if(n.x<t.x+t.w&&n.x+n.w>t.x&&n.y<t.y+t.h&&n.y+n.h>t.y)return!0}}return!1}function yc(e){if(!mc(e))return null;let{id:t}=e;if(typeof t!=`string`||!fc.has(t))return null;let n=t,r=Js[n],i=hc(e.x,0,11,0),a=hc(e.w,r.minW,12,r.defaultW);return{id:n,x:i+a>12?12-a:i,y:hc(e.y,0,999,0),w:a,h:hc(e.h,r.minH,99,r.defaultH)}}function bc(e,t){if(!mc(e))return{layout:null,droppedPanels:0};let n=typeof e.id==`string`&&e.id.length>0?e.id:null;if(!n)return{layout:null,droppedPanels:0};let r=gc(e.name,t),i=pc.has(n),a=e.panels;if(!Array.isArray(a))return{layout:null,droppedPanels:0};let o=new Set,s=[],c=0;for(let e of a){let t=yc(e);if(!t){c+=1;continue}if(o.has(t.id)){c+=1;continue}o.add(t.id),s.push(t)}return s.length===0?{layout:null,droppedPanels:c}:{layout:{id:n,name:r,builtIn:i,panels:_c(s)},droppedPanels:c}}function xc(e){if(!mc(e)||e.version!==1)return{config:uc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let t=e.layouts;if(!Array.isArray(t)||t.length===0)return{config:uc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let n=[],r=0,i=0,a=0;for(let e of t){let{layout:t,droppedPanels:o}=bc(e,`Layout ${n.length+1}`);if(r+=o,t){if(!t.builtIn){if(i>=12){a+=1;continue}i+=1}n.push(t)}}if(n.length===0)return{config:uc(),droppedPanels:r,prunedLayouts:a,fellBackToDefault:!0};let o=new Set(n.map(e=>e.id));for(let e of cc)o.has(e.id)||n.push({...e,panels:e.panels.map(e=>({...e}))});let s=new Map(cc.map(e=>[e.id,e])),c=0,l=0;for(let e=0;e<n.length;e++){let t=n[e],r=s.get(t.id);if(!r)continue;if(vc(t.panels)){n[e]={...r,panels:r.panels.map(e=>({...e}))},l+=1;continue}let i=new Set(t.panels.map(e=>e.id)),a=r.panels.filter(e=>!i.has(e.id));if(a.length===0)continue;let o=t.panels.reduce((e,t)=>Math.max(e,t.y+t.h),0);for(let e of a)t.panels.push({id:e.id,x:0,y:o,w:e.w,h:e.h}),o+=e.h,c+=1}let u=e.activeLayoutId;return{config:{version:1,activeLayoutId:typeof u==`string`&&n.some(e=>e.id===u)?u:cc[0]?.id,layouts:n},droppedPanels:r,prunedLayouts:a,fellBackToDefault:!1,backfilledPanels:c,refreshedBuiltins:l}}var Sc=`ssg:dashboard-layout:v1`,Cc=300;function wc(){if(typeof localStorage>`u`)return null;try{let e=`__ssg_probe__`;return localStorage.setItem(e,`1`),localStorage.removeItem(e),localStorage}catch{return null}}var Tc;function Ec(){return Tc===void 0&&(Tc=wc()),Tc}function Dc(){let e=Ec();if(!e)return{config:uc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let t=null;try{t=e.getItem(Sc)}catch{t=null}if(t===null)return{config:uc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let n=null;try{n=JSON.parse(t)}catch{return{config:uc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0}}return xc(n)}var Oc=null,kc=null,Ac=null;function jc(e){return Ac=e,()=>{Ac===e&&(Ac=null)}}function Mc(e){Ac?Ac(e):typeof console<`u`&&console.warn(`[ssg-layout]`,e)}function Nc(){if(kc=null,!Oc)return;let e=Ec();if(!e){Oc=null;return}let t=Oc;Oc=null;try{e.setItem(Sc,JSON.stringify(t))}catch(e){e instanceof Error&&e.name===`QuotaExceededError`?Mc(`Layout storage full — save skipped`):Mc(`Layout save failed: ${e instanceof Error?e.message:String(e)}`)}}function Pc(e){Oc=e,kc===null&&(kc=setTimeout(Nc,Cc))}function Fc(e){Oc=e,kc!==null&&(clearTimeout(kc),kc=null),Nc()}function Ic(e){let t=0;for(let n of e.layouts)n.builtIn||(t+=1);return t}function Lc(e){return e.map(e=>({...e}))}function Rc(){return`user-${Math.random().toString(16).slice(2,11)}`}function zc(){let[e,t]=(0,_.useState)(()=>Dc().config),[n,r]=(0,_.useState)(null);(0,_.useEffect)(()=>jc(e=>r(e)),[]),(0,_.useEffect)(()=>{Pc(e)},[e]);let i=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0]??lc()[0],a=Ic(e)<12,o=(0,_.useCallback)(e=>{t(t=>t.layouts.some(t=>t.id===e)?{...t,activeLayoutId:e}:t)},[]),s=(0,_.useCallback)(e=>{t(t=>{let n=t.activeLayoutId;return{...t,layouts:t.layouts.map(t=>t.id===n?{...t,panels:Lc(e)}:t)}})},[]),c=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>{if(Ic(e)>=12)return e;let t=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0];if(!t)return e;let r={id:Rc(),name:n,builtIn:!1,panels:Lc(t.panels)};return{...e,activeLayoutId:r.id,layouts:[...e.layouts,r]}})},[]),l=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>({...e,layouts:e.layouts.map(t=>t.id===e.activeLayoutId&&!t.builtIn?{...t,name:n}:t)}))},[]),u=(0,_.useCallback)(e=>{t(t=>{let n=t.layouts.find(t=>t.id===e);if(!n||n.builtIn)return t;let r=t.layouts.filter(t=>t.id!==e),i=t.activeLayoutId===e?r[0]?.id??cc[0]?.id:t.activeLayoutId;return{...t,activeLayoutId:i,layouts:r}})},[]),d=(0,_.useCallback)(()=>{t(e=>{let t=e.layouts.find(t=>t.id===e.activeLayoutId);if(!t)return e;let n=dc(t.id)?cc.find(e=>e.id===t.id):cc[0];return n?{...e,layouts:e.layouts.map(e=>e.id===t.id?{...e,panels:Lc(n.panels)}:e)}:e})},[]),f=(0,_.useCallback)(()=>JSON.stringify(e,null,2),[e]),p=(0,_.useCallback)(e=>{let n;try{n=JSON.parse(e)}catch{return{ok:!1,message:`Import failed: not valid JSON`}}let r=xc(n);if(r.fellBackToDefault)return{ok:!1,message:`Import rejected: schema invalid, no changes applied`};t(r.config),Fc(r.config);let i=[`Layout imported`];return r.droppedPanels>0&&i.push(`${r.droppedPanels} unrecognized panel(s) dropped`),r.prunedLayouts>0&&i.push(`${r.prunedLayouts} excess layout(s) pruned`),{ok:!0,message:i.join(` · `)}},[]);return(0,_.useEffect)(()=>{e.layouts.length===0&&t(uc())},[e.layouts.length]),{config:e,activeLayout:i,canAddUserLayout:a,saveError:n,selectLayout:o,updateActivePanels:s,saveAs:c,renameActive:l,deleteLayout:u,resetActive:d,exportConfig:f,importConfig:p}}var Bc=[`rules-changed`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`],Vc={critical:{border:`border-l-red-500/70`,iconBg:`bg-red-500/15`,iconFg:`text-red-400`,chipBg:`bg-red-500/10`,chipFg:`text-red-300`,label:`Critical`},warning:{border:`border-l-amber-400/70`,iconBg:`bg-amber-500/15`,iconFg:`text-amber-300`,chipBg:`bg-amber-500/10`,chipFg:`text-amber-200`,label:`Heads up`},info:{border:`border-l-sky-500/70`,iconBg:`bg-sky-500/15`,iconFg:`text-sky-300`,chipBg:`bg-sky-500/10`,chipFg:`text-sky-200`,label:`Tip`}};function Hc({severity:e}){return e===`critical`?(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}):e===`warning`?(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,D.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}):(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,D.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`})]})}function Uc({notification:e,onAction:t}){let[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(null),o=Vc[e.severity],s=async()=>{if(e.action&&!(e.action.confirm&&!confirm(e.action.confirm))){r(`loading`),a(null);try{await t(e),r(`done`)}catch(e){r(`error`),a(e instanceof Error?e.message:String(e))}}};return(0,D.jsxs)(`div`,{className:`hig-card border-l-2 ${o.border} flex items-start gap-3 px-3 py-2.5`,children:[(0,D.jsx)(`span`,{className:`shrink-0 mt-0.5 inline-flex items-center justify-center w-6 h-6 rounded-full ${o.iconBg} ${o.iconFg}`,"aria-hidden":!0,children:(0,D.jsx)(Hc,{severity:e.severity})}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`text-[9px] font-mono font-medium uppercase tracking-wider px-1.5 py-0.5 rounded ${o.chipBg} ${o.chipFg}`,children:o.label}),(0,D.jsx)(`h3`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-tight`,children:e.title})]}),(0,D.jsx)(`p`,{className:`mt-1 text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:e.detail}),n===`error`&&i&&(0,D.jsxs)(`p`,{className:`mt-1.5 text-[11px] font-mono text-red-300`,children:[`Failed: `,i]}),n===`done`&&(0,D.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-emerald-300`,children:`✓ Done — refreshing…`})]}),(0,D.jsx)(`div`,{className:`shrink-0 self-center`,children:e.action?(0,D.jsx)(`button`,{type:`button`,onClick:s,disabled:n===`loading`||n===`done`,className:`inline-flex items-center gap-1 h-8 px-3 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-[var(--color-surface-2)] text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:bg-[var(--color-surface-3)] hover:border-[var(--color-line-2)] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:n===`loading`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`animate-spin`,children:`⟳`}),` working…`]}):n===`done`?(0,D.jsx)(D.Fragment,{children:`✓ done`}):e.action.label}):e.link?(0,D.jsxs)(`a`,{href:e.link.href,className:`inline-flex items-center gap-1 h-8 px-3 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-[var(--color-surface-2)] text-[var(--color-fg-1)] border border-[var(--color-line-1)] hover:bg-[var(--color-surface-3)] hover:border-[var(--color-line-2)] transition-colors whitespace-nowrap`,children:[e.link.label,` →`]}):null})]})}function Wc({showEmptyState:e=!1,hideHeader:t=!1}={}){let n=Nt(Bc),{data:r,refetch:i}=V(`/api/json/maintenance`,[n[`rules-changed`],n[`activity-updated`],n[`pending-changed`],n[`runtime-tick`],n[`limits-breach`]]),a=async e=>{if(!e.action)return;let t=await fetch(e.action.url,{method:e.action.method,headers:{Accept:`application/json`,"Content-Type":`application/json`,...H()}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(e||`HTTP ${t.status}`)}setTimeout(()=>i(),600)},o=r?.notifications??[];return o.length===0&&!e?null:(0,D.jsxs)(`section`,{"data-reveal":!0,children:[!t&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,D.jsx)(`h2`,{className:`overline text-[11px]`,children:o.length===0?`maintenance · all clear`:`maintenance · ${o.length} item${o.length===1?``:`s`}`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] transition-colors cursor-pointer`,title:`Re-check now`,children:`refresh`})]}),o.length===0?(0,D.jsxs)(`div`,{className:`hig-card border-l-2 border-l-emerald-500/60 px-4 py-5 flex items-center gap-3`,children:[(0,D.jsx)(`span`,{className:`inline-flex items-center justify-center w-8 h-8 rounded-full bg-emerald-500/15 text-emerald-300 shrink-0`,children:(0,D.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M20 6L9 17l-5-5`})})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-tight`,children:`Everything looks good`}),(0,D.jsx)(`p`,{className:`mt-1 text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:`No drift, no capacity warnings, no stalled daemons. We'll let you know if anything changes.`})]})]}):(0,D.jsx)(`div`,{className:`space-y-2`,children:o.map(e=>(0,D.jsx)(Uc,{notification:e,onAction:a},e.id))})]})}var Gc=e=>Math.round(e).toLocaleString(void 0,{useGrouping:!0});function Kc(e,t){if(e===`spring`){let e=ui();return{ease:e.fn,durationMs:e.duration}}return e===`quart`?{ease:Kr.out,durationMs:t}:{ease:Gr.out,durationMs:t}}function qc({value:e,duration:t=320,format:n=Gc,className:r,curve:i=`cubic`}){let[a,o]=(0,_.useState)(e),s=(0,_.useRef)(e),c=(0,_.useRef)(e),l=(0,_.useRef)(0),u=(0,_.useRef)(null),d=(0,_.useRef)(vi()),f=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(c.current===e)return;let n=f.current;if(n&&!d.current){for(let e of n.getAnimations())e.id===`lc-value-pulse`&&e.cancel();let e=n.animate([{textShadow:`0 0 0 rgba(245, 158, 11, 0)`},{textShadow:`0 0 10px rgba(245, 158, 11, 0.55)`,offset:.2},{textShadow:`0 0 0 rgba(245, 158, 11, 0)`}],{duration:520,easing:`ease-out`});e.id=`lc-value-pulse`}if(d.current){c.current=e,s.current=e,o(e);return}s.current=a,c.current=e,l.current=performance.now(),u.current!==null&&cancelAnimationFrame(u.current);let{ease:r,durationMs:p}=Kc(i,t),m=e=>{let t=Math.min(1,(e-l.current)/p),n=r(t);o(s.current+(c.current-s.current)*n),t<1?u.current=requestAnimationFrame(m):u.current=null};return u.current=requestAnimationFrame(m),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,i,a]),(0,D.jsx)(`span`,{ref:f,className:Lr(`tabular-nums`,r),children:n(a)})}function Jc({counters:e,className:t,showLegend:n=!0}){let r=[{key:`allow`,label:`Allow`,value:e.allow,color:`var(--color-decision-allow)`,textClass:`text-emerald-300`},{key:`ask`,label:`Ask`,value:e.ask,color:`var(--color-decision-ask)`,textClass:`text-amber-300`},{key:`block`,label:`Block`,value:e.block,color:`var(--color-decision-block)`,textClass:`text-red-300`},{key:`force`,label:`Force`,value:e.force,color:`var(--color-decision-force)`,textClass:`text-sky-300`},{key:`log`,label:`Log`,value:e.log,color:`var(--color-decision-log)`,textClass:`text-violet-300`},{key:`shadow`,label:`Shadow`,value:e.shadow,color:`var(--color-decision-shadow)`,textClass:`text-[var(--color-fg-3)]`}],i=r.reduce((e,t)=>e+t.value,0),a=(0,_.useRef)(null),o=(0,_.useRef)({});return(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let t=e.querySelectorAll(`[data-seg]`);if(t.length===0)return;let n=vi();t.forEach(e=>{let t=e.dataset.seg,a=r.find(e=>e.key===t);if(!a)return;let s=i===0?0:a.value/i*100,c=o.current[t]??0;n||Math.abs(c-s)<.01?e.style.width=`${s}%`:Ii(e,{width:[`${c}%`,`${s}%`],duration:480,ease:`outExpo`}),o.current[t]=s})},[i,r.find]),(0,D.jsxs)(`div`,{className:Lr(`flex flex-col gap-2`,t),children:[(0,D.jsx)(`div`,{ref:a,className:`flex h-3 w-full overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-2)]`,children:i===0?(0,D.jsx)(`div`,{className:`w-full bg-[var(--color-surface-3)]`}):r.map(e=>(0,D.jsx)(`div`,{"data-seg":e.key,style:{width:`${i===0?0:e.value/i*100}%`,background:e.color}},e.key))}),n?(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] font-mono`,children:r.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,D.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-sm`,style:{background:e.color}}),(0,D.jsx)(`span`,{className:Lr(`uppercase tracking-wide truncate`,e.textClass),children:e.label})]}),(0,D.jsx)(qc,{value:e.value,className:`shrink-0 tabular-nums text-[var(--color-fg-1)]`})]},e.key))}):null]})}function Yc({data:e,width:t=80,height:n=24,color:r=`#38bdf8`,threshold:i,maxValue:a}){if(e.length<2)return(0,D.jsx)(`svg`,{width:t,height:n,className:`shrink-0`,children:(0,D.jsx)(`line`,{x1:0,y1:n/2,x2:t,y2:n/2,stroke:`var(--color-line-2)`,strokeWidth:1})});let o=a??Math.max(...e,1),s=t-2,c=n-2,l=e.map((t,n)=>{let r=1+n/(e.length-1)*s,i=1+c-t/o*c;return`${r.toFixed(1)},${i.toFixed(1)}`}),u=i===void 0?null:1+c-Math.min(i,o)/o*c;return(0,D.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,children:[(0,D.jsx)(`polyline`,{points:l.join(` `),fill:`none`,stroke:r,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`}),u!==null&&(0,D.jsx)(`line`,{x1:1,y1:u,x2:t-1,y2:u,stroke:`var(--color-brand)`,strokeWidth:1,strokeDasharray:`3,2`,opacity:.7})]})}function Xc(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Zc({value:e,samples:t,maxValue:n,width:r=320,height:i=64,windowMs:a=6e4,color:o=`var(--color-brand)`,fillColor:s=`rgba(245, 158, 11, 0.12)`,className:c}){let l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useRef)([]),f=(0,_.useRef)(t??null),p=(0,_.useRef)(e??0),m=(0,_.useRef)(Xc());return(0,_.useEffect)(()=>{f.current=t??null},[t]),(0,_.useEffect)(()=>{t===void 0&&e!==void 0&&e!==p.current&&(p.current=e,d.current.push({ts:Date.now(),v:e}),d.current.length>600&&d.current.splice(0,d.current.length-600))},[e,t]),(0,_.useEffect)(()=>{let e=()=>{let e=Date.now(),t=e-a,o;if(f.current){let e=f.current;o=[];for(let n of e)n.ts>=t&&o.push(n)}else{let n=d.current;for(;n.length>1&&n[1]?.ts<t;)n.shift();(n.length===0||n[n.length-1]?.ts<e-200)&&n.push({ts:e,v:p.current}),o=n.filter(e=>e.ts>=t)}if(o.length<2)l.current&&l.current.setAttribute(`points`,``),u.current&&u.current.setAttribute(`points`,``);else{let e=n??Math.max(1,...o.map(e=>e.v)),s=[];for(let n of o){let o=(n.ts-t)/a*r,c=i-n.v/e*(i-2)-1;s.push(`${o.toFixed(1)},${c.toFixed(1)}`)}let c=s.join(` `);if(l.current&&l.current.setAttribute(`points`,c),u.current){let e=s[0]?.split(`,`),t=s[s.length-1]?.split(`,`),n=`${e[0]},${i} ${c} ${t[0]},${i}`;u.current.setAttribute(`points`,n)}}};if(m.current){let t=window.setInterval(e,500);return()=>clearInterval(t)}let[t]=Jo(e);return t},[r,i,a,n]),(0,D.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 ${r} ${i}`,className:Lr(`block`,c),preserveAspectRatio:`none`,children:[(0,D.jsx)(`polygon`,{ref:u,fill:s,stroke:`none`}),(0,D.jsx)(`polyline`,{ref:l,fill:`none`,stroke:o,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`})]})}var Qc=pn(`hero-metric relative flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] px-4 py-3 overflow-hidden`,{variants:{tone:{neutral:`hero-metric--neutral`,amber:`hero-metric--amber`,green:`hero-metric--green`,red:`hero-metric--red`,blue:`hero-metric--blue`,purple:`hero-metric--purple`,gray:`hero-metric--gray`}},defaultVariants:{tone:`neutral`}}),$c={neutral:`var(--color-fg-1)`,amber:`var(--color-decision-ask)`,green:`var(--color-decision-allow)`,red:`var(--color-decision-block)`,blue:`var(--color-decision-force)`,purple:`var(--color-decision-log)`,gray:`var(--color-fg-3)`},el={neutral:`color-mix(in srgb, var(--color-fg-1) 10%, transparent)`,amber:`color-mix(in srgb, var(--color-decision-ask) 14%, transparent)`,green:`color-mix(in srgb, var(--color-decision-allow) 14%, transparent)`,red:`color-mix(in srgb, var(--color-decision-block) 14%, transparent)`,blue:`color-mix(in srgb, var(--color-decision-force) 14%, transparent)`,purple:`color-mix(in srgb, var(--color-decision-log) 14%, transparent)`,gray:`color-mix(in srgb, var(--color-fg-3) 10%, transparent)`},tl={neutral:`text-[var(--color-fg-0)]`,amber:`text-amber-300`,green:`text-emerald-300`,red:`text-red-300`,blue:`text-sky-300`,purple:`text-violet-300`,gray:`text-[var(--color-fg-2)]`},nl=1e3,rl=.35;function il(e,t,n){let r=Date.now(),i=r-n,a=Math.max(2,Math.floor(n/nl)),o=Array(a).fill(0);for(let n of e){if(t&&!t(n)||n.ts_ms<i||n.ts_ms>r)continue;let e=a-1-Math.floor((r-n.ts_ms)/nl);e>=0&&e<a&&o[e]++}let s=Array(a),c=o[0];for(let e=0;e<a;e++)c=rl*o[e]+(1-rl)*c,s[e]={ts:i+(e+1)*nl,v:c};return s}function al({label:e,value:t,series:n,burstRing:r,filter:i,sparkWindowMs:a=6e4,sub:o,tone:s,format:c,className:l,...u}){let d=s??`neutral`,f=$c[d]??$c.neutral,p=el[d]??el.neutral,m=tl[d]??tl.neutral,h=(0,_.useRef)(null),g=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(g.current===t)return;g.current=t;let e=h.current;e&&Ii(e,{"--tick":[0,1],duration:160,ease:`outCubic`,onComplete:()=>{Ii(e,{"--tick":[1,0],duration:520,ease:`outCubic`,onComplete:e=>{e.style.removeProperty(`--tick`)}})}})},[t]);let v=(0,_.useMemo)(()=>r?il(r,i,a):null,[r,i,a]),y=v!==null,b=!y&&n&&n.length>=2;return(0,D.jsxs)(`div`,{ref:h,className:Lr(Qc({tone:s,className:l})),...u,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:e}),o?(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:o}):null]}),(0,D.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,D.jsx)(qc,{value:t,format:c,className:Lr(`text-[2.4rem] leading-none font-semibold tracking-tight`,m)}),y?(0,D.jsx)(Zc,{samples:v,width:108,height:36,windowMs:a,color:f,fillColor:p,className:`shrink-0`}):b?(0,D.jsx)(Yc,{data:n,width:96,height:28,color:f}):null]})]})}var ol={containerPaddingY:24,containerPaddingX:24,topToTrendGap:12,scatterHeaderH:18,scatterLegendH:16,scatterInnerGap:8,trendRowH:28,trendRowGap:6,trendTopPad:9,scatterAbsoluteMin:60,scatterAcceptableMin:70,gaugeFootprintFactor:1.36,gaugeAbsoluteMin:84,gaugeAbsoluteMax:240};function sl(e,t,n=200){let r=Math.max(0,Math.floor(e)),i=Math.max(0,Math.floor(t)),a=Math.max(0,r-ol.containerPaddingX),o=Math.max(0,i-ol.containerPaddingY),s=o-(ol.trendRowH*3+ol.trendRowGap*2+ol.trendTopPad+ol.topToTrendGap),c=s-ol.scatterHeaderH-ol.scatterLegendH-ol.scatterInnerGap>=ol.scatterAcceptableMin,l=c?s:o,u=l-ol.scatterHeaderH-ol.scatterLegendH-ol.scatterInnerGap,d=u>=ol.scatterAbsoluteMin,f=u>=ol.scatterAbsoluteMin&&l>=140,p=Math.floor(l/ol.gaugeFootprintFactor),m=Math.floor(a*.45/ol.gaugeFootprintFactor),h=Math.max(ol.gaugeAbsoluteMin,Math.min(ol.gaugeAbsoluteMax,n,p,m)),g=Math.ceil(h*ol.gaugeFootprintFactor+8),_=l-(d?ol.scatterHeaderH:0)-(f?ol.scatterLegendH:0)-ol.scatterInnerGap;return{gaugeSize:h,gaugeColumnMaxWidth:g,scatterMinHeight:Math.max(ol.scatterAbsoluteMin,Math.min(160,_)),showTrendRows:c,showScatterHeader:d,showLegend:f,variant:o>=480?`wide`:o>=300?`normal`:`compact`}}var cl=135,ll=405,ul=ll-cl,dl=`#34d399`,fl=`#f59e0b`,pl=`#ef4444`;function ml(e,t,n,r){let i=(r-90)*(Math.PI/180);return{x:e+n*Math.cos(i),y:t+n*Math.sin(i)}}function hl(e,t,n,r,i){let a=ml(e,t,n,r),o=ml(e,t,n,i),s=i-r>180?1:0;return`M ${a.x.toFixed(2)} ${a.y.toFixed(2)} A ${n} ${n} 0 ${s} 1 ${o.x.toFixed(2)} ${o.y.toFixed(2)}`}function gl(e,t){return cl+Math.max(0,Math.min(1,e/Math.max(t,1e-9)))*ul}function _l(e,t,n){return e+(t-e)*n}function vl(e){let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}function yl(e,t,n){let[r,i,a]=vl(e),[o,s,c]=vl(t);return`rgb(${Math.round(_l(r,o,n))},${Math.round(_l(i,s,n))},${Math.round(_l(a,c,n))})`}function bl(e,t,n){let r=.04;return e<t-r?dl:e<t+r?yl(dl,fl,(e-(t-r))/(r*2)):e<n-r?fl:e<n+r?yl(fl,pl,(e-(n-r))/(r*2)):pl}function xl(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Sl=0;function Cl(){return Sl=Sl+1|0,Sl.toString(36)}function wl({value:e,max:t,warnAt:n=.7,critAt:r=.9,marker50:i,marker99:a,label:o,display:s,displayFormat:c,scaleLabels:l,mode:u=`needle`,size:d=180,className:f,revLights:p=!0,revLightCount:m=20}){let h=Math.ceil(u===`needle`&&l!==void 0?d*.2:d*.08),g=-h,v=-h,y=d+h*2,b=d+h*2,x=d/2,S=d/2,C=d*.42,w=Math.max(0,Math.min(1,e/Math.max(t,1e-9))),T=(0,_.useMemo)(()=>hl(x,S,C,cl,ll),[x,S,C]),E=(0,_.useMemo)(()=>hl(x,S,C-8,cl,ll),[x,S,C]),O=cl+n*ul,k=cl+r*ul,A=(0,_.useMemo)(()=>hl(x,S,C,cl,O),[x,S,C,O]),j=(0,_.useMemo)(()=>hl(x,S,C,O,k),[x,S,C,O,k]),M=(0,_.useMemo)(()=>hl(x,S,C,k,ll),[x,S,C,k]),N=(0,_.useMemo)(()=>hl(x,S,C-14,300,420),[x,S,C]),ee=cl+w*ul,te=(0,_.useMemo)(()=>hl(x,S,C,cl,Math.max(cl+.01,ee)),[x,S,C,ee]),P=bl(w,n,r),F=(0,_.useMemo)(()=>Cl(),[]),ne=`lgf-${F}`,re=`lgb-${F}`,ie=`lgd-${F}`,I=`lgh-${F}`,L=`lgg-${F}`,R=`lgl-${F}`,ae=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=10;t++)e.push(cl+t/10*ul);return e},[u]),z=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=40;t++)t%4!=0&&e.push(cl+t/40*ul);return e},[u]),oe=(0,_.useRef)(null),se=(0,_.useRef)(null),ce=(0,_.useRef)(null),le=(0,_.useRef)(null),ue=(0,_.useRef)(null),de=(0,_.useRef)(null),fe=(0,_.useRef)(null),pe=(0,_.useRef)(null),me=(0,_.useRef)([]),he=(0,_.useRef)(e),ge=(0,_.useRef)(t),_e=(0,_.useRef)(n),ve=(0,_.useRef)(r);(0,_.useEffect)(()=>{he.current=e,ge.current=t,_e.current=n,ve.current=r},[e,t,n,r]);let ye=(0,_.useMemo)(()=>{if(!p||u!==`needle`)return[];let e=Math.max(4,m),t=C-11,n=[];for(let r=0;r<e;r++){let i=cl+(r+.5)/e*ul;n.push(ml(x,S,t,i))}return n},[p,m,u,x,S,C]);me.current.length!==ye.length&&(me.current.length=ye.length);let be=x+C-6,xe=x+d*.04,Se=Math.max(2,d*.016),Ce=`${be},${S} ${xe},${S-Se} ${xe},${S+Se}`,we=x-d*.04,Te=x-C*.24,Ee=Math.max(1.4,d*.012),De=`${Te},${S} ${we},${S-Ee} ${we},${S+Ee}`,Oe=d*.48,ke=d*.17,Ae=x-Oe/2,je=S+d*.16,Me=je+ke*.68;return(0,_.useEffect)(()=>{let e=xl(),t=performance.now(),n=he.current,r=0,i=he.current,a=0,o=he.current,s=``,l=``,d=``,f=-1,m=``,h=``,[g]=Jo(()=>{let g=performance.now(),_=(g-t)/1e3;t=g;let v=Math.min(.04,Math.max(.001,_)),y=he.current,b=ge.current,w=_e.current,T=ve.current,E=Math.max(b,1e-9),D=y;if(e)n=y,i=y,o=y,r=0,a=0;else{let e=v/2;for(let t=0;t<2;t++){let t=-210*(n-D)-22*r;r+=t*e,n+=r*e;let o=-55*(i-n)-13*a;a+=o*e,i+=a*e}let t=1-Math.exp(-v*8);o+=(y-o)*t,Math.abs(n-y)<E*1e-5&&Math.abs(r)<1e-4&&(n=y,r=0),Math.abs(o-y)<E*1e-5&&(o=y)}let O=Math.max(0,Math.min(1,n/Math.max(b,1e-9))),k=cl+O*ul,A=cl+Math.max(0,Math.min(1,i/Math.max(b,1e-9)))*ul,j=bl(O,w,T),M=`rotate(${(k-90).toFixed(3)} ${x} ${S})`;oe.current&&M!==s&&(oe.current.setAttribute(`transform`,M),s=M),j!==d&&(se.current&&se.current.setAttribute(`fill`,j),ce.current&&ce.current.setAttribute(`fill`,j),le.current&&le.current.setAttribute(`stroke`,j),de.current&&de.current.setAttribute(`fill`,j),d=j);let N=`rotate(${(A-90).toFixed(3)} ${x} ${S})`;if(ue.current&&N!==l&&(ue.current.setAttribute(`transform`,N),l=N),fe.current&&c){let e=c(o);e!==h&&(fe.current.textContent=e,h=e)}if(pe.current&&u===`ring`){let e=hl(x,S,C,cl,Math.max(cl+.01,k));e!==m&&(pe.current.setAttribute(`d`,e),m=e)}if(p&&u===`needle`){let e=Math.round(O*1e3)/1e3;if(e!==f){f=e;let t=me.current,n=t.length;if(n>0){let e=1/n;for(let r=0;r<n;r++){let i=t[r];if(!i)continue;let a=(r+.5)/n,o=O-a,s=Math.max(0,Math.min(1,.5+o/e));i.setAttribute(`fill`,bl(a,w,T)),i.setAttribute(`opacity`,s.toFixed(3))}}}}});return g},[x,S,C,u,p,c]),(0,D.jsxs)(`div`,{className:Lr(`flex flex-col items-center justify-center gap-1 min-h-0 min-w-0`,f),children:[(0,D.jsxs)(`svg`,{width:y,height:b,viewBox:`${g} ${v} ${y} ${b}`,preserveAspectRatio:`xMidYMid meet`,className:`block max-w-full max-h-full min-h-0`,children:[(0,D.jsxs)(`defs`,{children:[(0,D.jsxs)(`filter`,{id:ne,x:`-40%`,y:`-40%`,width:`180%`,height:`180%`,children:[(0,D.jsx)(`feGaussianBlur`,{stdDeviation:`1.2`,result:`blur`}),(0,D.jsxs)(`feMerge`,{children:[(0,D.jsx)(`feMergeNode`,{in:`blur`}),(0,D.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,D.jsxs)(`radialGradient`,{id:re,cx:`50%`,cy:`32%`,r:`80%`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`#4e535d`}),(0,D.jsx)(`stop`,{offset:`55%`,stopColor:`#2a2e36`}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`#0b0d11`})]}),(0,D.jsxs)(`radialGradient`,{id:ie,cx:`50%`,cy:`45%`,r:`75%`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`#1b1f27`}),(0,D.jsx)(`stop`,{offset:`80%`,stopColor:`#0a0c10`}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`#05060a`})]}),(0,D.jsxs)(`radialGradient`,{id:I,cx:`40%`,cy:`30%`,r:`70%`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`#f4f5f8`}),(0,D.jsx)(`stop`,{offset:`45%`,stopColor:`#aab1bd`}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`#1c1f26`})]}),(0,D.jsxs)(`linearGradient`,{id:L,x1:`50%`,y1:`0%`,x2:`50%`,y2:`100%`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`#ffffff`,stopOpacity:`0.22`}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`#ffffff`,stopOpacity:`0`})]}),(0,D.jsxs)(`linearGradient`,{id:R,x1:`50%`,y1:`0%`,x2:`50%`,y2:`100%`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`#0a0c11`}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`#15181f`})]})]}),u===`needle`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`circle`,{cx:x,cy:S,r:C+12,fill:`url(#${re})`,stroke:`#000`,strokeOpacity:.55,strokeWidth:1}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:C+5,fill:`none`,stroke:`#0a0c11`,strokeWidth:1}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:C-2,fill:`url(#${ie})`})]}):null,(0,D.jsx)(`path`,{d:T,fill:`none`,stroke:`var(--color-line-1)`,strokeWidth:u===`ring`?12:3,strokeLinecap:`round`,opacity:u===`ring`?1:.35}),u===`needle`?(0,D.jsx)(`path`,{d:E,fill:`none`,stroke:`var(--color-line-0)`,strokeWidth:1,strokeLinecap:`round`,opacity:.55}):null,u===`needle`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`path`,{d:A,fill:`none`,stroke:dl,strokeWidth:5,strokeLinecap:`round`,opacity:.78}),(0,D.jsx)(`path`,{d:j,fill:`none`,stroke:fl,strokeWidth:5,strokeLinecap:`round`,opacity:.82}),(0,D.jsx)(`path`,{d:M,fill:`none`,stroke:pl,strokeWidth:5,strokeLinecap:`round`,opacity:.9}),z.map((e,t)=>{let n=ml(x,S,C-4,e),r=ml(x,S,C+2,e);return(0,D.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`var(--color-fg-4)`,strokeWidth:.9,strokeLinecap:`round`,opacity:.7},`mi-${t}`)}),ae.map((e,t)=>{let n=ml(x,S,C-8,e),r=ml(x,S,C+4,e);return(0,D.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`var(--color-fg-2)`,strokeWidth:1.8,strokeLinecap:`round`},`ma-${t}`)}),p?ye.map((e,t)=>(0,D.jsx)(`circle`,{ref:e=>{me.current[t]=e},cx:e.x,cy:e.y,r:Math.max(1.6,d*.013),fill:dl,opacity:0,filter:`url(#${ne})`},t)):null,i===void 0?null:(0,D.jsx)(Tl,{cx:x,cy:S,r:C,angle:gl(i,t),emphasis:!0}),a===void 0?null:(0,D.jsx)(Tl,{cx:x,cy:S,r:C,angle:gl(a,t),emphasis:!0}),l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(El,{cx:x,cy:S,r:C,angle:O,text:l(n),size:d}),(0,D.jsx)(El,{cx:x,cy:S,r:C,angle:k,text:l(r),size:d}),(0,D.jsx)(El,{cx:x,cy:S,r:C,angle:ll,text:l(1),size:d})]}):null,(0,D.jsx)(`path`,{d:N,fill:`none`,stroke:`url(#${L})`,strokeWidth:d*.14,strokeLinecap:`butt`}),c||s!==void 0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{x:Ae,y:je,width:Oe,height:ke,rx:d*.022,ry:d*.022,fill:`url(#${R})`,stroke:`#242a33`,strokeWidth:1}),(0,D.jsx)(`rect`,{x:Ae+1,y:je+1,width:Oe-2,height:1,fill:`#ffffff`,opacity:.08})]}):null,(0,D.jsx)(`g`,{ref:ue,opacity:.28,children:(0,D.jsx)(`polygon`,{ref:de,points:Ce,fill:P})}),(0,D.jsxs)(`g`,{ref:oe,children:[(0,D.jsx)(`polygon`,{ref:se,points:Ce,fill:P,stroke:`#05070a`,strokeWidth:.6}),(0,D.jsx)(`polygon`,{ref:ce,points:De,fill:P,opacity:.7})]}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.06,fill:`url(#${I})`,stroke:`#06080c`,strokeWidth:1}),(0,D.jsx)(`circle`,{ref:le,cx:x,cy:S,r:d*.036,fill:`#0a0c11`,stroke:P,strokeWidth:1.4}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.012,fill:`#f5f7fb`,opacity:.9})]}):(0,D.jsx)(`path`,{ref:pe,d:te,fill:`none`,stroke:P,strokeWidth:12,strokeLinecap:`round`}),u===`needle`&&(c||s!==void 0)?c?(0,D.jsx)(`text`,{ref:fe,x,y:Me,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:c(e)}):(0,D.jsx)(`text`,{x,y:Me,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:s}):c?(0,D.jsx)(`text`,{ref:fe,x,y:S+4,textAnchor:`middle`,className:`font-mono tabular-nums`,fontSize:d*.13,fill:`var(--color-fg-0)`,children:c(e)}):s===void 0?null:(0,D.jsx)(`text`,{x,y:S+4,textAnchor:`middle`,className:`font-mono tabular-nums`,fontSize:d*.13,fill:`var(--color-fg-0)`,children:s})]}),o?(0,D.jsx)(`span`,{className:`overline shrink-0 tracking-[0.12em] uppercase`,children:o}):null]})}function Tl({cx:e,cy:t,r:n,angle:r,emphasis:i=!1}){let a=ml(e,t,n-(i?10:6),r),o=ml(e,t,n+(i?8:6),r);return(0,D.jsx)(`line`,{x1:a.x,y1:a.y,x2:o.x,y2:o.y,stroke:i?`var(--color-fg-1)`:`var(--color-fg-2)`,strokeWidth:i?2:1.5,strokeLinecap:`round`})}function El({cx:e,cy:t,r:n,angle:r,text:i,size:a}){let o=ml(e,t,n+Math.max(16,a*.1),r),s=r>=135&&r<215?`end`:r>=325?`start`:`middle`;return(0,D.jsx)(`text`,{x:o.x,y:o.y,textAnchor:s,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:a*.062,fontWeight:600,fill:`var(--color-fg-2)`,stroke:`var(--color-bg-0)`,strokeWidth:3,paintOrder:`stroke`,children:i})}var Dl={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`};function Ol(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}function kl({latency:e,bursts:t,gaugeMaxMs:n=10,windowMs:r=3e4,trendWindowSec:i=60,gaugeSize:a=200,compact:o=!1,className:s}){let c=e?e.p50_ns/1e6:0,l=e?e.p95_ns/1e6:0,u=e?e.p99_ns/1e6:0,d=(0,_.useRef)(null),[f,p]=(0,_.useState)((0,_.useMemo)(()=>sl(a*2,a*2,a),[a]));(0,_.useEffect)(()=>{let e=d.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=0,r=0,i=e=>{let t=Math.round(e.width/4)*4,i=Math.round(e.height/4)*4;t===n&&i===r||(n=t,r=i,p(sl(t,i,a)))};i(e.getBoundingClientRect());let o=new ResizeObserver(e=>{let n=e[0];n&&(t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(n.contentRect)}))});return o.observe(e),()=>{t&&cancelAnimationFrame(t),o.disconnect()}},[a]);let m=(0,_.useRef)(null),h=(0,_.useRef)([]),g=(0,_.useRef)(0);(0,_.useEffect)(()=>{if(t.length===0)return;let e=h.current,n=g.current,i=n;for(let r of t)r.ts_ms<=n||(e.push({ts:r.ts_ms,durationNs:r.duration_ns,color:Dl[r.decision]??`#6e7076`}),r.ts_ms>i&&(i=r.ts_ms));g.current=i;let a=Date.now()-r*2;for(;e.length&&e[0]?.ts<a;)e.shift()},[t,r]),(0,_.useEffect)(()=>{let e=m.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let i=0,a=0,o=0,s=8e3,c=.25,l=1e3,u=n*1e6,d=Math.log10(l),f=Math.log10(u),[p]=Jo(()=>{let n=window.devicePixelRatio||1,p=e.clientWidth,m=e.clientHeight;if(p===0||m===0)return;(p!==a||m!==o||n!==i)&&(e.width=Math.floor(p*n),e.height=Math.floor(m*n),t.setTransform(n,0,0,n,0,0),a=p,o=m,i=n),t.clearRect(0,0,p,m),t.strokeStyle=`rgba(110, 112, 118, 0.18)`,t.lineWidth=1,t.setLineDash([2,4]);let g=[{ns:1e5,label:`100µs`},{ns:1e6,label:`1ms`},{ns:1e7,label:`10ms`}];t.font=`9px ui-monospace, SFMono-Regular, Menlo, monospace`,t.textBaseline=`middle`,t.fillStyle=`rgba(110, 112, 118, 0.7)`;for(let e of g){if(e.ns<l||e.ns>u)continue;let n=m-(Math.log10(e.ns)-d)/(f-d)*m;t.beginPath(),t.moveTo(0,n),t.lineTo(p-28,n),t.stroke(),t.fillText(e.label,p-26,n)}t.setLineDash([]);let _=Date.now(),v=_-r,y=h.current;for(;y.length&&y[0]?.ts<v;)y.shift();t.globalCompositeOperation=`source-over`;for(let e of y){let n=(e.ts-v)/r*p,i=Math.max(l,Math.min(u,e.durationNs)),a=m-(Math.log10(i)-d)/(f-d)*m,o=_-e.ts,h;if(o<=s)h=1-o/s*(1-c);else{let e=r-s;h=e>0?Math.max(0,c*(1-(o-s)/e)):0}h<=0||(t.globalAlpha=h,t.fillStyle=e.color,t.beginPath(),t.arc(n,a,2.5,0,Math.PI*2),t.fill())}t.globalAlpha=1,t.fillStyle=`rgba(110, 112, 118, 0.55)`,t.font=`9px ui-monospace, SFMono-Regular, Menlo, monospace`,t.textBaseline=`bottom`,t.textAlign=`left`,t.fillText(`← ${Math.round(r/1e3)} s ago`,4,m-2),t.textAlign=`right`,t.fillText(`now →`,p-4,m-2),t.textAlign=`left`});return p},[r,n]);let v=(0,_.useRef)({p50:[],p95:[],p99:[]});(0,_.useEffect)(()=>{if(!e)return;let t=v.current,n=Date.now(),r=n-i*1e3,a=(e,t)=>{let i=t/1e6;for(e.length===0&&e.push({ts:r,v:i}),e.push({ts:n,v:i});e.length>1&&e[0]?.ts<r;)e.shift()};a(t.p50,e.p50_ns),a(t.p95,e.p95_ns),a(t.p99,e.p99_ns)},[e,i]);let y=(0,_.useMemo)(()=>{let e=v.current;return{p50:[...e.p50],p95:[...e.p95],p99:[...e.p99]}},[]);return(0,D.jsxs)(`div`,{ref:d,"data-lt-variant":f.variant,className:Lr(`flex h-full min-h-0 flex-col gap-3 overflow-hidden rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] p-3`,s),children:[(0,D.jsxs)(`div`,{className:Lr(`grid gap-3 min-h-0 flex-1`,`grid-cols-[auto_1fr]`),children:[(0,D.jsx)(`div`,{className:`flex items-stretch justify-center overflow-hidden min-h-0 min-w-0`,style:{maxWidth:f.gaugeColumnMaxWidth},children:(0,D.jsx)(wl,{value:l,max:n,warnAt:Math.min(.85,.5/n),critAt:Math.min(.92,2/n),marker50:c,marker99:u,displayFormat:e=>Ol(e*1e6),scaleLabels:f.gaugeSize>=130?e=>Ol(e*n*1e6):void 0,size:f.gaugeSize,label:`p95 latency`})}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 min-h-0 flex-1`,children:[f.showScatterHeader?(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 shrink-0 min-w-0`,children:[(0,D.jsx)(`span`,{className:`overline truncate min-w-0`,children:`live trace · 30 s scatter`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] shrink min-w-0 truncate text-right`,children:[h.current.length,` live · log-Y`]})]}):null,f.showLegend?(0,D.jsx)(`div`,{className:`shrink-0`,children:(0,D.jsx)(Al,{})}):null,(0,D.jsx)(`canvas`,{ref:m,"data-testid":`latency-scatter-canvas`,className:`block w-full flex-1 min-h-0 rounded-sm bg-[var(--color-surface-0)] border border-[var(--color-line-0)]`,style:{minHeight:f.scatterMinHeight}})]})]}),f.showTrendRows?(0,D.jsxs)(`div`,{"data-testid":`latency-trend-rows`,className:`grid grid-cols-1 gap-1.5 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(jl,{label:`p50 · median`,value:Ol(e?.p50_ns??0),color:`#34d399`,fill:`rgba(52, 211, 153, 0.14)`,samples:y.p50,windowMs:i*1e3}),(0,D.jsx)(jl,{label:`p95 · 95th`,value:Ol(e?.p95_ns??0),color:`#38bdf8`,fill:`rgba(56, 189, 248, 0.14)`,samples:y.p95,windowMs:i*1e3}),(0,D.jsx)(jl,{label:`p99 · 99th`,value:Ol(e?.p99_ns??0),color:`#6366f1`,fill:`rgba(99, 102, 241, 0.14)`,samples:y.p99,windowMs:i*1e3})]}):null]})}function Al(){return(0,D.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[{key:`allow`,color:Dl.allow},{key:`ask`,color:Dl.ask},{key:`block`,color:Dl.block},{key:`force`,color:Dl.force},{key:`log`,color:Dl.log},{key:`shadow`,color:Dl.shadow}].map(e=>(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:e.color}}),(0,D.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.key})]},e.key))})}function jl({label:e,value:t,color:n,fill:r,samples:i,windowMs:a}){return(0,D.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)_92px] items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`overline text-right truncate min-w-0`,children:e}),(0,D.jsx)(Zc,{samples:i,width:1200,height:28,windowMs:a,color:n,fillColor:r,className:`w-full h-7`}),(0,D.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-right truncate min-w-0`,style:{color:n},title:t,children:t})]})}function Ml(e){return e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.floor(e%60)}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function Nl(e,t){if(t===void 0||t<=0)return`var(--color-brand)`;let n=e/t;return n>=.9?`var(--color-decision-block)`:n>=.7?`var(--color-decision-ask)`:`var(--color-decision-allow)`}function Pl(e){return e===`var(--color-decision-block)`?`color-mix(in srgb, var(--color-decision-block) 14%, transparent)`:e===`var(--color-decision-ask)`?`color-mix(in srgb, var(--color-decision-ask) 14%, transparent)`:e===`var(--color-decision-allow)`?`color-mix(in srgb, var(--color-decision-allow) 14%, transparent)`:e===`var(--color-decision-log)`?`color-mix(in srgb, var(--color-decision-log) 14%, transparent)`:`color-mix(in srgb, var(--color-brand) 12%, transparent)`}function Q(e,t){if(e.length===0)return[];let n=Date.now(),r=t/Math.max(1,e.length),i=Array(e.length);for(let t=0;t<e.length;t++)i[t]={ts:n-(e.length-1-t)*r,v:e[t]};return i}function Fl({cpuPct:e,cpuSeries:t,cpuLimit:n,memMb:r,memSeries:i,memLimit:a,heapUsedMb:o,heapTotalMb:s,heapSeries:c,uptimeSec:l,className:u}){let d=6e4,f=Nl(e,n),p=Nl(r,a),m=`var(--color-decision-log)`,h=(0,_.useMemo)(()=>Q(t,d),[t]),g=(0,_.useMemo)(()=>Q(i,d),[i]),v=(0,_.useMemo)(()=>Q(c,d),[c]),y=(0,_.useRef)([]);(0,_.useEffect)(()=>{let e=y.current.filter(e=>!!e);if(e.length===0)return;e.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(28px) scale(0.94)`});let t=Ii(e,{translateY:[28,0],scale:[.94,1],opacity:[0,1],duration:720,delay:mi(140),ease:`outBack(1.25)`,onComplete:e=>{e.style.transform=``}});return()=>t.cancel()},[]);let b=n!==void 0&&n>0&&e>=n*.9,x=a!==void 0&&a>0&&r>=a*.9;return(0,D.jsx)(`div`,{className:Lr(`rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] p-3`,u),children:(0,D.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,D.jsx)(Il,{registerRef:e=>y.current[0]=e,label:`CPU`,color:f,fill:Pl(f),pulse:b,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(qc,{value:e,format:e=>e.toFixed(1),className:`text-[var(--color-fg-0)]`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:`%`})]}),subText:n?`limit ${n}%`:void 0,samples:h,maxValue:100,windowMs:d}),(0,D.jsx)(Il,{registerRef:e=>y.current[1]=e,label:`Memory`,color:p,fill:Pl(p),pulse:x,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(qc,{value:r,format:e=>e.toFixed(0),className:`text-[var(--color-fg-0)]`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:`MB`})]}),subText:a?`limit ${a} MB`:void 0,samples:g,maxValue:a?a*1.1:void 0,windowMs:d}),(0,D.jsx)(Il,{registerRef:e=>y.current[2]=e,label:`Heap`,color:m,fill:Pl(m),valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(qc,{value:o,format:e=>e.toFixed(0),className:`text-[var(--color-fg-0)]`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-base`,children:[`/ `,s.toFixed(0),` MB`]})]}),subText:s>0?`${(o/s*100).toFixed(0)}% used`:void 0,samples:v,maxValue:s>0?s:void 0,windowMs:d}),(0,D.jsx)(Il,{registerRef:e=>y.current[3]=e,label:`Uptime`,color:`var(--color-fg-2)`,fill:`rgba(214, 215, 217, 0.04)`,valueNode:(0,D.jsx)(`span`,{className:`text-[var(--color-fg-0)] tabular-nums`,children:Ml(l)}),subText:`since daemon start`})]})})}function Il({label:e,valueNode:t,subText:n,color:r,fill:i,samples:a,maxValue:o,windowMs:s,pulse:c,registerRef:l}){let u=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!c||!u.current)return;let e=!1,t=null,n=()=>{e||!u.current||(t=Ii(u.current,{"--breach":[0,1],duration:420,ease:`outCubic`,onComplete:()=>{e||!u.current||(t=Ii(u.current,{"--breach":[1,0],duration:560,ease:`outCubic`,onComplete:()=>{e||n()}}))}}))};return n(),()=>{e=!0,t?.cancel();let n=u.current;n&&n.style.removeProperty(`--breach`)}},[c]),(0,D.jsxs)(`div`,{ref:e=>{u.current=e,l(e)},className:`flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-0)] border-[var(--color-line-1)] px-4 py-3 min-h-[140px] system-pulse__tile`,"data-breach":c?`true`:void 0,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:e}),n?(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:n}):null]}),(0,D.jsx)(`span`,{className:`text-[1.9rem] leading-none font-semibold tracking-tight font-mono`,style:{color:r},children:t}),a&&a.length>=2?(0,D.jsx)(`div`,{className:`mt-auto`,children:(0,D.jsx)(Zc,{samples:a,width:320,height:64,windowMs:s??6e4,color:r,fillColor:i,maxValue:o,className:`w-full`})}):(0,D.jsx)(`div`,{className:`mt-auto h-[64px] flex items-end`,children:(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`— no series —`})})]})}var Ll=pn(`relative font-mono text-[11px] overflow-hidden border bg-[var(--color-surface-1)] border-[var(--color-line-1)] rounded-sm`,{variants:{density:{compact:``,roomy:`text-[12px]`}},defaultVariants:{density:`compact`}}),Rl={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`},zl={allow:`text-emerald-300`,block:`text-red-300`,ask:`text-amber-300`,log:`text-violet-300`,force:`text-sky-300`,shadow:`text-[var(--color-fg-3)]`};function Bl(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function Vl(e){return e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:e<1e9?`${(e/1e6).toFixed(2)} ms`:`${(e/1e9).toFixed(2)} s`}function Hl(e){return e.variant===`raw`?(0,D.jsx)(Wl,{...e}):(0,D.jsx)(Ul,{...e})}function Ul({bursts:e,windowSize:t=60,filterDecision:n,filterClient:r,className:i,density:a,height:o=260}){let[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useMemo)(()=>{let i=e;n&&(i=i.filter(e=>e.decision===n)),r&&(i=i.filter(e=>e.client===r));let a=i.slice(-t),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a[a.length-1-e];return o},[e,n,r,t]);s?l.current===null&&(l.current=u):l.current=null;let d=s&&l.current?l.current:u,f=(0,_.useRef)(null),p=(0,_.useRef)(0);return(0,_.useLayoutEffect)(()=>{if(s)return;let e=d[0];if(!e||e.ts_ms===p.current)return;p.current=e.ts_ms;let t=f.current;t&&(vi()||Ii(t,{translateX:[-10,0],opacity:[0,1],duration:220,ease:`outExpo`}))},[d,s]),(0,D.jsxs)(`div`,{className:Lr(Ll({density:a,className:i})),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,D.jsx)(`div`,{className:`overflow-auto`,style:{height:o},children:d.length===0?(0,D.jsx)(`div`,{className:`px-3 py-4 text-[var(--color-fg-4)]`,children:`— waiting for events —`}):d.map((e,t)=>{let n=e.input_preview&&e.input_preview.length>0?e.input_preview:e.rule_id?`rule: ${e.rule_id}`:`—`;return(0,D.jsxs)(`div`,{ref:t===0?f:void 0,className:`telemetry-row grid items-center gap-2 px-3 py-1 border-b border-[var(--color-line-0)] last:border-b-0 hover:bg-[var(--color-surface-2)]`,style:{gridTemplateColumns:`90px 56px minmax(80px, 130px) minmax(0, 1fr) 70px 80px`,borderLeft:`3px solid ${Rl[e.decision]??`#666`}`},children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:Bl(e.ts_ms)}),(0,D.jsx)(`span`,{className:Lr(`uppercase tracking-wide font-medium`,zl[e.decision]??`text-[var(--color-fg-2)]`),children:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,title:e.tool?`${e.tool} — ${ha(e.tool)}`:`unknown tool`,children:e.tool||`—`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] truncate`,title:n,children:n}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums text-right`,children:Vl(e.duration_ns)}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate text-right`,title:e.client,children:e.client})]},e.audit_id??`${e.ts_ms}:${e.tool}`)})}),s?(0,D.jsx)(Gl,{}):null]})}function Wl({lines:e,windowSize:t=300,className:n,density:r,height:i=260}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useMemo)(()=>{let n=e.slice(-t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[n.length-1-e];return r},[e,t]);a?s.current===null&&(s.current=c):s.current=null;let l=a&&s.current?s.current:c;return(0,D.jsxs)(`div`,{className:Lr(Ll({density:r,className:n})),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,D.jsx)(`div`,{className:`overflow-auto px-3 py-2 leading-relaxed text-[var(--color-fg-2)] whitespace-pre`,style:{height:i},children:l.length===0?(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`— empty —`}):l.map((e,t)=>(0,D.jsx)(`div`,{className:`hover:bg-[var(--color-surface-2)]`,children:e},`${t}:${e.slice(0,40)}`))}),a?(0,D.jsx)(Gl,{}):null]})}function Gl(){return(0,D.jsx)(`span`,{className:`absolute top-1 right-2 text-[10px] uppercase tracking-wider font-mono text-[var(--color-brand)] bg-[var(--color-surface-0)] px-1.5 py-0.5 border border-[var(--color-brand)]/40 rounded-sm`,children:`paused`})}function Kl(e={}){let t=(0,_.useRef)(null),n=(0,_.useRef)(!1),r=(0,_.useCallback)(()=>{if(n.current)return;let r=t.current;if(!r)return;let i=r.querySelectorAll(`[data-reveal]`);if(i.length===0)return;if(n.current=!0,vi()){i.forEach(e=>{e.style.opacity=`1`,e.style.transform=``});return}let a=e.staggerMs??40,o=e.maxStaggerMs??320,s=Math.min(a,Math.max(10,o/i.length)),c=e.translateY??14,l=e.durationMs??520,u=e.from??`center`;i.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(${c}px)`,e.style.willChange=`transform, opacity`}),Ii(Array.from(i),{opacity:[0,1],translateY:[c,0],duration:l,ease:`outBack(1.2)`,delay:mi(s,{from:u}),onComplete:e=>{e.style.willChange=``}})},[e.staggerMs,e.maxStaggerMs,e.durationMs,e.translateY,e.from]);return(0,_.useEffect)(()=>{let n=t.current;if(!n)return;if(typeof IntersectionObserver>`u`){r();return}let i=!1,a=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting&&!i){r(),a.disconnect();return}},{threshold:.08});a.observe(n);let o=n.querySelectorAll(`[data-reveal]`);if(!vi()){let t=e.translateY??14;o.forEach(e=>{e.style.opacity=`0`,e.style.transform=`translateY(${t}px)`})}let s=n.getBoundingClientRect();return s.top<(window.innerHeight||document.documentElement.clientHeight)&&s.bottom>0&&(r(),a.disconnect()),()=>{i=!0,a.disconnect()}},[r,e.translateY]),t}var ql=`ssg.sfx.enabled`;function Jl(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(ql)===`true`}catch{return!1}}function Yl(e){if(!(typeof window>`u`))try{window.localStorage.setItem(ql,String(e))}catch{}}function Xl(e,t,n,r,i,a,o=`sine`){try{let s=e.createOscillator(),c=e.createGain(),l=i/1e3;s.type=o,s.frequency.setValueAtTime(n,e.currentTime),s.frequency.exponentialRampToValueAtTime(Math.max(1,r),e.currentTime+l),c.gain.setValueAtTime(a,e.currentTime),c.gain.exponentialRampToValueAtTime(.001,e.currentTime+l),s.connect(c),c.connect(t),s.start(e.currentTime),s.stop(e.currentTime+l+.02)}catch{}}function Zl(){let[e,t]=(0,_.useState)(Jl),n=(0,_.useRef)(null),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=()=>{let t=n.current;t&&(document.hidden?t.suspend().catch(()=>{}):e&&t.resume().catch(()=>{}))};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e]),{enabled:e,toggle:(0,_.useCallback)(()=>{t(e=>{let t=!e;if(Yl(t),t){if(!n.current)try{let e=new AudioContext,t=e.createGain();t.gain.value=.8,t.connect(e.destination),n.current=e,r.current=t}catch{}n.current?.resume().catch(()=>{})}else n.current?.suspend().catch(()=>{});return t})},[]),play:(0,_.useCallback)(t=>{if(!e)return;let i=n.current,a=r.current;if(!(!i||!a||i.state===`suspended`))switch(t){case`block`:Xl(i,a,110,55,150,.08);break;case`force`:Xl(i,a,80,40,200,.1),Xl(i,a,160,80,200,.05,`square`);break;case`milestone`:{Xl(i,a,660,880,100,.06);let e=i,t=a;setTimeout(()=>{e.state!==`suspended`&&Xl(e,t,880,1320,100,.05)},115);break}case`record`:Xl(i,a,880,1320,350,.07);break}},[e])}}function Ql(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}async function $l(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:H()})}var eu=e=>!0,tu=e=>e.decision===`allow`,nu=e=>e.decision===`block`,ru=e=>e.decision===`ask`,iu=e=>e.decision===`force`,au=e=>e.decision===`log`;function ou(){let e=new Date;return e.setHours(0,0,0,0),e.getTime()}function su(){let e=Nt([`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`]),t=Va();Ua();let n=Ha(),r=Zl();(0,_.useEffect)(()=>{t&&(t.decision===`block`?r.play(`block`):t.decision===`force`&&r.play(`force`))},[r.play,t.decision,t]);let[i,a]=(0,_.useState)(()=>ou());(0,_.useEffect)(()=>{let e=()=>{if(document.visibilityState!==`visible`)return;let e=ou();a(t=>e===t?t:e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{data:o}=V(`/api/state/counters?since_ms=${i}`,[e[`counters-updated`],i]),{data:s}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:c}=V(`/api/json/limits`,[e[`runtime-tick`]]),{data:l,refetch:u}=V(`/api/json/pending`,[e[`pending-changed`]]),{data:d}=V(`/api/json/blocked`,[e[`activity-updated`]]),f=zc(),[p,m]=(0,_.useState)(!1),h=(0,_.useMemo)(()=>{let e=o?.allow??0,n=o?.block??0,r=o?.ask??0,i=o?.log??0,a=o?.force??0,s=e+n+r+i+a,c=t?.counters.total??0;return t&&c>=s&&t?{allow:t.counters.allow,block:t.counters.block,ask:t.counters.ask,log:t.counters.log,force:t.counters.force,shadow:t.counters.shadow,total:t.counters.total}:{allow:e,block:n,ask:r,log:i,force:a,shadow:0,total:s}},[t,o]),g=(0,_.useMemo)(()=>{if(n.length===0)return 0;let e=Date.now()-1e4;return n.filter(t=>t.ts_ms>=e).length/10},[n]),v=s?.history?.cpu_pct??[],y=s?.history?.memory_rss_mb??[],b=[],x=s?.latency,S=(0,_.useMemo)(()=>({"hero-metrics":()=>(0,D.jsx)(`div`,{className:`grid-bleed rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 h-full`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 h-full`,children:[(0,D.jsx)(al,{label:`Total`,value:h.total,tone:`amber`,sub:t?Ql(t.duration_ns):void 0,burstRing:n,filter:eu}),(0,D.jsx)(al,{label:`Allow`,value:h.allow,tone:`green`,burstRing:n,filter:tu}),(0,D.jsx)(al,{label:`Block`,value:h.block,tone:`red`,burstRing:n,filter:nu}),(0,D.jsx)(al,{label:`Ask`,value:h.ask,tone:`amber`,burstRing:n,filter:ru}),(0,D.jsx)(al,{label:`Force`,value:h.force,tone:`blue`,burstRing:n,filter:iu}),(0,D.jsx)(al,{label:`Log`,value:h.log,tone:`purple`,burstRing:n,filter:au})]})}),graph:()=>(0,D.jsx)(Cs,{}),"latency-trace":()=>(0,D.jsx)(kl,{latency:x,bursts:n,gaugeMaxMs:10,windowMs:3e4,trendWindowSec:60,gaugeSize:200}),throughput:()=>(0,D.jsxs)(J,{className:`h-full`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`throughput · evals/s`}),(0,D.jsxs)(K,{variant:`blue`,children:[g.toFixed(1),`/s`]})]}),(0,D.jsxs)(X,{children:[(0,D.jsx)(Zc,{value:g,width:360,height:96,windowMs:6e4,className:`w-full`}),(0,D.jsx)(`p`,{className:`overline mt-2 text-center`,children:`60-second rolling window`})]})]}),"decision-mix":()=>(0,D.jsxs)(J,{className:`h-full`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`decision mix`}),(0,D.jsx)(K,{variant:`gray`,children:h.total.toLocaleString()})]}),(0,D.jsx)(X,{children:(0,D.jsx)(Jc,{counters:{allow:h.allow,block:h.block,ask:h.ask,log:h.log,force:h.force,shadow:h.shadow}})})]}),"telemetry-feed":()=>(0,D.jsxs)(J,{variant:`flush`,className:`h-full flex flex-col`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`telemetry · live · newest first`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:[`hover to pause · scroll for history · `,n.length,` events buffered`]})]}),(0,D.jsx)(X,{className:`p-0 flex-1 min-h-0`,children:(0,D.jsx)(Hl,{variant:`decision`,bursts:n,windowSize:80,height:360,className:`border-0 rounded-none`})})]}),"system-pulse":()=>(0,D.jsx)(Fl,{cpuPct:s?.cpu_pct??0,cpuSeries:v,cpuLimit:c?.config.cpuLimitPct,memMb:s?.memory_rss_mb??0,memSeries:y,memLimit:c?.config.memoryLimitMb,heapUsedMb:s?.heap_used_mb??0,heapTotalMb:s?.heap_total_mb??0,heapSeries:b,uptimeSec:(s?.uptime_ms??0)/1e3}),"pending-approvals":()=>(0,D.jsxs)(J,{className:`h-full`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`pending approvals`}),(0,D.jsx)(K,{variant:l&&l.length>0?`amber`:`gray`,children:l?.length??0})]}),(0,D.jsx)(X,{children:l&&l.length>0?(0,D.jsx)(`ul`,{className:`space-y-2`,children:l.slice(0,5).map(e=>(0,D.jsxs)(`li`,{className:`flex items-center justify-between gap-2 border-b border-[var(--color-line-0)] last:border-b-0 py-1.5 text-[12px] font-mono`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`text-[var(--color-fg-1)] truncate`,children:[e.toolCall.tool,` · `,e.ruleId]}),(0,D.jsx)(`div`,{className:`text-[var(--color-fg-3)] text-[11px] truncate`,children:Br(e.toolCall.tool,JSON.stringify(e.toolCall.input??{}))})]}),(0,D.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,D.jsx)(q,{size:`sm`,variant:`primary`,onClick:()=>$l(e.id,`allow`).then(u),children:`allow`}),(0,D.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>$l(e.id,`block`).then(u),children:`block`})]})]},e.id))}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] py-3 text-center`,children:`— no pending approvals —`})})]}),"recent-blocks":()=>(0,D.jsxs)(J,{className:`h-full`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent blocks & forces`}),(0,D.jsx)(K,{variant:d&&d.length>0?`red`:`gray`,children:d?.length??0})]}),(0,D.jsx)(X,{children:d&&d.length>0?(0,D.jsx)(`ul`,{className:`space-y-1.5`,children:d.slice(0,6).map((e,t)=>(0,D.jsxs)(`li`,{className:`flex items-center gap-2 text-[12px] font-mono border-b border-[var(--color-line-0)] last:border-b-0 py-1.5`,children:[(0,D.jsx)(K,{variant:e.decision===`force`?`amber`:`red`,children:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate flex-1`,children:Br(e.tool,e.input)}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate text-[11px] max-w-[120px]`,children:e.rule_id??`—`})]},`${e.timestamp}-${t}`))}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] py-3 text-center`,children:`— no recent blocks —`})})]})}),[h,t,n,x,g,s,v,y,b,c,l,d,u]),C=Kl({from:`first`,translateY:22,durationMs:640,staggerMs:80,maxStaggerMs:520});return(0,D.jsxs)(`div`,{ref:p?void 0:C,className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`flex-1`,children:(0,D.jsx)(ec,{manager:f,isEditing:p,onToggleEditing:m})}),(0,D.jsx)(`button`,{type:`button`,onClick:r.toggle,className:`chip cursor-pointer hover:border-sky-500/50 hover:text-sky-300 transition-colors shrink-0`,title:r.enabled?`Mute stream sounds`:`Enable stream sounds`,children:r.enabled?`SFX ON`:`SFX OFF`})]}),(0,D.jsx)(Wc,{}),(0,D.jsx)($s,{panels:f.activeLayout.panels,isEditing:p,renderers:S,onPanelsChange:f.updateActivePanels})]})}var cu={centre:`#FF9500`,"cf-worker":`#5AC8FA`,bun:`#FFCC00`,elixir:`#AF52DE`,native:`#FF3B30`,unknown:`#8E8E93`},lu={centre:`monorepo`,"cf-worker":`CF Worker`,bun:`Bun / TS`,elixir:`Elixir`,native:`Native`,unknown:`Other`};function uu({refreshKey:e=0}){let t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)([]),i=(0,_.useRef)(null),a=(0,_.useRef)(null),o=(0,_.useRef)(0),s=(0,_.useRef)(null),c=(0,_.useRef)({w:0,h:0}),l=(0,_.useRef)(!1),u=(0,_.useRef)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)({centre:0,"cf-worker":0,bun:0,elixir:0,native:0,unknown:0});(0,_.useEffect)(()=>{let e=!1;return m(!1),f(null),fetch(`/api/json/monorepo/graph`).then(async e=>{let t=e.headers.get(`content-type`)??``;if(!e.ok)throw Error(`HTTP ${e.status}`);if(!t.includes(`application/json`))throw Error(`expected JSON, got ${t||`unknown`}`);return e.json()}).then(t=>{if(e)return;let i=n.current?.clientWidth??800,a=n.current?.clientHeight??420,s=i/2,c=a/2,l=Math.min(i,a)*.36,u=t.projects,d=[{id:t.centre.id,label:t.centre.label,type:`centre`,description:`Monorepo root — every sigmashake-* project lives here`,isCentre:!0,x:s,y:c,vx:0,vy:0,radius:0,phase:0},...u.map((e,t)=>{let n=t/Math.max(1,u.length)*Math.PI*2;return{id:e.id,label:e.label.replace(/^sigmashake-/,``),type:e.type,description:e.description||`${lu[e.type]} project`,isCentre:!1,x:s+Math.cos(n)*l,y:c+Math.sin(n)*l,vx:0,vy:0,radius:l,phase:n}})];r.current=d,o.current=0,g(d.reduce((e,t)=>(e[t.type]=(e[t.type]??0)+1,e),{centre:0,"cf-worker":0,bun:0,elixir:0,native:0,unknown:0})),m(!0)}).catch(t=>{e||f(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]),(0,_.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>{l.current=e.matches};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,_.useEffect)(()=>{let e=t.current,s=n.current;if(!e||!s)return;let u=e.getContext(`2d`,{alpha:!0});if(!u)return;let d=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect,i=window.devicePixelRatio||1;c.current.w=t.width,c.current.h=t.height,e.width=Math.max(1,Math.floor(t.width*i)),e.height=Math.max(1,Math.floor(t.height*i)),e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,u.setTransform(i,0,0,i,0,0);let a=r.current;if(a.length>0){let e=t.width/2,n=t.height/2,r=Math.min(t.width,t.height)*.36;for(let t of a){if(t.isCentre){t.x=e,t.y=n;continue}t.radius=r}}}});d.observe(s);let f=0,p=performance.now(),m=[],h=(e,t)=>{let n=new Map;e.forEach((e,t)=>n.set(e.id,t));let r=[];for(let e of t){let t=n.get(e.from),i=n.get(e.to);t===void 0||i===void 0||r.push([t,i])}return r},g=e=>{let t=Math.min(.05,(e-p)/1e3);p=e;let n=r.current,{w:s,h:d}=c.current,h=s/2,_=d/2,v=i.current,y=l.current||v?0:.06;o.current+=y*t;let b=5.5,x=.86;for(let e=0;e<n.length;e++){let r=n[e];if(r.isCentre||r.id===v)continue;let i=0,a=0;for(let t=0;t<n.length;t++){if(e===t)continue;let o=n[t];if(o.isCentre)continue;let s=r.x-o.x,c=r.y-o.y,l=s*s+c*c+.01,u=Math.sqrt(l),d=1700/l;i+=s/u*d,a+=c/u*d}let s=r.phase+o.current,c=h+Math.cos(s)*r.radius,l=_+Math.sin(s)*r.radius;i+=(c-r.x)*b,a+=(l-r.y)*b;let u=r.x-h,d=r.y-_,f=Math.sqrt(u*u+d*d)||1,p=r.radius-f;i+=u/f*p*.6,a+=d/f*p*.6,r.vx=(r.vx+i*t)*x,r.vy=(r.vy+a*t)*x,r.x+=r.vx*t,r.y+=r.vy*t}u.clearRect(0,0,s,d);let S=u.createRadialGradient(h,_,0,h,_,Math.max(s,d)/1.4);S.addColorStop(0,`rgba(255, 149, 0, 0.06)`),S.addColorStop(1,`rgba(255, 149, 0, 0)`),u.fillStyle=S,u.fillRect(0,0,s,d),u.lineCap=`round`;for(let e=1;e<n.length;e++){let t=n[0],r=n[e];du(u,t,r,.1)}for(let[e,t]of m){let r=n[e],i=n[t];!r||!i||du(u,r,i,.24,`#5AC8FA`)}let C=a.current;for(let e of n){let t=cu[e.type],n=C===e.id,r=v===e.id,i=e.isCentre?22:11,a=n||r?i+4:i;if(n||r||e.isCentre){let n=e.isCentre?a+14:a+8,r=u.createRadialGradient(e.x,e.y,a,e.x,e.y,n);r.addColorStop(0,t),r.addColorStop(1,`rgba(0,0,0,0)`),u.globalAlpha=e.isCentre?.22:.32,u.fillStyle=r,u.beginPath(),u.arc(e.x,e.y,n,0,Math.PI*2),u.fill(),u.globalAlpha=1}if(u.fillStyle=t,u.beginPath(),u.arc(e.x,e.y,a,0,Math.PI*2),u.fill(),u.lineWidth=e.isCentre?2:1.25,u.strokeStyle=`rgba(0,0,0,0.18)`,u.stroke(),u.font=e.isCentre?`600 12px ui-sans-serif, system-ui`:`500 10.5px ui-sans-serif, system-ui`,u.fillStyle=`rgba(60,60,67,0.85)`,u.textBaseline=`middle`,u.textAlign=`center`,e.isCentre)u.fillText(e.label,e.x,e.y+a+14);else{let t=e.x-h,n=e.y-_,r=Math.sqrt(t*t+n*n)||1,i=e.x+t/r*(a+12),o=e.y+n/r*(a+12);u.textAlign=t>=0?`left`:`right`,u.textBaseline=n>=0?`top`:`bottom`,u.fillText(e.label,i,o)}}u.textAlign=`start`,u.textBaseline=`alphabetic`,f=requestAnimationFrame(g)};f=requestAnimationFrame(g);let _=-1,v=``,y=setInterval(()=>{let e=r.current,t=window.__SSG_MONOREPO_EDGES__??``;e.length===_&&t===v||(_=e.length,v=t,m=h(e,t?JSON.parse(t):[]))},250);return()=>{cancelAnimationFrame(f),clearInterval(y),d.disconnect()}},[]),(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=t=>{let n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},o=(e,t)=>{let n=r.current;for(let r=n.length-1;r>=0;r--){let i=n[r],a=i.x-e,o=i.y-t,s=i.isCentre?26:14;if(a*a+o*o<=s*s)return i}return null},c=t=>{let{x:s,y:c}=n(t),l=i.current;if(l){let e=r.current.find(e=>e.id===l);if(e&&!e.isCentre){let t=e.x,n=e.y;e.x=s,e.y=c,e.vx=(s-t)*12,e.vy=(c-n)*12}return}let d=o(s,c);a.current=d?.id??null,e.style.cursor=d&&!d.isCentre?`grab`:`default`,d&&u.current?(u.current.style.display=`block`,u.current.style.left=`${s+14}px`,u.current.style.top=`${c+14}px`,u.current.innerHTML=`<strong>${fu(d.id)}</strong><span class="mg-tooltip__kind">${lu[d.type]}</span>`+(d.description?`<p>${fu(d.description)}</p>`:``)):u.current&&(u.current.style.display=`none`)},l=t=>{let{x:r,y:a}=n(t),c=o(r,a);c&&!c.isCentre&&(i.current=c.id,e.setPointerCapture(t.pointerId),e.style.cursor=`grabbing`,s.current={x:r,y:a,downX:r,downY:a,downAt:performance.now()})},d=t=>{if(i.current)try{e.releasePointerCapture(t.pointerId)}catch{}i.current=null,e.style.cursor=`default`},f=()=>{a.current=null,u.current&&(u.current.style.display=`none`)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerdown`,l),e.addEventListener(`pointerup`,d),e.addEventListener(`pointercancel`,d),e.addEventListener(`pointerleave`,f),()=>{e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`pointerup`,d),e.removeEventListener(`pointercancel`,d),e.removeEventListener(`pointerleave`,f)}},[]),(0,_.useEffect)(()=>{p&&fetch(`/api/json/monorepo/graph`).then(e=>e.json()).then(e=>{window.__SSG_MONOREPO_EDGES__=JSON.stringify(e.serviceEdges??[])}).catch(()=>{window.__SSG_MONOREPO_EDGES__=`[]`})},[p]);let v=[`cf-worker`,`bun`,`elixir`,`native`,`unknown`];return(0,D.jsxs)(`div`,{className:`mg`,ref:n,children:[(0,D.jsx)(`canvas`,{ref:t,className:`mg__canvas`,"aria-label":`Monorepo dependency graph`}),(0,D.jsxs)(`div`,{className:`mg__overlay`,children:[(0,D.jsxs)(`div`,{className:`mg__title`,children:[(0,D.jsx)(`strong`,{children:`monorepo map`}),(0,D.jsx)(`span`,{className:`mg__hint`,children:`drag to pluck a project • hover for details`})]}),d&&(0,D.jsx)(`div`,{className:`mg__error`,children:d}),(0,D.jsx)(`ul`,{className:`mg__legend`,children:v.map(e=>h[e]>0?(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`mg__swatch`,style:{background:cu[e]}}),(0,D.jsx)(`span`,{children:lu[e]}),(0,D.jsx)(`span`,{className:`mg__count`,children:h[e]})]},e):null)})]}),(0,D.jsx)(`div`,{ref:u,className:`mg-tooltip`})]})}function du(e,t,n,r,i=`#FF9500`){let a=n.x-t.x,o=n.y-t.y,s=(t.x+n.x)/2-o*.05,c=(t.y+n.y)/2+a*.05;e.globalAlpha=r,e.strokeStyle=i,e.lineWidth=1.25,e.beginPath(),e.moveTo(t.x,t.y),e.quadraticCurveTo(s,c,n.x,n.y),e.stroke(),e.globalAlpha=1}function fu(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function pu(e,t){let n=Array(t).fill(0);if(e.length===0)return n;let r=Date.now()-t*1e3;for(let i=e.length-1;i>=0;i--){let a=e[i];if(!a)continue;if(a.ts_ms<r)break;let o=Math.floor((a.ts_ms-r)/1e3);o>=0&&o<t&&n[o]++}return n}function mu({bins:e=60,height:t=38,className:n}){let r=Ha(),i=(0,_.useRef)(null),a=(0,_.useRef)([]),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=i.current;if(!t)return;let n=t.getContext(`2d`);if(!n)return;let s=Math.min(window.devicePixelRatio??1,2),c=vi(),l=()=>{let i=pu(r,e);if(a.current.length!==e)a.current=i.slice();else if(c)a.current=i;else for(let t=0;t<e;t++){let e=a.current[t]??0,n=i[t]??0;a.current[t]=e+(n-e)*.18}let u=t.clientWidth,d=t.clientHeight;(t.width!==u*s||t.height!==d*s)&&(t.width=u*s,t.height=d*s,n.scale(s,s)),n.clearRect(0,0,u,d);let f=Math.max(1,...a.current),p=u/e;for(let t=0;t<e;t++){let e=a.current[t]??0,r=e/f*d,i=t*p,o=e/f;n.fillStyle=`rgba(${Math.round(56+o*199)},${Math.round(189-o*100)},${Math.round(248-o*200)},${.4+o*.55})`,n.fillRect(i+.5,d-r,Math.max(1,p-1),r)}n.strokeStyle=`rgba(148, 163, 184, 0.1)`,n.lineWidth=1,n.beginPath(),n.moveTo(0,d-.5),n.lineTo(u,d-.5),n.stroke(),o.current=requestAnimationFrame(l)};return o.current=requestAnimationFrame(l),()=>{o.current!==null&&cancelAnimationFrame(o.current),o.current=null}},[r,e]),(0,D.jsxs)(`div`,{className:Lr(`relative w-full`,n),style:{height:t},children:[(0,D.jsx)(`canvas`,{ref:i,className:`block w-full h-full`,style:{width:`100%`,height:`100%`}}),(0,D.jsxs)(`span`,{className:`absolute top-1 left-2 text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)] pointer-events-none`,children:[`bursts/sec · `,e,`s window`]})]})}var hu=8,gu=6,_u=Math.PI*.75,vu=Math.PI*2.25;function yu({size:e=110,className:t}){let n=Ha(),r=(0,_.useRef)(null),i=(0,_.useRef)(0),a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=r.current;if(!t)return;let o=t.getContext(`2d`);if(!o)return;let s=Math.min(window.devicePixelRatio??1,2),c=vi(),l=()=>{let r=Date.now()-1500,u=0;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){if(t.ts_ms<r)break;u++}}let d=u/1.5,f=Math.min(1,d/hu);c?i.current=f:i.current+=(f-i.current)*.16;let p=e,m=e;(t.width!==p*s||t.height!==m*s)&&(t.width=p*s,t.height=m*s,t.style.width=`${p}px`,t.style.height=`${m}px`,o.scale(s,s)),o.clearRect(0,0,p,m);let h=p/2,g=m/2+4,_=p/2-8;o.lineWidth=6,o.lineCap=`round`,o.strokeStyle=`rgba(148, 163, 184, 0.18)`,o.beginPath(),o.arc(h,g,_,_u,vu),o.stroke();let v=_u+gu/hu*(vu-_u);o.strokeStyle=`rgba(239, 68, 68, 0.45)`,o.beginPath(),o.arc(h,g,_,v,vu),o.stroke();let y=_u+i.current*(vu-_u),b=i.current*hu>=gu;o.strokeStyle=b?`rgba(239, 68, 68, 0.95)`:`rgba(56, 189, 248, 0.92)`,o.lineWidth=6,o.beginPath(),o.arc(h,g,_,_u,y),o.stroke();let x=h+Math.cos(y)*(_-2),S=g+Math.sin(y)*(_-2);o.strokeStyle=b?`#fca5a5`:`#e0e7ff`,o.lineWidth=2,o.beginPath(),o.moveTo(h,g),o.lineTo(x,S),o.stroke(),o.fillStyle=b?`#fca5a5`:`#e0e7ff`,o.beginPath(),o.arc(h,g,3,0,Math.PI*2),o.fill(),o.fillStyle=b?`#fca5a5`:`#e0e7ff`,o.font=`bold 20px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,o.textAlign=`center`,o.fillText(d.toFixed(1),h,g+_*.55),o.fillStyle=`rgba(148, 163, 184, 0.85)`,o.font=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,o.fillText(`eps`,h,g+_*.55+12),a.current=requestAnimationFrame(l)};return a.current=requestAnimationFrame(l),()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=null}},[n,e]),(0,D.jsx)(`canvas`,{ref:r,className:Lr(`block`,t),style:{width:e,height:e}})}var bu={allow:`#22c55e`,block:`#ef4444`,force:`#a855f7`,ask:`#f59e0b`,log:`#60a5fa`,shadow:`#6b7280`},xu=[`allow`,`block`,`force`,`ask`,`log`];function Su({windowSec:e=30,height:t=14,className:n}){let r=Ha(),[i,a]=(0,_.useState)({}),o=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=vi(),n=()=>{let i=Date.now()-e*1e3,s={},c=0;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t){if(t.ts_ms<i)break;s[t.decision]=(s[t.decision]??0)+1,c++}}let l={};for(let e of xu)l[e]=c===0?0:(s[e]??0)/c;if(t){a(l);return}a(e=>{let t={};for(let n of xu){let r=e[n]??0;t[n]=r+((l[n]??0)-r)*.22}return t}),o.current=requestAnimationFrame(n)};return o.current=requestAnimationFrame(n),()=>{o.current!==null&&cancelAnimationFrame(o.current),o.current=null}},[r,e]);let s=xu.map(e=>({key:e,color:bu[e]??`#6b7280`,pct:Math.max(0,i[e]??0)})),c=s.reduce((e,t)=>e+t.pct,0)===0;return(0,D.jsxs)(`div`,{className:Lr(`w-full`,n),children:[(0,D.jsx)(`div`,{className:`flex w-full overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,style:{height:t},title:`decision mix · last ${e}s`,children:c?(0,D.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)]`,children:`— idle —`}):s.map(e=>(0,D.jsx)(`div`,{style:{width:`${e.pct*100}%`,background:e.color,transition:`width 240ms ease-out`},title:`${e.key} · ${(e.pct*100).toFixed(1)}%`},e.key))}),(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[9px] font-mono uppercase tracking-widest text-[var(--color-fg-4)]`,children:s.map(e=>(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:e.color}}),e.key,` · `,(e.pct*100).toFixed(0),`%`]},e.key))})]})}var Cu={neutral:`text-[var(--color-fg-0)]`,green:`text-emerald-300`,red:`text-red-300`,amber:`text-amber-300`,blue:`text-sky-300`,purple:`text-violet-300`,gray:`text-[var(--color-fg-3)]`},wu={neutral:`bg-[var(--color-fg-3)]`,green:`bg-emerald-500`,red:`bg-red-500`,amber:`bg-[var(--color-brand)]`,blue:`bg-sky-500`,purple:`bg-violet-500`,gray:`bg-[var(--color-line-2)]`},Tu=[{label:`User code`,color:`#451a03`},{label:`Runtime (bun:/node:)`,color:`#172554`},{label:`Native/other`,color:`#1f2937`},{label:`GC/idle`,color:`#450a0a`}],Eu={neutral:`#d0d0d0`,green:`#34d399`,red:`#f87171`,amber:`#fbbf24`,blue:`#38bdf8`,purple:`#a78bfa`,gray:`#6e7076`};function Du({label:e,value:t,sub:n,tone:r=`neutral`,align:i=`left`,labelPlacement:a=`above`,labelClassName:o,valueClassName:s,subClassName:c,trend:l,trendColor:u}){let d=(0,D.jsx)(`div`,{className:Lr(a===`above`?`overline mb-1.5`:`mt-1 text-[11px] text-[var(--color-fg-3)]`,o),children:e}),f=(0,D.jsx)(`div`,{className:Lr(`font-mono font-medium tabular-nums`,i===`center`&&`text-center`,Cu[r],s),children:t}),p=l&&l.length>1,m=u??Eu[r];return(0,D.jsxs)(D.Fragment,{children:[a===`above`&&d,p?(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[f,(0,D.jsx)(Yc,{data:l,width:48,height:18,color:m})]}):f,a===`below`&&d,n&&(0,D.jsx)(`div`,{className:Lr(`mt-1 text-[10px] font-mono text-[var(--color-fg-3)]`,i===`center`&&`text-center`,c),children:n})]})}function Ou({className:e,contentClassName:t,label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f,...p}){return(0,D.jsx)(J,{className:e,...p,children:(0,D.jsx)(X,{className:Lr(`py-3`,o===`center`&&`text-center`,t),children:(0,D.jsx)(Du,{label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f})})})}function ku({className:e,...t}){return(0,D.jsx)(`div`,{className:Lr(`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)] p-3`,t.align===`center`&&`text-center`,e),children:(0,D.jsx)(Du,{...t})})}function Au({pct:e,tone:t=`green`,markerPct:n,className:r,barClassName:i,markerTitle:a}){let o=Math.max(0,Math.min(100,e)),s=n===void 0?null:Math.max(0,Math.min(100,n));return(0,D.jsxs)(`div`,{className:Lr(`relative w-full overflow-hidden rounded-sm bg-[var(--color-surface-3)]`,r),children:[(0,D.jsx)(`div`,{className:Lr(`h-full rounded-sm transition-all duration-500`,wu[t],i),style:{width:`${o}%`}}),s!==null&&(0,D.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-[var(--color-brand)]/70`,style:{left:`${s}%`},title:a})]})}function ju({label:e,value:t,tone:n=`neutral`,breached:r=!1,breachLabel:i=`limit exceeded`,trendData:a,trendColor:o,threshold:s,maxValue:c,footer:l,className:u,valueClassName:d}){return(0,D.jsxs)(J,{className:u,children:[(0,D.jsxs)(Y,{className:`py-2`,children:[(0,D.jsx)(`span`,{className:`overline`,children:e}),r&&(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300`,children:i})]}),(0,D.jsxs)(X,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`div`,{className:Lr(`text-2xl font-mono font-medium tabular-nums`,Cu[n],d),children:t}),(a?.length??0)>1&&o&&(0,D.jsx)(Yc,{data:a??[],width:80,height:28,color:o,threshold:s,maxValue:c})]}),l]})]})}function Mu({profile:e,children:t}){return(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsxs)(`span`,{children:[`nodes:`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.nodes.length})]}),(0,D.jsxs)(`span`,{children:[`duration:`,` `,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[((e.endTime-e.startTime)/1e3).toFixed(0),`ms`]})]}),(0,D.jsxs)(`span`,{children:[`samples:`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.samples?.length??0})]})]}),(0,D.jsx)(`div`,{className:`flex gap-3 text-[10px] font-mono text-[var(--color-fg-3)]`,children:Tu.map(e=>(0,D.jsxs)(`span`,{className:`flex items-center`,children:[(0,D.jsx)(`span`,{className:`mr-1 inline-block h-2.5 w-2.5 rounded-[1px]`,style:{background:e.color}}),e.label]},e.label))}),t]})}function Nu({memory:e,formatValue:t}){return(0,D.jsx)(`div`,{className:`grid grid-cols-4 gap-3`,children:[{label:`RSS`,value:t(e.rss)},{label:`Heap Total`,value:t(e.heapTotal)},{label:`Heap Used`,value:t(e.heapUsed)},{label:`External`,value:t(e.external)}].map(e=>(0,D.jsx)(ku,{align:`center`,label:e.label,value:e.value,valueClassName:`text-lg font-medium text-[var(--color-fg-0)]`},e.label))})}var Pu=3;function Fu(e){return e===null?`—`:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}var Iu=[`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`];function Lu({info:e}){let t=e.tier===`pro`||e.tier===`enterprise`,n=e.status===`needs_reauth`,r=e.pct_used??0,i=r>=90?`bg-red-500`:r>=70?`bg-amber-500`:`bg-emerald-500`;return(0,D.jsxs)(J,{className:n?`border-l-2 border-l-amber-500/70`:t?`border-l-2 border-l-emerald-500/70`:`border-l-2 border-l-sky-500/70`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-xs font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`license`}),(0,D.jsx)(K,{variant:t?`green`:n?`amber`:`blue`,children:e.tier_label}),e.fleet_enrolled&&(0,D.jsx)(K,{variant:`gray`,children:`fleet`})]}),e.email&&(0,D.jsx)(`span`,{className:`text-xs text-[var(--color-fg-3)]`,children:e.email})]}),(0,D.jsxs)(X,{className:`space-y-3`,children:[n&&e.detail&&(0,D.jsxs)(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200`,children:[e.detail,` — run`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg auth login`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex justify-between text-xs text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{children:`evals today`}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(qc,{value:e.evals_today,curve:`spring`}),e.eval_daily_limit!==null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:` / `}),e.eval_daily_limit.toLocaleString()]}),e.eval_daily_limit===null&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:` · unlimited`})]})]}),e.eval_daily_limit!==null&&(0,D.jsx)(`div`,{className:`mt-1 h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-2)]`,children:(0,D.jsx)(`div`,{className:`h-full transition-all duration-700 ease-out ${i}`,style:{width:`${r}%`}})})]}),!t&&(0,D.jsxs)(`a`,{href:e.upgrade_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-[var(--color-brand)] hover:underline`,children:[`Upgrade to Pro · $`,e.pricing.pro_monthly_usd,`/mo →`]}),t&&e.retention_days>0&&(0,D.jsxs)(`div`,{className:`text-[10px] text-[var(--color-fg-3)] font-mono uppercase tracking-wider`,children:[`cloud retention: `,e.retention_days,` days`]})]})]})}function Ru(e){return new Date(e*1e3).toLocaleTimeString()}function zu(e,t=24){let n=(0,_.useRef)(null),[r,i]=(0,_.useState)([]);return(0,_.useEffect)(()=>{let r=n.current;if(n.current=e,r===null)return;let a=Math.max(0,e-r);i(e=>{let n=e.length>=t?e.slice(-(t-1)):e.slice();return n.push(a),n})},[e,t]),r}async function Bu(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:H()})}async function Vu(e,t){let n=await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t})});if(!n.ok)throw Error(`Toggle failed: ${n.status}`)}async function Hu(e,t){let n=await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t})});if(!n.ok)throw Error(`Toggle failed: ${n.status}`)}async function Uu(e,t){let n=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t,decision:`ask`})});if(!n.ok)throw Error(`Update decision failed: ${n.status}`)}async function Wu(e,t){let n=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t,decision:`block`})});if(!n.ok)throw Error(`Update decision failed: ${n.status}`)}function Gu({ruleId:e}){return e?(0,D.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e)}`,className:`text-[var(--color-brand)] hover:underline text-xs font-mono break-all`,title:`Go to rule: ${e}`,children:e}):(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}function Ku({title:e,right:t}){return(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,D.jsx)(`h2`,{className:`overline text-[11px]`,children:e}),t]})}function qu({children:e}){return(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:e})}function Ju({item:e,onDisable:t,onChangeToAsk:n,onUndo:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(`idle`),[c,l]=(0,_.useState)(!1),u=Br(e.tool,e.input),d=e.rule_id&&e.source_file,f=e.decision===`force`?`force`:`block`,p=f===`force`?`amber`:`red`,m=async()=>{s(`loading`);try{await n(),s(`done-ask`)}catch{s(`error`)}},h=async()=>{s(`loading`);try{await t(),s(`done-disable`)}catch{s(`error`)}},g=async()=>{l(!0);try{await r(o===`done-disable`?`disable`:`ask`),s(`idle`)}catch{}finally{l(!1)}},v=o===`done-ask`||o===`done-disable`;return(0,D.jsx)(J,{className:`border-l-2 ${v?`border-l-[var(--color-line-1)]`:f===`force`?`border-l-amber-400/60`:`border-l-red-500/60`} ${v?`opacity-60`:``}`,children:(0,D.jsxs)(`div`,{className:`px-3 py-3`,children:[v&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-2.5 py-1.5 mb-3 text-[11px] font-mono ${o===`done-ask`?`bg-sky-500/5 border border-sky-500/25 text-sky-300`:`bg-amber-500/5 border border-amber-500/25 text-amber-300`}`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:o===`done-ask`?`✓ rule "${e.rule_id}" → ask · prompts next time`:`✓ rule "${e.rule_id}" disabled · no longer blocks`}),(0,D.jsx)(`button`,{onClick:g,disabled:c,className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-current/40 hover:bg-white/5 transition-colors cursor-pointer disabled:opacity-50 uppercase tracking-wider text-[10px]`,children:c?`…`:`↩ undo`})]}),o===`error`&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-2.5 py-1.5 mb-3 text-[11px] font-mono bg-red-500/5 border border-red-500/25 text-red-300`,children:[(0,D.jsx)(`span`,{children:`failed to update rule — check server logs`}),(0,D.jsx)(`button`,{onClick:()=>s(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-current/40 hover:bg-white/5 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`retry`})]}),(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5 flex-wrap`,children:[(0,D.jsx)(K,{variant:v?o===`done-ask`?`blue`:`gray`:p,children:v?o===`done-ask`?`ask`:`disabled`:f}),(0,D.jsx)(`code`,{className:`text-[var(--color-brand)] text-xs font-mono`,children:e.tool}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-xs`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] text-[11px] font-mono tabular-nums`,children:Ru(e.timestamp)}),e.repeat_count>1&&(0,D.jsxs)(K,{variant:`gray`,children:[`×`,e.repeat_count]})]}),(0,D.jsx)(`div`,{className:`text-xs font-mono truncate cursor-pointer hover:text-[var(--color-fg-0)] transition-colors ${v?`text-[var(--color-fg-4)] line-through`:`text-[var(--color-fg-1)]`}`,title:u,onClick:()=>a(e=>!e),children:u})]}),d&&!v&&o!==`error`&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pt-0.5`,children:[(0,D.jsxs)(`button`,{onClick:m,disabled:o===`loading`,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-sky-500/8 text-sky-300 border border-sky-500/25 hover:bg-sky-500/15 hover:border-sky-500/40 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:[o===`loading`?(0,D.jsx)(`span`,{className:`animate-spin`,children:`⟳`}):(0,D.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,D.jsx)(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),`ask instead`]}),(0,D.jsxs)(`button`,{onClick:h,disabled:o===`loading`,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-sm text-[11px] font-medium uppercase tracking-wider bg-red-500/8 text-red-300 border border-red-500/25 hover:bg-red-500/15 hover:border-red-500/40 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:[o===`loading`?(0,D.jsx)(`span`,{className:`animate-spin`,children:`⟳`}):(0,D.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,D.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,D.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`disable rule`]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 mt-2 text-[11px] font-mono`,children:[e.rule_id&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`rule`}),(0,D.jsx)(Gu,{ruleId:e.rule_id})]}),e.source_file&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`src`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:e.source_file})]}),e.rules_evaluated!==null&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`evals`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums`,children:e.rules_evaluated})]}),(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`latency`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums`,children:Fu(e.duration_ns)})]}),(0,D.jsx)(`button`,{onClick:()=>a(e=>!e),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] transition-colors ml-auto cursor-pointer uppercase tracking-wider text-[10px]`,children:i?`▾ hide`:`▸ details`})]}),i&&(0,D.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`div`,{className:`overline mb-2`,children:`full input`}),(0,D.jsx)(Bi,{children:(()=>{try{return JSON.stringify(JSON.parse(e.input),null,2)}catch{return e.input}})()})]})]})})}function Yu(){let e=Nt(Iu),t=[e[`counters-updated`],e[`activity-updated`],e[`pending-changed`]],{data:n}=V(`/api/state/counters`,t),{data:r,refetch:i}=V(`/api/json/pending`,t),{data:a,refetch:o}=V(`/api/json/blocked`,t),{data:s}=V(`/api/state/activity`,t),{data:c}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:l}=V(`/api/json/limits`,[e[`limits-breach`]]),{data:u}=V(`/api/json/license`,[e[`activity-updated`]]),[d,f]=(0,_.useState)(!1),p=a?.reduce((e,t)=>e+t.repeat_count,0)??0,m=n?.allow??0,h=(n?.block??0)+(n?.force??0),g=n?.force??0,v=n?.pending??0,y=n?.log??0,b=zu(m),x=zu(h),S=zu(g),C=zu(v),w=zu(y),T=[{label:`allow`,value:m,tone:`green`,trend:b},{label:`block`,value:h,tone:`red`,trend:x},{label:`force`,value:g,tone:`amber`,trend:S},{label:`pending`,value:v,tone:`blue`,trend:C},{label:`log`,value:y,tone:`gray`,trend:w}];return(0,D.jsxs)(`div`,{ref:Kl({from:`first`}),className:`space-y-8`,children:[(0,D.jsx)(Wc,{}),(0,D.jsx)(`div`,{"data-reveal":!0,children:(0,D.jsx)(uu,{})}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-5 gap-2`,children:T.map(e=>(0,D.jsx)(Ou,{align:`left`,label:e.label,value:(0,D.jsx)(qc,{value:e.value,curve:`spring`}),tone:e.tone,labelPlacement:`above`,contentClassName:`py-3`,valueClassName:`text-2xl font-medium`,trend:e.trend,"data-reveal":!0},e.label))}),(0,D.jsxs)(`div`,{"data-reveal":!0,className:`grid grid-cols-12 gap-2 items-stretch`,children:[(0,D.jsxs)(`div`,{className:`col-span-12 md:col-span-7 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 flex flex-col gap-2`,children:[(0,D.jsx)(mu,{bins:60,height:42}),(0,D.jsx)(Su,{windowSec:60,height:12})]}),(0,D.jsx)(`div`,{className:`col-span-12 md:col-span-5 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 flex items-center justify-center`,children:(0,D.jsx)(yu,{size:130})})]}),u&&(0,D.jsx)(`div`,{"data-reveal":!0,children:(0,D.jsx)(Lu,{info:u})}),c&&(0,D.jsxs)(`div`,{"data-reveal":!0,className:`grid grid-cols-2 gap-2`,children:[(0,D.jsx)(ju,{label:`cpu`,value:c.cpu_pct==null?`—`:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(qc,{value:c.cpu_pct,format:e=>Math.round(e).toString()}),`%`]}),tone:l?.breaches.cpu?`red`:(c.cpu_pct??0)>=60?`amber`:`green`,breached:l?.breaches.cpu??!1,trendData:c.history?.cpu_pct,trendColor:l?.breaches.cpu?`#f87171`:`#34d399`,threshold:l?.config.cpuLimitPct,maxValue:100,className:l?.breaches.cpu?`border-red-500/40`:``,footer:(0,D.jsx)(`a`,{href:`/monitor`,className:`mt-1 block text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`view details →`})}),(0,D.jsx)(ju,{label:`memory rss`,value:c.memory_rss_mb==null?`—`:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(qc,{value:c.memory_rss_mb,format:e=>Math.round(e).toString()}),(0,D.jsx)(`span`,{className:`ml-1 text-sm text-[var(--color-fg-3)]`,children:`MB`})]}),tone:l?.breaches.memory?`red`:`neutral`,breached:l?.breaches.memory??!1,trendData:c.history?.memory_rss_mb,trendColor:l?.breaches.memory?`#f87171`:`#38bdf8`,threshold:l?.config.memoryLimitMb,className:l?.breaches.memory?`border-red-500/40`:``,footer:(0,D.jsx)(`a`,{href:`/monitor`,className:`mt-1 block text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`view details →`})})]}),(0,D.jsxs)(`section`,{"data-reveal":!0,children:[(0,D.jsx)(Ku,{title:`pending approvals`}),!r||r.length===0?(0,D.jsx)(qu,{children:`no pending approvals`}):(0,D.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,D.jsxs)(J,{className:`border-l-2 border-l-sky-500/50`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(q,{size:`sm`,variant:`primary`,onClick:async()=>{await Bu(e.id,`allow`),i()},children:`approve`}),(0,D.jsx)(q,{size:`sm`,variant:`danger`,onClick:async()=>{await Bu(e.id,`block`),i()},children:`deny`})]})]}),(0,D.jsxs)(X,{className:`space-y-2 text-xs`,children:[(0,D.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`tool`}),(0,D.jsx)(`code`,{className:`text-[var(--color-brand)] font-mono`,children:e.toolCall.tool})]}),e.prompt&&(0,D.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,D.jsx)(`span`,{className:`overline pt-0.5`,children:`prompt`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.prompt})]}),(0,D.jsx)(Bi,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id))})]}),a&&a.length>0&&(0,D.jsxs)(`section`,{"data-reveal":!0,children:[(0,D.jsx)(Ku,{title:`blocked actions`,right:(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[a.length,` active`,p>a.length?` · ${p} total hits`:``]})}),(0,D.jsx)(`div`,{className:`space-y-2`,children:(d?a:a.slice(0,Pu)).map(e=>(0,D.jsx)(Ju,{item:e,onDisable:async()=>{await Vu(e.rule_id,e.source_file),o()},onChangeToAsk:async()=>{await Uu(e.rule_id,e.source_file),o()},onUndo:async t=>{t===`disable`?await Hu(e.rule_id,e.source_file):await Wu(e.rule_id,e.source_file),o()}},`${e.decision}:${e.rule_id??`none`}:${e.tool}:${e.timestamp}:${e.input}`))}),a.length>Pu&&(0,D.jsx)(`div`,{className:`mt-3 flex justify-center`,children:(0,D.jsx)(q,{size:`sm`,variant:`secondary`,onClick:()=>f(e=>!e),children:d?`↑ show less`:`↓ show ${a.length-Pu} more`})})]}),(0,D.jsxs)(`section`,{"data-reveal":!0,children:[(0,D.jsx)(Ku,{title:`recent audit log`,right:s&&s.length>0?(0,D.jsx)(`a`,{href:`/audit`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors`,children:`view all →`}):void 0}),!s||s.length===0?(0,D.jsx)(qu,{children:`no audit entries yet`}):(0,D.jsx)(`div`,{className:`space-y-1.5`,children:s.slice(0,15).map(e=>(0,D.jsx)(Na,{row:e},e.id))})]})]})}var Xu=[{id:`rca`,label:`rca`,hint:`pre-computed root cause`},{id:`timeline`,label:`timeline`,hint:`recent frames across traces`},{id:`watch`,label:`watch`,hint:`subscribe to any ssg:// URI`},{id:`state`,label:`state`,hint:`daemon runtime snapshot`},{id:`metrics`,label:`metrics`,hint:`latency + counters`}];function Zu(){let[e,t]=(0,_.useState)(`rca`);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 min-h-[70vh]`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`h1`,{className:`text-sm font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`ai-native debugger`}),(0,D.jsx)(`span`,{className:`chip text-sky-300 border-sky-500/30`,children:`ssg:// unified resolver`}),(0,D.jsx)(Qu,{})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`one surface · cli · mcp · dashboard`})]}),(0,D.jsx)(`nav`,{className:`flex items-center gap-1 border-b border-[var(--color-line-1)]`,children:Xu.map(n=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),title:n.hint,className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider border-b-2 transition-colors `+(e===n.id?`border-[var(--color-brand)] text-[var(--color-fg-1)]`:`border-transparent text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`),children:n.label},n.id))}),(0,D.jsxs)(`section`,{className:`flex-1 min-h-0`,children:[e===`rca`&&(0,D.jsx)($u,{}),e===`timeline`&&(0,D.jsx)(id,{}),e===`watch`&&(0,D.jsx)(fd,{}),e===`state`&&(0,D.jsx)(pd,{uri:`ssg://daemon/state`}),e===`metrics`&&(0,D.jsx)(pd,{uri:`ssg://daemon/metrics`})]})]})}function Qu(){let e=Nt([`debug-frame`])[`debug-frame`]??0;return(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,title:`${e} debug-frame bursts received`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`live · `,e]})}function $u(){let e=Nt([`debug-frame`,`activity-updated`]),{data:t,loading:n,error:r,refetch:i}=V(`/api/json/debug?uri=ssg%3A%2F%2Frca%2Fcurrent`,[e[`debug-frame`],e[`activity-updated`]]),a=t?.data?.pack??null;return(0,D.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[1fr_340px] gap-4`,children:[(0,D.jsxs)(`article`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-4 space-y-3`,children:[n&&!t&&(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`loading RCA pack…`}),r&&(0,D.jsxs)(`p`,{className:`text-sm text-rose-300`,children:[`rca fetch error: `,r]}),!n&&!a&&(0,D.jsxs)(`div`,{className:`text-sm text-[var(--color-fg-3)] space-y-2`,children:[(0,D.jsx)(`p`,{className:`font-mono`,children:`no current RCA pack`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Packs are composed automatically when an eval errors, an ssqa finding arrives, or a daemon-level error fires. Nothing to diagnose yet — you're green.`})]}),a&&(0,D.jsx)(td,{pack:a})]}),(0,D.jsxs)(`aside`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 text-[11px] font-mono text-[var(--color-fg-4)] space-y-2`,children:[(0,D.jsx)(`p`,{className:`uppercase tracking-wider text-[var(--color-fg-2)]`,children:`how claude sees this`}),(0,D.jsxs)(`pre`,{className:`text-[10px] whitespace-pre-wrap leading-snug`,children:[`ssg debug rca --current --json`,`
13
+ `,`# or via MCP:`,`
14
+ `,`ssg_debug_rca(`,`{`,`auto_current:true`,`}`,`)`]}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`w-full mt-2 px-2 py-1 border border-[var(--color-line-1)] rounded-sm hover:bg-[var(--color-surface-2)]`,children:`refresh`}),t?.snapshot_hash&&(0,D.jsxs)(`p`,{className:`text-[10px] opacity-60`,children:[`hash `,t.snapshot_hash.slice(0,12),`…`]})]})]})}function ed(e){return e===`critical`?`text-rose-400 border-rose-500/40`:e===`high`?`text-amber-300 border-amber-500/40`:e===`medium`?`text-sky-300 border-sky-500/40`:`text-[var(--color-fg-3)] border-[var(--color-line-1)]`}function td({pack:e}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[`rca pack · `,new Date(e.ts_ms).toLocaleTimeString()]}),(0,D.jsx)(`h2`,{className:`text-[15px] font-medium text-[var(--color-fg-1)] mt-1`,children:e.summary}),e.trace_id&&(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] mt-1`,children:[`trace_id · `,e.trace_id]})]}),(0,D.jsx)(`span`,{className:`chip uppercase text-[10px] tracking-wider `+ed(e.severity),children:e.severity})]}),e.hypothesis&&e.hypothesis.length>0&&(0,D.jsxs)(`section`,{children:[(0,D.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`hypothesis`}),(0,D.jsx)(`ol`,{className:`space-y-2`,children:e.hypothesis.map((e,t)=>(0,D.jsxs)(`li`,{className:`p-2 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-1)]`,children:e.cause}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`conf `,(e.confidence*100).toFixed(0),`%`]})]}),e.evidence.length>0&&(0,D.jsx)(`ul`,{className:`mt-1 pl-3 text-[11px] text-[var(--color-fg-3)] list-disc list-inside space-y-0.5`,children:e.evidence.map((e,t)=>(0,D.jsx)(`li`,{children:e},t))})]},t))})]}),e.suggested_next_actions&&e.suggested_next_actions.length>0&&(0,D.jsxs)(`section`,{children:[(0,D.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`suggested next actions`}),(0,D.jsx)(`ul`,{className:`space-y-1 text-[13px] text-[var(--color-fg-2)]`,children:e.suggested_next_actions.map((e,t)=>(0,D.jsxs)(`li`,{className:`font-mono text-[12px]`,children:[`→ `,e]},t))})]}),e.state_snapshot&&e.state_snapshot.length>0&&(0,D.jsxs)(`section`,{children:[(0,D.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`expand`}),(0,D.jsx)(`ul`,{className:`space-y-1 text-[11px] font-mono`,children:e.state_snapshot.map(e=>(0,D.jsxs)(`li`,{className:`text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`code`,{className:`text-sky-300`,children:e.uri}),(0,D.jsxs)(`span`,{className:`opacity-50 ml-2`,children:[e.hash.slice(0,10),`…`]})]},e.uri))})]})]})}var nd=[`hook-ingress`,`parse`,`match`,`ffi-call`,`decide`,`audit`,`respond`],rd={"hook-ingress":`#6ea8ff`,parse:`#a78bfa`,match:`#60d394`,"ffi-call":`#f59e0b`,decide:`#f472b6`,audit:`#94a3b8`,respond:`#22d3ee`};function id(){let{data:e,loading:t,error:n}=V(`/api/json/debug?uri=ssg%3A%2F%2Fframes%2Frecent%3Flimit%3D1024`,[Nt([`debug-frame`])[`debug-frame`]]),r=e?.data?.frames??[],i=e?.data?.dropped??0,[a,o]=(0,_.useState)(null);return(0,D.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[1fr_320px] gap-4`,children:[(0,D.jsxs)(`article`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:[`frames · `,r.length,i>0&&(0,D.jsxs)(`span`,{className:`ml-2 text-amber-300`,children:[`dropped · `,i]})]}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`ssg://frames/recent`})]}),n&&(0,D.jsxs)(`p`,{className:`text-sm text-rose-300`,children:[`timeline fetch error: `,n]}),t&&r.length===0?(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`loading…`}):r.length===0?(0,D.jsx)(ad,{}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(sd,{frames:r,onSelect:o}),(0,D.jsx)(od,{})]})]}),(0,D.jsxs)(`aside`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`p`,{className:`uppercase tracking-wider text-[var(--color-fg-2)]`,children:`frame inspector`}),a?(0,D.jsx)(cd,{frame:a}):(0,D.jsx)(`p`,{className:`opacity-60`,children:`click a bar to inspect`})]})]})}function ad(){return(0,D.jsxs)(`div`,{className:`text-[12px] text-[var(--color-fg-3)] space-y-1 py-4`,children:[(0,D.jsx)(`p`,{children:`no frames yet`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] font-mono`,children:`SSG_DEBUG_ENABLED=1 ssg daemon`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`then fire an eval — frames stream in live.`})]})}function od(){return(0,D.jsx)(`div`,{className:`flex flex-wrap gap-3 text-[10px] font-mono text-[var(--color-fg-4)]`,children:nd.map(e=>(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:rd[e]}}),e]},e))})}function sd({frames:e,onSelect:t}){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(-1),{rows:o,tMin:s,tMax:c}=(0,_.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.trace_id)??[];e.push(n),t.set(n.trace_id,e)}let n=Array.from(t.entries()).map(([e,t])=>({trace_id:e,frames:t.slice().sort((e,t)=>ud(e.ts_start_ns,t.ts_start_ns))}));n.sort((e,t)=>ud(e.frames[0].ts_start_ns,t.frames[0].ts_start_ns));let r=null,i=null;for(let t of e){let e=BigInt(t.ts_start_ns),n=BigInt(t.ts_end_ns);(r===null||e<r)&&(r=e),(i===null||n>i)&&(i=n)}return{rows:n,tMin:r??0n,tMax:i??1n}},[e]);(0,_.useEffect)(()=>{let e=n.current;if(!e)return;let t=window.devicePixelRatio||1,a=e.clientWidth,l=Math.max(120,o.length*22+24);e.width=a*t,e.height=l*t,e.style.height=`${l}px`;let u=e.getContext(`2d`);if(!u)return;u.setTransform(t,0,0,t,0,0),u.clearRect(0,0,a,l),u.strokeStyle=`rgba(255,255,255,0.04)`,u.lineWidth=1;for(let e=1;e<4;e++){let t=e*a/4;u.beginPath(),u.moveTo(t,0),u.lineTo(t,l),u.stroke()}let d=c>s?Number(c-s):1,f=a-110-8;u.font=`10px ui-monospace, monospace`,u.textBaseline=`middle`;let p=[];if(o.forEach((e,t)=>{let n=8+t*22;u.fillStyle=`rgba(255,255,255,0.55)`,u.fillText(e.trace_id.slice(0,10),6,n+18/2);for(let t of e.frames){let e=Number(BigInt(t.ts_start_ns)-s),r=Number(BigInt(t.ts_end_ns)-s),i=110+e/d*f,a=Math.max(2,(r-e)/d*f);u.fillStyle=rd[t.stage]??`#888`,u.globalAlpha=t.result===`error`?1:.82,u.fillRect(i,n,a,18),u.globalAlpha=1,t.result===`error`&&(u.strokeStyle=`#f43f5e`,u.lineWidth=1.5,u.strokeRect(i+.5,n+.5,a-1,17)),p.push({x:i,y:n,w:a,h:18,frame:t})}}),r.current=p,i>=0&&i<p.length){let e=p[i];u.strokeStyle=`#fff`,u.lineWidth=1.5,u.strokeRect(e.x+.5,e.y+.5,e.w-1,e.h-1)}},[o,s,c,i]);function l(e){let t=n.current;if(!t)return-1;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;for(let e=r.current.length-1;e>=0;e--){let t=r.current[e];if(a>=t.x&&a<=t.x+t.w&&o>=t.y&&o<=t.y+t.h)return e}return-1}return(0,D.jsx)(`canvas`,{ref:n,className:`w-full block cursor-crosshair`,onMouseMove:e=>a(l(e)),onMouseLeave:()=>a(-1),onClick:e=>{let n=l(e);t(n>=0?r.current[n].frame:null)}})}function cd({frame:e}){let t=Number(BigInt(e.ts_end_ns)-BigInt(e.ts_start_ns)),n=t>=1e6?`${(t/1e6).toFixed(2)}ms`:t>=1e3?`${(t/1e3).toFixed(1)}µs`:`${t}ns`;return(0,D.jsxs)(`dl`,{className:`space-y-1`,children:[(0,D.jsxs)(ld,{k:`stage`,children:[(0,D.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm mr-1 align-middle`,style:{background:rd[e.stage]??`#888`}}),e.stage]}),(0,D.jsx)(ld,{k:`tool`,children:e.tool}),(0,D.jsx)(ld,{k:`result`,children:(0,D.jsx)(`span`,{className:e.result===`error`?`text-rose-300`:e.result===`skip`?`text-[var(--color-fg-4)]`:`text-emerald-300`,children:e.result})}),(0,D.jsx)(ld,{k:`dur`,children:n}),e.rule_id&&(0,D.jsx)(ld,{k:`rule`,children:e.rule_id}),e.error&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ld,{k:`err.type`,children:(0,D.jsx)(`span`,{className:`text-rose-300`,children:e.error.type})}),(0,D.jsx)(ld,{k:`err.msg`,children:(0,D.jsx)(`span`,{className:`text-rose-200`,children:e.error.message})})]}),e.input_preview&&(0,D.jsx)(ld,{k:`input`,children:(0,D.jsx)(`code`,{className:`text-[10px] break-all`,children:e.input_preview})}),(0,D.jsx)(ld,{k:`trace`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.trace_id})}),(0,D.jsx)(ld,{k:`frame`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.frame_id})})]})}function ld({k:e,children:t}){return(0,D.jsxs)(`div`,{className:`flex gap-2 text-[11px] leading-tight`,children:[(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)] w-16 shrink-0 uppercase tracking-wider`,children:e}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-all min-w-0`,children:t})]})}function ud(e,t){let n=BigInt(e),r=BigInt(t);return n<r?-1:n>r?1:0}var dd=[`ssg://daemon/state`,`ssg://daemon/metrics`,`ssg://audit/recent?limit=10`,`ssg://frames/recent?limit=32`,`ssg://rules/list`,`ssg://rca/current`,`ssg://native/stats`];function fd(){let[e,t]=(0,_.useState)(`ssg://daemon/state`),[n,r]=(0,_.useState)(`ssg://daemon/state`);return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:dd.map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>{t(e),r(e)},className:`chip text-[10px] `+(n===e?`border-[var(--color-brand)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)]`),children:e},e))}),(0,D.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:t=>{t.preventDefault(),r(e)},children:[(0,D.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),placeholder:`ssg://source/path?k=v`,className:`flex-1 px-3 py-1.5 text-[12px] font-mono rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-1)]`}),(0,D.jsx)(`button`,{type:`submit`,className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm hover:bg-[var(--color-surface-2)]`,children:`resolve`})]}),(0,D.jsx)(pd,{uri:n})]})}function pd({uri:e}){let t=Nt([`debug-frame`,`activity-updated`,`counters-updated`]),{data:n,loading:r,error:i,refetch:a}=V(`/api/json/debug?uri=${encodeURIComponent(e)}`,[t[`debug-frame`],t[`activity-updated`],t[`counters-updated`],e]),o=n?JSON.stringify(n.data,null,2):``;return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:e}),n?.snapshot_hash&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`hash `,n.snapshot_hash.slice(0,10),`…`]}),n?.stale&&(0,D.jsxs)(`span`,{className:`chip text-amber-300 border-amber-500/40 text-[10px]`,children:[`stale `,n.age_ms?`${Math.round(n.age_ms/1e3)}s`:``]})]}),(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`,children:`refresh`})]}),r&&!n&&(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`resolving…`}),i&&(0,D.jsx)(`p`,{className:`text-sm text-rose-300`,children:i}),o&&(0,D.jsx)(`pre`,{className:`text-[11px] leading-snug font-mono text-[var(--color-fg-2)] overflow-auto max-h-[60vh] whitespace-pre-wrap break-all`,children:o})]})}var md=200;function hd(e){let t=Date.now()-e;return t<2e3?`now`:t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function gd(e){let t=e/1e6;return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.floor(t/6e4)}m${Math.floor(t%6e4/1e3)}s`}function _d(e){let{bursts:t,selectedId:n,onSelect:r}=e,i=(0,_.useMemo)(()=>{let e=new Map;for(let n of t){if(_a(n.tool))continue;let t=Wa(n),r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}let n=Array.from(e.entries());return n.sort((e,t)=>{let n=e[1][e[1].length-1]?.ts_ms??0;return(t[1][t[1].length-1]?.ts_ms??0)-n}),n},[t]);return t.length===0?(0,D.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center px-4`,children:[(0,D.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`feed · idle`}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[260px]`,children:[`Each entry is one tool call your AI agent made.`,(0,D.jsx)(`br`,{}),`Color = the ssg rule decision.`]})]}):(0,D.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3 space-y-5`,children:i.map(([e,t])=>{let i=e.indexOf(`:`),a=i>=0?e.slice(0,i):e;i>=0&&e.slice(i+1);let o=t[t.length-1],s=o?Ga[o.decision]??`#6b7280`:`#6b7280`,c=t.slice(-md).reverse();return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 pb-1 border-b border-[var(--color-line-1)] text-[11px]`,children:[(0,D.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:s}}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-medium`,children:ga(a)}),(0,D.jsxs)(`span`,{className:`ml-auto text-[10px] text-[var(--color-fg-4)]`,children:[t.length,` `,t.length===1?`action`:`actions`]})]}),(0,D.jsxs)(`div`,{className:`relative pl-4`,children:[(0,D.jsx)(`div`,{className:`absolute left-[7px] top-0 bottom-0 w-px`,style:{background:`${s}33`}}),(0,D.jsx)(`div`,{className:`space-y-1.5`,children:c.map(e=>{let t=e.audit_id??`${e.ts_ms}:${e.tool}`,i=t===n,a=Ga[e.decision]??`#6b7280`,o=e.input_tokens??0,s=e.output_tokens??0,c=o>0||s>0;return(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`span`,{className:`absolute -left-[9px] top-1/2 -translate-y-1/2 w-[6px] h-[6px] rounded-full border border-[var(--color-surface-1)]`,style:{background:a}}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>r(i?null:t),className:`w-full text-left flex items-center gap-2 px-2.5 py-1.5 rounded-sm border text-[11.5px] transition-colors ${i?`border-sky-500/50 bg-sky-500/5 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-2)] hover:bg-white/3 hover:border-[var(--color-line-2)]`}`,children:[(0,D.jsx)(`span`,{className:`flex-1 font-medium truncate text-[var(--color-fg-1)]`,title:e.tool,children:ha(e.tool)}),(0,D.jsxs)(`span`,{className:`shrink-0 flex items-center gap-2 text-[9px] text-[var(--color-fg-4)]`,children:[c&&(0,D.jsxs)(`span`,{className:`font-mono`,title:`Input: ${o} tokens · Output: ${s} tokens`,children:[`↓`,Qa(o),` ↑`,Qa(s)]}),e.duration_ns>0&&(0,D.jsx)(`span`,{children:gd(e.duration_ns)}),(0,D.jsx)(`span`,{className:`px-1.5 py-px rounded text-[9px] font-semibold tracking-wide`,style:{color:a,background:`${a}22`},children:e.decision===`allow`?`Allowed`:e.decision===`block`?`Blocked`:e.decision===`ask`?`Held`:e.decision===`force`?`Forced`:e.decision===`log`?`Logged`:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:hd(e.ts_ms)})]})]})]},t)})})]})]},e)})})}function vd(e){let{sessionKey:t,entries:n,loading:r,error:i,playingIndex:a}=e,o=(0,_.useRef)(null),s=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{if(a<0)return;let e=s.current.get(a);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},[a]);let c=e=>t=>{t?s.current.set(e,t):s.current.delete(e)};return(0,D.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`audit log`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] truncate`,title:t,children:t})]}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:r?`loading…`:i?`error`:`${n.length} event${n.length===1?``:`s`}`})]}),(0,D.jsxs)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto divide-y divide-[var(--color-line-1)]/40`,children:[i&&(0,D.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-rose-300`,children:i}),!i&&!r&&n.length===0&&(0,D.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No audit entries for this session yet.`}),n.map((e,t)=>{let n=Ga[e.decision]??`#6b7280`,r=t===a,i=e.duration_ns==null?null:e.duration_ns/1e6;return(0,D.jsxs)(`div`,{ref:c(t),className:`relative px-3 py-2 transition-colors ${r?`bg-white/[0.04] ring-1 ring-inset ring-sky-400/40`:`hover:bg-white/[0.02]`}`,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,className:`absolute left-0 top-0 bottom-0 w-1`,style:{background:n}}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] font-mono`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider shrink-0`,style:{color:n},children:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.tool})]}),(0,D.jsx)(`span`,{className:`shrink-0 text-[10px] text-[var(--color-fg-4)] tabular-nums`,children:$(e.ts_ms)})]}),(e.rule_id||i!=null)&&(0,D.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[e.rule_id&&(0,D.jsxs)(`span`,{className:`truncate`,title:e.rule_id,children:[`rule · `,e.rule_id]}),i!=null&&(0,D.jsx)(`span`,{className:`tabular-nums shrink-0`,children:i<1?`${(i*1e3).toFixed(0)}µs`:`${i.toFixed(2)}ms`})]}),e.rule_message&&(0,D.jsx)(`div`,{className:`mt-1 text-[10px] font-mono text-[var(--color-fg-3)] break-words`,children:e.rule_message}),e.input_preview&&(0,D.jsx)(`pre`,{className:`mt-1 text-[10px] text-[var(--color-fg-3)] whitespace-pre-wrap break-all bg-black/30 rounded-sm px-2 py-1 max-h-24 overflow-y-auto`,children:e.input_preview})]},e.id)})]})]})}function $(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}`}var yd=[100,500,1e3,5e3,1e4,1e5];function bd(e){return e>=1e5||e>=1e3?`${e/1e3|0}k`:String(e)}function xd(e){let t=Math.floor(e/100),n=Math.floor(t/600),r=Math.floor(t%600/10),i=t%10;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}.${i}`}function Sd(e){let t=Math.floor(e/100);return`${Math.floor(t/10)}.${t%10}s`}function Cd({className:e,onMilestone:t,onRecord:n}){let r=(0,_.useRef)(null),i=(0,_.useRef)(null),[a,o]=(0,_.useState)(0),[s,c]=(0,_.useState)(0),[l,u]=(0,_.useState)(0),[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(0),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=Va(),C=Ua(),w=Ha(),T=(0,_.useRef)(null),E=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(0),A=(0,_.useRef)(0),j=(0,_.useRef)(new Set),M=(0,_.useRef)(performance.now());(0,_.useEffect)(()=>{let e=performance.now();if(vi()){let t=setInterval(()=>{let t=performance.now();r.current&&(r.current.textContent=xd(t-e)),i.current&&(i.current.textContent=Sd(t-M.current))},1e3);return()=>clearInterval(t)}let[t]=Jo(()=>{let t=performance.now();r.current&&(r.current.textContent=xd(t-e)),i.current&&(i.current.textContent=Sd(t-M.current))});return t},[]);let N=(0,_.useRef)(0);return(0,_.useEffect)(()=>{if(T.current===null){T.current=C,E.current=C;return}if(C<=E.current)return;let e=C-E.current;E.current=C,u(n=>{let r=n+e,i=yd.find(e=>e>A.current&&r>=e);return i&&(A.current=i,g(bd(i)),x(!0),t?.(),setTimeout(()=>{g(``),x(!1)},700)),r});let r=Date.now();if(r-N.current>=1e3){N.current=r;let e=w.filter(e=>r-e.ts_ms<=6e4);f(new Set(e.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size)}S?.rule_id&&j.current.add(S.rule_id),m(j.current.size),S&&(S.decision===`block`?(O.current=0,o(0),M.current=performance.now()):(O.current+=e,O.current>k.current&&(k.current=O.current,c(k.current),y(!0),n?.(),setTimeout(()=>y(!1),450)),o(O.current)))},[C,S,w,t,n]),(0,D.jsxs)(`div`,{className:Lr(`pointer-events-none select-none`,`flex flex-col gap-2 p-3 rounded-md`,`bg-[var(--color-bg-2,#0c0d12)]/95`,`border border-[var(--color-border-1,#1c1f26)]`,`shadow-lg shadow-black/40`,`min-w-[180px] font-mono text-[11px]`,`text-[var(--color-fg-2,#9aa1ad)]`,b&&`milestone-ring`,e),"aria-label":`Live engagement counters`,children:[(0,D.jsx)(wd,{label:`uptime`,children:(0,D.jsx)(`span`,{ref:r,className:`tabular-nums text-[var(--color-fg-0,#e6e8ed)] text-[15px] tracking-tight`,children:`00:00.0`})}),(0,D.jsx)(wd,{label:`evals`,children:(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(qc,{value:l,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`}),h&&(0,D.jsxs)(`span`,{className:`text-[10px] text-emerald-400 uppercase tracking-wide`,children:[`+`,h]})]})}),(0,D.jsx)(wd,{label:`since block`,children:(0,D.jsx)(`span`,{ref:i,className:`tabular-nums text-emerald-300 text-[15px]`,children:`0.0s`})}),(0,D.jsx)(wd,{label:`streak / best`,children:(0,D.jsxs)(`span`,{className:Lr(`tabular-nums text-[15px]`,v?`record-beat`:`text-[var(--color-fg-0,#e6e8ed)]`),children:[(0,D.jsx)(qc,{value:a,curve:`spring`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4,#5a6071)] mx-1`,children:`/`}),(0,D.jsx)(qc,{value:s})]})}),(0,D.jsx)(wd,{label:`agents`,children:(0,D.jsx)(qc,{value:d,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})}),(0,D.jsx)(wd,{label:`rules`,children:(0,D.jsx)(qc,{value:p,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})})]})}function wd({label:e,children:t}){return(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider text-[10px] text-[var(--color-fg-4,#5a6071)]`,children:e}),t]})}function Td(e){let t=new Map;for(let n of e){let e=`${n.client}:${n.agent_id??`solo`}`,r=t.get(e);r?(r.count+=1,n.ts_ms>r.newest_ts_ms&&(r.newest_ts_ms=n.ts_ms)):t.set(e,{client:n.client,agent_id:n.agent_id??`solo`,count:1,newest_ts_ms:n.ts_ms})}return Array.from(t.values()).sort((e,t)=>t.newest_ts_ms===e.newest_ts_ms?t.count-e.count:t.newest_ts_ms-e.newest_ts_ms)}function Ed(e){let{bursts:t,allBursts:n}=e,r=n??t,{toolCounts:i,decisionCounts:a,ruleCounts:o,unmatchedCount:s}=(0,_.useMemo)(()=>{let e=new Map,n=new Map,r=new Map,i=0;for(let a of t)if(e.set(a.tool,(e.get(a.tool)??0)+1),n.set(a.decision,(n.get(a.decision)??0)+1),a.rule_id){let e=r.get(a.rule_id);e?(e.count+=1,e.decisions.add(a.decision)):r.set(a.rule_id,{count:1,decisions:new Set([a.decision])})}else i+=1;return{toolCounts:Array.from(e.entries()).sort((e,t)=>t[1]-e[1]),decisionCounts:Array.from(n.entries()),ruleCounts:Array.from(r.entries()).map(([e,t])=>({id:e,count:t.count,decisions:t.decisions})).sort((e,t)=>t.count-e.count),unmatchedCount:i}},[t]),c=(0,_.useMemo)(()=>Td(r),[r]),l=i[0]?.[1]??0,u=c[0]?.count??0,d=o[0]?.count??0,f=e=>{for(let t of[`block`,`ask`,`force`,`log`,`allow`,`shadow`])if(e.has(t))return Ga[t];return`#6b7280`};return(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 text-[11px] font-mono`,children:[(0,D.jsx)(`div`,{className:`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-0)] p-2 text-[10px] text-[var(--color-fg-3)] leading-relaxed`,children:`Each dot is one tool call by an AI agent. Color encodes the ssg rule decision; lines link calls from the same agent in time order.`}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`rules · `,o.length,` matched`,s>0&&(0,D.jsxs)(`span`,{className:`ml-2 text-[var(--color-fg-4)] normal-case tracking-normal`,children:[s,` unmatched`]})]}),o.length===0?(0,D.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no rules matched in window`}):(0,D.jsx)(`ul`,{className:`space-y-0.5`,children:o.slice(0,6).map(e=>{let t=d>0?e.count/d*100:0,n=f(e.decisions);return(0,D.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,title:`${e.id} — decisions: ${Array.from(e.decisions).join(`, `)}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:n},"aria-hidden":!0}),(0,D.jsx)(`a`,{href:`/rules#${encodeURIComponent(e.id)}`,className:`truncate text-[var(--color-fg-2)] hover:text-[var(--color-fg-1)]`,children:e.id}),(0,D.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full`,style:{background:n,width:`${t}%`,opacity:.6}})})]}),(0,D.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:e.count})]},e.id)})})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:`decisions`}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[`allow`,`block`,`ask`,`log`,`force`,`shadow`].map(e=>{let t=a.find(([t])=>t===e)?.[1]??0;return(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:Ga[e]},"aria-hidden":!0}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider`,children:e}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums`,children:t})]},e)})})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`agents · `,c.length,` active`,n&&n!==t&&(0,D.jsx)(`span`,{className:`ml-2 text-[var(--color-fg-4)] normal-case tracking-normal`,children:`roster: today`})]}),c.length===0?(0,D.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no agents in window`}):(0,D.jsx)(`ul`,{className:`space-y-0.5`,children:c.slice(0,8).map(e=>{let t=u>0?e.count/u*100:0,n=`${e.client}:${e.agent_id}`,r=Date.now()-e.newest_ts_ms,i=r<5e3;return(0,D.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,title:`${n} — last eval ${Math.max(0,Math.round(r/1e3))}s ago`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i?(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft shrink-0`,"aria-hidden":!0}):(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-[var(--color-fg-4)]/40`,"aria-hidden":!0}),(0,D.jsxs)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:[e.client,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`:`,e.agent_id]})]}),(0,D.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full bg-violet-400/60`,style:{width:`${t}%`}})})]}),(0,D.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:e.count})]},n)})})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`tools · `,t.length,` in window`]}),i.length===0?(0,D.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no tool activity`}):(0,D.jsx)(`ul`,{className:`space-y-0.5`,children:i.slice(0,8).map(([e,t])=>{let n=l>0?t/l*100:0;return(0,D.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:e}),(0,D.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full bg-sky-400/60`,style:{width:`${n}%`}})})]}),(0,D.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:t})]},e)})})]})]})}var Dd=320,Od=8,kd=12;function Ad(e){let{burst:t,anchor:n,onClose:r}=e,i=(0,_.useRef)(null),[a,o]=(0,_.useState)({left:-9999,top:-9999});if((0,_.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&r()},n=e=>{i.current&&!i.current.contains(e.target)&&r()};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,n),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,n)}},[t,r]),(0,_.useLayoutEffect)(()=>{if(!t||!n||!i.current)return;let e=i.current.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,s=e.height>0?e.height:280,c=n.x+kd+Dd>r?n.x-kd-Dd:n.x+kd,l=n.y+kd+s>a?n.y-kd-s:n.y+kd;c=Math.min(Math.max(Od,c),r-Dd-Od),l=Math.min(Math.max(Od,l),a-s-Od),o({left:c,top:l})},[t,n]),(0,_.useEffect)(()=>{o({left:-9999,top:-9999})},[]),!t||!n)return null;let s=Ga[t.decision]??`#6b7280`,c=t.duration_ns/1e6,l=Date.now()-t.ts_ms;return(0,D.jsxs)(`div`,{ref:i,className:`fixed z-50 flex flex-col gap-3 text-[12px] font-mono rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] shadow-2xl p-4`,style:{left:a.left,top:a.top,width:Dd,maxHeight:`80vh`,overflowY:`auto`},children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`node · inspect`}),(0,D.jsx)(`button`,{onClick:r,className:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] cursor-pointer`,title:`Close inspector`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`w-2 h-2 rounded-full`,style:{background:s},"aria-hidden":!0}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider`,style:{color:s},children:t.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:t.tool})]}),(0,D.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[11px]`,children:[(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`rule`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-all`,children:t.rule_id??`—`}),(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`client`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.client}),(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`agent`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.agent_id?(0,D.jsx)(`span`,{className:`chip text-violet-300 border-violet-500/30`,children:t.agent_id}):(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}),(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`eval duration`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:c<1?`${(c*1e3).toFixed(0)}µs`:`${c.toFixed(2)}ms`}),t.complete_duration_ms!=null&&t.complete_duration_ms>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`tool duration`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.complete_duration_ms>=1e3?`${(t.complete_duration_ms/1e3).toFixed(2)}s`:`${t.complete_duration_ms.toFixed(0)}ms`})]}),t.message&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`reason`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-words`,children:t.message})]}),(t.input_tokens!=null||t.output_tokens!=null)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`tokens`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:Nd(t.input_tokens,t.output_tokens)})]}),(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`age`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:jd(l)}),(0,D.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`timestamp`}),(0,D.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:new Date(t.ts_ms).toLocaleString()})]}),t.input_preview&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:`input`}),(0,D.jsx)(`pre`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm p-2 text-[10px] text-[var(--color-fg-2)] whitespace-pre-wrap break-all max-h-48 overflow-y-auto`,children:t.input_preview})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.audit_id&&(0,D.jsx)(`a`,{href:`/audit?id=${encodeURIComponent(t.audit_id)}`,className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:text-[var(--color-fg-1)]`,title:`Open full audit record`,children:`audit ↗`}),t.rule_id&&(0,D.jsx)(`a`,{href:`/rules#${encodeURIComponent(t.rule_id)}`,className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:text-[var(--color-fg-1)]`,title:`Jump to rule`,children:`rule ↗`})]})]})}function jd(e){if(e<1500)return`just now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m${t%60}s ago`:`${Math.floor(n/60)}h${n%60}m ago`}function Md(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.round(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}function Nd(e,t){let n=[];return e!=null&&n.push(`${Md(e)} in`),t!=null&&n.push(`${Md(t)} out`),n.length>0?n.join(` · `):`—`}var Pd=900,Fd=180,Id=320,Ld=800,Rd=4;function zd({sessionKey:e}={}){let t=Va(),n=Ua(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`idle`),s=(0,_.useRef)([]),c=(0,_.useRef)(-1),l=(0,_.useRef)(0),u=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!t||n===c.current||(c.current=n,t.decision!==`block`&&t.decision!==`force`)||e&&Wa(t)!==e)return;let u=Date.now(),d=s.current,f=d[0];if(f&&u-l.current<Ld){f.extra+=1,f.burst=t,f.seq=n,l.current=u;return}if(d.length>=Rd&&d.shift(),d.push({seq:n,burst:t,extra:0}),l.current=u,a===`idle`&&!r){let e=d.shift()??null;e&&(i(e),o(`in`))}},[n,t,e,a,r]),(0,_.useEffect)(()=>{if(a===`idle`)return;let e=null;return a===`in`?e=setTimeout(()=>o(`visible`),Fd):a===`visible`?e=setTimeout(()=>o(`out`),Pd):a===`out`&&(e=setTimeout(()=>{let e=s.current.shift()??null;e?(i(e),o(`in`)):(i(null),o(`idle`))},Id)),u.current=e,()=>{e&&clearTimeout(e)}},[a]),!r)return null;let{burst:d,extra:f}=r,p=Ga[d.decision]??`#ef4444`,m=vi(),h=a===`in`||a===`visible`?1:0,g=m||a===`in`||a===`visible`?0:-8,v=d.rule_id??`rule`,y=d.decision===`block`?`BLOCKED`:`FORCED`,b=f>0?`${d.tool} · +${f} more in this burst`:`${d.tool} · ${d.client}${d.agent_id?`:${d.agent_id}`:``}`;return(0,D.jsx)(`div`,{className:e?`pointer-events-none absolute top-2 left-1/2 z-30 select-none`:`pointer-events-none fixed top-20 left-1/2 z-40 select-none`,style:{transform:`translateX(-50%) translateY(${g}px) scale(1)`,opacity:h,transition:m?`opacity ${Fd}ms ease-out`:`opacity ${Fd}ms ease-out, transform ${Fd}ms cubic-bezier(0.34, 1.56, 0.64, 1)`},"aria-live":`polite`,"aria-atomic":`true`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3 rounded-md border bg-black/95 shadow-2xl`,style:{borderColor:p},children:[(0,D.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full shrink-0`,style:{background:p,boxShadow:m?`none`:`0 0 16px ${p}`}}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`text-[11px] font-mono uppercase tracking-[0.18em]`,style:{color:p},children:[y,` BY SSG`]}),(0,D.jsx)(`div`,{className:`text-[14px] font-mono text-[var(--color-fg-1)] truncate max-w-[420px]`,children:v}),(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] truncate max-w-[420px]`,children:b})]})]})})}var Bd=(0,_.memo)(function(e){let{sessionKey:t,bursts:n,paused:r,selectedId:i,onSelect:a,burstSeq:o,isStale:s,isFadingOut:c,minHeight:l,pinned:u,minimized:d,isFullscreen:f,viewMode:p=`full`,thumbnail:m=!1,onPromote:h,activePanelCount:g=1,onTogglePin:v,onToggleMinimize:y,onToggleFullscreen:b,onClose:x,onFrameTime:S}=e,C=p===`broadcast`,w=!m&&(p===`stream`||p===`broadcast`||f)?`large`:`normal`,T=t.indexOf(`:`),E=T>=0?t.slice(0,T):t,O=T>=0?t.slice(T+1):``,k=(0,_.useRef)(null),[A,j]=(0,_.useState)(!0),[M,N]=(0,_.useState)(null),ee=()=>{let e=k.current;if(!e)return;let t=e.querySelector(`canvas`);t instanceof HTMLCanvasElement&&N(t.toDataURL(`image/png`))},te=()=>{if(!M)return;let e=document.createElement(`a`),n=t.replace(/[^a-z0-9._-]+/gi,`-`);e.href=M,e.download=`ssg-graph-${n}-${Date.now()}.png`,document.body.appendChild(e),e.click(),e.remove()},P=()=>{!M||!navigator.clipboard?.write||fetch(M).then(e=>e.blob()).then(e=>{let t=new ClipboardItem({"image/png":e});return navigator.clipboard.write([t])}).catch(()=>{})},F=typeof navigator<`u`&&typeof navigator.clipboard?.write==`function`&&typeof ClipboardItem<`u`;(0,_.useEffect)(()=>{if(f){j(!0);return}let e=k.current;if(!e)return;let t=new IntersectionObserver(e=>{for(let t of e)j(t.isIntersecting)},{threshold:.01});return t.observe(e),()=>t.disconnect()},[f]);let ne=n.length>0?n[n.length-1]:null,re=ne?Ga[ne.decision]??`#6b7280`:`#6b7280`,ie=ne?.decision??null,I=ne?.tool??null,L=r||!A||d,R=(0,_.useMemo)(()=>n.length>24?n.slice(n.length-24):n,[n]);return(0,D.jsxs)(`div`,{ref:k,className:`relative flex flex-col shrink-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden${f?` flex-1 min-h-0`:``}`,style:{minHeight:d||f?void 0:l,opacity:c?0:1,transform:c?`scale(0.985)`:`scale(1)`,transformOrigin:`center center`,transition:`opacity 1100ms cubic-bezier(0.22, 1, 0.36, 1), transform 1100ms cubic-bezier(0.22, 1, 0.36, 1)`},children:[!C&&(0,D.jsxs)(`header`,{className:`group flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0 gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono min-w-0`,children:[u&&(0,D.jsx)(`span`,{className:`text-amber-300`,title:`Pinned`,children:`▲`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider`,children:E}),O&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate`,children:O})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono text-[var(--color-fg-4)]`,children:[I&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 max-w-[180px]`,title:ie?`latest: ${I} → ${ie}`:`latest: ${I}`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:re}}),(0,D.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:I})]}),(0,D.jsxs)(`span`,{className:`hidden md:inline text-[var(--color-fg-4)]`,children:[n.length,`n`]}),s?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-amber-300`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-amber-400`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`idle`})]}):(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-emerald-300`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`live`})]}),!m&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:v,className:`px-1.5 py-0.5 rounded border text-[10px] uppercase tracking-wider transition-colors ${u?`border-amber-500/60 text-amber-300`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-amber-300 hover:border-amber-500/40`}`,title:u?`Unpin`:`Pin to top`,children:`pin`}),(0,D.jsx)(`button`,{type:`button`,onClick:y,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:d?`Expand`:`Minimize`,children:d?`+`:`–`}),(0,D.jsx)(`button`,{type:`button`,onClick:ee,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:`Preview PNG snapshot of this panel`,children:`▣`}),(0,D.jsx)(`button`,{type:`button`,onClick:b,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:f?`Exit fullscreen`:`Fullscreen`,children:f?`×`:`⛶`}),x&&(0,D.jsx)(`button`,{type:`button`,onClick:x,"aria-label":`Close session ${t}`,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-rose-300 hover:border-rose-500/40 transition-colors`,title:`End this session on the graph`,children:`╳`})]})]})]}),!d&&!m&&!C&&(0,D.jsx)(bs,{sessionKey:t,className:`rounded-none border-x-0 border-t-0 border-b border-[var(--color-line-1)] shrink-0`}),M&&(0,D.jsxs)(`div`,{className:`absolute inset-0 z-40 flex flex-col items-center justify-center gap-3 bg-black/80 backdrop-blur-sm p-4`,children:[(0,D.jsx)(`img`,{src:M,alt:`Panel snapshot`,className:`max-w-full max-h-[60%] rounded-sm border border-[var(--color-line-1)] object-contain`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F&&(0,D.jsx)(`button`,{type:`button`,onClick:P,className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-2)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,children:`copy`}),(0,D.jsx)(`button`,{type:`button`,onClick:te,className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-2)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,children:`download`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-3)] hover:text-rose-300 hover:border-rose-500/40 transition-colors`,children:`close`})]})]}),!d&&(0,D.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[(0,D.jsx)(zd,{sessionKey:t}),(0,D.jsx)(ps,{bursts:R,paused:L,selectedId:i,onSelect:a,burstSeq:o,compact:!0,activePanelCount:g,labelDensity:w,onFrameTime:S}),m&&(0,D.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Promote ${E} to spotlight`,title:`Spotlight ${E}${O?` · ${O}`:``}`,className:`absolute inset-0 cursor-pointer bg-transparent hover:bg-sky-400/5 transition-colors`})]})]})}),Vd=200,Hd=.9,Ud=40,Wd=32,Gd=480,Kd=`transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease-out, fill 320ms ease-out`;function qd(e){let{playback:t,bursts:n,rangeStart:r,rangeEnd:i,loading:a,onPlayhead:o,onLive:s,onPause:c,onResume:l,on24h:u}=e,d=(0,_.useRef)(null),f=(0,_.useRef)(!1),[p,m]=(0,_.useState)(null),h=Math.max(1,i-r),g=(t.playhead_ms-r)/h*100,v=Math.max(0,Math.min(100,g)),y=(0,_.useMemo)(()=>{let e=[];for(let t=0;t<Vd;t++)e.push({allow:0,block:0,ask:0,other:0});for(let t of n){let n=t.ts_ms;if(n<r||n>i)continue;let a=e[Math.floor((n-r)/h*(Vd-1))];t.decision===`allow`?a.allow++:t.decision===`block`||t.decision===`force`?a.block++:t.decision===`ask`?a.ask++:a.other++}return e},[n,r,i,h]),b=(0,_.useCallback)(e=>{let t=d.current;if(!t)return;let n=t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(e-n.left)/n.width));if(i>=.98){s();return}o(r+i*h)},[r,h,o,s]),x=(0,_.useCallback)(e=>{let t=d.current;if(!t)return;let n=t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(e-n.left)/n.width));m({rel:i,ts:r+i*h})},[r,h]);(0,_.useEffect)(()=>{let e=e=>{f.current&&b(e.clientX)},t=()=>{f.current=!1};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[b]);let S=t.mode===`live`,C=S?`left ${Gd}ms linear`:`none`;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono uppercase tracking-wider`,children:[(0,D.jsx)(`button`,{onClick:()=>S?c():l(),className:`px-2.5 py-1 rounded-sm border transition-colors cursor-pointer ${S?`border-emerald-500/40 text-emerald-300 hover:bg-emerald-500/10`:`border-amber-500/40 text-amber-300 hover:bg-amber-500/10`}`,title:S?`Pause the live stream`:`Resume updates at this playhead`,children:S?`⏸ pause`:`▶ resume`}),(0,D.jsx)(`button`,{onClick:s,disabled:S,className:`px-2.5 py-1 rounded-sm border transition-colors cursor-pointer ${S?`border-[var(--color-line-1)] text-[var(--color-fg-4)] opacity-50`:`border-sky-500/40 text-sky-300 hover:bg-sky-500/10`}`,title:`Jump to live (now)`,children:`⏭ live`}),(0,D.jsx)(`button`,{onClick:u,className:`px-2.5 py-1 rounded-sm border border-violet-500/40 text-violet-300 hover:bg-violet-500/10 transition-colors cursor-pointer`,title:`Expand to last 24h — window covers now−24h through now. Backfills audit_log so the scrubber shows all recent evals.`,children:`◉ 24h`}),(0,D.jsx)(`div`,{className:`flex-1`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`mode`}),(0,D.jsx)(`span`,{className:S?`text-emerald-300`:t.mode===`paused`?`text-amber-300`:`text-violet-300`,children:t.mode}),a&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] animate-pulse`,children:`· backfilling`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`· t=`,Jd(t.playhead_ms)]})]}),(0,D.jsxs)(`div`,{ref:d,className:`relative h-10 w-full rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] cursor-pointer overflow-hidden select-none`,onPointerDown:e=>{f.current=!0,e.target.setPointerCapture?.(e.pointerId),b(e.clientX)},onPointerMove:e=>x(e.clientX),onPointerLeave:()=>m(null),children:[a&&(0,D.jsx)(`div`,{className:`absolute inset-0 pointer-events-none opacity-40 shimmer`,"aria-hidden":!0}),(0,D.jsxs)(`svg`,{viewBox:`0 0 ${Vd} ${Ud}`,preserveAspectRatio:`none`,className:`absolute inset-0 w-full h-full pointer-events-none`,"aria-hidden":!0,children:[[.25,.5,.75].map(e=>(0,D.jsx)(`line`,{x1:e*Vd,x2:e*Vd,y1:0,y2:Ud,stroke:`var(--color-line-1)`,strokeWidth:.3,strokeDasharray:`1,2`,opacity:.55},e)),y.map((e,t)=>{let n=e.allow+e.block+e.ask+e.other,r=Math.min(Wd,n*3),i=n===0?0:r/Wd,a=e.block>0?Ga.block:e.ask>0?Ga.ask:e.other>0&&e.allow===0?Ga.log:Ga.allow;return(0,D.jsx)(`rect`,{x:t+.05,y:Ud-Wd,width:Hd,height:Wd,rx:.3,fill:a,style:{opacity:n===0?0:.78,transform:`scaleY(${i})`,transformOrigin:`50% 100%`,transformBox:`fill-box`,transition:Kd}},t)})]}),p&&(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-white/15 pointer-events-none`,style:{left:`${p.rel*100}%`},"aria-hidden":!0}),(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 pointer-events-none`,style:{left:`${v}%`,width:`1px`,background:`linear-gradient(to bottom, rgba(125,211,252,0.85), rgba(56,189,248,1) 30%, rgba(56,189,248,0.85))`,boxShadow:`0 0 6px rgba(56,189,248,0.55)`,transition:C,willChange:`left`},children:(0,D.jsx)(`div`,{className:`absolute -top-0.5 -translate-x-1/2 w-2 h-2 rotate-45 bg-sky-300`,style:{boxShadow:`0 0 6px rgba(56,189,248,0.7)`}})}),S&&(0,D.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 pointer-events-none`,style:{width:`8px`,background:`linear-gradient(to left, rgba(74,222,128,0.55), rgba(74,222,128,0))`},"aria-hidden":!0,children:(0,D.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 w-[2px] bg-emerald-400 pulse-soft`})})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-mono text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{children:Yd(r)}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider transition-colors ${p?`text-sky-300`:``}`,children:p?`↳ ${Yd(p.ts)}`:`${Xd(t.window_ms)} window`}),(0,D.jsx)(`span`,{children:Yd(i)})]})]})}function Jd(e){let t=Date.now()-e;if(Math.abs(t)<1500)return`live`;let n=Math.round(t/1e3);if(n<60)return`−${n}s`;let r=Math.floor(n/60);return r<60?`−${r}m${n%60}s`:`−${Math.floor(r/60)}h${r%60}m`}function Yd(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Xd(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}var Zd=80,Qd=600,$d=Object.freeze({stop:()=>{},count:0}),ef=new Set([`allow`,`block`,`ask`,`log`,`force`,`shadow`]);function tf(e){if(!Se()||e.length===0)return $d;let t=[],n=!1,r=0;for(let i=0;i<e.length;i++){let a=e[i];if(i>0){let t=e[i-1],n=Math.max(0,a.ts_ms-t.ts_ms),o=Zd+Math.log2(1+n)*14;r+=Math.max(Zd,Math.min(Qd,o))}let o=ef.has(a.decision)?a.decision:null;if(!o)continue;let s=setTimeout(()=>{n||Oe(o)},r);t.push(s)}return{count:t.length,stop(){if(!n){n=!0;for(let e of t)clearTimeout(e);t.length=0}}}}var nf=1200,rf=3e4,af=3e3,of=6,sf=3,cf=`graph.panelState.v1`,lf=14400*1e3;function uf(e,t){let n=new Map;for(let t of e){let e=Wa(t),r=n.get(e);r?r.push(t):n.set(e,[t])}for(let[e,r]of n){let i=t.get(e);i&&i.length===r.length&&i[i.length-1]===r[r.length-1]&&n.set(e,i)}return n}function df(){if(typeof window>`u`)return new Map;try{let e=window.localStorage.getItem(cf);if(!e)return new Map;let t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function ff(e){if(!(typeof window>`u`))try{let t={};for(let[n,r]of e)t[n]=r;window.localStorage.setItem(cf,JSON.stringify(t))}catch{}}function pf(){let e=uo(),t=Ua(),n=Va(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),s=(0,_.useCallback)((e,t)=>{i(e),o(t??null)},[]),c=Zl();(0,_.useEffect)(()=>{n&&(n.decision===`block`?c.play(`block`):n.decision===`force`&&c.play(`force`))},[c.play,n.decision,n]);let l=(0,_.useCallback)(()=>c.play(`milestone`),[c]),u=(0,_.useCallback)(()=>c.play(`record`),[c]),[d,f]=(0,_.useState)(()=>{if(typeof window>`u`)return`full`;try{let e=window.localStorage.getItem(`graph.viewMode.v1`);if(e===`full`||e===`feed`||e===`stream`||e===`broadcast`)return e}catch{}return`full`});(0,_.useEffect)(()=>{if(!(typeof window>`u`))try{window.localStorage.setItem(`graph.viewMode.v1`,d)}catch{}},[d]),(0,_.useEffect)(()=>{let e=e=>e===`full`?`feed`:e===`feed`?`stream`:e===`stream`?`broadcast`:`full`,t=t=>{if(t.key===`Escape`&&d!==`full`){f(`full`);return}if(t.key===`b`||t.key===`B`){let n=t.target?.tagName;if(n===`INPUT`||n===`TEXTAREA`)return;f(e)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[d]);let p=d===`broadcast`,m=d===`stream`,h=d===`feed`,g=m||p,v=p,y=m,[b,x]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`ssg.sfx.enabled`)===null}catch{return!1}}),S=(0,_.useCallback)(()=>{c.toggle(),x(!1)},[c]),[C,w]=(0,_.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 767px)`).matches);(0,_.useEffect)(()=>{let e=window.matchMedia(`(max-width: 767px)`),t=e=>w(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[T,E]=(0,_.useState)(!1),O=(0,_.useRef)(null),k=(0,_.useCallback)(async e=>{try{await fetch(`/api/json/graph/close-sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e.length>0?{session_keys:e}:{})})}catch{}E(!1),O.current&&clearTimeout(O.current)},[]),A=(0,_.useCallback)(e=>{if(!T){E(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>E(!1),3e3);return}k(e)},[T,k]);(0,_.useEffect)(()=>()=>{O.current&&clearTimeout(O.current)},[]);let j=(0,_.useRef)(new Map),M=(0,_.useRef)(0),[N,ee]=(0,_.useState)({fps:0,active:0,hitches:0}),te=(0,_.useCallback)((e,t)=>{j.current.set(e,t),t>33&&(M.current+=1)},[]);(0,_.useEffect)(()=>{let e=setInterval(()=>{let e=j.current,t=M.current;if(M.current=0,e.size===0){ee(e=>e.active===0?e:{fps:0,active:0,hitches:0});return}let n=0;for(let t of e.values())n+=t;let r=n/e.size,i=r>0?Math.max(1,Math.round(1e3/r)):0;ee(n=>n.fps===i&&n.active===e.size&&n.hitches===t?n:{fps:i,active:e.size,hitches:t})},1e3);return()=>clearInterval(e)},[]);let{bursts:P,playback:F,oldest_known_ms:ne,newest_known_ms:re,loading_backfill:ie}=e.snapshot,I=(0,_.useRef)(new Map),L=(0,_.useMemo)(()=>{let e=uf(P,I.current);return I.current=e,e},[P]),[R,ae]=(0,_.useState)(()=>df()),[z,oe]=(0,_.useState)(null);(0,_.useEffect)(()=>{ff(R)},[R]),(0,_.useEffect)(()=>{let e=Date.now(),t=!1,n=new Map(R);for(let r of L.keys())n.has(r)||(n.set(r,{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:e}),t=!0);for(let[r,i]of n)L.has(r)||i.pinned||e-i.firstSeenAt<lf||(n.delete(r),t=!0);t&&ae(n)},[L,R]);let se=(0,_.useRef)(new Map),ce=(0,_.useRef)(new Set),le=(0,_.useRef)(new Map),[,ue]=(0,_.useState)(0);(0,_.useEffect)(()=>{let e=performance.now(),t=se.current,n=ce.current,r=le.current,i=new Set;for(let[e,n]of L)i.add(e),r.set(e,n.slice()),t.delete(e);for(let a of n)if(!i.has(a)&&!t.has(a)){let n=r.get(a)??[],i=n[n.length-1]?.ts_ms??0;t.set(a,{bursts:n,diedAt:e,newestTs:i})}for(let[n,i]of t)e-i.diedAt>=nf&&(t.delete(n),r.delete(n));if(ce.current=i,t.size>0){let n=1/0;for(let e of t.values())n=Math.min(n,e.diedAt+nf);let r=Math.max(16,n-e+16),i=setTimeout(()=>ue(e=>e+1),r);return()=>clearTimeout(i)}},[L]);let de=(0,_.useCallback)(e=>{ae(t=>{let n=new Map(t),r=n.get(e)??{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()};return n.set(e,{...r,pinned:!r.pinned,pinnedAt:r.pinned?0:Date.now()}),n})},[]),fe=(0,_.useCallback)(e=>{ae(t=>{let n=new Map(t),r=n.get(e)??{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()};return n.set(e,{...r,minimized:!r.minimized}),n})},[]),pe=(0,_.useCallback)(e=>{oe(t=>t===e?null:e)},[]);(0,_.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&oe(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let me=(0,_.useRef)(null),[he,ge]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!z){me.current?.stop(),me.current=null,ge(null);return}let e=!1;ge({sessionKey:z,entries:[],loading:!0,error:null});let t=`/api/json/graph/session-audit?session_key=${encodeURIComponent(z)}`;return fetch(t,{credentials:`same-origin`}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(e)return;let n=Array.isArray(t.rows)?t.rows:[];ge({sessionKey:z,entries:n,loading:!1,error:null});let r=n.map(e=>({ts_ms:e.ts_ms,decision:e.decision,tool:e.tool}));me.current?.stop(),me.current=tf(r)}).catch(t=>{e||ge({sessionKey:z,entries:[],loading:!1,error:t instanceof Error?t.message:`failed to load audit log`})}),()=>{e=!0,me.current?.stop(),me.current=null}},[z]);let _e=(0,_.useMemo)(()=>{let e={pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()},t=[];for(let[n,r]of L){let i=r[r.length-1]?.ts_ms??0;t.push({key:n,bursts:r,newestTs:i,fadingOutAt:null,state:R.get(n)??e})}for(let[n,r]of se.current)L.has(n)||t.push({key:n,bursts:r.bursts,newestTs:r.newestTs,fadingOutAt:r.diedAt,state:R.get(n)??e});return t.sort((e,t)=>e.state.pinned===t.state.pinned?e.state.pinned&&t.state.pinned?e.state.pinnedAt-t.state.pinnedAt:e.state.firstSeenAt-t.state.firstSeenAt:e.state.pinned?-1:1),t},[L,R]),ve=(0,_.useMemo)(()=>{if(!r)return null;for(let e of P)if((e.audit_id??`${e.ts_ms}:${e.tool}`)===r||r.startsWith(`${e.ts_ms}:${e.tool}`))return e;return null},[P,r]),[ye,be]=(0,_.useState)(null),xe=(0,_.useRef)(null),Se=(0,_.useMemo)(()=>{if(_e.length===0)return xe.current=null,null;if(ye!=null&&_e.some(e=>e.key===ye))return xe.current=ye,ye;let e=_e.filter(e=>e.state.pinned);if(e.length>0)return e.sort((e,t)=>t.state.pinnedAt-e.state.pinnedAt),xe.current=e[0].key,e[0].key;let t=_e[0];for(let e of _e)e.newestTs>t.newestTs&&(t=e);let n=xe.current;if(n!=null&&n!==t.key){let e=_e.find(e=>e.key===n);if(e&&Date.now()-e.newestTs<af)return n}return xe.current=t.key,t.key},[_e,ye]);(0,_.useEffect)(()=>{ye!=null&&(_e.some(e=>e.key===ye)||be(null))},[ye,_e]),(0,_.useEffect)(()=>{be(null)},[]);let Ce=(0,_.useMemo)(()=>{if(_e.length===0)return{hero:null,grid:[],rail:[],overflow:[]};if(d===`full`||d===`feed`)return{hero:null,grid:_e.slice(0,of),rail:_e.slice(of),overflow:[]};let e=_e.find(e=>e.key===Se)??_e[_e.length-1],t=_e.filter(t=>t.key!==e.key);return d===`broadcast`?{hero:e,grid:[],rail:[],overflow:t}:{hero:e,grid:[],rail:t.slice(0,sf),overflow:t.slice(sf)}},[_e,d,Se]),we=(0,_.useCallback)(e=>{be(e)},[]),Te=(0,_.useCallback)(()=>{be(null)},[]);_e.map(e=>e.key).join(`,`);let Ee=(0,_.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;for(let o of _e){let s=o.key;e.set(s,()=>de(s)),t.set(s,()=>fe(s)),n.set(s,()=>pe(s)),r.set(s,()=>void k([s])),i.set(s,e=>te(s,e)),a.set(s,()=>we(s))}return{onTogglePin:e,onToggleMinimize:t,onToggleFullscreen:n,onClose:r,onFrameTime:i,onPromote:a}},[de,fe,pe,k,te,we,_e]);(0,_.useEffect)(()=>{let e=new Set(_e.map(e=>e.key)),t=j.current;for(let n of Array.from(t.keys()))e.has(n)||t.delete(n)},[_e]);let De=(0,_.useMemo)(()=>{let e=n?.counters,t=e?.total??0,r=(e?.block??0)+(e?.force??0),i=0;if(P.length>0){let e=0,t=P.slice(-100);for(let n of t)e+=n.duration_ns;i=e/t.length/1e6}return{evals:t,blocks:r,avgMs:i,agents:_e.length}},[n,P,_e.length]),Oe=Math.min(ne,F.playhead_ms-F.window_ms),ke=Math.max(re,F.playhead_ms),Ae=Ce.grid.length,je=C||Ae<=1?1:Ae<=4?2:3,Me=Math.max(1,Math.ceil(Math.max(1,Ae)/je)),Ne=Ae<=1||C?360:180,Pe=z?_e.find(e=>e.key===z):null,B=e=>e>=1e4?`${Math.round(e/1e3)}k`:e.toLocaleString();return(0,D.jsxs)(`div`,{className:`grid gap-3 md:h-[calc(100dvh-4.5rem)] md:min-h-[560px] ${g?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[auto_minmax(0,1fr)_auto]`} ${p?`bg-black`:``}`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between flex-wrap gap-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,D.jsx)(`h1`,{className:`text-sm font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`graph intelligence`}),!p&&(0,D.jsx)(`span`,{className:`chip text-sky-300 border-sky-500/30`,children:`real-time tool-use`}),F.mode===`live`?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`streaming`]}):(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-amber-300`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-amber-400`}),F.mode]}),(0,D.jsxs)(`span`,{className:`flex items-center gap-x-3 gap-y-1 flex-wrap text-[11px] font-mono text-[var(--color-fg-3)] pl-3 border-l border-[var(--color-line-1)]`,children:[(0,D.jsxs)(`span`,{title:`Total evaluations since daemon start`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`↑`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:B(De.evals)}),` `,(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`evals`})]}),(0,D.jsxs)(`span`,{title:`Block + force decisions — dangerous tool calls intercepted by SSG rules`,children:[(0,D.jsx)(`span`,{className:`text-rose-400`,children:`⛔`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:B(De.blocks)}),` `,(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`blocks`})]}),(0,D.jsxs)(`span`,{className:`hidden md:inline`,title:`Mean eval latency over the last 100 bursts`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`⏱`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:De.avgMs<1?`${(De.avgMs*1e3).toFixed(0)}µs`:`${De.avgMs.toFixed(1)}ms`})]}),(0,D.jsxs)(`span`,{title:`Concurrent agent sessions in this window`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`⌥`}),` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:De.agents}),` `,(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`agent`,De.agents===1?``:`s`]})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!p&&(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[P.length,`n · window `,Math.round(F.window_ms/1e3),`s`]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,title:`Average RAF interval across ${N.active} canvas${N.active===1?``:`es`}${N.hitches>0?` · ${N.hitches} hitch${N.hitches===1?``:`es`} (>33ms frames)`:``}`,children:[N.active===0?`—`:`${N.fps}fps${N.hitches>0?` (${N.hitches}h)`:``}`,` · `,N.active,`/`,_e.length]}),(0,D.jsx)(`div`,{role:`group`,"aria-label":`Graph view mode`,className:`inline-flex items-stretch rounded border border-[var(--color-line-1)] overflow-hidden text-[10px] font-mono uppercase tracking-wider`,title:`View mode — B cycles, Esc returns to full`,children:[`full`,`feed`,`stream`,`broadcast`].map(e=>{let t=d===e,n=e===`broadcast`?`cast`:e,r=e===`full`?`Full dashboard — sidebar, timeline, all controls`:e===`feed`?`Feed mode — vertical timeline of tool calls for non-technical users`:e===`stream`?`Stream mode — spotlight layout for Twitch/YouTube viewers`:`Broadcast mode — pure canvas for OBS scenes (Esc to exit)`;return(0,D.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":t,title:r,className:`px-2 py-0.5 transition-colors cursor-pointer ${t?e===`broadcast`?`bg-amber-500/15 text-amber-300`:e===`stream`?`bg-sky-500/15 text-sky-300`:e===`feed`?`bg-emerald-500/15 text-emerald-300`:`bg-[var(--color-fg-4)]/10 text-[var(--color-fg-1)]`:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] hover:bg-white/5`}`,children:n},e)})}),(0,D.jsx)(`button`,{type:`button`,onClick:S,className:`chip cursor-pointer transition-colors ${b&&!c.enabled?`border-amber-500/60 text-amber-300 animate-pulse`:`hover:border-sky-500/50 hover:text-sky-300`}`,title:c.enabled?`Mute stream sounds`:`Enable stream sounds`,children:c.enabled?`SFX ON`:b?`🔊 enable cues`:`SFX OFF`}),!p&&_e.length>0&&(0,D.jsx)(`div`,{"aria-live":`polite`,children:(0,D.jsx)(`button`,{type:`button`,"aria-label":`Clear all visible graph sessions`,onClick:()=>A(_e.filter(e=>!e.fadingOutAt).map(e=>e.key)),className:`chip cursor-pointer transition-colors ${T?`border-rose-500/60 text-rose-300`:`hover:border-rose-500/40 hover:text-rose-300`}`,title:`Close all active sessions on the graph — equivalent to /clear but reflects on the graph`,children:T?`confirm clear ${_e.filter(e=>!e.fadingOutAt).length}`:`clear`})})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 ${v?``:y?`lg:grid-cols-[1fr_240px]`:`lg:grid-cols-[1fr_300px]`} gap-3 min-h-0 md:overflow-hidden`,children:[(0,D.jsx)(`div`,{className:`flex flex-col gap-3 min-h-0 min-w-0`,children:h?(0,D.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:(0,D.jsx)(_d,{bursts:P,selectedId:r,onSelect:s})}):_e.length===0?(0,D.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-center px-4`,style:{minHeight:240},children:[(0,D.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`graph · idle`}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[280px]`,children:`No active sessions in the current window. Each session will render as its own tree as bursts arrive.`})]}):(0,D.jsxs)(D.Fragment,{children:[Ce.hero&&(z==null||z===Ce.hero.key)&&(0,D.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2`,children:[ye!=null&&(0,D.jsx)(`button`,{type:`button`,onClick:Te,className:`self-end chip text-amber-300 border-amber-500/40 hover:border-amber-400 cursor-pointer text-[10px]`,title:`Release manual spotlight — return to auto-follow`,children:`spotlight: locked · release ↺`}),(0,D.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,D.jsx)(Bd,{sessionKey:Ce.hero.key,bursts:Ce.hero.bursts,paused:F.mode!==`live`||Ce.hero.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Ce.hero.fadingOutAt!=null||F.playhead_ms-Ce.hero.newestTs>rf,isFadingOut:Ce.hero.fadingOutAt!=null,minHeight:0,pinned:Ce.hero.state.pinned,minimized:Ce.hero.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:1,onTogglePin:Ee.onTogglePin.get(Ce.hero.key),onToggleMinimize:Ee.onToggleMinimize.get(Ce.hero.key),onToggleFullscreen:Ee.onToggleFullscreen.get(Ce.hero.key),onClose:Ee.onClose.get(Ce.hero.key),onFrameTime:Ee.onFrameTime.get(Ce.hero.key)},Ce.hero.key)})]}),Ce.grid.length>0&&(0,D.jsx)(`div`,{className:`flex-1 grid gap-3 min-h-0 min-w-0`,style:{gridTemplateColumns:`repeat(${je}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${Me}, minmax(180px, 1fr))`},children:Ce.grid.map(e=>{let n=e.fadingOutAt!=null||F.playhead_ms-e.newestTs>rf;return z!=null&&z!==e.key?null:(0,D.jsx)(Bd,{sessionKey:e.key,bursts:e.bursts,paused:F.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:Ne,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:Ce.grid.length,onTogglePin:Ee.onTogglePin.get(e.key),onToggleMinimize:Ee.onToggleMinimize.get(e.key),onToggleFullscreen:Ee.onToggleFullscreen.get(e.key),onClose:Ee.onClose.get(e.key),onFrameTime:Ee.onFrameTime.get(e.key)},e.key)})}),Ce.rail.length>0&&(0,D.jsxs)(`div`,{className:`shrink-0 flex flex-col gap-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:[(0,D.jsxs)(`span`,{children:[d===`full`?`overflow rail`:`spotlight rail`,` · `,Ce.rail.length,` session`,Ce.rail.length===1?``:`s`]}),Ce.overflow.length>0&&(0,D.jsxs)(`span`,{title:Ce.overflow.map(e=>e.key).join(`
15
+ `),children:[`+`,Ce.overflow.length,` more`]})]}),(0,D.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${Math.min(Ce.rail.length,4)}, minmax(0, 1fr))`,gridAutoRows:`110px`},children:Ce.rail.map(e=>{let n=e.fadingOutAt!=null||F.playhead_ms-e.newestTs>rf;return z!=null&&z!==e.key?null:(0,D.jsx)(Bd,{sessionKey:e.key,bursts:e.bursts,paused:F.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:110,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,thumbnail:!0,onPromote:Ee.onPromote.get(e.key),activePanelCount:Ce.rail.length+1,onTogglePin:Ee.onTogglePin.get(e.key),onToggleMinimize:Ee.onToggleMinimize.get(e.key),onToggleFullscreen:Ee.onToggleFullscreen.get(e.key),onClose:Ee.onClose.get(e.key),onFrameTime:Ee.onFrameTime.get(e.key)},e.key)})})]}),d===`broadcast`&&Ce.overflow.length>0&&(0,D.jsxs)(`div`,{className:`shrink-0 self-end pointer-events-none chip text-[var(--color-fg-3)] border-[var(--color-line-1)]`,children:[`+`,Ce.overflow.length,` more session`,Ce.overflow.length===1?``:`s`,` off-screen`]})]})}),!v&&(0,D.jsxs)(`aside`,{className:`flex flex-col gap-2 min-w-0 min-h-0 overflow-y-auto`,children:[(0,D.jsx)(Cd,{onMilestone:l,onRecord:u}),!y&&(0,D.jsx)(`section`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,D.jsx)(Ed,{bursts:P,allBursts:e.allBursts})}),(0,D.jsx)(Ad,{burst:ve,anchor:a,onClose:()=>{i(null),o(null)}})]})]}),!g&&(0,D.jsx)(`section`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,D.jsx)(qd,{playback:F,bursts:P,rangeStart:Oe,rangeEnd:ke,loading:ie,onPlayhead:t=>e.setPlayhead(t),onLive:()=>e.jumpToLive(),onPause:()=>e.setMode(`paused`),onResume:()=>e.setMode(`scrubbing`),on24h:()=>e.jumpTo24h()})}),p&&(0,D.jsxs)(`div`,{className:`pointer-events-none fixed bottom-3 right-4 flex flex-col items-end gap-1 z-30`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-[0.18em] text-[var(--color-fg-3)]`,children:`sigmashake gov`}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`broadcast mode · press B or Esc to exit`})]}),Pe&&(0,D.jsxs)(`div`,{className:`fixed inset-0 z-50 bg-black/90 backdrop-blur-sm flex p-6 gap-4`,children:[(0,D.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:(0,D.jsx)(Bd,{sessionKey:Pe.key,bursts:Pe.bursts,paused:F.mode!==`live`||Pe.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Pe.fadingOutAt!=null||F.playhead_ms-Pe.newestTs>rf,isFadingOut:!1,minHeight:0,pinned:Pe.state.pinned,minimized:!1,isFullscreen:!0,viewMode:d,onTogglePin:()=>de(Pe.key),onToggleMinimize:()=>fe(Pe.key),onToggleFullscreen:()=>pe(Pe.key)},`fs-${Pe.key}`)}),(0,D.jsx)(`aside`,{className:`hidden md:flex shrink-0 w-[380px] lg:w-[420px] flex-col min-h-0`,children:(0,D.jsx)(vd,{sessionKey:Pe.key,entries:he?.sessionKey===Pe.key?he.entries:[],loading:he?.sessionKey===Pe.key?he.loading:!0,error:he?.sessionKey===Pe.key?he.error:null,playingIndex:-1})})]})]})}function mf(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!1);async function u(){l(!0),a(``);try{let e=await fetch(`/api/hub/device-start`,{method:`POST`,headers:{Accept:`application/json`,...H()}}),n=await e.json();if(!e.ok){let t=n;t.error===`not_configured`?(r(`not_configured`),s(t.setup_steps??[]),a(t.message??`GitHub OAuth not configured.`)):(a(n.error??`HTTP ${e.status}`),r(`error`));return}t(n),r(`polling`)}catch(e){a(e instanceof Error?e.message:`Failed to start`),r(`error`)}finally{l(!1)}}return(0,_.useEffect)(()=>{if(n!==`polling`||!e)return;let t=setInterval(async()=>{try{let n=await(await fetch(`/api/hub/device-poll?flow=${e.flow_id}`,{headers:{Accept:`application/json`}})).json();n.status===`complete`?(clearInterval(t),r(`done`),a(`connected as @${n.session?.login??`GitHub`} — you can now publish rulesets`)):(n.status===`expired`||n.status===`error`)&&(clearInterval(t),r(`error`),a(n.error??`Authentication failed`))}catch{}},3e3);return()=>clearInterval(t)},[n,e]),(0,D.jsxs)(`div`,{className:`max-w-lg mx-auto space-y-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`a`,{href:`/hub`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors`,children:[(0,D.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,D.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),`back to hub`]}),(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-2 text-[var(--color-fg-0)]`,children:`Connect GitHub`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`authenticate with github to publish rulesets to the hub`})]}),n===`not_configured`&&(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`span`,{className:`text-amber-300 shrink-0 mt-0.5`,children:(0,D.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-[var(--color-fg-0)]`,children:`GitHub OAuth not configured`}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:i})]})]}),(0,D.jsxs)(`div`,{className:`border-t border-[var(--color-line-0)] pt-4`,children:[(0,D.jsx)(`div`,{className:`overline mb-3`,children:`setup steps`}),(0,D.jsx)(`ol`,{className:`space-y-2`,children:o.map((e,t)=>(0,D.jsxs)(`li`,{className:`flex items-start gap-2.5 text-xs text-[var(--color-fg-1)]`,children:[(0,D.jsx)(`span`,{className:`shrink-0 w-5 h-5 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)] text-[var(--color-fg-3)] text-[10px] font-mono flex items-center justify-center tabular-nums`,children:t+1}),(0,D.jsx)(`span`,{className:`mt-0.5 leading-relaxed`,children:e.replace(/^\d+\.\s+/,``)})]},t))})]}),(0,D.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3`,children:[(0,D.jsx)(`div`,{className:`overline mb-1.5`,children:`quick start`}),(0,D.jsx)(`code`,{className:`text-[11px] text-[var(--color-brand)]/90 font-mono`,children:`export SSG_GITHUB_CLIENT_ID=<your-client-id>`}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1`,children:[`then restart:`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-fg-1)]`,children:`ssg serve`})]})]}),(0,D.jsx)(`a`,{href:`https://github.com/settings/applications/new`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline`,children:`create github oauth app →`})]})}),n===`idle`&&(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mb-4 leading-relaxed`,children:`This uses GitHub's device authorization flow — no redirect URIs needed. You'll be shown a code to enter at github.com.`}),(0,D.jsx)(q,{onClick:u,disabled:c,variant:`primary`,children:c?`starting…`:`connect with github`})]})}),e&&n===`polling`&&(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`text-center`,children:[(0,D.jsx)(`div`,{className:`overline mb-2`,children:`open this url in your browser`}),(0,D.jsx)(`a`,{href:e.verification_uri,target:`_blank`,rel:`noreferrer`,className:`text-sm text-[var(--color-brand)] hover:underline font-mono`,children:e.verification_uri})]}),(0,D.jsxs)(`div`,{className:`border border-[var(--color-line-1)] bg-[var(--color-surface-0)] rounded-sm py-5 text-center`,children:[(0,D.jsx)(`div`,{className:`overline mb-3`,children:`enter this code`}),(0,D.jsx)(`div`,{className:`text-4xl font-mono font-bold tracking-[0.3em] text-[var(--color-fg-0)]`,children:e.user_code})]}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] text-center flex items-center justify-center gap-2`,children:[(0,D.jsx)(`svg`,{className:`animate-spin`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`waiting for github authorization…`]})]})}),n===`done`&&(0,D.jsxs)(`div`,{className:`rounded-sm border border-emerald-500/25 bg-emerald-500/5 p-4 text-sm text-emerald-200 space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,D.jsx)(`span`,{className:`font-mono text-xs`,children:i})]}),(0,D.jsx)(`a`,{href:`/hub/publish`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline block mt-1`,children:`publish a ruleset →`})]}),n===`error`&&i&&(0,D.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/5 p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-red-200 font-mono`,children:i}),(0,D.jsx)(`button`,{onClick:()=>{r(`idle`),a(``)},className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] mt-3 cursor-pointer uppercase tracking-wider`,children:`← try again`})]})]})}var hf={deny:`red`,block:`red`,ask:`amber`,allow:`green`,log:`gray`,force:`blue`};function gf({id:e}){let{data:t,error:n}=V(`/api/json/hub/${e}`),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1);if(n)return(0,D.jsxs)(`div`,{className:`text-sm text-red-300 font-mono`,children:[(0,D.jsx)(`p`,{children:n}),(0,D.jsx)(`a`,{href:`/hub`,className:`text-[var(--color-brand)] hover:underline mt-3 block text-[11px] uppercase tracking-wider`,children:`← back to hub`})]});if(!t)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading ruleset…`});async function s(){o(!0);try{(await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({id:e})})).ok&&i(!0)}finally{o(!1)}}return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← hub`}),(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-1.5 text-[var(--color-fg-0)]`,children:t.title}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 tabular-nums`,children:[`@`,t.author,` · v`,t.version,` · `,t.rule_count,` rule`,t.rule_count===1?``:`s`]})]}),(0,D.jsx)(q,{variant:r?`secondary`:`primary`,onClick:s,disabled:a||r,children:r?`✓ installed`:a?`installing…`:`install`})]}),t.technologies.length>0&&(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.technologies.map(e=>(0,D.jsx)(K,{variant:`blue`,children:e},e))}),t.github_repo&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`source`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:t.github_repo})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`rules · `,t.rules.length]})}),(0,D.jsx)(X,{className:`space-y-4`,children:t.rules.map((e,t)=>(0,D.jsxs)(`div`,{className:t>0?`border-t border-[var(--color-line-0)] pt-4`:void 0,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[(0,D.jsx)(K,{variant:hf[e.decision]??`gray`,children:e.decision}),(0,D.jsx)(`code`,{className:`text-xs text-[var(--color-brand)] font-mono`,children:e.name}),e.capability&&(0,D.jsx)(K,{variant:`gray`,children:e.capability})]}),(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-1)] mb-2`,children:e.message}),(0,D.jsx)(Bi,{children:e.raw_text})]},e.id))})]})]})}var _f=[{id:`safe-writes`,title:`Protect your files from accidents`,plainDescription:`Asks before AI overwrites or erases anything important — so you stay in control of what changes.`,example:`If AI tries to overwrite a config file, you get to approve it first.`,hubRulesetId:`safe-writes`,scenario:`any`,emoji:`🛡️`,details:{protects:[`Asks first before editing project manifests & lockfiles — package.json, Cargo.toml, go.mod, and friends`,`Asks first before editing shell startup files — .bashrc, .zshrc, .profile`,`Asks first before editing git config or git hooks`,`Asks first before editing CI / build pipeline files`,`Asks first before editing AI-agent instruction files — CLAUDE.md, .cursorrules, AGENTS.md`],tryThis:`Ask your AI to add a dependency to package.json. Instead of saving silently, it pauses for your approval first.`}},{id:`no-destructive-fs`,title:`Stop AI from erasing files`,plainDescription:`Blocks the kind of filesystem operations that can permanently delete your work.`,example:`If AI tries to wipe a folder, SSG blocks it automatically.`,hubRulesetId:`no-destructive-fs`,scenario:`coding`,emoji:`🗑️`,details:{protects:[`Blocks recursive force-deletes that can wipe an entire directory tree in a single command`,`Blocks bulk deletes through find with delete or exec-remove predicates`,`Blocks disk-wipe, format & partition tools — dd, mkfs, shred, fdisk`,`Blocks Windows recursive deletes — Remove-Item with Recurse, rmdir /s, del /s`,`Blocks git clean with its force flags, which erases untracked and ignored files alike`],tryThis:`Ask your AI to recursively delete a throwaway folder. The attempt is blocked outright — it never reaches your shell.`}},{id:`secrets-guard`,title:`Keep secrets and credentials safe`,plainDescription:`Watches for AI trying to read or write your passwords, API keys, and private keys.`,example:`Reading your .env file, SSH keys, or .netrc triggers an approval request.`,hubRulesetId:`secrets-guard`,scenario:`any`,emoji:`🔑`,details:{protects:[`Blocks reading .env files`,`Blocks reading private keys, SSH keys, .netrc & .pgpass`,`Blocks reading cloud credential stores — AWS, GCP, Azure, kube, docker`,`Blocks dumping secret files through cat / head / tail / type`,`Blocks writing hardcoded API keys — AWS, Anthropic, OpenAI — into source`,`Blocks writing PEM private keys into source files`],tryThis:`Ask your AI to read your .env file. The read is blocked, so the contents never land in the chat transcript.`}},{id:`email-guardrails`,title:`Ask before AI sends emails`,plainDescription:`Makes sure AI never sends a message on your behalf without your explicit OK.`,example:`Any outbound email action is queued for your approval before it goes.`,hubRulesetId:`email-guardrails`,scenario:`knowledge-work`,emoji:`📧`,details:{protects:[`Asks first before local mail commands — mail, sendmail, mutt, msmtp`,`Asks first before curl is used to talk SMTP directly`,`Asks first before calls to transactional-email APIs — SendGrid, Mailgun, Postmark, Resend, SES, and more`],tryThis:`Ask your AI to send a quick test email. It pauses and asks you to confirm the recipient and body before anything goes out.`}},{id:`no-paid-apis`,title:`Block surprise charges from paid APIs`,plainDescription:`Blocks AI from calling APIs that can rack up unexpected bills — cloud storage, AI providers, payment services.`,example:`A call to OpenAI, AWS S3, or Stripe triggers a block until you allow it.`,hubRulesetId:`no-paid-apis`,scenario:`any`,emoji:`💳`,details:{protects:[`Asks first before calls to paid LLM APIs — OpenAI, Anthropic, Groq, Bedrock, and more`,`Asks first before payment APIs — Stripe, PayPal, Square, Adyen`,`Asks first before SMS / voice APIs — Twilio, Vonage, MessageBird`,`Asks first before cloud-storage writes — aws s3 cp/sync, gsutil, az storage`],tryThis:`Ask your AI to call the OpenAI API. It checks with you before sending — so a runaway loop cannot quietly rack up spend.`}},{id:`read-only-mode`,title:`Read-only mode (maximum safety)`,plainDescription:`AI can look but not touch — all write operations are blocked. Great when you just want to explore safely.`,example:`AI can read your codebase and answer questions but cannot change any files.`,hubRulesetId:`read-only`,scenario:`any`,emoji:`🔒`,details:{protects:[`Blocks every file write and edit`,`Blocks state-changing shell commands — file deletes & moves, package installs, sudo, docker, kubectl, terraform`,`Blocks shell redirection that writes to disk`,`Blocks git commands that change state — commit, push, reset, checkout`,`Blocks network requests that are not GET — no POST, PUT, PATCH, DELETE`],tryThis:`Ask your AI to edit any file. Every write is refused until you remove this pack — but reading code and answering questions still works.`}}];function vf(e){return e?_f.filter(t=>t.scenario===`any`||t.scenario===e):_f}function yf({pack:e,installed:t,state:n,expanded:r,onInstall:i,onUninstall:a,onToggleDetails:o}){let s=n!==`idle`;return(0,D.jsxs)(`div`,{className:`ss-list-row ss-list-row--pack`,style:{cursor:`default`,background:t?`linear-gradient(180deg, color-mix(in oklab, var(--color-hig-green) 8%, transparent) 0%, transparent 60%), var(--color-surface-1)`:`var(--color-surface-1)`,borderColor:t?`color-mix(in oklab, var(--color-hig-green) 28%, var(--color-line-1))`:`var(--color-line-1)`},children:[(0,D.jsxs)(`div`,{className:`ss-pack-main`,children:[(0,D.jsx)(`span`,{className:`ss-pack-emoji`,"aria-hidden":`true`,children:e.emoji}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`h3`,{className:`ss-pack-title`,children:e.title}),t&&(0,D.jsxs)(`span`,{className:`agent-badge agent-badge--detected`,title:`This pack is currently active.`,children:[(0,D.jsx)(`span`,{className:`agent-badge-dot`}),`Installed`]})]}),(0,D.jsx)(`p`,{className:`ss-pack-desc`,children:e.plainDescription}),(0,D.jsxs)(`p`,{className:`ss-pack-example`,children:[(0,D.jsx)(`span`,{className:`ss-pack-example__label`,children:`Example`}),e.example]}),(0,D.jsx)(`button`,{type:`button`,className:`ss-pack-detail-toggle`,"aria-expanded":r,onClick:()=>o(e.id),children:r?`Hide details`:t?`What this is doing →`:`What's inside →`})]}),(0,D.jsx)(`div`,{className:`ss-pack-action`,children:t?(0,D.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:`ss-btn ss-btn--secondary`,style:{height:30,padding:`0 12px`,fontSize:11},title:`Remove this pack from your machine.`,children:n===`uninstalling`?`Removing…`:`Remove`}):(0,D.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:`ss-btn ss-btn--primary`,style:{height:30,padding:`0 14px`,fontSize:11},title:`Install this guardrail pack.`,children:n===`installing`?`Installing…`:`Install`})})]}),r&&(0,D.jsxs)(`div`,{className:`ss-pack-detail`,children:[(0,D.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,D.jsx)(`span`,{className:`ss-pack-detail__label`,children:t?`Installed`:`What gets installed`}),(0,D.jsxs)(`p`,{className:`ss-pack-detail__text`,children:[(0,D.jsxs)(`code`,{children:[e.hubRulesetId,`.rules`]}),` — one plain-text rules file`,t?` now living in `:`, written to `,`your `,(0,D.jsx)(`code`,{children:`.sigmashake/rules/`}),` folder.`,` `,t?`It's active right away — no restart needed.`:`Installing adds just this one file; removing the pack deletes it.`]})]}),(0,D.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,D.jsx)(`span`,{className:`ss-pack-detail__label`,children:`What it does`}),(0,D.jsx)(`ul`,{className:`ss-pack-detail__list`,children:e.details.protects.map(e=>(0,D.jsx)(`li`,{children:e},e))})]}),(0,D.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,D.jsx)(`span`,{className:`ss-pack-detail__label`,children:`See it working`}),(0,D.jsx)(`p`,{className:`ss-pack-detail__text`,children:e.details.tryThis}),(0,D.jsxs)(`p`,{className:`ss-pack-detail__hint`,children:[`Every block and approval prompt is logged on the`,` `,(0,D.jsx)(`a`,{href:`/audit`,children:`Activity`}),` page. To fire a rule on purpose without leaving the dashboard, open `,(0,D.jsx)(`a`,{href:`/try`,children:`Try It`}),`.`]})]})]})]})}function bf(){let e=new URLSearchParams(window.location.search).get(`starter`),t=vf(e),[n,r]=(0,_.useState)(new Set),[i,a]=(0,_.useState)({}),[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)(null);function u(e){s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}(0,_.useEffect)(()=>{let e=!1;return fetch(`/api/json/hub/installed`).then(e=>e.json()).then(t=>{e||r(new Set(t.installed))}).catch(()=>{}),()=>{e=!0}},[]);function d(e,t){l({msg:e,type:t}),setTimeout(()=>l(null),5e3)}async function f(){try{let e=await(await fetch(`/api/json/hub/installed`)).json();r(new Set(e.installed))}catch{}}async function p(e){let t=_f.find(t=>t.id===e);if(t){a(t=>({...t,[e]:`installing`}));try{let n=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({id:t.hubRulesetId})}),i=await n.text(),a=n.headers.get(`Content-Type`)??``,o=null;if(a.includes(`application/json`))try{o=JSON.parse(i)}catch{}o?.ok?(r(e=>new Set([...e,t.hubRulesetId])),s(t=>new Set([...t,e])),d(o.already_installed?`${t.title} — already installed`:`${t.title} — installed`,`ok`)):d(o?o.error??`Could not install ${t.title}`:i.replace(/<[^>]+>/g,``).trim()||`Could not install ${t.title} (HTTP ${n.status})`,`error`)}catch(e){d(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{a(t=>({...t,[e]:`idle`})),f()}}}async function m(e){let t=_f.find(t=>t.id===e);if(t&&window.confirm(`Remove “${t.title}”?\n\nThe rules in this pack stop applying. You can install it again any time.`)){a(t=>({...t,[e]:`uninstalling`}));try{let e=await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({id:t.hubRulesetId})}),n=await e.text(),i=e.headers.get(`Content-Type`)??``,a=null;if(i.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok||e.ok&&!a?(r(e=>{let n=new Set(e);return n.delete(t.hubRulesetId),n}),d(`${t.title} — removed`,`ok`)):d(a?a.error??`Could not remove ${t.title}`:n.replace(/<[^>]+>/g,``).trim()||`Could not remove ${t.title} (HTTP ${e.status})`,`error`)}catch(e){d(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{a(t=>({...t,[e]:`idle`})),f()}}}let h={coding:`for coding with AI`,"knowledge-work":`for email and docs`},g=t.filter(e=>n.has(e.hubRulesetId)).length;return(0,D.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,D.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid var(--color-line-1)`,background:`var(--color-surface-1)`},children:[(0,D.jsx)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:8},children:`Guardrails`}),(0,D.jsxs)(`h1`,{className:`text-[18px] font-semibold text-[var(--color-fg-0)] tracking-tight`,children:[`One-tap protection`,e&&h[e]?` ${h[e]}`:``]}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-1.5 leading-relaxed`,children:[`Each pack is a small set of rules that guard against a specific AI risk. Toggle them on and off — installing or removing only touches rule files in`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`.sigmashake/`}),`.`]}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-3`,children:[g,` of `,t.length,` active`]})]}),c&&(0,D.jsx)(`div`,{className:`rounded-xl px-4 py-2.5 text-[12px]`,style:{border:`1px solid ${c.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 36%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 36%, transparent)`}`,background:c.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 12%, var(--color-surface-1))`:`color-mix(in oklab, var(--color-hig-red) 12%, var(--color-surface-1))`,color:c.type===`ok`?`var(--color-hig-green)`:`var(--color-hig-red)`,backdropFilter:`saturate(180%) blur(10px)`},children:c.msg}),(0,D.jsx)(`div`,{className:`ss-list`,children:t.map(e=>(0,D.jsx)(yf,{pack:e,installed:n.has(e.hubRulesetId),state:i[e.id]??`idle`,expanded:o.has(e.id),onInstall:p,onUninstall:m,onToggleDetails:u},e.id))}),(0,D.jsx)(`div`,{className:`rounded-xl p-4`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:[`Want more control? The`,` `,(0,D.jsx)(`a`,{href:`/hub`,className:`text-[var(--color-brand)] hover:underline`,children:`advanced library`}),` `,`has the full set of community rulesets and lets you preview every rule before installing.`]})})]})}function xf(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Sf(e){let t=e;if(t.endsWith(`/.sigmashake/rules`)&&(t=t.slice(0,-18)),t.endsWith(`\\.sigmashake\\rules`)&&(t=t.slice(0,-18)),t.startsWith(`/home/`)){let e=t.slice(6),n=e.indexOf(`/`);return n>=0?`~/${e.slice(n+1)}`:`~`}if(t.startsWith(`C:\\Users\\`)){let e=t.slice(9),n=e.indexOf(`\\`);return n>=0?`~\\${e.slice(n+1)}`:`~`}if(t.length>40){let e=t.split(/[/\\]/);if(e.length>2)return`…/${e[e.length-1]}`}return t}var Cf=[{value:`downloads`,label:`most downloaded`},{value:`newest`,label:`newest`},{value:`rules`,label:`most rules`}],wf=[``,`critical`,`high`,`medium`,`low`],Tf=[``,`deny`,`ask`,`allow`,`log`];function Ef(){return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)] p-4 space-y-3 shimmer`,children:[(0,D.jsx)(`div`,{className:`h-4 bg-[var(--color-surface-3)] rounded-sm w-2/3`}),(0,D.jsx)(`div`,{className:`h-3 bg-[var(--color-surface-2)] rounded-sm w-1/3`}),(0,D.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,D.jsx)(`div`,{className:`h-5 bg-[var(--color-surface-3)] rounded-sm w-14`}),(0,D.jsx)(`div`,{className:`h-5 bg-[var(--color-surface-3)] rounded-sm w-10`})]}),(0,D.jsx)(`div`,{className:`h-7 bg-[var(--color-surface-3)] rounded-sm`})]})}function Df({tech:e}){return(0,D.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border ${{typescript:`bg-sky-500/8 text-sky-300 border-sky-500/25`,ts:`bg-sky-500/8 text-sky-300 border-sky-500/25`,javascript:`bg-amber-500/8 text-amber-300 border-amber-500/25`,js:`bg-amber-500/8 text-amber-300 border-amber-500/25`,python:`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`,rust:`bg-orange-500/8 text-orange-300 border-orange-500/25`,go:`bg-cyan-500/8 text-cyan-300 border-cyan-500/25`,bash:`bg-violet-500/8 text-violet-300 border-violet-500/25`}[e.toLowerCase()]??`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`}`,children:e})}function Of({install:e,onRemove:t,removing:n}){let r=Sf(e.path),i=e.in_sync?`bg-emerald-400`:`bg-amber-400 animate-pulse`;return(0,D.jsxs)(`div`,{className:`group/chip inline-flex items-center gap-1.5 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)] text-[10px] font-mono text-[var(--color-fg-2)]`,title:e.in_sync?`In sync — files present in ${e.path}`:`Drift — ${e.drift_reason??`files missing or empty`} (${e.path})`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i}`,"aria-hidden":!0}),(0,D.jsx)(`span`,{className:`truncate`,title:e.path,children:r}),(0,D.jsx)(`button`,{type:`button`,onClick:r=>{r.preventDefault(),r.stopPropagation(),n||t(e.path)},disabled:n,title:`Remove from this location`,"aria-label":`Uninstall from ${e.path}`,className:`shrink-0 inline-flex items-center justify-center w-4 h-4 rounded-sm text-[var(--color-fg-4)] hover:text-red-300 hover:bg-red-500/10 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`,children:n?(0,D.jsx)(`svg`,{className:`animate-spin`,width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}):(0,D.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:[(0,D.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,D.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function kf({isInstalling:e,hasInstalls:t,onInstallDefault:n,onPickPath:r}){let[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!i)return;function e(e){o.current&&(o.current.contains(e.target)||a(!1))}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,D.jsxs)(`div`,{ref:o,className:`relative flex w-full`,children:[(0,D.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},disabled:e,className:`flex-1 h-7 rounded-l-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer
16
+ bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30 border-r-0
17
+ hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
18
+ disabled:opacity-40 disabled:cursor-not-allowed`,children:e?(0,D.jsxs)(`span`,{className:`flex items-center justify-center gap-1.5`,children:[(0,D.jsx)(`svg`,{className:`animate-spin`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`installing…`]}):t?`install elsewhere`:`install`}),(0,D.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(e=>!e)},disabled:e,title:`Install to another folder`,"aria-label":`Install to a custom folder`,className:`shrink-0 w-7 h-7 rounded-r-sm flex items-center justify-center cursor-pointer
19
+ bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30
20
+ hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
21
+ disabled:opacity-40 disabled:cursor-not-allowed`,children:(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),i&&(0,D.jsxs)(`div`,{className:`absolute z-20 bottom-full right-0 mb-1 min-w-[180px] rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-2)] shadow-lg overflow-hidden`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(!1),n()},className:`w-full text-left px-3 py-2 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:bg-[var(--color-surface-3)] cursor-pointer`,children:`default rules dir`}),(0,D.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(!1),r()},className:`w-full text-left px-3 py-2 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:bg-[var(--color-surface-3)] cursor-pointer border-t border-[var(--color-line-1)]`,children:`pick folder…`})]})]})}function Af({rs:e,installs:t,installingId:n,uninstallingKey:r,onInstall:i,onUninstall:a,onPickAndInstall:o,flashId:s}){let c=n===e.id,l=s===e.id,u=t.length,d=t.some(e=>!e.in_sync);return(0,D.jsxs)(`div`,{className:`group relative flex flex-col rounded-sm border bg-[var(--color-surface-1)] transition-colors overflow-hidden
22
+ ${d?`border-amber-500/40 hover:border-amber-500/60`:u>0?`border-emerald-500/25 hover:border-emerald-500/40`:`border-[var(--color-line-1)] hover:border-[var(--color-line-2)]`}
23
+ ${l?`ring-1 ring-emerald-500/40`:``}`,children:[u>0&&(0,D.jsxs)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 px-1.5 py-0.5 rounded-sm border text-[10px] font-mono uppercase tracking-wider
24
+ ${d?`bg-amber-500/10 border-amber-500/30 text-amber-300`:`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`}`,title:d?`At least one install has drifted from the recorded files`:`All installs are in sync with the database`,children:[d?(0,D.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:[(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,D.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}):(0,D.jsx)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:(0,D.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),u===1?`installed`:`${u}× installed`]}),(0,D.jsxs)(`a`,{href:`/hub/${e.id}`,className:`block p-3 flex-1 min-h-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1 pr-20`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-[var(--color-fg-0)] leading-snug`,children:e.title}),e.tested_versions&&e.tested_versions.length>0&&(0,D.jsx)(`span`,{title:`Certified ruleset`,className:`text-[var(--color-brand)] text-[11px]`,children:`★`})]}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-0.5 font-mono`,children:[`@`,e.author]})]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] shrink-0 mt-0.5`,children:[`v`,e.version]})]}),e.technologies.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:[e.technologies.slice(0,4).map(e=>(0,D.jsx)(Df,{tech:e},e)),e.technologies.length>4&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] self-center`,children:[`+`,e.technologies.length-4]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,D.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,D.jsx)(`span`,{className:`tabular-nums`,children:e.rule_count}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider text-[10px] text-[var(--color-fg-4)]`,children:`rules`})]}),(0,D.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,D.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`polyline`,{points:`8 17 12 21 16 17`}),(0,D.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`21`}),(0,D.jsx)(`path`,{d:`M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29`})]}),(0,D.jsx)(`span`,{className:`tabular-nums`,children:xf(e.download_count)})]})]})]}),u>0&&(0,D.jsx)(`div`,{className:`px-3 pb-2 flex flex-wrap gap-1`,children:t.map(t=>(0,D.jsx)(Of,{install:t,onRemove:t=>a(e.id,t),removing:r===`${e.id}::${t.path}`},t.path))}),(0,D.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:(0,D.jsx)(kf,{isInstalling:c,hasInstalls:u>0,onInstallDefault:()=>i(e.id),onPickPath:()=>o(e.id)})})]})}function jf(){let{mode:e}=se();return e===`newcomer`?(0,D.jsx)(bf,{}):(0,D.jsx)(Mf,{})}function Mf(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(`downloads`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`all`),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(0),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)({}),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),A=(0,_.useCallback)((t=0)=>{let r=new URLSearchParams({page:String(t)});return e&&r.set(`search`,e),n&&n!==`downloads`&&r.set(`sort`,n),i&&r.set(`decision`,i),o&&r.set(`severity`,o),r},[e,n,i,o]),j=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/hub/installed`);if(!e.ok)return;let t=await e.json(),n={};for(let e of t.installs??[])n[e.id]||(n[e.id]=[]),n[e.id]?.push(e);b(n)}catch{}},[]);(0,_.useEffect)(()=>{j()},[j]),(0,_.useEffect)(()=>{let e=!1;return v(!0),h(0),fetch(`/api/json/hub?${A(0)}`).then(e=>e.json()).then(t=>{e||(d(t.data),p(t.has_more),h(0))}).catch(()=>{}).finally(()=>{e||v(!1)}),()=>{e=!0}},[A]);async function M(){let e=m+1;v(!0);try{let t=await fetch(`/api/json/hub?${A(e)}`);if(!t.ok)return;let n=await t.json();d(e=>[...e,...n.data]),p(n.has_more),h(e)}catch{}finally{v(!1)}}async function N(){let e=await fetch(`/api/json/hub?${A(0)}`);if(!e.ok)return;let t=await e.json();d(t.data),p(t.has_more),h(0)}async function ee(e,t){S(e);try{let n={id:e};t&&(n.path=t);let r=await(await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify(n)})).json();r.ok?(E(e),setTimeout(()=>E(null),2e3),k({msg:r.already_installed?`${r.title??e} — already installed${r.path?` at ${Sf(r.path)}`:``}`:`installed ${r.title??e}${r.path?` → ${Sf(r.path)}`:``}`,type:`ok`}),await Promise.all([j(),N()])):k({msg:r.error??`install failed`,type:`error`})}catch(e){k({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{S(null),setTimeout(()=>k(null),5e3)}}async function te(e){await ee(e)}async function P(e){let t=null;try{let e=await fetch(`/api/json/pick-dir`,{method:`POST`});if(e.ok){let n=await e.json();if(n.ok&&n.path)t=n.path;else if(n.reason===`user_cancelled`)return;else if(n.reason===`no_display`||n.reason===`no_picker_found`){let e=prompt(`Folder picker is unavailable on this host. Type the absolute path to install to:`);e?.trim()&&(t=e.trim())}else{k({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>k(null),5e3);return}}}catch{let e=prompt(`Folder picker is unavailable. Type the absolute path to install to:`);e?.trim()&&(t=e.trim())}t&&await ee(e,t)}async function F(e,t){w(`${e}::${t}`);try{let n=await(await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({id:e,path:t})})).json();n.ok?(k({msg:`removed ${e} from ${Sf(t)}`,type:`ok`}),await Promise.all([j(),N()])):k({msg:n.error??`uninstall failed`,type:`error`})}catch(e){k({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{w(null),setTimeout(()=>k(null),5e3)}}let ne=c===`installed`?u.filter(e=>(y[e.id]?.length??0)>0):u,re=u.filter(e=>(y[e.id]?.length??0)>0).length,ie=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-2)] text-[11px] font-mono rounded-sm px-2.5 h-8 focus:outline-none focus:border-[var(--color-brand)]/50 cursor-pointer`;return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`overline text-[11px]`,children:`hub`}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:`install community rule packs from hub.sigmashake.com`})]}),(0,D.jsxs)(`a`,{href:`/hub/connect`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] hover:text-[var(--color-brand)] transition-colors border border-[var(--color-line-1)] hover:border-[var(--color-brand)]/40 rounded-sm px-3 h-7`,children:[(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,D.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`})}),`connect github`]})]}),O&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-3 py-2 text-[11px] font-mono border
25
+ ${O.type===`ok`?`bg-emerald-500/5 border-emerald-500/25 text-emerald-300`:`bg-red-500/5 border-red-500/25 text-red-300`}`,children:[(0,D.jsxs)(`span`,{children:[O.type===`ok`?`✓ `:`✗ `,O.msg]}),(0,D.jsx)(`button`,{onClick:()=>k(null),className:`ml-3 opacity-60 hover:opacity-100 cursor-pointer`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm p-0.5 shrink-0`,children:[(0,D.jsx)(`button`,{onClick:()=>l(`all`),className:`px-3 h-6 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer
26
+ ${c===`all`?`bg-[var(--color-surface-3)] text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:`all`}),(0,D.jsxs)(`button`,{onClick:()=>l(`installed`),className:`px-3 h-6 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer flex items-center gap-1.5
27
+ ${c===`installed`?`bg-[var(--color-surface-3)] text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:[`installed`,re>0&&(0,D.jsx)(`span`,{className:`text-[9px] bg-emerald-500/15 text-emerald-300 rounded-sm px-1 py-0.5 font-medium tabular-nums`,children:re})]})]}),(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[160px]`,children:[(0,D.jsxs)(`svg`,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)]`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,D.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,D.jsx)(`input`,{type:`text`,placeholder:`search rulesets…`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-xs rounded-sm pl-8 pr-3 h-8 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,D.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:ie,children:Cf.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,D.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:ie,children:[(0,D.jsx)(`option`,{value:``,children:`any decision`}),Tf.filter(Boolean).map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))]}),(0,D.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:ie,children:[(0,D.jsx)(`option`,{value:``,children:`any severity`}),wf.filter(Boolean).map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))]})]}),g&&u.length===0?(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,D.jsx)(Ef,{},t))}):ne.length===0?(0,D.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] py-16 flex flex-col items-center justify-center text-center`,children:[(0,D.jsxs)(`svg`,{className:`text-[var(--color-fg-4)] mb-3`,width:`36`,height:`36`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,D.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,D.jsx)(`p`,{className:`text-xs font-mono text-[var(--color-fg-3)] uppercase tracking-wider`,children:c===`installed`?`no rulesets installed yet — browse and click install`:`no rulesets found${e?` matching "${e}"`:``}`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:ne.map(e=>(0,D.jsx)(Af,{rs:e,installs:y[e.id]??[],installingId:x,uninstallingKey:C,onInstall:te,onUninstall:F,onPickAndInstall:P,flashId:T},e.id))}),f&&c===`all`&&(0,D.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,D.jsx)(`button`,{onClick:M,disabled:g,className:`h-8 px-5 rounded-sm text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] border border-[var(--color-line-1)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-2)] transition-colors cursor-pointer disabled:opacity-40`,children:g?`loading…`:`load more`})})]})]})}function Nf(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null);async function o(t){if(t.preventDefault(),e.trim()){r(!0),a(null);try{a(await(await fetch(`/api/hub/publish`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({repo_url:e.trim()})})).json())}catch(e){a({ok:!1,error:e instanceof Error?e.message:`Unknown error`})}finally{r(!1)}}}return(0,D.jsxs)(`div`,{className:`max-w-md mx-auto space-y-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← hub`}),(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-2 text-[var(--color-fg-0)]`,children:`Publish Ruleset`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`publish a github repository containing .rules files to the hub`})]}),(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`form`,{onSubmit:o,className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block overline mb-1.5`,children:`github repository url`}),(0,D.jsx)(`input`,{type:`url`,placeholder:`https://github.com/owner/repo`,value:e,onChange:e=>t(e.target.value),required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,D.jsx)(q,{type:`submit`,variant:`primary`,disabled:n,children:n?`publishing…`:`publish to hub`})]})})}),i&&(0,D.jsx)(`div`,{className:`rounded-sm border px-3 py-2 text-xs font-mono ${i.ok?`border-emerald-500/25 bg-emerald-500/5 text-emerald-300`:`border-red-500/25 bg-red-500/5 text-red-300`}`,children:i.ok?(0,D.jsxs)(D.Fragment,{children:[`✓ published!`,` `,i.id&&(0,D.jsx)(`a`,{href:`/hub/${i.id}`,className:`text-[var(--color-brand)] hover:underline uppercase tracking-wider text-[11px] ml-2`,children:`view ruleset →`})]}):i.error??`publish failed`})]})}function Pf(e){return e===0?`—`:e<1e3?`${e}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(1)}ms`}function Ff(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function If(e){let t=e<1e10?e*1e3:e,n=new Date(t);return`${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}:${String(n.getSeconds()).padStart(2,`0`)}`}function Lf(e){let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var Rf={allow:`text-emerald-300`,block:`text-red-300`,force:`text-violet-300`,log:`text-amber-300`,ask:`text-sky-300`,shadow:`text-[var(--color-fg-3)]`},zf={allow:`✓`,block:`✗`,force:`→`,log:`·`,ask:`?`,shadow:`~`};function Bf({label:e,ns:t,maxNs:n}){let r=n>0?Math.min(100,t/n*100):0;return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] w-8 text-right font-mono uppercase tracking-wider text-[10px]`,children:e}),(0,D.jsx)(Au,{pct:r,tone:t<1e5?`green`:t<1e6?`amber`:`red`,className:`h-1 flex-1`}),(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-1)] tabular-nums w-14 text-right`,children:Pf(t)})]})}function Vf({value:e,max:t,threshold:n,breached:r}){let i=t>0?Math.min(100,e/t*100):0,a=t>0?Math.min(100,n/t*100):0;return(0,D.jsx)(Au,{pct:i,tone:r?`red`:e/t>=.6?`amber`:`green`,markerPct:a,markerTitle:`limit: ${n}`,className:`h-1`})}function Hf({limitsData:e,onSaved:t}){let[n,r]=(0,_.useState)(String(e.config.cpuLimitPct)),[i,a]=(0,_.useState)(String(e.config.memoryLimitMb)),[o,s]=(0,_.useState)(e.config.breachAction),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null);async function f(){l(!0),d(null);try{let e=await fetch(`/api/json/limits`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({cpu_limit_pct:parseFloat(n),memory_limit_mb:parseFloat(i),breach_action:o})});e.ok?t():d((await e.json()).error??`save failed`)}catch{d(`network error`)}finally{l(!1)}}let p=`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5 text-[var(--color-fg-1)] font-mono text-xs focus:outline-none focus:border-[var(--color-brand)]/50`;return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`overline block mb-1.5`,children:`cpu limit (%)`}),(0,D.jsx)(`input`,{type:`number`,min:1,max:100,value:n,onChange:e=>r(e.target.value),className:p})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`overline block mb-1.5`,children:`memory limit (mb)`}),(0,D.jsx)(`input`,{type:`number`,min:1,value:i,onChange:e=>a(e.target.value),className:p})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`overline block mb-1.5`,children:`on breach`}),(0,D.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:p,children:[(0,D.jsx)(`option`,{value:`warn`,children:`warn in ui only`}),(0,D.jsx)(`option`,{value:`log`,children:`warn + write to audit log`})]})]}),u&&(0,D.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:u}),(0,D.jsx)(q,{onClick:f,disabled:c,variant:`primary`,size:`sm`,children:c?`saving…`:`save limits`})]})}var Uf={running:`green`,hibernating:`amber`,exhausted:`red`,stopped:`gray`,idle:`gray`};function Wf(e,t){let n=e-t;if(n<=0)return`any moment`;let r=Math.round(n/1e3);if(r<60)return`in ${r}s`;let i=Math.floor(r/60);return i<60?`in ${i}m ${r%60}s`:`in ${Math.floor(i/60)}h ${i%60}m`}function Gf({supervisors:e}){let[t,n]=(0,_.useState)(Date.now());return(0,_.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2 overline`,children:[`supervisor health`,e.some(e=>e.state===`hibernating`||e.state===`exhausted`)&&(0,D.jsx)(K,{variant:`amber`,children:`degraded`})]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono tabular-nums text-[var(--color-fg-4)]`,children:[e.length,` supervisor`,e.length===1?``:`s`]})]}),(0,D.jsx)(X,{children:e.length===0?(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no supervisors registered yet`}):(0,D.jsx)(`div`,{className:`overflow-x-auto`,children:(0,D.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`name`}),(0,D.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`kind`}),(0,D.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`state`}),(0,D.jsx)(`th`,{className:`text-right font-normal pb-1.5`,children:`restarts`}),(0,D.jsx)(`th`,{className:`text-left font-normal pb-1.5 pl-4`,children:`last restart`}),(0,D.jsx)(`th`,{className:`text-left font-normal pb-1.5 pl-4`,children:`next retry`})]})}),(0,D.jsx)(`tbody`,{children:e.map(e=>(0,D.jsxs)(`tr`,{className:`border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`td`,{className:`py-1.5 text-[var(--color-fg-1)]`,children:e.name}),(0,D.jsx)(`td`,{className:`py-1.5 text-[var(--color-fg-3)]`,children:e.kind===`single`?`single`:`tree`}),(0,D.jsx)(`td`,{className:`py-1.5`,children:(0,D.jsx)(K,{variant:Uf[e.state],children:e.state})}),(0,D.jsx)(`td`,{className:`py-1.5 text-right tabular-nums text-[var(--color-fg-1)]`,children:e.restarts}),(0,D.jsx)(`td`,{className:`py-1.5 pl-4 tabular-nums text-[var(--color-fg-3)]`,children:e.lastRestartAt>0?Lf(e.lastRestartAt):`—`}),(0,D.jsx)(`td`,{className:`py-1.5 pl-4 tabular-nums text-[var(--color-fg-3)]`,children:e.nextRetryAt>0?(0,D.jsx)(`span`,{title:e.hibernateReason?`reason: ${e.hibernateReason}`:void 0,children:Wf(e.nextRetryAt,t)}):`—`})]},e.name))})]})})})]})}function Kf(){let e=Nt([`runtime-tick`,`activity-updated`,`limits-breach`,`supervisor-changed`]),t=Ha(),[n,r]=(0,_.useState)(Date.now()),[i,a]=(0,_.useState)(0),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(0),[u,d]=(0,_.useState)(!1),f=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let{data:p}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:m,refetch:h}=V(`/api/json/limits`,[e[`limits-breach`]]),{data:g}=V(`/api/state/activity-tail?after=${i}&limit=50`,[e[`activity-updated`]]),{data:v}=V(`/api/json/supervisors`,[e[`supervisor-changed`],e[`runtime-tick`]]);(0,_.useEffect)(()=>{g&&g.rows.length>0&&(a(e=>Math.max(e,g.maxId)),s(e=>{let t=new Set(e.map(e=>e.id));return[...g.rows.filter(e=>!t.has(e.id)),...e].slice(0,100)}))},[g]),(0,_.useEffect)(()=>{let e=p!==null;f.current===!1&&e&&l(e=>e+1),f.current=e},[p]);let y=p?Ff(p.uptime_ms):null,b=p&&p.last_eval_at>0?Lf(p.last_eval_at):null,x=m?.breaches.cpu??!1,S=m?.breaches.memory??!1,C=p?x?`text-red-300`:(p.cpu_pct??0)>=60?`text-amber-300`:`text-emerald-300`:`text-[var(--color-fg-1)]`,w=S?`text-red-300`:`text-[var(--color-fg-1)]`;return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Daemon Monitor`}),(0,D.jsx)(`p`,{className:`text-[12px] font-mono text-[var(--color-fg-3)] mt-0.5`,children:`live metrics · audit tail · resource limits`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[c>0&&(0,D.jsxs)(K,{variant:`amber`,children:[c,` restart`,c===1?``:`s`]}),(0,D.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-[var(--color-fg-3)]`,children:If(n)})]})]}),(0,D.jsx)(qf,{cpuPct:p?.cpu_pct??0,cpuLimit:m?.config.cpuLimitPct,memMb:p?.memory_rss_mb??0,memLimit:m?.config.memoryLimitMb,decisions:p?.decisions,latency:p?.latency,burstBuffer:t,evalsTotal:p?.evals_total??0}),m&&(x||S)&&(0,D.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/[0.06] border-l-2 border-l-red-500/70 px-3 py-2.5 flex items-start gap-2.5`,children:[(0,D.jsx)(`span`,{className:`text-red-300 shrink-0 mt-0.5`,children:(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,D.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]})}),(0,D.jsxs)(`div`,{className:`space-y-0.5 text-xs font-mono`,children:[x&&(0,D.jsxs)(`div`,{className:`text-red-200`,children:[`cpu limit exceeded: `,p?.cpu_pct??`?`,`% >`,` `,m.config.cpuLimitPct,`%`]}),S&&(0,D.jsxs)(`div`,{className:`text-red-200`,children:[`memory limit exceeded: `,p?.memory_rss_mb??`?`,`mb >`,` `,m.config.memoryLimitMb,`mb`]})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`daemon status`})}),(0,D.jsx)(X,{children:p===null?(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`}),(0,D.jsx)(`span`,{className:`text-red-300 font-mono uppercase tracking-wider text-xs`,children:`down`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] text-xs font-mono`,children:`— socket not reachable`})]}):(0,D.jsxs)(`div`,{className:`flex items-center gap-5 flex-wrap text-xs font-mono`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-emerald-400 pulse-soft shrink-0`}),(0,D.jsx)(`span`,{className:`text-emerald-300 uppercase tracking-wider`,children:`up`})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`pid`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:p.pid})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`uptime`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:y})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`mem`,` `,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:[p.memory_rss_mb,`MB`]})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`cpu`,` `,(0,D.jsxs)(`span`,{className:`${C} tabular-nums`,children:[p.cpu_pct,`%`]})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`last eval`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:b??`—`})]})]})})]}),(0,D.jsx)(Gf,{supervisors:v?.supervisors??[]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2 overline`,children:[`system resources`,m&&(x||S)&&(0,D.jsx)(K,{variant:`red`,children:`limit exceeded`})]}),(0,D.jsx)(`button`,{onClick:()=>d(e=>!e),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors cursor-pointer`,children:u?`hide limits`:`configure limits`})]}),(0,D.jsxs)(X,{children:[p===null?(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data — daemon not running`}):(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`cpu`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(p.history.cpu_pct.length??0)>1&&(0,D.jsx)(Yc,{data:p.history.cpu_pct,width:80,height:20,color:x?`#f87171`:`#34d399`,threshold:m?.config.cpuLimitPct,maxValue:100}),(0,D.jsxs)(`span`,{className:`font-mono font-medium w-12 text-right tabular-nums ${C}`,children:[p.cpu_pct,`%`]})]})]}),(0,D.jsx)(Vf,{value:p.cpu_pct,max:100,threshold:m?.config.cpuLimitPct??90,breached:x}),m&&(0,D.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`limit: `,m.config.cpuLimitPct,`%`]})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`memory rss`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(p.history.memory_rss_mb.length??0)>1&&(0,D.jsx)(Yc,{data:p.history.memory_rss_mb,width:80,height:20,color:S?`#f87171`:`#38bdf8`,threshold:m?.config.memoryLimitMb}),(0,D.jsxs)(`span`,{className:`font-mono font-medium w-16 text-right tabular-nums ${w}`,children:[p.memory_rss_mb,`MB`]})]})]}),(0,D.jsx)(Vf,{value:p.memory_rss_mb,max:Math.max(p.memory_rss_mb*1.5,m?.config.memoryLimitMb??512),threshold:m?.config.memoryLimitMb??512,breached:S}),m&&(0,D.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`limit: `,m.config.memoryLimitMb,`MB`]})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`heap`}),(0,D.jsxs)(`span`,{className:`font-mono text-[var(--color-fg-1)] tabular-nums`,children:[p.heap_used_mb,`MB / `,p.heap_total_mb,`MB`]})]}),(0,D.jsx)(Au,{pct:p.heap_total_mb>0?Math.min(100,p.heap_used_mb/p.heap_total_mb*100):0,tone:`blue`,className:`h-1`})]})]}),u&&m&&(0,D.jsxs)(`div`,{className:`mt-5 pt-4 border-t border-[var(--color-line-0)]`,children:[(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-3 leading-relaxed`,children:[`thresholds trigger ui warnings. values are persisted to`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-fg-1)]`,children:`.sigmashake/config.toml`}),`.`]}),(0,D.jsx)(Hf,{limitsData:m,onSaved:()=>{h(),d(!1)}})]})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2`,children:[(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`total evals`,value:p?.evals_total??`—`,valueClassName:`text-xl font-medium tabular-nums text-[var(--color-fg-0)]`}),(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`allow`,value:p?.decisions.allow??`—`,valueClassName:`text-xl font-medium tabular-nums text-emerald-300`}),(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`block`,value:p?.decisions.block??`—`,valueClassName:`text-xl font-medium tabular-nums text-red-300`}),(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`force`,value:p?.decisions.force??`—`,valueClassName:`text-xl font-medium tabular-nums text-violet-300`}),(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`log`,value:p?.decisions.log??`—`,valueClassName:`text-xl font-medium tabular-nums text-amber-300`}),(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`ask`,value:p?.decisions.ask??`—`,valueClassName:`text-xl font-medium tabular-nums text-sky-300`})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`eval latency`}),p&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[p.latency.samples,` samples`]})]}),(0,D.jsx)(X,{children:p===null?(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data`}):(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(Bf,{label:`p50`,ns:p.latency.p50_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Bf,{label:`p95`,ns:p.latency.p95_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Bf,{label:`p99`,ns:p.latency.p99_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Bf,{label:`max`,ns:p.latency.max_ns,maxNs:p.latency.max_ns})]})})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`engine`})}),(0,D.jsx)(X,{children:p===null?(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data`}):(0,D.jsx)(`div`,{className:`space-y-1.5 text-xs font-mono`,children:[[`native evals`,p.engine.native_evals],[`ts evals`,p.engine.ts_evals],[`native %`,`${p.engine.native_pct}%`],[`rule reloads`,p.rule_reloads],[`rate limit trips`,p.rate_limit_trips],[`loop guard blocks`,p.loop_guard_blocks],[`connection errors`,p.connection_errors]].map(([e,t])=>(0,D.jsxs)(`div`,{className:`flex justify-between py-0.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:e}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:t})]},e))})})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`live event tail`}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`newest first · auto-updating`})]}),(0,D.jsx)(X,{children:o.length===0?(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-4 py-6 text-center`,children:(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no events yet`})}):(0,D.jsx)(`div`,{className:`font-mono text-[11px] max-h-96 overflow-y-auto divide-y divide-[var(--color-line-0)]`,children:o.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] shrink-0 w-16 tabular-nums`,children:If(e.timestamp)}),e.tool===`__daemon`?(0,D.jsxs)(`span`,{className:`text-sky-400`,children:[`daemon `,(()=>{try{let t=JSON.parse(e.input??`{}`);return`${t.event??e.decision}${t.detail?` (${t.detail})`:``}`}catch{return e.decision}})()]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`shrink-0 w-16 uppercase tracking-wider text-[10px] ${Rf[e.decision]??`text-[var(--color-fg-3)]`}`,children:[zf[e.decision]??`·`,` `,e.decision]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] shrink-0 w-24 truncate`,children:e.tool}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] shrink-0 w-14 text-right tabular-nums`,children:Pf(e.duration_ns)}),e.rule_id&&(0,D.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] truncate transition-colors`,title:e.rule_id,children:e.rule_id})]})]},e.id))})})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`ai agent debug endpoints`})}),(0,D.jsxs)(X,{children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-2.5`,children:`agents can query these endpoints directly for automated triage:`}),(0,D.jsx)(`div`,{className:`space-y-1 font-mono text-[11px]`,children:[[`/api/state/runtime`,`full metrics snapshot (cpu, memory, history, latency)`],[`/api/json/limits`,`resource limits config + breach state`],[`/api/state/activity-tail?after=0&limit=20`,`recent eval events`],[`/api/json/daemon-status`,`status, pid, log tail`],[`/healthz`,`process uptime`]].map(([e,t])=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`GET`}),(0,D.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] transition-colors`,children:e}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`— `,t]})]},e))})]})]})]})}function qf({cpuPct:e,cpuLimit:t,memMb:n,memLimit:r,decisions:i,latency:a,evalsTotal:o,burstBuffer:s}){let c=(0,_.useMemo)(()=>{if(s.length===0)return 0;let e=Date.now()-1e4;return s.filter(t=>t.ts_ms>=e).length/10},[s]);return(a?.p95_ns??0)/1e6,(a?.p50_ns??0)/1e6,(a?.p99_ns??0)/1e6,(0,D.jsxs)(`div`,{className:`grid-bleed rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,style:{contain:`layout paint`},children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-4 lg:min-h-[320px]`,children:[(0,D.jsxs)(`div`,{className:`lg:col-span-3 flex flex-col items-center justify-start gap-2 lg:max-h-[320px]`,children:[(0,D.jsx)(wl,{mode:`ring`,value:e,max:100,warnAt:(t??90)/100*.7,critAt:(t??90)/100,display:`${e.toFixed(1)}%`,label:`cpu`,size:220,className:`max-h-[240px]`}),(0,D.jsx)(Zc,{value:e,width:260,height:56,windowMs:6e4,color:`#34d399`,fillColor:`rgba(52, 211, 153, 0.14)`,maxValue:100,className:`w-full`})]}),(0,D.jsxs)(`div`,{className:`lg:col-span-3 flex flex-col items-center justify-start gap-2 lg:max-h-[320px]`,children:[(0,D.jsx)(wl,{mode:`ring`,value:n,max:r??1024,warnAt:.7,critAt:.9,display:`${n.toFixed(0)} MB`,label:`memory`,size:220,className:`max-h-[240px]`}),(0,D.jsx)(Zc,{value:n,width:260,height:56,windowMs:6e4,color:`#38bdf8`,fillColor:`rgba(56, 189, 248, 0.14)`,maxValue:r?r*1.1:void 0,className:`w-full`})]}),(0,D.jsx)(`div`,{className:`lg:col-span-6 lg:max-h-[320px]`,children:(0,D.jsx)(kl,{latency:a,bursts:s,gaugeMaxMs:10,windowMs:3e4,trendWindowSec:60,gaugeSize:200})})]}),(0,D.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,D.jsx)(al,{label:`Total Evals`,value:o,tone:`amber`,sub:`${c.toFixed(1)}/s`,burstRing:s}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] px-4 py-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`throughput · 60 s`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[c.toFixed(1),`/s`]})]}),(0,D.jsx)(Zc,{value:c,width:420,height:56,windowMs:6e4,className:`w-full`})]})]}),i?(0,D.jsx)(`div`,{className:`mt-4 pt-3 border-t border-[var(--color-line-0)]`,children:(0,D.jsx)(Jc,{counters:{allow:i.allow,block:i.block,ask:i.ask,log:i.log,force:i.force,shadow:i.shadow}})}):null,(0,D.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`live event stream · newest first`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:[s.length,` buffered · hover to pause`]})]}),(0,D.jsx)(Hl,{variant:`decision`,bursts:s,windowSize:300,height:260})]})]})}function Jf(){return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`Notifications`}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:`Things that need your attention — rule drift, audit log capacity, daemon health, noisy rules. We update this list whenever something changes.`})]}),(0,D.jsx)(Wc,{showEmptyState:!0,hideHeader:!0})]})}var Yf=18,Xf=5e-4;function Zf(e,t){return t===`(garbage collector)`||t===`(idle)`?`#450a0a`:e?e.startsWith(`node:`)||e.startsWith(`bun:`)?`#172554`:e.startsWith(`file:`)||e.startsWith(`/`)||e.includes(`.ts`)||e.includes(`.js`)?`#451a03`:`#1f2937`:`#1f2937`}function Qf(e,t){return t===`(garbage collector)`||t===`(idle)`?`#fca5a5`:e?e.startsWith(`node:`)||e.startsWith(`bun:`)?`#93c5fd`:e.startsWith(`file:`)||e.startsWith(`/`)||e.includes(`.ts`)||e.includes(`.js`)?`#fbbf24`:`#6b7280`:`#6b7280`}function $f(e,t){let n=new Map;for(let t of e.nodes)n.set(t.id,t);let r=new Map;function i(e){let t=n.get(e);if(!t)return 0;let a=t.hitCount??0;for(let e of t.children??[])a+=i(e);return r.set(e,a),a}let a=e.nodes[0];if(!a)return[];i(a.id);let o=t??a.id,s=r.get(o)??0;if(s===0)return[];let c=[];function l(e,t,i){let a=n.get(e);if(!a)return;let o=r.get(e)??0,u=o/s;if(u<Xf)return;c.push({x:i,width:u,depth:t,node:a,subtreeHits:o});let d=i;for(let e of a.children??[]){let n=(r.get(e)??0)/s;l(e,t+1,d),d+=n}}return l(o,0,0),c}function ep(e){return e<1e3?`${e}µs`:e<1e6?`${(e/1e3).toFixed(1)}ms`:`${(e/1e6).toFixed(2)}s`}function tp({profile:e}){let t=(0,_.useRef)(null),[n,r]=(0,_.useState)(800),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t&&r(t)});return n.observe(e),r(e.clientWidth||800),()=>n.disconnect()},[]);let c=$f(e,i),l=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*Yf+4,u=e.endTime-e.startTime,d=(0,_.useCallback)(e=>{a(t=>t===e.node.id?null:e.node.id),s(null)},[]);return c.length===0?(0,D.jsx)(`p`,{className:`text-xs text-[#555] py-2`,children:`No samples — profile may be empty.`}):(0,D.jsxs)(`div`,{className:`relative select-none`,children:[i!==null&&(0,D.jsx)(`button`,{onClick:()=>a(null),className:`mb-2 text-xs text-amber-400 hover:underline`,children:`← Reset zoom`}),(0,D.jsx)(`div`,{ref:t,className:`overflow-x-hidden`,children:(0,D.jsx)(`svg`,{width:n,height:l,onMouseLeave:()=>s(null),children:c.map((e,t)=>{let r=e.x*n,a=Math.max(e.width*n,1),o=e.depth*Yf+1,c=e.node.callFrame.functionName||`(anonymous)`,l=e.node.callFrame.url,f=i===e.node.id;return(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:r,y:o,width:a,height:Yf-1,fill:f?`#92400e`:Zf(l,c),stroke:`#080808`,strokeWidth:.5,style:{cursor:`pointer`},onClick:()=>d(e),onMouseMove:t=>s({clientX:t.clientX,clientY:t.clientY,rect:e,totalDuration:u})}),a>24&&(0,D.jsx)(`text`,{x:r+2,y:o+Yf-5,fontSize:9,fill:Qf(l,c),style:{pointerEvents:`none`,userSelect:`none`},clipPath:`url(#fc-clip-${t})`,children:c}),a>24&&(0,D.jsx)(`clipPath`,{id:`fc-clip-${t}`,children:(0,D.jsx)(`rect`,{x:r,y:o,width:a,height:Yf})})]},t)})})}),o&&(0,D.jsxs)(`div`,{className:`fixed z-50 bg-[#111] border border-[#2a2a2a] rounded-lg p-2.5 text-xs shadow-xl pointer-events-none`,style:{left:o.clientX+14,top:o.clientY-8,maxWidth:320},children:[(0,D.jsx)(`div`,{className:`font-mono text-amber-400 truncate font-medium`,children:o.rect.node.callFrame.functionName||`(anonymous)`}),o.rect.node.callFrame.url&&(0,D.jsxs)(`div`,{className:`text-[#666] truncate mt-0.5 text-[10px]`,children:[o.rect.node.callFrame.url,`:`,o.rect.node.callFrame.lineNumber]}),(0,D.jsxs)(`div`,{className:`mt-1.5 space-y-0.5 text-[#aaa]`,children:[(0,D.jsxs)(`div`,{children:[`Samples:`,` `,(0,D.jsx)(`span`,{className:`text-white tabular-nums`,children:o.rect.subtreeHits})]}),(0,D.jsxs)(`div`,{children:[`Time share:`,` `,(0,D.jsxs)(`span`,{className:`text-white tabular-nums`,children:[(o.rect.width*100).toFixed(1),`%`]})]}),u>0&&(0,D.jsxs)(`div`,{children:[`Est. duration:`,` `,(0,D.jsx)(`span`,{className:`text-white tabular-nums`,children:ep(Math.round(o.rect.width*u))})]})]}),o.rect.node.deoptReason&&(0,D.jsxs)(`div`,{className:`text-red-400 mt-1.5 text-[10px]`,children:[`⚠ `,o.rect.node.deoptReason]}),(0,D.jsx)(`div`,{className:`text-[#555] mt-1.5 text-[10px]`,children:`Click to zoom · click again to reset`})]})]})}var np={ok:`green`,warn:`amber`,error:`red`,unknown:`gray`},rp={ok:`OK`,warn:`Warn`,error:`Error`,unknown:`Idle`};function ip({title:e,status:t=`unknown`,statusLabel:n,className:r,children:i}){return(0,D.jsxs)(J,{className:Lr(`flex flex-col`,r),children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-2)]`,children:e}),(0,D.jsx)(K,{variant:np[t],children:n??rp[t]})]}),(0,D.jsx)(X,{className:`flex flex-col gap-2 text-[12px]`,children:i})]})}function ap({label:e,value:t,mono:n=!1,tone:r}){return(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-[var(--color-line-0)] last:border-b-0 py-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] uppercase tracking-wider text-[10px] font-mono`,children:e}),(0,D.jsx)(`span`,{className:Lr(n?`font-mono`:`font-sans`,`tabular-nums text-right truncate`,r===`good`?`text-emerald-300`:r===`warn`?`text-amber-300`:r===`bad`?`text-red-300`:`text-[var(--color-fg-1)]`),children:t})]})}function op(){let{data:e,refetch:t}=V(`/api/json/inspector-targets`),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(1),u=(0,_.useRef)(new Map),d=(0,_.useRef)(new Map),f=(0,_.useCallback)(()=>{let e=c.current;if(c.current=null,e)try{e.close()}catch{}r(!1),a(!1),s(null)},[]),p=(0,_.useCallback)(e=>{c.current&&f(),a(!0),s(null);let t=new WebSocket(`/ws/inspector?target=${encodeURIComponent(e)}`);c.current=t,t.onopen=()=>{r(!0),a(!1),s(null)},t.onclose=()=>{c.current=null,r(!1),a(!1)},t.onerror=()=>{a(!1),s(`Connection failed — is the inspector running with the correct target ID?`)},t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.id!=null){let e=u.current.get(t.id);e&&(u.current.delete(t.id),e(t.result))}else if(t.method){let e=d.current.get(t.method);if(e)for(let n of e)n(t.params)}}catch{}}},[f]),m=(0,_.useCallback)((e,t)=>new Promise((n,r)=>{let i=c.current;if(!i||i.readyState!==WebSocket.OPEN){r(Error(`Not connected`));return}let a=l.current++;u.current.set(a,e=>n(e)),i.send(JSON.stringify({id:a,method:e,params:t})),setTimeout(()=>{u.current.has(a)&&(u.current.delete(a),r(Error(`Command timed out`)))},1e4)}),[]),h=(0,_.useCallback)((e,t)=>{let n=d.current.get(e);return n||(n=new Set,d.current.set(e,n)),n.add(t),()=>{d.current.get(e)?.delete(t)}},[]),g=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{e?.active&&e?.target&&!n&&!i&&!g.current&&(g.current=!0,p(e.target.id))},[e?.active,e?.target?.id,n,i,p,e?.target]),(0,_.useEffect)(()=>()=>{f()},[f]),{active:e?.active??!1,bunVersion:e?.version?.[`Bun-Version`]??null,preconfiguredTarget:e?.target??null,connected:n,connecting:i,error:o,connect:p,disconnect:f,sendCommand:m,onEvent:h,refetch:t}}function sp(e){return e===0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function cp(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function lp(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function up(e){return e?new Date(e*1e3).toLocaleString():`—`}function dp(e){if(!e||e===0)return`never`;let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function fp({children:e,className:t}){return(0,D.jsx)(`div`,{className:`overline mb-2.5 ${t??``}`,children:e})}function pp({label:e,value:t,mono:n=!0,accent:r}){return(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,D.jsx)(`span`,{className:`text-xs text-[var(--color-fg-3)] shrink-0 font-mono`,children:e}),(0,D.jsx)(`span`,{className:`text-xs text-right truncate max-w-[65%] ${n?`font-mono tabular-nums`:``} ${r??`text-[var(--color-fg-1)]`}`,children:t})]})}function mp({ok:e,label:t,badLabel:n}){return e?(0,D.jsx)(K,{variant:`green`,children:t}):(0,D.jsx)(K,{variant:`red`,children:n??t})}function hp({pct:e,total:t,max:n}){let r=e<60?`green`:e<85?`amber`:`red`,i=e>=85?`text-red-300`:e>=60?`text-amber-300`:`text-emerald-300`;return(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-mono tabular-nums`,children:[(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[t.toLocaleString(),` / `,n.toLocaleString(),` rows`]}),(0,D.jsxs)(`span`,{className:i,children:[e,`%`]})]}),(0,D.jsx)(Au,{pct:e,tone:r,className:`h-1.5`})]})}var gp=3e3,_p={log:`text-[var(--color-fg-1)]`,info:`text-sky-300`,warn:`text-amber-300`,error:`text-red-300`,debug:`text-[var(--color-fg-3)]`};function vp(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function yp(){let e=op(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),m=(0,_.useRef)(0),h=(0,_.useRef)(!0);(0,_.useEffect)(()=>{if(h.current){h.current=!1;return}let e=p.current;if(!e)return;let t=e.parentElement;t&&(t.scrollTop=t.scrollHeight)},[]),(0,_.useEffect)(()=>{if(e.connected)return e.sendCommand(`Runtime.enable`).catch(()=>{}),e.onEvent(`Runtime.consoleAPICalled`,e=>{let t=e;o(e=>{let n=[...e,{id:m.current++,type:t.type??`log`,args:t.args??[],timestamp:t.timestamp??Date.now()}];return n.length>500?n.slice(-500):n})})},[e.connected,e.onEvent,e.sendCommand]),(0,_.useEffect)(()=>{e.preconfiguredTarget&&!e.connected&&!e.connecting&&e.connect(e.preconfiguredTarget.id)},[e]),(0,_.useEffect)(()=>{!e.connected||d||t||r||(f(!0),(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),setTimeout(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch{n(!1)}},gp)}catch{}})(),e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0}).then(e=>{c(JSON.parse(e.result.value))}).catch(()=>{}))},[e.connected,d,t,r,e.sendCommand]);let g=(0,_.useCallback)(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),i(null)}catch(e){console.error(`Profiler.start failed:`,e)}},[e]),v=(0,_.useCallback)(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch(e){console.error(`Profiler.stop failed:`,e),n(!1)}},[e]),y=(0,_.useCallback)(async()=>{u(!0);try{let t=await e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0});c(JSON.parse(t.result.value))}catch{}finally{u(!1)}},[e]),b=(0,_.useCallback)(()=>{e.preconfiguredTarget&&e.connect(e.preconfiguredTarget.id)},[e]);return e.active?e.connected?(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-emerald-400`}),`connected`,e.bunVersion?` · bun v${e.bunVersion}`:``]}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`})]})]}),e.error&&(0,D.jsx)(X,{children:(0,D.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:e.error})})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`cpu profiler`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300 flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-400 pulse-soft`}),`recording`]}),t?(0,D.jsx)(q,{variant:`danger`,size:`sm`,onClick:v,children:`stop & render`}):(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:g,children:`start recording`})]})]}),(0,D.jsx)(X,{children:r?(0,D.jsx)(Mu,{profile:r,children:(0,D.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 overflow-x-hidden`,children:(0,D.jsx)(tp,{profile:r})})}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording cpu profile (auto-captures ${gp/1e3}s)… perform actions in ssg to generate data.`:`click start recording, or wait for auto-capture on page load.`})})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`memory`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:y,disabled:l,children:l?`…`:`refresh`})]}),(0,D.jsx)(X,{children:s?(0,D.jsx)(Nu,{memory:s,formatValue:cp}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:d?`fetching memory metrics…`:`click refresh to fetch process.memoryUsage().`})})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`console`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 h-40 overflow-y-auto font-mono text-[11px]`,children:[a.length===0?(0,D.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`console output will appear here…`}):a.map(e=>(0,D.jsxs)(`div`,{className:`py-0.5 border-b border-[var(--color-line-0)] ${_p[e.type]??`text-[var(--color-fg-1)]`}`,children:[(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] mr-2 uppercase tracking-wider`,children:[`[`,e.type,`]`]}),e.args.map(vp).join(` `)]},e.id)),(0,D.jsx)(`div`,{ref:p})]})})]})]}):(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(K,{variant:`amber`,children:e.connecting?`connecting…`:`available`}),!e.connecting&&(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:b,children:`connect`})]})]}),(0,D.jsx)(X,{children:(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:e.connecting?`establishing websocket connection to bun inspector…`:`inspector is active but not connected. click connect to start profiling.`})})]}):(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,D.jsx)(K,{variant:`outline`,children:`inactive`})]}),(0,D.jsx)(X,{children:(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[`the bun inspector is not active. restart`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg serve`}),` to enable it automatically.`]})})]})}function bp(){let[e,t]=(0,_.useState)(0),{data:n}=V(`/api/json/evald-log`,[e]),r=(0,_.useRef)(null),i=(0,_.useRef)(!0);(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),5e3);return()=>clearInterval(e)},[]),(0,_.useEffect)(()=>{if(i.current){i.current=!1;return}let e=r.current;if(!e)return;let t=e.parentElement;t&&(t.scrollTop=t.scrollHeight)},[]);let a=n?.lines??[];return(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`daemon log`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] truncate max-w-[60%]`,children:[n?.path?n.path:`loading…`,` · last 200 lines · 5s refresh`]})]}),(0,D.jsxs)(X,{children:[n?.error&&(0,D.jsx)(`p`,{className:`text-xs text-red-300 font-mono mb-2`,children:n.error}),a.length===0&&!n?.error&&(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-4 py-6 text-center`,children:(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[`no log entries yet. start the daemon with`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg serve`}),` to generate log output.`]})}),a.length>0&&(0,D.jsxs)(`pre`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3 text-[10px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto font-mono leading-relaxed`,children:[a.join(`
28
+ `),(0,D.jsx)(`div`,{ref:r})]})]})]})}function xp(){let e=Nt([`runtime-tick`,`rules-changed`]),{data:t,refetch:n}=V(`/api/json/observability`,[e[`runtime-tick`],e[`rules-changed`]]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(Date.now()),[l,u]=(0,_.useState)(`idle`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`idle`);(0,_.useEffect)(()=>{t&&c(Date.now())},[t]);let h=(0,_.useCallback)(async()=>{u(`loading`);try{let e=await(await fetch(`/api/rules/sync-to-db`,{method:`POST`,headers:H()})).json();if(e.ok){u(`done`);let t=(e.pruned_count??0)>0?` (${e.pruned_count} orphan(s) pruned)`:``;f((e.message??`synced ${e.synced} rules`)+t),n()}else u(`error`),f(e.error??`sync failed`)}catch(e){u(`error`),f(String(e))}},[n]),g=(0,_.useCallback)(async()=>{m(`loading`);try{await fetch(`/api/rules/force-reload`,{method:`POST`,headers:H()}),m(`done`),n(),setTimeout(()=>m(`idle`),3e3)}catch{m(`idle`)}},[n]),v=t?.db,y=t?.rules,b=t?.audit,x=t?.process,S=t?.flight_recorder,C=y?.drift_detected??!1;return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Observability`}),(0,D.jsx)(`p`,{className:`text-[12px] font-mono text-[var(--color-fg-3)] mt-0.5`,children:`sqlite health · rule drift · runtime profiler · diagnostics`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:[`refreshed `,dp(s)]}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n,children:`refresh`})]})]}),(0,D.jsx)(Sp,{db:v,audit:b,proc:x,flight:S,driftDetected:C}),(0,D.jsxs)(J,{className:C?`border-red-500/30 border-l-2 border-l-red-500/70`:`border-emerald-500/20 border-l-2 border-l-emerald-500/60`,children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`rule drift detector`}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`— .rules files vs sqlite`}),(0,D.jsx)(`button`,{onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`Explain these counts`,title:`Why do these numbers differ?`,className:`text-[10px] font-mono text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 transition-colors cursor-pointer`,children:a?`× close`:`? why these numbers`})]}),y&&(C?(0,D.jsx)(K,{variant:`red`,children:`⚠ drift detected`}):(0,D.jsx)(K,{variant:`green`,children:`✓ in sync`}))]}),(0,D.jsxs)(X,{children:[a&&(0,D.jsxs)(`div`,{className:`mb-4 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-3 py-2.5 space-y-2 text-[11px] font-mono leading-relaxed text-[var(--color-fg-3)]`,children:[(0,D.jsxs)(`div`,{className:`text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`code`,{children:`.rules files`}),` and `,(0,D.jsx)(`code`,{children:`db rules`}),` are`,` `,(0,D.jsx)(`span`,{className:`text-amber-300`,children:`not auto-synced`}),`. A mismatch is usually expected:`]}),(0,D.jsxs)(`ul`,{className:`space-y-1 pl-3 list-disc marker:text-[var(--color-fg-4)]`,children:[(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`one file can hold many rules`}),` `,`— compare `,(0,D.jsx)(`code`,{children:`db rules`}),` against`,` `,(0,D.jsx)(`code`,{children:`file_rule_count`}),`, not `,(0,D.jsx)(`code`,{children:`file_count`}),`.`]}),(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in files`}),` `,`means unsynced edits — run`,` `,(0,D.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`}),` or click`,` `,(0,D.jsx)(`code`,{children:`↑ sync files → db`}),`.`]}),(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in db`}),` `,`with `,(0,D.jsx)(`code`,{children:`source_file IS NULL`}),` is healthy — hub, fleet, or cloud-synced rules legitimately live only in the db.`]}),(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in db`}),` `,`with `,(0,D.jsx)(`code`,{children:`source_file`}),` set means an orphan from a deleted file —`,` `,(0,D.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`}),` prunes it.`]}),(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`db rules`}),` `,`includes disabled rows; `,(0,D.jsx)(`code`,{children:`db_enabled_count`}),` excludes them.`]})]}),(0,D.jsxs)(`div`,{className:`pt-1.5 border-t border-[var(--color-line-0)]`,children:[`full reference:`,` `,(0,D.jsx)(`a`,{href:`https://docs.sigmashake.com/rule-storage`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[var(--color-fg-2)] underline decoration-dotted underline-offset-2 hover:text-amber-300 transition-colors`,children:`docs.sigmashake.com/rule-storage ↗`})]})]}),y?(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[{label:`.rules files`,value:y.file_count,sub:`${y.file_rule_count} rules total`,tone:`neutral`},{label:`db rules`,value:y.db_rule_count,sub:`${y.db_enabled_count} enabled`,tone:`neutral`},{label:`only in files`,value:y.drift_details.only_in_files.length,tone:y.drift_details.only_in_files.length>0?`amber`:`gray`},{label:`only in db`,value:y.drift_details.only_in_db.length,tone:y.drift_details.only_in_db.length>0?`red`:`gray`}].map(({label:e,value:t,sub:n,tone:r})=>(0,D.jsx)(ku,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)]`,label:e,value:t,sub:n,tone:r,labelPlacement:`above`,subClassName:`text-[var(--color-fg-4)]`,valueClassName:`text-xl font-medium tabular-nums`},e))}),C&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`button`,{onClick:()=>i(e=>!e),className:`text-[10px] font-mono uppercase tracking-wider text-amber-300 hover:text-amber-200 flex items-center gap-1 transition-colors cursor-pointer`,children:[r?`▾`:`▸`,` view drift details`]}),r&&(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[y.drift_details.only_in_files.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-amber-300/80 mb-1.5`,children:[`in .rules files but not in db — run`,` `,(0,D.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`})]}),(0,D.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-amber-400/20 rounded-sm p-2 space-y-0.5 max-h-40 overflow-y-auto`,children:y.drift_details.only_in_files.map(e=>(0,D.jsxs)(`div`,{className:`font-mono text-[11px] text-amber-200/80`,children:[`+ `,e]},e))})]}),y.drift_details.only_in_db.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300/80 mb-1.5`,children:`in db but not in any .rules file — orphaned rules`}),(0,D.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-red-400/20 rounded-sm p-2 space-y-0.5 max-h-40 overflow-y-auto`,children:y.drift_details.only_in_db.map(e=>(0,D.jsxs)(`div`,{className:`font-mono text-[11px] text-red-200/80`,children:[`− `,e]},e))})]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:h,disabled:l===`loading`,children:l===`loading`?`syncing…`:`↑ sync files → db`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,disabled:p===`loading`,children:p===`loading`?`…`:p===`done`?`✓ reloaded`:`↻ force reload`}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] ml-auto`,children:y.db_rule_count===0?`⚠ db empty — daemon falls back to file-based loading`:`db has ${y.db_rule_count} rules — indexed queries`})]}),l===`done`&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm border border-emerald-500/25 bg-emerald-500/[0.06] px-3 py-2 text-xs font-mono text-emerald-200`,children:[(0,D.jsxs)(`span`,{children:[`✓ `,d]}),(0,D.jsx)(`button`,{onClick:()=>u(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-emerald-500/30 hover:bg-emerald-500/10 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`dismiss`})]}),l===`error`&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm border border-red-500/25 bg-red-500/[0.06] px-3 py-2 text-xs font-mono text-red-200`,children:[(0,D.jsxs)(`span`,{children:[`✗ `,d]}),(0,D.jsx)(`button`,{onClick:()=>u(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-red-500/30 hover:bg-red-500/10 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`dismiss`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-[var(--color-fg-4)] pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsxs)(`span`,{children:[`rules dir:`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:y.rules_dir})]}),(0,D.jsxs)(`span`,{className:`ml-auto`,children:[`last reload:`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:dp(y.last_reload_at)})]})]})]}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`sqlite database`}),v&&!v.error&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(mp,{ok:v.journal_mode===`wal`,label:`wal`,badLabel:`no wal`}),(0,D.jsx)(mp,{ok:v.synchronous===`NORMAL`,label:`normal`,badLabel:v.synchronous})]})]}),(0,D.jsx)(X,{children:v?v.error?(0,D.jsx)(`div`,{className:`text-xs text-red-300 font-mono bg-red-500/[0.06] border border-red-500/25 rounded-sm p-2`,children:v.error}):(0,D.jsxs)(`div`,{children:[(0,D.jsx)(fp,{children:`storage`}),(0,D.jsx)(pp,{label:`file path`,value:v.path}),(0,D.jsx)(pp,{label:`file size`,value:sp(v.file_size_bytes)}),(0,D.jsx)(pp,{label:`allocated`,value:`${sp(v.allocated_bytes)} (${v.page_count.toLocaleString()} pages × ${v.page_size}B)`}),(0,D.jsx)(fp,{className:`mt-4`,children:`pragma configuration`}),(0,D.jsx)(pp,{label:`journal_mode`,value:v.journal_mode,accent:v.journal_mode===`wal`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(pp,{label:`synchronous`,value:v.synchronous,accent:v.synchronous===`NORMAL`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(pp,{label:`cache_size`,value:`${v.cache_size_kb.toLocaleString()} KB (${Math.round(v.cache_size_kb/1024)} MB)`}),(0,D.jsx)(pp,{label:`page_size`,value:`${v.page_size.toLocaleString()} B`}),v.wal_checkpoint&&(0,D.jsx)(pp,{label:`wal checkpoint`,value:`log ${v.wal_checkpoint.log}, checkpointed ${v.wal_checkpoint.checkpointed}, busy ${v.wal_checkpoint.busy}`}),(0,D.jsx)(fp,{className:`mt-4`,children:`table row counts`}),v.tables.map(e=>(0,D.jsx)(pp,{label:e.name,value:e.row_count>=0?e.row_count.toLocaleString():`error`,accent:e.row_count<0?`text-red-300`:`text-[var(--color-fg-1)]`},e.name))]}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`audit log capacity`})}),(0,D.jsx)(X,{children:b?(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(hp,{pct:b.utilization_pct,total:b.total_rows,max:b.max_rows}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(pp,{label:`total rows`,value:b.total_rows.toLocaleString()}),(0,D.jsx)(pp,{label:`rotation limit`,value:b.max_rows.toLocaleString()}),(0,D.jsx)(pp,{label:`utilization`,value:`${b.utilization_pct}%`,accent:b.utilization_pct>=85?`text-red-300`:b.utilization_pct>=60?`text-amber-300`:`text-emerald-300`}),(0,D.jsx)(pp,{label:`oldest entry`,value:up(b.oldest_timestamp)}),(0,D.jsx)(pp,{label:`newest entry`,value:up(b.newest_timestamp)})]}),b.utilization_pct>=85&&(0,D.jsx)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/[0.06] px-3 py-2 text-[11px] font-mono text-red-200`,children:`⚠ audit log nearing rotation limit. oldest entries will be purged automatically.`})]}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`process & runtime`})}),(0,D.jsx)(X,{children:x?(0,D.jsxs)(`div`,{children:[(0,D.jsx)(pp,{label:`pid`,value:x.pid}),(0,D.jsx)(pp,{label:`uptime`,value:lp(x.uptime_ms)}),(0,D.jsx)(pp,{label:`memory (rss)`,value:`${x.memory_rss_mb} MB`}),(0,D.jsx)(pp,{label:`bun version`,value:x.bun_version}),(0,D.jsx)(pp,{label:`node compat`,value:x.node_version}),(0,D.jsx)(pp,{label:`platform`,value:`${x.platform} / ${x.arch}`})]}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`flight recorder`})}),(0,D.jsx)(X,{children:S?(0,D.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline mb-1.5`,children:`log file`}),(0,D.jsx)(`div`,{className:`text-xs font-mono text-[var(--color-fg-1)] truncate`,children:`…${S.path.slice(-50)}`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline mb-1.5`,children:`file size`}),(0,D.jsx)(`div`,{className:`text-xs font-mono tabular-nums ${S.file_size_bytes===0?`text-[var(--color-fg-4)]`:`text-[var(--color-fg-1)]`}`,children:sp(S.file_size_bytes)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline mb-1.5`,children:`approx. entries`}),(0,D.jsx)(`div`,{className:`text-xs font-mono tabular-nums ${S.approx_entries===0?`text-[var(--color-fg-4)]`:`text-[var(--color-fg-1)]`}`,children:S.approx_entries===0?`—`:S.approx_entries.toLocaleString()})]})]}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,D.jsx)(yp,{}),(0,D.jsx)(bp,{}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`observability api`})}),(0,D.jsxs)(X,{children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-2.5`,children:`machine-readable endpoints for automated monitoring and ai agent triage:`}),(0,D.jsx)(`div`,{className:`space-y-1 font-mono text-[11px]`,children:[[`/api/json/observability`,`sqlite health, rule drift, process info`],[`/api/state/runtime`,`eval latency, decision counters, memory`],[`/api/state/activity-tail?after=0&limit=20`,`recent eval events (live feed)`],[`/api/json/daemon-status`,`daemon pid, status, log tail`],[`/api/json/evald-log`,`last 200 lines of evald.log (daemon stderr)`],[`/healthz`,`process liveness`],[`/readyz`,`sqlite liveness`]].map(([e,t])=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`GET`}),(0,D.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] transition-colors`,children:e}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] hidden sm:inline`,children:[`— `,t]})]},e))})]})]})]})}function Sp({db:e,audit:t,proc:n,flight:r,driftDetected:i}){let a=e?e.error?`error`:e.journal_mode===`wal`&&e.synchronous===`NORMAL`?`ok`:`warn`:`unknown`,o=t?t.utilization_pct>=85?`error`:t.utilization_pct>=60?`warn`:`ok`:`unknown`,s=n?n.memory_rss_mb>600?`warn`:`ok`:`unknown`;return(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,D.jsxs)(ip,{title:`sqlite`,status:a,statusLabel:e?.journal_mode?.toUpperCase()??`idle`,children:[(0,D.jsx)(ap,{label:`size`,value:e?(0,D.jsx)(qc,{value:e.file_size_bytes,format:e=>cp(e)}):`—`,mono:!0}),(0,D.jsx)(ap,{label:`journal`,value:e?.journal_mode??`—`,mono:!0}),(0,D.jsx)(ap,{label:`sync`,value:e?.synchronous??`—`,mono:!0}),(0,D.jsx)(ap,{label:`tables`,value:e?.tables.length??0,tone:i?`warn`:`neutral`})]}),(0,D.jsxs)(ip,{title:`audit log`,status:o,statusLabel:t?`${t.utilization_pct}%`:`idle`,children:[(0,D.jsx)(ap,{label:`rows`,value:t?(0,D.jsx)(qc,{value:t.total_rows}):`—`}),(0,D.jsx)(ap,{label:`capacity`,value:t?`${(t.total_rows/Math.max(1,t.max_rows)*100).toFixed(1)}%`:`—`,tone:t&&t.utilization_pct>=85?`bad`:t&&t.utilization_pct>=60?`warn`:`good`}),(0,D.jsx)(ap,{label:`oldest`,value:up(t?.oldest_timestamp??null),mono:!0}),(0,D.jsx)(ap,{label:`newest`,value:up(t?.newest_timestamp??null),mono:!0})]}),(0,D.jsxs)(ip,{title:`process`,status:s,statusLabel:n?`pid ${n.pid}`:`idle`,children:[(0,D.jsx)(ap,{label:`uptime`,value:n?lp(n.uptime_ms):`—`,mono:!0}),(0,D.jsx)(ap,{label:`rss`,value:n?(0,D.jsxs)(`span`,{children:[(0,D.jsx)(qc,{value:n.memory_rss_mb,format:e=>e.toFixed(0)}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1`,children:`MB`})]}):`—`}),(0,D.jsx)(ap,{label:`bun`,value:n?.bun_version??`—`,mono:!0}),(0,D.jsx)(ap,{label:`platform`,value:n?`${n.platform}/${n.arch}`:`—`,mono:!0})]}),(0,D.jsxs)(ip,{title:`flight recorder`,status:r&&r.file_size_bytes>0?`ok`:`unknown`,statusLabel:r?`${r.approx_entries.toLocaleString()} entries`:`idle`,children:[(0,D.jsx)(ap,{label:`size`,value:r?(0,D.jsx)(qc,{value:r.file_size_bytes,format:e=>cp(e)}):`—`,mono:!0}),(0,D.jsx)(ap,{label:`entries`,value:r?(0,D.jsx)(qc,{value:r.approx_entries}):`—`})]})]})}function Cp(e){return e<1e6?`${(e/1e3).toFixed(0)}µs`:e<1e9?`${(e/1e6).toFixed(1)}ms`:`${(e/1e9).toFixed(2)}s`}function wp(e){return new Date(e*1e3).toLocaleString()}var Tp={critical:`red`,high:`red`,medium:`amber`,low:`blue`},Ep={critical:`border-l-red-500/70`,high:`border-l-red-500/50`,medium:`border-l-amber-400/60`,low:`border-l-sky-400/50`};function Dp(){let{data:e}=V(`/api/json/profile`);if(!e)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading profile…`});let{diagnosis:t,sessions:n}=e;return!t||t.analyzed_evals===0?(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center`,children:(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] font-mono`,children:[`no eval data yet — run`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg eval`}),` to start recording`]})}):(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[{label:`evals analyzed`,value:String(t.analyzed_evals)},{label:`median (inside)`,value:Cp(t.median_eval_ns)},{label:`p99 (inside)`,value:Cp(t.p99_eval_ns)},{label:`bottleneck`,value:t.bottleneck??`—`}].map(e=>(0,D.jsx)(Ou,{label:e.label,value:e.value,labelPlacement:`above`,valueClassName:`text-xl font-medium tabular-nums text-[var(--color-fg-0)]`},e.label))}),t.phases.length>0&&(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`overline`,children:`phase breakdown`})}),(0,D.jsx)(X,{children:(0,D.jsx)(`div`,{className:`space-y-2`,children:t.phases.filter(e=>e.median_ns>0).map(e=>{let n=e.name===t.bottleneck;return(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,D.jsx)(`span`,{className:`w-28 font-mono truncate ${n?`text-[var(--color-brand)] font-medium`:`text-[var(--color-fg-2)]`}`,title:n?`bottleneck`:void 0,children:e.name}),(0,D.jsx)(Au,{pct:Math.min(e.pct_of_total,100),tone:n?`amber`:`gray`,className:`h-1 flex-1`}),(0,D.jsx)(`span`,{className:`w-16 text-right text-[var(--color-fg-1)] tabular-nums font-mono`,children:Cp(e.median_ns)}),(0,D.jsxs)(`span`,{className:`w-10 text-right text-[var(--color-fg-3)] tabular-nums font-mono`,children:[e.pct_of_total,`%`]}),(0,D.jsxs)(`span`,{className:`w-20 text-right text-[var(--color-fg-4)] tabular-nums font-mono text-[10px]`,children:[`p95 `,Cp(e.p95_ns)]})]},e.name)})})})]}),t.recommendations.length>0&&(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`recommendations · `,t.recommendations.length]})}),(0,D.jsx)(X,{className:`space-y-2`,children:t.recommendations.map((e,t)=>(0,D.jsxs)(`div`,{className:`border border-[var(--color-line-1)] bg-[var(--color-surface-0)] rounded-sm px-3 py-2.5 border-l-2 ${Ep[e.severity]??`border-l-[var(--color-line-2)]`}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,D.jsx)(K,{variant:Tp[e.severity]??`gray`,children:e.severity}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:e.type})]}),(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-1)] leading-relaxed`,children:e.message}),e.fix_command&&(0,D.jsxs)(`code`,{className:`text-[11px] text-[var(--color-brand)] font-mono mt-1.5 block`,children:[`$ `,e.fix_command]})]},t))})]}),t.anomalies.length>0&&(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`anomalies · `,t.anomalies.length]})}),(0,D.jsx)(X,{children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:t.anomalies.map((e,t)=>(0,D.jsxs)(`div`,{className:`py-2 flex items-center gap-4 text-xs font-mono`,children:[(0,D.jsx)(`span`,{className:`w-24 text-[var(--color-brand)] uppercase tracking-wider text-[10px]`,children:e.type}),(0,D.jsxs)(`span`,{className:`w-10 tabular-nums text-[var(--color-fg-1)]`,children:[e.count,`×`]}),(0,D.jsxs)(`span`,{className:`w-20 tabular-nums text-[var(--color-fg-1)]`,children:[e.max_ms,`ms max`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:e.likely_cause})]},t))})})]}),n.length>0&&(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`session history`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[n.length,` session`,n.length===1?``:`s`]})]}),(0,D.jsx)(X,{className:`p-0`,children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:[...n].reverse().map((e,t)=>(0,D.jsxs)(`div`,{className:`px-4 py-2.5 flex flex-wrap items-center gap-x-5 gap-y-1 text-xs ${e.is_current?`bg-amber-400/[0.04] border-l-2 border-l-amber-400/60`:``}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 w-48 shrink-0`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums font-mono`,children:wp(e.start_ts)}),e.is_current&&(0,D.jsx)(K,{variant:`amber`,children:`current`})]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums font-mono w-20`,children:[e.evals,` eval`,e.evals===1?``:`s`]}),(0,D.jsxs)(`span`,{className:`text-emerald-300 tabular-nums font-mono`,children:[e.allowed,` allow`]}),e.blocked>0&&(0,D.jsxs)(`span`,{className:`text-red-300 tabular-nums font-mono`,children:[e.blocked,` block (`,e.block_rate_pct,`%)`]}),e.asked>0&&(0,D.jsxs)(`span`,{className:`text-sky-300 tabular-nums font-mono`,children:[e.asked,` ask`]}),e.forced>0&&(0,D.jsxs)(`span`,{className:`text-violet-300 tabular-nums font-mono`,children:[e.forced,` force`]}),e.avg_ns>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums ml-auto font-mono`,children:[`avg `,Cp(e.avg_ns)]}),e.top_rule&&(0,D.jsxs)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.top_rule)}`,className:`text-[var(--color-fg-4)] hover:text-[var(--color-brand)] font-mono truncate max-w-xs transition-colors w-full pl-48`,title:`most blocked rule: ${e.top_rule}`,children:[`top block: `,e.top_rule]})]},t))})})]})]})}var Op={log:`text-[var(--color-fg-1)]`,info:`text-sky-300`,warn:`text-amber-300`,error:`text-red-300`,debug:`text-[var(--color-fg-3)]`};function kp(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function Ap(){let e=op(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(0);(0,_.useEffect)(()=>{d.current?.scrollIntoView({behavior:`smooth`})},[]),(0,_.useEffect)(()=>{if(e.connected)return e.sendCommand(`Runtime.enable`).catch(()=>{}),e.onEvent(`Runtime.consoleAPICalled`,e=>{let t=e;o(e=>{let n=[...e,{id:f.current++,type:t.type??`log`,args:t.args??[],timestamp:t.timestamp??Date.now()}];return n.length>500?n.slice(-500):n})})},[e.connected,e.sendCommand,e.onEvent]);let p=(0,_.useCallback)(()=>{e.preconfiguredTarget&&e.connect(e.preconfiguredTarget.id)},[e]),m=(0,_.useCallback)(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),i(null)}catch(e){console.error(`Profiler.start failed:`,e)}},[e]),h=(0,_.useCallback)(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch(e){console.error(`Profiler.stop failed:`,e),n(!1)}},[e]),g=(0,_.useCallback)(async()=>{u(!0);try{let t=await e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0});c(JSON.parse(t.result.value))}catch{}finally{u(!1)}},[e]);function v(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}let y=e.connected?`connected${e.bunVersion?` · bun v${e.bunVersion}`:``}`:e.connecting?`connecting…`:e.active?`inspector active, connecting…`:`inspector not available`,b=e.connected?`bg-emerald-400`:e.connecting?`bg-amber-400 pulse-soft`:e.active?`bg-sky-400`:`bg-[var(--color-line-2)]`;return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${b}`}),y]}),e.connected?(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`}):(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e.preconfiguredTarget?p:e.refetch,disabled:e.connecting,children:e.preconfiguredTarget?`reconnect`:`refresh`})]})]}),e.error&&(0,D.jsx)(X,{children:(0,D.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:e.error})})]}),e.connected&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`cpu profiler`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300 flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-400 pulse-soft`}),`recording`]}),t?(0,D.jsx)(q,{variant:`danger`,size:`sm`,onClick:h,children:`stop & render`}):(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:m,children:`start recording`})]})]}),(0,D.jsx)(X,{children:r?(0,D.jsx)(Mu,{profile:r,children:(0,D.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 overflow-x-hidden`,children:(0,D.jsx)(tp,{profile:r})})}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording… perform actions in ssg, then stop.`:`click start recording, perform actions, then stop.`})})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`memory`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,disabled:l,children:l?`…`:`refresh`})]}),(0,D.jsx)(X,{children:s?(0,D.jsx)(Nu,{memory:s,formatValue:v}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`click refresh to fetch process.memoryUsage().`})})]}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`console`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 h-56 overflow-y-auto font-mono text-[11px]`,children:[a.length===0?(0,D.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`console output will appear here…`}):a.map(e=>(0,D.jsxs)(`div`,{className:`py-0.5 border-b border-[var(--color-line-0)] ${Op[e.type]??`text-[var(--color-fg-1)]`}`,children:[(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] mr-2 uppercase tracking-wider`,children:[`[`,e.type,`]`]}),e.args.map(kp).join(` `)]},e.id)),(0,D.jsx)(`div`,{ref:d})]})})]})]}),!e.connected&&!e.connecting&&(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center`,children:(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:e.active?`waiting for inspector connection…`:`inspector auto-starts with ssg serve. profiler, memory, and console appear here once connected.`})})]})}function jp({active:e,onClick:t,children:n}){return(0,D.jsxs)(`button`,{onClick:t,className:`relative px-3 h-9 text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${e?`text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:[n,e&&(0,D.jsx)(`span`,{className:`absolute inset-x-2 -bottom-px h-px bg-[var(--color-brand)]`})]})}function Mp(){let[e,t]=(0,_.useState)(`eval`);return(0,D.jsxs)(`div`,{className:`space-y-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center border-b border-[var(--color-line-0)] mb-5`,children:[(0,D.jsx)(jp,{active:e===`eval`,onClick:()=>t(`eval`),children:`eval profile`}),(0,D.jsx)(jp,{active:e===`inspector`,onClick:()=>t(`inspector`),children:`runtime inspector`})]}),e===`eval`?(0,D.jsx)(Dp,{}):(0,D.jsx)(Ap,{})]})}function Np(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function Pp({open:e,onClose:t,onSaved:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(`error`),[w,T]=(0,_.useState)(50),[E,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(``),j=(0,_.useRef)(null);(0,_.useEffect)(()=>{f(Np()!==void 0)},[]),(0,_.useEffect)(()=>{fetch(`/api/rules/dictate/templates`).then(e=>e.json()).then(e=>i(e.templates??[])).catch(()=>void 0)},[]),(0,_.useEffect)(()=>{e?(o(``),c(``),m(null),A(``),y({}),x(``),C(`error`),T(50)):N()},[e,N]);function M(){let e=Np();if(!e)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=`en-US`,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i&&(i.isFinal?t+=i[0].transcript:n+=i[0].transcript)}t&&o(e=>(e?`${e} ${t}`:t).trim()),c(n)},t.onend=()=>u(!1),t.onerror=()=>u(!1),t.start(),j.current=t,u(!0)}function N(){if(j.current){try{j.current.stop()}catch{}j.current=null}u(!1)}async function ee(e){let t=e.trim();if(!t){m(null);return}g(!0);try{let e=await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({transcript:t})})).json();m(e),e.matched&&e.slots&&y({...e.slots}),e.args?(x(e.args.name),C(e.args.severity),T(e.args.priority)):e.modifiers?.severity&&C(e.modifiers.severity)}finally{g(!1)}}async function te(){if(p?.templateId){g(!0);try{m(await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({templateId:p.templateId,slots:v,severity:S,priority:w,name:b})})).json())}finally{g(!1)}}}async function P(e=!1){if(p?.args){O(!0),A(``);try{let r={args:{...p.args,name:b||p.args.name,severity:S,priority:w},overwrite:e},i=await(await fetch(`/api/rules/dictate/save`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify(r)})).json();i.ok?(n?.(),t()):i.error===`exists`&&!e?window.confirm(`A rule named "${r.args.name}" already exists. Overwrite it?`)&&await P(!0):A(i.error??`save failed`)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}}let F=p?.templateId?r.find(e=>e.id===p.templateId):void 0;return(0,D.jsx)(Kt,{open:e,onClose:t,title:`Dictate a Rule`,subtitle:`Speak or type — SSG matches a template, deterministic, no inference cost`,size:`lg`,footer:p?.args?(0,D.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[k?(0,D.jsx)(`span`,{className:`text-[11px] font-mono text-red-300 mr-auto`,children:k}):(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mr-auto`,children:[`will write .sigmashake/rules/`,b||p.args.name,`.rules`]}),(0,D.jsx)(q,{variant:`secondary`,onClick:t,disabled:E,children:`Cancel`}),(0,D.jsx)(q,{variant:`primary`,onClick:()=>P(!1),disabled:E,children:E?`Saving…`:`Save Rule`})]}):(0,D.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mr-auto`,children:`dictate or pick a template to begin`}),(0,D.jsx)(q,{variant:`secondary`,onClick:t,children:`Close`})]}),children:(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(Fp,{transcript:a,interim:s,listening:l,voiceSupported:d,onChange:o,onToggleMic:l?N:M,onSubmit:()=>ee(a),matching:h}),!p&&r.length>0&&(0,D.jsx)(Ip,{templates:r,onPick:e=>{o(e.example),ee(e.example)}}),p&&!p.matched&&(0,D.jsx)(Lp,{onTryAgain:()=>{o(``),m(null)},templates:r,onPick:e=>{o(e.example),ee(e.example)}}),p?.matched&&F&&(0,D.jsx)(Rp,{template:F,args:p.args,preview:p.preview,previewError:p.previewError,missingSlots:p.missingSlots??[],editedSlots:v,editedName:b,editedSeverity:S,editedPriority:w,onSlotChange:(e,t)=>y(n=>({...n,[e]:t})),onNameChange:x,onSeverityChange:C,onPriorityChange:T,onApply:te,applying:h,alternatives:p.alternatives.map(e=>r.find(t=>t.id===e)).filter(e=>!!e),onSwitchTemplate:e=>{y({}),m({...p,templateId:e.id,args:void 0,preview:void 0}),setTimeout(()=>te(),0)}})]})})}function Fp({transcript:e,interim:t,listening:n,voiceSupported:r,onChange:i,onToggleMic:a,onSubmit:o,matching:s}){return(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`label`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`what should the rule do?`}),r?(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`ml-auto px-2 py-1 text-[11px] font-mono uppercase tracking-wider rounded-sm border cursor-pointer transition-colors ${n?`border-red-400 text-red-300 bg-red-500/10`:`border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:bg-[var(--color-surface-2)]`}`,"aria-pressed":n,children:n?`● recording — click to stop`:`🎙 dictate`}):(0,D.jsx)(`span`,{className:`ml-auto text-[10px] font-mono text-[var(--color-fg-4)]`,children:`voice unavailable in this browser`})]}),(0,D.jsx)(`textarea`,{rows:3,value:e+(t?` ${t}`:``),onChange:e=>i(e.target.value),placeholder:`e.g. "block any command containing dangerous-cmd" or "ask before editing the migrations folder"`,className:`w-full font-mono text-[13px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm p-3 text-[var(--color-fg-0)] placeholder:text-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-brand)]`}),(0,D.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:o,disabled:s||!e.trim(),children:s?`Matching…`:`Match Template`})})]})}function Ip({templates:e,onPick:t}){return(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`or pick a template`}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:e.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`text-left p-3 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] hover:bg-[var(--color-surface-2)] cursor-pointer transition-colors`,children:[(0,D.jsx)(`div`,{className:`font-mono text-[12px] text-[var(--color-fg-0)] mb-1`,children:e.name}),(0,D.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)] mb-1`,children:e.description}),(0,D.jsxs)(`div`,{className:`font-mono text-[10px] text-[var(--color-fg-4)] italic`,children:[`"`,e.example,`"`]})]},e.id))})]})}function Lp({onTryAgain:e,templates:t,onPick:n}){return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/5 p-3`,children:[(0,D.jsx)(`div`,{className:`font-mono text-[12px] text-amber-300 mb-1`,children:`no template matched`}),(0,D.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`The deterministic matcher could not recognise the intent in your dictation. Try one of the templates below — they show the phrasing the matcher understands.`})]}),(0,D.jsx)(`button`,{type:`button`,onClick:e,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline cursor-pointer`,children:`← clear and try again`}),(0,D.jsx)(Ip,{templates:t,onPick:n})]})}function Rp({template:e,args:t,preview:n,previewError:r,missingSlots:i,editedSlots:a,editedName:o,editedSeverity:s,editedPriority:c,onSlotChange:l,onNameChange:u,onSeverityChange:d,onPriorityChange:f,onApply:p,applying:m,alternatives:h,onSwitchTemplate:g}){return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`rounded-sm border border-emerald-500/40 bg-emerald-500/5 p-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-emerald-300`,children:`matched`}),(0,D.jsx)(`span`,{className:`font-mono text-[12px] text-[var(--color-fg-0)]`,children:e.name})]}),(0,D.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1`,children:e.description})]}),h.length>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`also matches:`}),h.map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:bg-[var(--color-surface-2)] cursor-pointer`,children:e.name},e.id))]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`slots`}),e.slots.map(e=>{let t=a[e.name]??``,n=i.includes(e.name);return(0,D.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,D.jsxs)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:[e.label,e.required&&(0,D.jsx)(`span`,{className:`text-red-300 ml-1`,children:`*`})]}),(0,D.jsx)(`input`,{type:`text`,value:t,onChange:t=>l(e.name,t.target.value),placeholder:e.placeholder,className:`font-mono text-[12px] bg-[var(--color-surface-1)] border rounded-sm px-2 py-1 text-[var(--color-fg-0)] placeholder:text-[var(--color-fg-4)] focus:outline-none ${n?`border-red-400 focus:border-red-300`:`border-[var(--color-line-1)] focus:border-[var(--color-brand)]`}`})]},e.name)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,D.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`rule name`}),(0,D.jsx)(`input`,{type:`text`,value:o,onChange:e=>u(e.target.value),placeholder:`kebab-case-id`,className:`font-mono text-[12px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[var(--color-fg-0)] focus:outline-none focus:border-[var(--color-brand)]`})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,D.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`severity`}),(0,D.jsx)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[`error`,`warning`,`info`].map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`px-2 py-0.5 rounded-sm border cursor-pointer transition-colors ${s===e?`border-[var(--color-brand)] text-[var(--color-fg-0)] bg-[var(--color-surface-2)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-[var(--color-surface-2)]`}`,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[140px_1fr] gap-2 items-center`,children:[(0,D.jsx)(`label`,{className:`text-[11px] font-mono text-[var(--color-fg-2)]`,children:`priority`}),(0,D.jsx)(`input`,{type:`number`,value:c,min:0,max:100,onChange:e=>f(Math.max(0,Math.min(100,Number(e.target.value)||0))),className:`font-mono text-[12px] bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2 py-1 text-[var(--color-fg-0)] focus:outline-none focus:border-[var(--color-brand)] w-24`})]}),(0,D.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,D.jsx)(q,{variant:`secondary`,size:`sm`,onClick:p,disabled:m,children:m?`Rebuilding…`:`Apply edits`})})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(`h3`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`generated .rules preview`}),i.length>0&&(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-amber-300`,children:`fill the required slots above to see the rule`}),r&&(0,D.jsxs)(`div`,{className:`text-[11px] font-mono text-red-300`,children:[`preview error: `,r]}),n&&(0,D.jsx)(`pre`,{className:`font-mono text-[12px] bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3 text-[var(--color-fg-0)] overflow-x-auto whitespace-pre`,children:n}),t&&(0,D.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`decision=`,t.decision,` · target=`,t.target,` · field=`,t.field,` `,`· op=`,t.operator]})]})]})}var zp=new Set([`block`,`ask`,`force`,`deny`]),Bp=[`rules-changed`],Vp=[`block`,`ask`,`log`,`allow`,`force`,`shadow`],Hp={block:`text-red-300`,deny:`text-red-300`,ask:`text-sky-300`,allow:`text-emerald-300`,log:`text-[var(--color-fg-3)]`,force:`text-amber-300`,shadow:`text-violet-300`},Up=[{value:`today`,label:`today`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`all`,label:`all`}];async function Wp(e,t){await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t})})}async function Gp(e,t,n){await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({ruleId:e,file:t,decision:n})})}async function Kp(e,t){return fetch(`/api/rules/bulk-set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({targets:e,enabled:t})}).then(e=>e.json())}async function qp(e,t){return fetch(`/api/rules/bulk-update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({targets:e,decision:t})}).then(e=>e.json())}async function Jp(e){return fetch(`/api/rules/bulk-delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({targets:e})}).then(e=>e.json())}async function Yp(e,t={}){return fetch(`/api/rules/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify(t)}).then(e=>e.json())}function Xp(e){if(!e)return`never`;let t=Date.now()/1e3-e;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Zp({rule:e,file:t,onToggle:n}){let[r,i]=(0,_.useState)(!1);return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider ${e.enabled?`text-[var(--color-fg-1)]`:`text-[var(--color-fg-4)]`}`,children:e.enabled?`on`:`off`}),(0,D.jsx)(Ht,{size:`sm`,checked:e.enabled,disabled:r,label:`${e.enabled?`Disable`:`Enable`} rule ${e.id}`,onChange:async()=>{i(!0);try{await n()}finally{i(!1)}}})]})}function Qp(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/json/rule-write-enforcement`,{headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json();!e&&typeof r.enforced==`boolean`&&t(r.enforced)}catch{}})(),()=>{e=!0}},[]);async function o(e){r(!0);try{let n=await fetch(`/api/json/rule-write-enforcement`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({enforced:e})});if(n.ok){let e=await n.json();typeof e.enforced==`boolean`&&t(e.enforced)}}finally{r(!1),a(!1)}}if(e===null)return null;let s=!e;return(0,D.jsx)(J,{className:s?`border-amber-500/40 bg-amber-500/5`:`border-[var(--color-line-1)]`,children:(0,D.jsx)(X,{className:`px-3 py-2.5`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`rule-write protection`}),(0,D.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider ${s?`text-amber-300`:`text-emerald-300`}`,children:s?`disabled`:`enforced`})]}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1 leading-snug`,children:s?`Agents can currently Write/Edit .rules files. Turn this back on when you finish authoring.`:`Agents cannot Write/Edit/MultiEdit any .sigmashake/rules/**/*.rules file. Disable only when curating rulesets.`})]}),(0,D.jsx)(`div`,{className:`shrink-0`,children:i?(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`button`,{onClick:()=>o(!1),disabled:n,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:`disable`}),(0,D.jsx)(`button`,{onClick:()=>a(!1),disabled:n,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`cancel`})]}):(0,D.jsx)(`button`,{onClick:()=>{e?a(!0):o(!0)},disabled:n,className:`text-[11px] font-mono uppercase tracking-wider border rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-50 ${s?`bg-emerald-500/10 border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20`:`bg-[var(--color-surface-1)] border-[var(--color-line-1)] text-[var(--color-fg-1)] hover:bg-[var(--color-surface-2)]`}`,children:s?`enable`:`disable`})})]})})})}function $p({perf:e}){if(!e)return null;let t=e.totalRules>0?e.activeRules/e.totalRules*100:0,n=e.avgEvalMs>50?`text-amber-300`:e.avgEvalMs>100?`text-red-300`:`text-emerald-300`;return(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`px-3 py-2.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`installed`}),(0,D.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:e.totalRules})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`active`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm text-emerald-300 tabular-nums`,children:[e.activeRules,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[11px]`,children:[`(`,t.toFixed(0),`%)`]})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`avg eval`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm tabular-nums ${n}`,children:[e.avgEvalMs.toFixed(1),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`p95`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:[e.p95EvalMs.toFixed(1),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`per-rule`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:[`~`,e.perRuleMs.toFixed(3),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] ml-0.5 text-[10px]`,children:`ms`})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`evals today`}),(0,D.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-1)] tabular-nums`,children:e.evalsToday.toLocaleString()})]}),(0,D.jsxs)(`div`,{className:`ml-auto text-right`,children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`all-time evals`}),(0,D.jsx)(`div`,{className:`font-mono text-sm text-[var(--color-fg-2)] tabular-nums`,children:e.evalsAllTime.toLocaleString()})]})]}),e.avgEvalMs>50&&(0,D.jsx)(`p`,{className:`mt-2 text-[11px] text-amber-300/80`,children:`⚡ avg eval > 50ms — consider trimming or disabling low-value rules.`})]})})}function em({totalRules:e,activeRules:t,onChanged:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);async function s(e){i(e);try{e===`disable`?await Yp(`disable-all`):e===`enable`?await Yp(`enable-all`):await Yp(`uninstall-all`,{confirm:`UNINSTALL_ALL_RULES`}),n()}finally{i(null),o(null)}}return(0,D.jsx)(J,{className:`border-[var(--color-line-1)]`,children:(0,D.jsx)(X,{className:`px-3 py-2.5`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`rule firewall`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:[t,`/`,e,` active`]})]}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1 leading-snug`,children:[`Master switches across every installed ruleset. Disable / enable are reversible; uninstall wipes `,(0,D.jsx)(`code`,{children:`~/.sigmashake/rules/`}),`.`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[a===`disable`?(0,D.jsx)(tm,{onConfirm:()=>void s(`disable`),onCancel:()=>o(null),tone:`amber`,label:`disable ${t} rules`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>o(`disable`),disabled:r!==null||t===0,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`disable`?`disabling…`:`disable all`}),a===`enable`?(0,D.jsx)(tm,{onConfirm:()=>void s(`enable`),onCancel:()=>o(null),tone:`emerald`,label:`enable ${e-t} rules`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>o(`enable`),disabled:r!==null||t===e,className:`text-[11px] font-mono uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`enable`?`enabling…`:`enable all`}),a===`uninstall`?(0,D.jsx)(tm,{onConfirm:()=>void s(`uninstall`),onCancel:()=>o(null),tone:`red`,label:`UNINSTALL ${e} rules`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>o(`uninstall`),disabled:r!==null||e===0,className:`text-[11px] font-mono uppercase tracking-wider bg-red-500/10 border border-red-500/40 text-red-200 hover:bg-red-500/20 rounded-sm px-2.5 py-0.5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r===`uninstall`?`uninstalling…`:`uninstall all`})]})]})})})}function tm({onConfirm:e,onCancel:t,tone:n,label:r,disabled:i}){let a={amber:`bg-amber-500/10 border-amber-500/40 text-amber-200 hover:bg-amber-500/20`,emerald:`bg-emerald-500/10 border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20`,red:`bg-red-500/10 border-red-500/40 text-red-200 hover:bg-red-500/20`}[n];return(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsxs)(`button`,{onClick:e,disabled:i,className:`text-[11px] font-mono uppercase tracking-wider border rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50 ${a}`,children:[`confirm: `,r]}),(0,D.jsx)(`button`,{onClick:t,disabled:i,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`cancel`})]})}function nm({selected:e,onClear:t,onApply:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`block`),[s,c]=(0,_.useState)(!1);if(e.length===0)return null;async function l(e,t){i(e);try{await n(e,t)}finally{i(null),c(!1)}}return(0,D.jsx)(`div`,{className:`sticky top-0 z-20 -mx-1 px-1`,children:(0,D.jsx)(J,{className:`border-sky-500/40 bg-sky-500/5 backdrop-blur`,children:(0,D.jsx)(X,{className:`px-3 py-2`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsxs)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-sky-200`,children:[e.length,` selected`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(`button`,{onClick:()=>void l(`enable`),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`enable`?`…`:`enable`}),(0,D.jsx)(`button`,{onClick:()=>void l(`disable`),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-amber-500/10 border border-amber-500/40 text-amber-200 hover:bg-amber-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`disable`?`…`:`disable`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),disabled:r!==null,className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50 ${Hp[a]??`text-[var(--color-fg-2)]`}`,children:Vp.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))}),(0,D.jsx)(`button`,{onClick:()=>void l(`decision`,a),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-sky-500/10 border border-sky-500/40 text-sky-200 hover:bg-sky-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:r===`decision`?`…`:`set decision`})]}),s?(0,D.jsx)(tm,{onConfirm:()=>void l(`delete`),onCancel:()=>c(!1),tone:`red`,label:`delete ${e.length}`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>c(!0),disabled:r!==null,className:`text-[11px] font-mono uppercase tracking-wider bg-red-500/10 border border-red-500/40 text-red-200 hover:bg-red-500/20 rounded-sm px-2 py-0.5 cursor-pointer transition-colors disabled:opacity-50`,children:`delete…`}),(0,D.jsx)(`button`,{onClick:t,disabled:r!==null,className:`ml-auto text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer disabled:opacity-50`,children:`clear`})]})})})})}function rm({ruleId:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),fetch(`/api/json/rule-audit?ruleId=${encodeURIComponent(e)}&limit=25`).then(e=>e.json()).then(e=>{t||n(e)}).catch(()=>{}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),r?(0,D.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-[var(--color-fg-3)]`,children:`loading audit…`}):!t||t.rows.length===0?(0,D.jsx)(`p`,{className:`mt-1.5 text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no audit entries for this rule`}):(0,D.jsxs)(`div`,{className:`mt-2 border border-[var(--color-line-0)] rounded-sm overflow-hidden`,children:[(0,D.jsx)(`div`,{className:`bg-[var(--color-surface-0)] px-2 py-1 flex items-center gap-2`,children:(0,D.jsxs)(`span`,{className:`overline text-[10px]`,children:[`audit log — last `,t.rows.length,` of `,t.total]})}),(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)] max-h-64 overflow-y-auto`,children:t.rows.map(e=>(0,D.jsxs)(`div`,{className:`px-2 py-1.5 flex items-center gap-3 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider w-14 shrink-0 ${Hp[e.decision]??`text-[var(--color-fg-2)]`}`,children:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] w-20 shrink-0 truncate`,children:e.tool}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] flex-1 min-w-0 truncate`,children:e.input}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0`,children:e.duration_ns?`${Math.round(e.duration_ns/1e6)}ms`:`–`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums shrink-0 w-16 text-right`,children:Xp(e.timestamp)})]},e.id))})]})}function im(){let[e,t]=(0,_.useState)(!1);return(0,D.jsx)(J,{children:(0,D.jsxs)(`details`,{open:e,onToggle:e=>t(e.target.open),children:[(0,D.jsxs)(`summary`,{className:`px-3 py-2 cursor-pointer list-none select-none flex items-center gap-2 hover:bg-[var(--color-surface-2)]/70`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`ai-native config`}),(0,D.jsx)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`curl recipes — every UI action is also a JSON endpoint`}),(0,D.jsx)(`svg`,{className:`ml-auto text-[var(--color-fg-3)]`,width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,D.jsx)(`polyline`,{points:e?`6 15 12 9 18 15`:`6 9 12 15 18 9`})})]}),(0,D.jsxs)(X,{className:`py-2`,children:[(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mb-2 leading-snug`,children:[`Point an agent at `,(0,D.jsx)(`code`,{children:`http://127.0.0.1:7901`}),`. Every bulk action below is one POST — no UI scraping required.`]}),(0,D.jsx)(`pre`,{className:`text-[10px] font-mono text-[var(--color-fg-2)] bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm p-2 overflow-x-auto whitespace-pre`,children:`# list rules + stats
11
29
  curl :7901/api/json/rules
12
30
  curl :7901/api/json/rules-stats?window=7d
13
31
  curl :7901/api/json/rules-performance
@@ -29,31 +47,12 @@ curl -X POST :7901/api/rules/disable-all
29
47
  curl -X POST :7901/api/rules/enable-all
30
48
  curl -X POST :7901/api/rules/uninstall-all \\
31
49
  -H 'content-type: application/json' \\
32
- -d '{"confirm":"UNINSTALL_ALL_RULES"}'`})]})]})})}function Wl(){let e=ke(El)[`rules-changed`],{data:t,refetch:n}=V(`/api/json/rules`,[e]),[r,i]=(0,_.useState)(`7d`),{data:a,refetch:o}=V(`/api/json/rules-stats?window=${r}`,[e,r]),{data:s,refetch:c}=V(`/api/json/rules-performance`,[e]),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(`all`),[p,m]=(0,_.useState)(new Set),[h,g]=(0,_.useState)(new Set),[v,y]=(0,_.useState)(!1),b=new URLSearchParams(window.location.search).get(`highlight`)??``,x=(0,_.useRef)(null);(0,_.useEffect)(()=>{x.current&&x.current.scrollIntoView({behavior:`smooth`,block:`center`})},[t,b]);let S=a?.stats??{},C=(0,_.useMemo)(()=>{let e=new Map;if(!t)return e;for(let n of t.rulesets)for(let t of n.rules)e.set(t.id,{rule:t,file:n.file});return e},[t]);function w(){n(),o(),c()}if(!t)return(0,K.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading rules…`});if(t.rulesets.length===0)return(0,K.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 p-10 text-center`,children:[(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-2)] mb-2`,children:`No .rules files found.`}),(0,K.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline`,children:`→ browse hub to install rulesets`})]});let T=l.toLowerCase();function E(e){if(d===`enabled`&&!e.enabled||d===`disabled`&&e.enabled)return!1;let t=S[e.id]?.hits??0;return!(d===`hit`&&t===0||d===`never`&&t>0)}let D=t.rulesets.map(e=>({...e,rules:e.rules.filter(e=>T&&!e.id.toLowerCase().includes(T)&&!e.message.toLowerCase().includes(T)?!1:E(e))})).filter(e=>e.rules.length>0||!T&&d===`all`),O=t.rulesets.reduce((e,t)=>e+t.rules.length,0),k=t.rulesets.reduce((e,t)=>e+t.rules.filter(e=>e.enabled).length,0),A=new Set;for(let e of D)for(let t of e.rules)A.add(t.id);let j=[];for(let e of p){let t=C.get(e);t&&j.push({ruleId:e,file:t.file})}function M(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function N(e){m(t=>{let n=new Set(t);if(e.rules.every(e=>n.has(e.id)))for(let t of e.rules)n.delete(t.id);else for(let t of e.rules)n.add(t.id);return n})}function ee(){m(e=>{let t=new Set(e);for(let e of A)t.add(e);return t})}function te(e){g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function P(e,t){j.length!==0&&(e===`enable`?await Ml(j,!0):e===`disable`?await Ml(j,!1):e===`delete`?(await Pl(j),m(new Set)):e===`decision`&&t&&await Nl(j,t),w())}return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`overline text-[11px]`,children:`rules`}),(0,K.jsxs)(`div`,{className:`flex items-baseline gap-3 mt-1`,children:[(0,K.jsxs)(`span`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:[k,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,O]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-[11px] uppercase tracking-wider`,children:`active`})]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--color-fg-3)] uppercase tracking-wider`,children:[t.files.length,` file`,t.files.length===1?``:`s`]})]})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:`px-2 py-1 text-[11px] font-mono uppercase tracking-wider rounded-sm border border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)] hover:bg-[var(--color-brand)]/20 cursor-pointer transition-colors`,title:`Dictate or type a new rule — deterministic match, no inference cost`,children:`🎙 dictate rule`}),(0,K.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider`,children:[`all`,`enabled`,`disabled`,`hit`,`never`].map(e=>(0,K.jsx)(`button`,{onClick:()=>f(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${d===e?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e},e))}),(0,K.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm`,children:kl.map(e=>(0,K.jsx)(`button`,{onClick:()=>i(e.value),className:`px-1.5 py-0.5 cursor-pointer transition-colors ${r===e.value?`bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e.label},e.value))}),(0,K.jsx)(`input`,{type:`text`,placeholder:`search rules…`,value:l,onChange:e=>u(e.target.value),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-xs rounded-sm px-2.5 py-1.5 w-48 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]})]}),(0,K.jsx)(Rl,{perf:s}),(0,K.jsx)(zl,{totalRules:O,activeRules:k,onChanged:w}),(0,K.jsx)(Ll,{}),(0,K.jsx)(Ul,{}),(0,K.jsx)(Vl,{selected:j,onClear:()=>m(new Set),onApply:P}),A.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono`,children:[(0,K.jsxs)(`button`,{onClick:ee,className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:[`select `,A.size,` visible`]}),p.size>0&&(0,K.jsx)(`button`,{onClick:()=>m(new Set),className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear selection`})]}),D.length===0&&(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no rules match the current filter`}),(0,K.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>{let t=e.rules.some(e=>e.id===b),n=e.rules.filter(e=>e.enabled).length,r=e.rules.length>0&&e.rules.every(e=>p.has(e.id)),i=!r&&e.rules.some(e=>p.has(e.id));return(0,K.jsx)(q,{children:(0,K.jsxs)(`details`,{open:t||!!T||d!==`all`,children:[(0,K.jsxs)(`summary`,{className:`flex items-center gap-2 px-3 py-2 cursor-pointer list-none select-none hover:bg-[var(--color-surface-2)]/70 border-b border-[var(--color-line-0)]`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,ref:e=>{e&&(e.indeterminate=i)},onChange:()=>N(e),onClick:e=>e.stopPropagation(),className:`accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select all rules in ${e.file}`}),(0,K.jsxs)(`svg`,{className:`text-[var(--color-fg-3)] shrink-0`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,K.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,K.jsx)(`code`,{className:`text-xs text-[var(--color-fg-0)] font-mono`,children:e.file}),(0,K.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-[var(--color-fg-3)] tabular-nums`,children:[n,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,e.rules.length]})]})]}),(0,K.jsxs)(Y,{className:`py-0`,children:[e.rules.length===0?(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] py-3`,children:`no rules in this file`}):(0,K.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:e.rules.map(t=>{let n=t.id===b,r=p.has(t.id),i=S[t.id],a=h.has(t.id);return(0,K.jsx)(`div`,{ref:n?x:null,className:`py-2.5 ${n?`bg-amber-400/8 border-l-2 border-l-amber-400/60 -mx-3 px-3 -my-px`:r?`bg-sky-400/5`:``}`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>M(t.id),className:`mt-1 accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select rule ${t.id}`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1 flex-wrap`,children:[(0,K.jsx)(`select`,{value:t.decision,onChange:async n=>{await jl(t.id,e.file,n.target.value),w()},className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50 ${Ol[t.decision]??`text-[var(--color-fg-2)]`}`,children:Dl.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),(0,K.jsx)(_l,{ruleId:t.id,children:(0,K.jsx)(`code`,{className:`text-xs font-mono text-[var(--color-fg-0)] break-all`,children:t.id})}),i&&i.hits>0&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`·`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:i.hits}),` `,`hit`,i.hits===1?``:`s`,i.avgDurationMs>0&&(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[i.avgDurationMs.toFixed(1),`ms`]}),` `,`avg`]}),` · `,Fl(i.lastSeen)]}),(!i||i.hits===0)&&(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:`· never fired`}),(0,K.jsx)(`button`,{onClick:()=>te(t.id),className:`ml-auto text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:a?`hide audit`:`audit`})]}),(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] truncate`,children:t.message}),a&&(0,K.jsx)(Hl,{ruleId:t.id})]})]}),(0,K.jsx)(Il,{rule:t,file:e.file,onToggle:async()=>{await Al(t.id,e.file),w()}})]})},t.id)})}),e.content&&(0,K.jsxs)(`details`,{className:`mt-3 pb-3`,children:[(0,K.jsx)(`summary`,{className:`overline cursor-pointer hover:text-[var(--color-fg-1)] select-none`,children:`raw source`}),(0,K.jsx)(`pre`,{className:`mt-2 p-3 bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm text-[11px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-words font-mono`,children:e.content})]})]})]})},e.file)})}),(0,K.jsx)(xl,{open:v,onClose:()=>y(!1),onSaved:w})]})}function Gl(e){return e==null?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function Kl(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d ${n%24}h`}function ql(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),g=async()=>{let e=await(await fetch(`/api/json/audit-config`)).json();t(e),a(String(e.config.maxRows)),s(String(e.config.absoluteMaxRows)),l(String(e.config.minRetentionHours)),d(e.config.maxBytes==null?``:String(Math.round(e.config.maxBytes/(1024*1024))))};(0,_.useEffect)(()=>{g()},[]);let v=(0,_.useMemo)(()=>!e?.usage.oldestTimestampSec||!e?.usage.newestTimestampSec?null:e.usage.newestTimestampSec-e.usage.oldestTimestampSec,[e]),y=async()=>{if(!e)return;p(!0),h(null);let t={},n=Number(i);Number.isFinite(n)&&n!==e.config.maxRows&&(t.maxRows=n);let r=Number(o);Number.isFinite(r)&&r!==e.config.absoluteMaxRows&&(t.absoluteMaxRows=r);let a=Number(c);if(Number.isFinite(a)&&a!==e.config.minRetentionHours&&(t.minRetentionHours=a),u.trim()===``)e.config.maxBytes!=null&&(t.maxBytes=null);else{let n=Number(u);if(Number.isFinite(n)){let r=Math.round(n*1024*1024);r!==e.config.maxBytes&&(t.maxBytes=r)}}if(Object.keys(t).length===0){h({kind:`ok`,text:`No changes.`}),p(!1);return}try{let e=await fetch(`/api/json/audit-config`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!e.ok){let t=await e.json();throw Error(t.error??`HTTP ${e.status}`)}await g(),h({kind:`ok`,text:`Saved. New budget applies within ~60 seconds.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}},b=async()=>{if(e){p(!0),h(null);try{let t=await fetch(`/api/json/audit-config`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e.defaults)});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await g(),h({kind:`ok`,text:`Reset to defaults.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}}};if(!e)return(0,K.jsx)(K.Fragment,{});let x=`w-32 bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50`,S=`text-[10.5px] uppercase tracking-wider text-[var(--color-fg-4)]`,C=`text-[10.5px] font-mono text-[var(--color-fg-4)] tabular-nums`;return(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,K.jsxs)(`button`,{onClick:()=>r(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 hover:bg-white/[0.02] cursor-pointer`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11.5px]`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[var(--color-fg-1)]`,children:`Storage budget`}),(0,K.jsxs)(`span`,{className:C,children:[e.usage.rows.toLocaleString(),` rows`,e.usage.bytes!=null&&` · ${Gl(e.usage.bytes)}`,v!=null&&` · spans ${Kl(v)}`]})]}),(0,K.jsx)(`span`,{className:C,children:n?`▾`:`▸`})]}),n&&(0,K.jsxs)(`div`,{className:`border-t border-[var(--color-line-1)] px-3 py-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:S,children:`Soft row cap`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:i,min:e.limits.maxRows.min,max:e.limits.maxRows.max,onChange:e=>a(e.target.value),className:x}),(0,K.jsx)(`span`,{className:C,children:`rows`})]}),(0,K.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Above this, old rows are rotated — but never within the retention window.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:S,children:`Hard ceiling`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:o,min:e.limits.absoluteMaxRows.min,max:e.limits.absoluteMaxRows.max,onChange:e=>s(e.target.value),className:x}),(0,K.jsx)(`span`,{className:C,children:`rows`})]}),(0,K.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Pruned regardless of age once exceeded. Protects against runaway disk growth.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:S,children:`Retention floor`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:c,step:`0.5`,min:e.limits.minRetentionHours.min,max:e.limits.minRetentionHours.max,onChange:e=>l(e.target.value),className:x}),(0,K.jsx)(`span`,{className:C,children:`hours`})]}),(0,K.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Rows newer than this are never deleted by the soft cap. Set 0 to disable the floor.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:S,children:`Size cap (optional)`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:u,placeholder:`off`,min:1,onChange:e=>d(e.target.value),className:x}),(0,K.jsx)(`span`,{className:C,children:`MB`})]}),(0,K.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-4)] leading-relaxed`,children:`Bytes-based eviction. Leave blank to disable. Honors the retention floor like the soft cap.`})]})]}),m&&(0,K.jsx)(`p`,{className:`text-[11px] font-mono ${m.kind===`err`?`text-rose-300`:`text-emerald-300`}`,children:m.text}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(`button`,{onClick:y,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:text-[var(--color-fg-0)] bg-[var(--color-surface-2)] hover:bg-[var(--color-surface-3)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:f?`saving…`:`save`}),(0,K.jsx)(`button`,{onClick:b,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:`reset to defaults`})]})]})]})}var Jl={"http-json":`HTTP webhook (generic JSON)`,"splunk-hec":`Splunk HEC`,datadog:`Datadog logs`,"file-jsonl":`Local JSONL file`};function Yl(e){if(!e)return`never`;let t=Date.now()/1e3-e;return t<60?Math.floor(t)+`s ago`:t<3600?Math.floor(t/60)+`m ago`:t<86400?Math.floor(t/3600)+`h ago`:Math.floor(t/86400)+`d ago`}function Xl(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=async()=>{t(await(await fetch(`/api/json/audit-sinks`)).json())};(0,_.useEffect)(()=>{y()},[]);let b=(0,_.useMemo)(()=>e?new Map(e.status.map(e=>[e.sink_id,e])):new Map,[e]),x=t=>{if(!e)return;let n=`${t}-${Date.now().toString(36).slice(-4)}`,r={id:n,name:Jl[t],type:t,enabled:!1,endpoint:t===`file-jsonl`?void 0:``,path:t===`file-jsonl`?`~/.sigmashake/audit-export.jsonl`:void 0,auth:{type:`none`},batch:{maxEvents:100,maxBytes:1e6,intervalMs:3e4},retry:{maxAttempts:5,baseMs:1e3,maxMs:6e4},filter:{},payload:{template:e.starterTemplates[t]}};a(n),s(r),l(!1),d(JSON.stringify(r,null,2)),h(null),v(null)},S=e=>{a(e.id),s(JSON.parse(JSON.stringify(e))),l(!1),d(JSON.stringify(e,null,2)),h(null),v(null)},C=()=>{a(null),s(null),l(!1),d(``),h(null),v(null)},w=()=>{if(c)try{return JSON.parse(u)}catch{return null}return o},T=async()=>{let e=w();if(!e){h({kind:`err`,text:`JSON is invalid`});return}p(!0),h(null);try{let t=await fetch(`/api/json/audit-sinks`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await y(),h({kind:`ok`,text:`Saved.`}),C()}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}},E=async e=>{if(confirm(`Delete sink "${e}"? Forwarded events stay; new events won't be sent here.`)){p(!0);try{let t=await fetch(`/api/json/audit-sinks?id=`+encodeURIComponent(e),{method:`DELETE`});if(!t.ok){let e=await t.json();throw Error(e.error??`HTTP ${t.status}`)}await y(),h({kind:`ok`,text:`Deleted.`})}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}}},D=async()=>{let e=w();if(!e){h({kind:`err`,text:`JSON is invalid`});return}p(!0),v(null);try{let t=await(await fetch(`/api/json/audit-sinks/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).json();v({...t.result,rendered:t.rendered})}catch(e){v({ok:!1,status:0,error:e instanceof Error?e.message:String(e)})}finally{p(!1)}},O=async e=>{p(!0);try{let t=await fetch(`/api/json/audit-sinks`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...e,enabled:!e.enabled})});if(!t.ok)throw Error(`HTTP ${t.status}`);await y()}catch(e){h({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{p(!1)}};if(!e)return(0,K.jsx)(K.Fragment,{});let k=`text-[10.5px] font-mono text-[var(--color-fg-4)] tabular-nums`,A=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50`,j=`text-[10.5px] uppercase tracking-wider text-[var(--color-fg-4)]`,M=`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`;return(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,children:[(0,K.jsxs)(`button`,{onClick:()=>r(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 hover:bg-white/[0.02] cursor-pointer`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11.5px]`,children:[(0,K.jsx)(`span`,{className:`font-medium text-[var(--color-fg-1)]`,children:`Centralized logging`}),(0,K.jsx)(`span`,{className:k,children:e.sinks.length===0?`no destinations`:`${e.sinks.filter(e=>e.enabled).length} of ${e.sinks.length} active`})]}),(0,K.jsx)(`span`,{className:k,children:n?`▾`:`▸`})]}),n&&(0,K.jsxs)(`div`,{className:`border-t border-[var(--color-line-1)] px-3 py-3 space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] leading-relaxed`,children:`Forward every audit event to your SIEM or log lake. Each destination has its own filter + payload template — edit the JSON directly to map fields to whatever shape your destination expects.`}),e.sinks.length>0&&(0,K.jsx)(`div`,{className:`space-y-1.5`,children:e.sinks.map(e=>{let t=b.get(e.id);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)]`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e.enabled?t?.last_status===`ok`?`bg-emerald-400`:t?.last_status===`dead-lettered`?`bg-rose-400`:`bg-amber-400`:`bg-[var(--color-fg-4)]`}`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11.5px] font-mono`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:Jl[e.type]})]}),(0,K.jsxs)(`div`,{className:k+` truncate`,children:[e.endpoint??e.path??``,t&&(0,K.jsxs)(K.Fragment,{children:[` · `,`sent: `,t.last_status??`—`,` ·`,` `,`last: `,Yl(t.last_sent_at),t.dropped_count>0&&(0,K.jsxs)(`span`,{className:`text-rose-300`,children:[` · `,`dropped: `,t.dropped_count]})]})]}),t?.last_error&&(0,K.jsx)(`div`,{className:`text-[10.5px] font-mono text-rose-300 truncate`,children:t.last_error})]}),(0,K.jsx)(`button`,{onClick:()=>O(e),disabled:f,className:M,children:e.enabled?`disable`:`enable`}),(0,K.jsx)(`button`,{onClick:()=>S(e),disabled:f,className:M,children:`edit`}),(0,K.jsx)(`button`,{onClick:()=>E(e.id),disabled:f,className:M+` hover:!text-rose-300`,children:`delete`})]},e.id)})}),i===null&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:k,children:`add destination:`}),(e.sinkTypes??[]).map(e=>(0,K.jsxs)(`button`,{onClick:()=>x(e),className:M,children:[`+ `,Jl[e]]},e))]}),i!==null&&o&&(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-brand)]/30 bg-[var(--color-surface-0)] p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`text-[11.5px] font-medium text-[var(--color-fg-1)]`,children:[i,` · `,Jl[o.type]]}),(0,K.jsx)(`button`,{onClick:()=>l(e=>!e),className:M,children:c?`form view`:`raw JSON`})]}),!c&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Display name`}),(0,K.jsx)(`input`,{type:`text`,value:o.name,onChange:e=>s({...o,name:e.target.value}),className:A+` w-full`})]}),o.type!==`file-jsonl`&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Endpoint URL`}),(0,K.jsx)(`input`,{type:`text`,value:o.endpoint??``,placeholder:`https://…`,onChange:e=>s({...o,endpoint:e.target.value}),className:A+` w-full`})]}),o.type===`file-jsonl`&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`File path`}),(0,K.jsx)(`input`,{type:`text`,value:o.path??``,onChange:e=>s({...o,path:e.target.value}),className:A+` w-full`})]}),o.type!==`file-jsonl`&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Auth`}),(0,K.jsxs)(`select`,{value:o.auth.type,onChange:e=>{let t=e.target.value,n=t===`bearer`?{type:`bearer`,token:``}:t===`basic`?{type:`basic`,username:``,password:``}:t===`header`?{type:`header`,name:``,value:``}:{type:`none`};s({...o,auth:n})},className:A+` w-full cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`none`,children:`none`}),(0,K.jsx)(`option`,{value:`bearer`,children:`bearer token`}),(0,K.jsx)(`option`,{value:`basic`,children:`basic auth`}),(0,K.jsx)(`option`,{value:`header`,children:`custom header`})]})]}),o.auth.type===`bearer`&&(0,K.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,K.jsx)(`label`,{className:j,children:`Token`}),(0,K.jsx)(`input`,{type:`password`,value:o.auth.token,onChange:e=>s({...o,auth:{type:`bearer`,token:e.target.value}}),className:A+` w-full`})]}),o.auth.type===`basic`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Username`}),(0,K.jsx)(`input`,{type:`text`,value:o.auth.username,onChange:e=>o.auth.type===`basic`&&s({...o,auth:{...o.auth,username:e.target.value}}),className:A+` w-full`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Password`}),(0,K.jsx)(`input`,{type:`password`,value:o.auth.password,onChange:e=>o.auth.type===`basic`&&s({...o,auth:{...o.auth,password:e.target.value}}),className:A+` w-full`})]})]}),o.auth.type===`header`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Header name`}),(0,K.jsx)(`input`,{type:`text`,value:o.auth.name,onChange:e=>o.auth.type===`header`&&s({...o,auth:{...o.auth,name:e.target.value}}),className:A+` w-full`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:j,children:`Header value`}),(0,K.jsx)(`input`,{type:`password`,value:o.auth.value,onChange:e=>o.auth.type===`header`&&s({...o,auth:{...o.auth,value:e.target.value}}),className:A+` w-full`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,K.jsxs)(`label`,{className:j,children:[`Payload template (JSON; `,`{{field}}`,` placeholders)`]}),(0,K.jsx)(`textarea`,{value:JSON.stringify(o.payload.template??{},null,2),rows:10,onChange:e=>{try{let t=JSON.parse(e.target.value);s({...o,payload:{...o.payload,template:t}}),h(null)}catch{h({kind:`err`,text:`Template is not valid JSON`})}},className:A+` w-full leading-snug`})]})]}),c&&(0,K.jsx)(`textarea`,{value:u,rows:20,onChange:e=>d(e.target.value),className:A+` w-full leading-snug`}),g&&(0,K.jsxs)(`div`,{className:`rounded-sm border px-3 py-2 text-[11px] font-mono ${g.ok?`border-emerald-400/40 text-emerald-200 bg-emerald-400/5`:`border-rose-400/40 text-rose-200 bg-rose-400/5`}`,children:[(0,K.jsxs)(`div`,{children:[g.ok?`✓ delivered`:`✗ failed`,` (HTTP`,` `,g.status,`)`,g.error&&(0,K.jsx)(`span`,{className:`ml-2 text-rose-200`,children:g.error})]}),g.rendered!=null&&(0,K.jsxs)(`details`,{className:`mt-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-[var(--color-fg-4)]`,children:`payload sent`}),(0,K.jsx)(`pre`,{className:`mt-1 text-[10px] whitespace-pre-wrap break-all bg-black/30 rounded-sm px-2 py-1 max-h-48 overflow-y-auto`,children:JSON.stringify(g.rendered,null,2)})]})]}),m&&(0,K.jsx)(`p`,{className:`text-[11px] font-mono ${m.kind===`err`?`text-rose-300`:`text-emerald-300`}`,children:m.text}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:T,disabled:f,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:text-[var(--color-fg-0)] bg-[var(--color-surface-2)] hover:bg-[var(--color-surface-3)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 disabled:opacity-50 cursor-pointer`,children:f?`saving…`:`save`}),(0,K.jsx)(`button`,{onClick:D,disabled:f,className:M,children:`send test event`}),(0,K.jsx)(`button`,{onClick:C,disabled:f,className:M,children:`cancel`})]})]})]})]})}var Zl=[``,`allow`,`block`,`force`,`ask`,`log`],Ql=[``,`claude-code`,`gemini`,`antigravity`,`cursor`,`copilot`,`codex`,`pi`,`generic`],$l=[50,100,250,500],eu=100;function tu(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(eu),[u,d]=(0,_.useState)(0),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null);(0,_.useEffect)(()=>{let t=!1,r=new URLSearchParams;return e&&r.set(`decision`,e),n&&r.set(`tool`,n),i&&r.set(`client`,i),r.set(`limit`,String(c)),r.set(`offset`,String(u)),r.set(`envelope`,`1`),h(!0),v(null),fetch(`/api/state/activity?`+r.toString()).then(e=>{if(!e.ok)throw Error(`HTTP `+e.status);return e.json()}).then(e=>{t||(p(e),h(!1))}).catch(e=>{t||(v(e instanceof Error?e.message:String(e)),h(!1))}),()=>{t=!0}},[e,n,i,c,u,ke([`activity-updated`])[`activity-updated`]]);let y=e=>t=>{e(t.target.value),d(0)},b=(0,_.useMemo)(()=>{if(!f)return[];let e=o.trim().toLowerCase();return e?f.rows.filter(t=>t.tool.toLowerCase().includes(e)||t.decision.toLowerCase().includes(e)||(t.rule_id??``).toLowerCase().includes(e)||(t.client??``).toLowerCase().includes(e)||(t.source_file??``).toLowerCase().includes(e)||t.input.toLowerCase().includes(e)):f.rows},[f,o]),x=f?.total??0,S=Math.floor(u/c)+1,C=Math.max(1,Math.ceil(x/c)),w=x===0?0:u+1,T=Math.min(u+(f?.rows.length??0),x),E=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-sm px-2 py-1.5 focus:outline-none focus:border-[var(--color-brand)]/50 cursor-pointer`,D=`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-3 py-1.5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`What your AI tried to do`}),(0,K.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`Every move your AI agent made — and what SigmaShake decided.`,f&&(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums ml-1.5`,children:[`· `,x.toLocaleString(),` action`,x===1?``:`s`,` on record`]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`select`,{id:`audit-filter-decision`,value:e,onChange:y(t),className:E,children:Zl.map(e=>(0,K.jsx)(`option`,{value:e,children:e===``?`All decisions`:e===`allow`?`Allowed`:e===`block`?`Blocked`:e===`force`?`Forced`:e===`ask`?`Held`:`Logged`},e))}),(0,K.jsx)(`select`,{id:`audit-filter-client`,value:i,onChange:y(a),className:E,children:Ql.map(e=>(0,K.jsx)(`option`,{value:e,children:e===``?`All AI agents`:e===`claude-code`?`Claude Code`:e===`copilot`?`GitHub Copilot`:e===`codex`?`OpenAI Codex`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,K.jsx)(`input`,{id:`audit-filter-tool`,type:`text`,placeholder:`Filter by tool…`,value:n,onChange:y(r),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] rounded-sm px-2.5 py-1.5 w-36 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)]`}),(0,K.jsx)(`select`,{id:`audit-page-size`,value:c,onChange:e=>{l(Number(e.target.value)),d(0)},className:E,title:`Rows per page`,children:$l.map(e=>(0,K.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]})]}),(0,K.jsx)(ql,{}),(0,K.jsx)(Xl,{}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`svg`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] pointer-events-none`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,K.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,K.jsx)(`input`,{id:`audit-search`,type:`text`,placeholder:`Search within this page…`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm pl-9 pr-10 py-2.5 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] transition-colors`}),o&&(0,K.jsx)(`button`,{onClick:()=>s(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] transition-colors cursor-pointer`,title:`Clear search`,children:(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,K.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),f&&f.rows.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-[10px] uppercase tracking-widest text-[var(--color-fg-4)] select-none`,children:[(0,K.jsx)(`span`,{className:`w-3`}),(0,K.jsx)(`span`,{className:`w-14`,children:`When`}),(0,K.jsx)(`span`,{className:`w-20`,children:`Decision`}),(0,K.jsx)(`span`,{className:`flex-1 min-w-0`,children:`Action`}),(0,K.jsx)(`span`,{className:`hidden md:inline w-12 text-right`,children:`Time`}),(0,K.jsx)(`span`,{className:`w-24 text-right`,children:`AI agent`})]}),g&&(0,K.jsxs)(`p`,{className:`text-sm text-red-300 font-mono`,children:[`failed to load audit log: `,g]}),m&&!f&&(0,K.jsx)(`div`,{className:`space-y-1.5`,children:Array.from({length:10}).map((e,t)=>(0,K.jsx)(`div`,{className:`h-9 bg-[var(--color-surface-1)] rounded-sm border border-[var(--color-line-0)] border-l-2 border-l-[var(--color-line-2)] shimmer`},t))}),!m&&!g&&b.length===0&&(0,K.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] py-16 flex flex-col items-center justify-center text-center`,children:[(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)]`,children:o?`No actions on this page match your search.`:x===0?`Nothing yet — connect an AI agent and its actions will show up here.`:`No rows on this page match the filter.`}),o&&(0,K.jsx)(`button`,{onClick:()=>s(``),className:`mt-3 text-[11.5px] text-[var(--color-brand)] hover:underline cursor-pointer`,children:`Clear search`})]}),b.length>0&&(0,K.jsx)(`div`,{className:`space-y-1.5`,children:b.map(e=>(0,K.jsx)(Sc,{row:e},e.id))}),f&&x>c&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:[`showing `,w.toLocaleString(),`–`,T.toLocaleString(),` of`,` `,x.toLocaleString()]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>d(0),disabled:u===0,className:D,children:`⟪ first`}),(0,K.jsx)(`button`,{onClick:()=>d(Math.max(0,u-c)),disabled:u===0,className:D,children:`‹ prev`}),(0,K.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`page `,S,` / `,C]}),(0,K.jsx)(`button`,{onClick:()=>d(f.nextOffset==null?u:f.nextOffset),disabled:f.nextOffset==null,className:D,children:`next ›`}),(0,K.jsx)(`button`,{onClick:()=>d((C-1)*c),disabled:f.nextOffset==null,className:D,children:`last ⟫`})]})]})]})}var nu={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},ru=[`all`,`allow`,`block`,`force`,`log`],iu={allow:`text-emerald-300`,block:`text-red-300`,force:`text-amber-300`,log:`text-[var(--color-fg-3)]`};function au(e){return new Date(e*1e3).toLocaleString()}function ou(e,t){if(!t)return``;let n=t-e;return n<60?`${n}s`:`${Math.round(n/60)}m`}async function su(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:B()})}async function cu(e,t){try{return await(await fetch(`/api/rules/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({ruleId:e,enabled:t})})).json()}catch(e){return{error:String(e)}}}function lu(e){try{let t=JSON.parse(e).input;return t&&typeof t==`object`?rr(``,JSON.stringify(t)):rr(``,e)}catch{return e.slice(0,80)}}function uu(e){try{let t=JSON.parse(e);return t.input===void 0?JSON.stringify(JSON.parse(e),null,2):JSON.stringify(t.input,null,2)}catch{return e}}function du({label:e,value:t,tone:n}){return(0,K.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-mono text-sm tabular-nums ${n??`text-[var(--color-fg-0)]`}`,children:t}),(0,K.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e})]})}function fu(e,t){let n=Math.floor(Date.now()/1e3),r=n-86400,i=new Map;for(let t of e){if(t.decision!==`ask`||t.created_at<r||!t.rule_id)continue;let e=i.get(t.rule_id);e?(e.count+=1,t.created_at>e.lastSeen&&(e.lastSeen=t.created_at)):i.set(t.rule_id,{ruleId:t.rule_id,ruleMessage:t.rule_message||t.rule_id,count:1,lastSeen:t.created_at})}for(let e of t){if(!e.ruleId)continue;let t=i.get(e.ruleId);t?(t.count+=1,t.lastSeen=n):i.set(e.ruleId,{ruleId:e.ruleId,ruleMessage:e.ruleMessage||e.ruleId,count:1,lastSeen:n})}return Array.from(i.values()).filter(e=>e.count>=3).sort((e,t)=>t.count-e.count||t.lastSeen-e.lastSeen).slice(0,5)}function pu(e){let t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function mu({ruleId:e,ruleMessage:t,onDismiss:n,onUndo:r}){let[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>(o.current=setTimeout(n,6e3),()=>{o.current&&clearTimeout(o.current)}),[n]),(0,K.jsxs)(`div`,{className:`fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 px-4 py-2.5 rounded-full border border-[var(--color-line-2)] bg-[var(--color-surface-1)] backdrop-blur-md shadow-lg`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-[var(--color-fg-1)]`,children:[`Silenced `,(0,K.jsx)(`span`,{className:`font-mono text-[var(--color-fg-0)]`,children:t})]}),(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0),await r(),n()},className:`text-[11px] font-mono uppercase tracking-wider px-2.5 py-1 rounded-full border border-[var(--color-brand)]/40 text-[var(--color-brand)] hover:bg-[var(--color-brand)]/10 cursor-pointer disabled:opacity-50`,"aria-label":`Undo silencing ${e}`,children:`undo`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,"aria-label":`Dismiss`,children:(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,K.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,K.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]})}function hu({target:e,onClose:t,onConfirm:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null);return(0,_.useEffect)(()=>{o(null)},[e]),e?(0,K.jsxs)(yl,{open:!!e,onClose:t,size:`sm`,title:`Silence this rule?`,subtitle:`It won't ask for approval again until you re-enable it on the Rules page.`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:r,onClick:t,children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,style:{"--tone":`#ff6f6f`},disabled:r,onClick:async()=>{i(!0),o(null);let r=await n(e);if(i(!1),!r.ok){o(r.message??`Could not silence rule.`);return}t()},children:r?`Silencing…`:`Disable rule`})]}),children:[(0,K.jsxs)(`div`,{className:`ss-list`,children:[(0,K.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},children:(0,K.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-1`,children:`rule`}),(0,K.jsx)(`div`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,K.jsx)(_l,{ruleId:e.ruleId,children:(0,K.jsx)(`code`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] block mt-1 break-all`,children:e.ruleId})})]})}),(0,K.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},children:(0,K.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-1`,children:`recent activity`}),(0,K.jsxs)(`div`,{className:`text-sm text-[var(--color-fg-1)]`,children:[`Triggered`,` `,(0,K.jsx)(`strong`,{className:`text-[var(--color-fg-0)] tabular-nums`,children:e.fireCount}),` `,e.fireCount===1?`time`:`times`,` in the last 24 hours.`]})]})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-3 leading-relaxed`,children:[`Disabling a rule is fully reversible — head to`,` `,(0,K.jsx)(`a`,{href:`/rules`,className:`text-[var(--color-brand)] hover:underline`,children:`Rules`}),` `,`to switch it back on.`]}),a&&(0,K.jsx)(`p`,{className:`mt-3 text-xs text-red-300`,role:`alert`,children:a})]}):null}function gu(){let e=ke([`pending-changed`,`rules-changed`]),{data:t,refetch:n}=V(`/api/json/pending`,[e[`pending-changed`]]),{data:r}=V(`/api/json/approvals`,[e[`pending-changed`]]),[i,a]=(0,_.useState)(`all`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(new Set),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),m=(0,_.useMemo)(()=>fu(r??[],t??[]),[r,t]),h=(0,_.useMemo)(()=>{let e=new Map;for(let t of m)e.set(t.ruleId,t.count);return e},[m]),g=Math.floor(Date.now()/1e3),v=(r??[]).filter(e=>e.created_at>=g-86400).length,y=(r??[]).reduce((e,t)=>(e[t.decision]=(e[t.decision]??0)+1,e),{}),b=(r??[]).filter(e=>{if(i!==`all`&&e.decision!==i)return!1;if(o){let t=o.toLowerCase(),n=lu(e.input).toLowerCase();if(!e.tool.toLowerCase().includes(t)&&!e.rule_id.toLowerCase().includes(t)&&!(e.rule_message??``).toLowerCase().includes(t)&&!n.includes(t))return!1}return!0});function x(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function S(e){let t=await cu(e.ruleId,!1);return t.error||t.ok===!1?{ok:!1,message:t.error??`Server rejected the request.`}:(e.pendingId&&await su(e.pendingId,`block`),p({ruleId:e.ruleId,ruleMessage:e.ruleMessage}),n(),{ok:!0})}async function C(e){await cu(e,!0),n()}return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`overline text-[11px]`,children:`approvals`}),(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:`approve or deny pending tool calls · review past decisions · silence noisy rules`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5 px-3 py-2.5 rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)]/60`,children:[(0,K.jsx)(du,{label:`pending`,value:t?.length??0,tone:`text-amber-300`}),(0,K.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),[`allow`,`block`,`force`,`log`].map(e=>(0,K.jsx)(du,{label:e,value:y[e]??0,tone:iu[e]},e)),(0,K.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),(0,K.jsx)(du,{label:`last 24h`,value:v})]}),m.length>0&&(0,K.jsxs)(`section`,{className:`ss-noisy-card`,"aria-label":`Noisy rules`,children:[(0,K.jsxs)(`div`,{className:`ss-noisy-card-head`,children:[(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12 9v4`}),(0,K.jsx)(`path`,{d:`M12 17h.01`}),(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`})]}),`asking too often · last 24h`]}),m.map(e=>(0,K.jsxs)(`div`,{className:`ss-noisy-row`,children:[(0,K.jsx)(`span`,{className:`ss-noisy-count`,"aria-label":`${e.count} fires`,children:e.count}),(0,K.jsxs)(`div`,{className:`ss-noisy-text`,children:[(0,K.jsx)(`span`,{className:`ss-noisy-title`,children:e.ruleMessage}),(0,K.jsxs)(`span`,{className:`ss-noisy-sub`,children:[(0,K.jsx)(_l,{ruleId:e.ruleId,children:(0,K.jsx)(`code`,{className:`font-mono`,children:e.ruleId})}),(0,K.jsx)(`span`,{style:{margin:`0 6px`},children:`·`}),`last fired `,pu(e.lastSeen)]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger`,onClick:()=>d({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:e.count}),"aria-label":`Silence rule ${e.ruleId}`,children:[(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,K.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,K.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Silence`]})]},e.ruleId))]}),t&&t.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,K.jsxs)(`h2`,{className:`overline text-[11px]`,children:[`pending · `,t.length]})}),(0,K.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=h.get(e.ruleId)??0;return(0,K.jsxs)(q,{className:`border-l-2 border-l-amber-400/60`,children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`text-sm text-[var(--color-fg-0)]`,children:e.ruleMessage}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,K.jsx)(X,{size:`sm`,variant:`primary`,onClick:async()=>{await su(e.id,`allow`),n()},children:`approve`}),(0,K.jsx)(X,{size:`sm`,variant:`danger`,onClick:async()=>{await su(e.id,`block`),n()},children:`deny`}),(0,K.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger`,onClick:()=>d({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:t||1,pendingId:e.id}),"aria-label":`Disable rule ${e.ruleId}`,children:[(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,K.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,K.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Disable rule`]})]})]}),(0,K.jsxs)(Y,{className:`space-y-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3 flex-wrap items-center`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`tool`}),(0,K.jsx)(`code`,{className:`text-[var(--color-brand)] font-mono`,children:e.toolCall.tool}),(0,K.jsx)(`span`,{className:`overline ml-2`,children:`rule`}),(0,K.jsx)(_l,{ruleId:e.ruleId,children:(0,K.jsx)(`span`,{className:`font-mono text-[var(--color-fg-2)]`,children:e.ruleId})}),t>=3&&(0,K.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded-full`,style:{background:`color-mix(in oklab, #ffa657 14%, transparent)`,color:`#ffb27d`,border:`1px solid color-mix(in oklab, #ffa657 28%, transparent)`},title:`Fired ${t} times in the last 24h`,children:[`asks often · `,t,`×`]})]}),e.prompt&&(0,K.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,K.jsx)(`span`,{className:`overline pt-0.5 shrink-0`,children:`why`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.prompt})]}),(0,K.jsx)(Cc,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id)})})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3 gap-3 flex-wrap`,children:[(0,K.jsx)(`h2`,{className:`overline text-[11px]`,children:`history`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`div`,{className:`flex gap-0.5 rounded-sm border border-[var(--color-line-1)] p-0.5 bg-[var(--color-surface-1)]`,children:ru.map(e=>(0,K.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${i===e?`bg-[var(--color-brand)]/10 text-[var(--color-brand)] border border-[var(--color-brand)]/30`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] border border-transparent`}`,children:e},e))}),(0,K.jsx)(`input`,{type:`text`,placeholder:`search tool, rule, command…`,value:o,onChange:e=>s(e.target.value),className:`text-xs font-mono bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-2.5 py-1 text-[var(--color-fg-1)] placeholder-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-brand)]/50 w-48`})]})]}),!r||r.length===0?(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no approval history yet`}):b.length===0?(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no results match your filter`}):(0,K.jsx)(q,{children:(0,K.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:b.map(e=>{let t=c.has(e.id),n=lu(e.input),r=ou(e.created_at,e.resolved_at);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{onClick:()=>x(e.id),className:`w-full text-left px-3 py-2 hover:bg-[var(--color-surface-2)]/60 transition-colors cursor-pointer flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-[10px] w-2.5 shrink-0 mt-1`,children:t?`▼`:`▶`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-nowrap tabular-nums`,children:au(e.resolved_at??e.created_at)}),(0,K.jsx)(sr,{variant:nu[e.decision]??`gray`,children:e.decision}),(0,K.jsx)(`code`,{className:`text-xs text-[var(--color-brand)] font-mono`,children:e.tool}),r&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] ml-auto`,children:[`Δ`,r]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-[var(--color-fg-2)] truncate flex-1 min-w-0`,children:e.rule_message||e.rule_id||`—`}),n&&(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)] font-mono truncate flex-1 min-w-0 hidden md:block`,children:n})]})]})]}),t&&(0,K.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-2 bg-[var(--color-surface-0)]`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs font-mono items-center`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`rule`}),` `,e.rule_id?(0,K.jsx)(_l,{ruleId:e.rule_id,children:(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.rule_id})}):(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:`—`})]}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`created`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:au(e.created_at)})]}),e.resolved_at&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] uppercase tracking-wider text-[10px]`,children:`resolved`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:au(e.resolved_at)})]}),e.rule_id&&(0,K.jsxs)(`button`,{type:`button`,className:`ss-pill ss-pill--danger ml-auto`,onClick:()=>d({ruleId:e.rule_id,ruleMessage:e.rule_message||e.rule_id,fireCount:h.get(e.rule_id)??1}),"aria-label":`Silence rule ${e.rule_id}`,children:[(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4z`}),(0,K.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,K.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}),`Silence rule`]})]}),e.prompt&&(0,K.jsxs)(`div`,{className:`text-xs flex gap-2 items-start`,children:[(0,K.jsx)(`span`,{className:`overline pt-0.5 shrink-0`,children:`why`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:e.prompt})]}),(0,K.jsx)(Cc,{children:uu(e.input)})]})]},e.id)})})})]}),(0,K.jsx)(hu,{target:u,onClose:()=>d(null),onConfirm:S}),f&&(0,K.jsx)(mu,{ruleId:f.ruleId,ruleMessage:f.ruleMessage,onDismiss:()=>p(null),onUndo:()=>C(f.ruleId)})]})}function _u(){let{data:e,refetch:t}=V(`/api/json/inspector-targets`),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(1),u=(0,_.useRef)(new Map),d=(0,_.useRef)(new Map),f=(0,_.useCallback)(()=>{let e=c.current;if(c.current=null,e)try{e.close()}catch{}r(!1),a(!1),s(null)},[]),p=(0,_.useCallback)(e=>{c.current&&f(),a(!0),s(null);let t=new WebSocket(`/ws/inspector?target=${encodeURIComponent(e)}`);c.current=t,t.onopen=()=>{r(!0),a(!1),s(null)},t.onclose=()=>{c.current=null,r(!1),a(!1)},t.onerror=()=>{a(!1),s(`Connection failed — is the inspector running with the correct target ID?`)},t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.id!=null){let e=u.current.get(t.id);e&&(u.current.delete(t.id),e(t.result))}else if(t.method){let e=d.current.get(t.method);if(e)for(let n of e)n(t.params)}}catch{}}},[f]),m=(0,_.useCallback)((e,t)=>new Promise((n,r)=>{let i=c.current;if(!i||i.readyState!==WebSocket.OPEN){r(Error(`Not connected`));return}let a=l.current++;u.current.set(a,e=>n(e)),i.send(JSON.stringify({id:a,method:e,params:t})),setTimeout(()=>{u.current.has(a)&&(u.current.delete(a),r(Error(`Command timed out`)))},1e4)}),[]),h=(0,_.useCallback)((e,t)=>{let n=d.current.get(e);return n||(n=new Set,d.current.set(e,n)),n.add(t),()=>{d.current.get(e)?.delete(t)}},[]),g=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{e?.active&&e?.target&&!n&&!i&&!g.current&&(g.current=!0,p(e.target.id))},[e?.active,e?.target?.id,n,i,p]),(0,_.useEffect)(()=>()=>{f()},[f]),{active:e?.active??!1,bunVersion:e?.version?.[`Bun-Version`]??null,preconfiguredTarget:e?.target??null,connected:n,connecting:i,error:o,connect:p,disconnect:f,sendCommand:m,onEvent:h,refetch:t}}var vu=18,yu=5e-4;function bu(e,t){return t===`(garbage collector)`||t===`(idle)`?`#450a0a`:e?e.startsWith(`node:`)||e.startsWith(`bun:`)?`#172554`:e.startsWith(`file:`)||e.startsWith(`/`)||e.includes(`.ts`)||e.includes(`.js`)?`#451a03`:`#1f2937`:`#1f2937`}function xu(e,t){return t===`(garbage collector)`||t===`(idle)`?`#fca5a5`:e?e.startsWith(`node:`)||e.startsWith(`bun:`)?`#93c5fd`:e.startsWith(`file:`)||e.startsWith(`/`)||e.includes(`.ts`)||e.includes(`.js`)?`#fbbf24`:`#6b7280`:`#6b7280`}function Su(e,t){let n=new Map;for(let t of e.nodes)n.set(t.id,t);let r=new Map;function i(e){let t=n.get(e);if(!t)return 0;let a=t.hitCount??0;for(let e of t.children??[])a+=i(e);return r.set(e,a),a}let a=e.nodes[0];if(!a)return[];i(a.id);let o=t??a.id,s=r.get(o)??0;if(s===0)return[];let c=[];function l(e,t,i){let a=n.get(e);if(!a)return;let o=r.get(e)??0,u=o/s;if(u<yu)return;c.push({x:i,width:u,depth:t,node:a,subtreeHits:o});let d=i;for(let e of a.children??[]){let n=(r.get(e)??0)/s;l(e,t+1,d),d+=n}}return l(o,0,0),c}function Cu(e){return e<1e3?`${e}µs`:e<1e6?`${(e/1e3).toFixed(1)}ms`:`${(e/1e6).toFixed(2)}s`}function wu({profile:e}){let t=(0,_.useRef)(null),[n,r]=(0,_.useState)(800),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=t.current;if(!e)return;let n=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t&&r(t)});return n.observe(e),r(e.clientWidth||800),()=>n.disconnect()},[]);let c=Su(e,i),l=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*vu+4,u=e.endTime-e.startTime,d=(0,_.useCallback)(e=>{a(t=>t===e.node.id?null:e.node.id),s(null)},[]);return c.length===0?(0,K.jsx)(`p`,{className:`text-xs text-[#555] py-2`,children:`No samples — profile may be empty.`}):(0,K.jsxs)(`div`,{className:`relative select-none`,children:[i!==null&&(0,K.jsx)(`button`,{onClick:()=>a(null),className:`mb-2 text-xs text-amber-400 hover:underline`,children:`← Reset zoom`}),(0,K.jsx)(`div`,{ref:t,className:`overflow-x-hidden`,children:(0,K.jsx)(`svg`,{width:n,height:l,onMouseLeave:()=>s(null),children:c.map((e,t)=>{let r=e.x*n,a=Math.max(e.width*n,1),o=e.depth*vu+1,c=e.node.callFrame.functionName||`(anonymous)`,l=e.node.callFrame.url,f=i===e.node.id;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{x:r,y:o,width:a,height:vu-1,fill:f?`#92400e`:bu(l,c),stroke:`#080808`,strokeWidth:.5,style:{cursor:`pointer`},onClick:()=>d(e),onMouseMove:t=>s({clientX:t.clientX,clientY:t.clientY,rect:e,totalDuration:u})}),a>24&&(0,K.jsx)(`text`,{x:r+2,y:o+vu-5,fontSize:9,fill:xu(l,c),style:{pointerEvents:`none`,userSelect:`none`},clipPath:`url(#fc-clip-${t})`,children:c}),a>24&&(0,K.jsx)(`clipPath`,{id:`fc-clip-${t}`,children:(0,K.jsx)(`rect`,{x:r,y:o,width:a,height:vu})})]},t)})})}),o&&(0,K.jsxs)(`div`,{className:`fixed z-50 bg-[#111] border border-[#2a2a2a] rounded-lg p-2.5 text-xs shadow-xl pointer-events-none`,style:{left:o.clientX+14,top:o.clientY-8,maxWidth:320},children:[(0,K.jsx)(`div`,{className:`font-mono text-amber-400 truncate font-medium`,children:o.rect.node.callFrame.functionName||`(anonymous)`}),o.rect.node.callFrame.url&&(0,K.jsxs)(`div`,{className:`text-[#666] truncate mt-0.5 text-[10px]`,children:[o.rect.node.callFrame.url,`:`,o.rect.node.callFrame.lineNumber]}),(0,K.jsxs)(`div`,{className:`mt-1.5 space-y-0.5 text-[#aaa]`,children:[(0,K.jsxs)(`div`,{children:[`Samples:`,` `,(0,K.jsx)(`span`,{className:`text-white tabular-nums`,children:o.rect.subtreeHits})]}),(0,K.jsxs)(`div`,{children:[`Time share:`,` `,(0,K.jsxs)(`span`,{className:`text-white tabular-nums`,children:[(o.rect.width*100).toFixed(1),`%`]})]}),u>0&&(0,K.jsxs)(`div`,{children:[`Est. duration:`,` `,(0,K.jsx)(`span`,{className:`text-white tabular-nums`,children:Cu(Math.round(o.rect.width*u))})]})]}),o.rect.node.deoptReason&&(0,K.jsxs)(`div`,{className:`text-red-400 mt-1.5 text-[10px]`,children:[`⚠ `,o.rect.node.deoptReason]}),(0,K.jsx)(`div`,{className:`text-[#555] mt-1.5 text-[10px]`,children:`Click to zoom · click again to reset`})]})]})}function Tu(e){return e<1e6?`${(e/1e3).toFixed(0)}µs`:e<1e9?`${(e/1e6).toFixed(1)}ms`:`${(e/1e9).toFixed(2)}s`}function Eu(e){return new Date(e*1e3).toLocaleString()}var Du={critical:`red`,high:`red`,medium:`amber`,low:`blue`},Ou={critical:`border-l-red-500/70`,high:`border-l-red-500/50`,medium:`border-l-amber-400/60`,low:`border-l-sky-400/50`};function ku(){let{data:e}=V(`/api/json/profile`);if(!e)return(0,K.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading profile…`});let{diagnosis:t,sessions:n}=e;return!t||t.analyzed_evals===0?(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center`,children:(0,K.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] font-mono`,children:[`no eval data yet — run`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg eval`}),` to start recording`]})}):(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[{label:`evals analyzed`,value:String(t.analyzed_evals)},{label:`median (inside)`,value:Tu(t.median_eval_ns)},{label:`p99 (inside)`,value:Tu(t.p99_eval_ns)},{label:`bottleneck`,value:t.bottleneck??`—`}].map(e=>(0,K.jsx)(kc,{label:e.label,value:e.value,labelPlacement:`above`,valueClassName:`text-xl font-medium tabular-nums text-[var(--color-fg-0)]`},e.label))}),t.phases.length>0&&(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`phase breakdown`})}),(0,K.jsx)(Y,{children:(0,K.jsx)(`div`,{className:`space-y-2`,children:t.phases.filter(e=>e.median_ns>0).map(e=>{let n=e.name===t.bottleneck;return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,K.jsx)(`span`,{className:`w-28 font-mono truncate ${n?`text-[var(--color-brand)] font-medium`:`text-[var(--color-fg-2)]`}`,title:n?`bottleneck`:void 0,children:e.name}),(0,K.jsx)(jc,{pct:Math.min(e.pct_of_total,100),tone:n?`amber`:`gray`,className:`h-1 flex-1`}),(0,K.jsx)(`span`,{className:`w-16 text-right text-[var(--color-fg-1)] tabular-nums font-mono`,children:Tu(e.median_ns)}),(0,K.jsxs)(`span`,{className:`w-10 text-right text-[var(--color-fg-3)] tabular-nums font-mono`,children:[e.pct_of_total,`%`]}),(0,K.jsxs)(`span`,{className:`w-20 text-right text-[var(--color-fg-4)] tabular-nums font-mono text-[10px]`,children:[`p95 `,Tu(e.p95_ns)]})]},e.name)})})})]}),t.recommendations.length>0&&(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`span`,{className:`overline`,children:[`recommendations · `,t.recommendations.length]})}),(0,K.jsx)(Y,{className:`space-y-2`,children:t.recommendations.map((e,t)=>(0,K.jsxs)(`div`,{className:`border border-[var(--color-line-1)] bg-[var(--color-surface-0)] rounded-sm px-3 py-2.5 border-l-2 ${Ou[e.severity]??`border-l-[var(--color-line-2)]`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(sr,{variant:Du[e.severity]??`gray`,children:e.severity}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:e.type})]}),(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-1)] leading-relaxed`,children:e.message}),e.fix_command&&(0,K.jsxs)(`code`,{className:`text-[11px] text-[var(--color-brand)] font-mono mt-1.5 block`,children:[`$ `,e.fix_command]})]},t))})]}),t.anomalies.length>0&&(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`span`,{className:`overline`,children:[`anomalies · `,t.anomalies.length]})}),(0,K.jsx)(Y,{children:(0,K.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:t.anomalies.map((e,t)=>(0,K.jsxs)(`div`,{className:`py-2 flex items-center gap-4 text-xs font-mono`,children:[(0,K.jsx)(`span`,{className:`w-24 text-[var(--color-brand)] uppercase tracking-wider text-[10px]`,children:e.type}),(0,K.jsxs)(`span`,{className:`w-10 tabular-nums text-[var(--color-fg-1)]`,children:[e.count,`×`]}),(0,K.jsxs)(`span`,{className:`w-20 tabular-nums text-[var(--color-fg-1)]`,children:[e.max_ms,`ms max`]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:e.likely_cause})]},t))})})]}),n.length>0&&(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`session history`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[n.length,` session`,n.length===1?``:`s`]})]}),(0,K.jsx)(Y,{className:`p-0`,children:(0,K.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:[...n].reverse().map((e,t)=>(0,K.jsxs)(`div`,{className:`px-4 py-2.5 flex flex-wrap items-center gap-x-5 gap-y-1 text-xs ${e.is_current?`bg-amber-400/[0.04] border-l-2 border-l-amber-400/60`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 w-48 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums font-mono`,children:Eu(e.start_ts)}),e.is_current&&(0,K.jsx)(sr,{variant:`amber`,children:`current`})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-2)] tabular-nums font-mono w-20`,children:[e.evals,` eval`,e.evals===1?``:`s`]}),(0,K.jsxs)(`span`,{className:`text-emerald-300 tabular-nums font-mono`,children:[e.allowed,` allow`]}),e.blocked>0&&(0,K.jsxs)(`span`,{className:`text-red-300 tabular-nums font-mono`,children:[e.blocked,` block (`,e.block_rate_pct,`%)`]}),e.asked>0&&(0,K.jsxs)(`span`,{className:`text-sky-300 tabular-nums font-mono`,children:[e.asked,` ask`]}),e.forced>0&&(0,K.jsxs)(`span`,{className:`text-violet-300 tabular-nums font-mono`,children:[e.forced,` force`]}),e.avg_ns>0&&(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums ml-auto font-mono`,children:[`avg `,Tu(e.avg_ns)]}),e.top_rule&&(0,K.jsxs)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.top_rule)}`,className:`text-[var(--color-fg-4)] hover:text-[var(--color-brand)] font-mono truncate max-w-xs transition-colors w-full pl-48`,title:`most blocked rule: ${e.top_rule}`,children:[`top block: `,e.top_rule]})]},t))})})]})]})}var Au={log:`text-[var(--color-fg-1)]`,info:`text-sky-300`,warn:`text-amber-300`,error:`text-red-300`,debug:`text-[var(--color-fg-3)]`};function ju(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function Mu(){let e=_u(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(0);(0,_.useEffect)(()=>{d.current?.scrollIntoView({behavior:`smooth`})},[a]),(0,_.useEffect)(()=>{if(e.connected)return e.sendCommand(`Runtime.enable`).catch(()=>{}),e.onEvent(`Runtime.consoleAPICalled`,e=>{let t=e;o(e=>{let n=[...e,{id:f.current++,type:t.type??`log`,args:t.args??[],timestamp:t.timestamp??Date.now()}];return n.length>500?n.slice(-500):n})})},[e.connected]);let p=(0,_.useCallback)(()=>{e.preconfiguredTarget&&e.connect(e.preconfiguredTarget.id)},[e]),m=(0,_.useCallback)(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),i(null)}catch(e){console.error(`Profiler.start failed:`,e)}},[e]),h=(0,_.useCallback)(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch(e){console.error(`Profiler.stop failed:`,e),n(!1)}},[e]),g=(0,_.useCallback)(async()=>{u(!0);try{let t=await e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0});c(JSON.parse(t.result.value))}catch{}finally{u(!1)}},[e]);function v(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}let y=e.connected?`connected${e.bunVersion?` · bun v${e.bunVersion}`:``}`:e.connecting?`connecting…`:e.active?`inspector active, connecting…`:`inspector not available`,b=e.connected?`bg-emerald-400`:e.connecting?`bg-amber-400 pulse-soft`:e.active?`bg-sky-400`:`bg-[var(--color-line-2)]`;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono text-[var(--color-fg-2)]`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${b}`}),y]}),e.connected?(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`}):(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:e.preconfiguredTarget?p:e.refetch,disabled:e.connecting,children:e.preconfiguredTarget?`reconnect`:`refresh`})]})]}),e.error&&(0,K.jsx)(Y,{children:(0,K.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:e.error})})]}),e.connected&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`cpu profiler`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300 flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-400 pulse-soft`}),`recording`]}),t?(0,K.jsx)(X,{variant:`danger`,size:`sm`,onClick:h,children:`stop & render`}):(0,K.jsx)(X,{variant:`primary`,size:`sm`,onClick:m,children:`start recording`})]})]}),(0,K.jsx)(Y,{children:r?(0,K.jsx)(Nc,{profile:r,children:(0,K.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 overflow-x-hidden`,children:(0,K.jsx)(wu,{profile:r})})}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording… perform actions in ssg, then stop.`:`click start recording, perform actions, then stop.`})})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`memory`}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:g,disabled:l,children:l?`…`:`refresh`})]}),(0,K.jsx)(Y,{children:s?(0,K.jsx)(Pc,{memory:s,formatValue:v}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`click refresh to fetch process.memoryUsage().`})})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`console`}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,K.jsx)(Y,{children:(0,K.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 h-56 overflow-y-auto font-mono text-[11px]`,children:[a.length===0?(0,K.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`console output will appear here…`}):a.map(e=>(0,K.jsxs)(`div`,{className:`py-0.5 border-b border-[var(--color-line-0)] ${Au[e.type]??`text-[var(--color-fg-1)]`}`,children:[(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] mr-2 uppercase tracking-wider`,children:[`[`,e.type,`]`]}),e.args.map(ju).join(` `)]},e.id)),(0,K.jsx)(`div`,{ref:d})]})})]})]}),!e.connected&&!e.connecting&&(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 px-4 py-6 text-center`,children:(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:e.active?`waiting for inspector connection…`:`inspector auto-starts with ssg serve. profiler, memory, and console appear here once connected.`})})]})}function Nu({active:e,onClick:t,children:n}){return(0,K.jsxs)(`button`,{onClick:t,className:`relative px-3 h-9 text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${e?`text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:[n,e&&(0,K.jsx)(`span`,{className:`absolute inset-x-2 -bottom-px h-px bg-[var(--color-brand)]`})]})}function Pu(){let[e,t]=(0,_.useState)(`eval`);return(0,K.jsxs)(`div`,{className:`space-y-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center border-b border-[var(--color-line-0)] mb-5`,children:[(0,K.jsx)(Nu,{active:e===`eval`,onClick:()=>t(`eval`),children:`eval profile`}),(0,K.jsx)(Nu,{active:e===`inspector`,onClick:()=>t(`inspector`),children:`runtime inspector`})]}),e===`eval`?(0,K.jsx)(ku,{}):(0,K.jsx)(Mu,{})]})}var Fu=`ssg:ui:mode:v1`,Iu=`ssg:ui:mode:seeded`,Lu=`ssg:ui-mode-change`,Ru=new Set([`professional`,`enterprise`,`agent-dev`]);function zu(){try{let e=localStorage.getItem(Fu);if(e===`newcomer`||e===`pro`)return e}catch{}return null}function Bu(e){try{localStorage.setItem(Fu,e)}catch{}}async function Vu(){if(zu()===null){try{if(localStorage.getItem(Iu))return;localStorage.setItem(Iu,`1`)}catch{return}try{let e=await fetch(`/api/json/wizard-state`);if(!e.ok){Bu(`newcomer`);return}let t=await e.json(),n=Ru.has(t.profile??``)?`pro`:`newcomer`;Bu(n),window.dispatchEvent(new CustomEvent(Lu,{detail:n}))}catch{Bu(`newcomer`)}}}function Hu(){let[e,t]=(0,_.useState)(()=>zu()??`newcomer`);return(0,_.useEffect)(()=>{Vu().then(()=>{let n=zu();n&&n!==e&&t(n)});let n=e=>{let n=e.detail;(n===`newcomer`||n===`pro`)&&t(n)};return window.addEventListener(Lu,n),()=>window.removeEventListener(Lu,n)},[]),{mode:e,setMode:(0,_.useCallback)(e=>{t(e),Bu(e),window.dispatchEvent(new CustomEvent(Lu,{detail:e}))},[])}}var Uu=[{id:`safe-writes`,title:`Protect your files from accidents`,plainDescription:`Asks before AI overwrites or erases anything important — so you stay in control of what changes.`,example:`If AI tries to overwrite a config file, you get to approve it first.`,hubRulesetId:`safe-writes`,scenario:`any`,emoji:`🛡️`,details:{protects:[`Asks first before editing project manifests & lockfiles — package.json, Cargo.toml, go.mod, and friends`,`Asks first before editing shell startup files — .bashrc, .zshrc, .profile`,`Asks first before editing git config or git hooks`,`Asks first before editing CI / build pipeline files`,`Asks first before editing AI-agent instruction files — CLAUDE.md, .cursorrules, AGENTS.md`],tryThis:`Ask your AI to add a dependency to package.json. Instead of saving silently, it pauses for your approval first.`}},{id:`no-destructive-fs`,title:`Stop AI from erasing files`,plainDescription:`Blocks the kind of filesystem operations that can permanently delete your work.`,example:`If AI tries to wipe a folder, SSG blocks it automatically.`,hubRulesetId:`no-destructive-fs`,scenario:`coding`,emoji:`🗑️`,details:{protects:[`Blocks recursive force-deletes that can wipe an entire directory tree in a single command`,`Blocks bulk deletes through find with delete or exec-remove predicates`,`Blocks disk-wipe, format & partition tools — dd, mkfs, shred, fdisk`,`Blocks Windows recursive deletes — Remove-Item with Recurse, rmdir /s, del /s`,`Blocks git clean with its force flags, which erases untracked and ignored files alike`],tryThis:`Ask your AI to recursively delete a throwaway folder. The attempt is blocked outright — it never reaches your shell.`}},{id:`secrets-guard`,title:`Keep secrets and credentials safe`,plainDescription:`Watches for AI trying to read or write your passwords, API keys, and private keys.`,example:`Reading your .env file, SSH keys, or .netrc triggers an approval request.`,hubRulesetId:`secrets-guard`,scenario:`any`,emoji:`🔑`,details:{protects:[`Blocks reading .env files`,`Blocks reading private keys, SSH keys, .netrc & .pgpass`,`Blocks reading cloud credential stores — AWS, GCP, Azure, kube, docker`,`Blocks dumping secret files through cat / head / tail / type`,`Blocks writing hardcoded API keys — AWS, Anthropic, OpenAI — into source`,`Blocks writing PEM private keys into source files`],tryThis:`Ask your AI to read your .env file. The read is blocked, so the contents never land in the chat transcript.`}},{id:`email-guardrails`,title:`Ask before AI sends emails`,plainDescription:`Makes sure AI never sends a message on your behalf without your explicit OK.`,example:`Any outbound email action is queued for your approval before it goes.`,hubRulesetId:`email-guardrails`,scenario:`knowledge-work`,emoji:`📧`,details:{protects:[`Asks first before local mail commands — mail, sendmail, mutt, msmtp`,`Asks first before curl is used to talk SMTP directly`,`Asks first before calls to transactional-email APIs — SendGrid, Mailgun, Postmark, Resend, SES, and more`],tryThis:`Ask your AI to send a quick test email. It pauses and asks you to confirm the recipient and body before anything goes out.`}},{id:`no-paid-apis`,title:`Block surprise charges from paid APIs`,plainDescription:`Blocks AI from calling APIs that can rack up unexpected bills — cloud storage, AI providers, payment services.`,example:`A call to OpenAI, AWS S3, or Stripe triggers a block until you allow it.`,hubRulesetId:`no-paid-apis`,scenario:`any`,emoji:`💳`,details:{protects:[`Asks first before calls to paid LLM APIs — OpenAI, Anthropic, Groq, Bedrock, and more`,`Asks first before payment APIs — Stripe, PayPal, Square, Adyen`,`Asks first before SMS / voice APIs — Twilio, Vonage, MessageBird`,`Asks first before cloud-storage writes — aws s3 cp/sync, gsutil, az storage`],tryThis:`Ask your AI to call the OpenAI API. It checks with you before sending — so a runaway loop cannot quietly rack up spend.`}},{id:`read-only-mode`,title:`Read-only mode (maximum safety)`,plainDescription:`AI can look but not touch — all write operations are blocked. Great when you just want to explore safely.`,example:`AI can read your codebase and answer questions but cannot change any files.`,hubRulesetId:`read-only`,scenario:`any`,emoji:`🔒`,details:{protects:[`Blocks every file write and edit`,`Blocks state-changing shell commands — file deletes & moves, package installs, sudo, docker, kubectl, terraform`,`Blocks shell redirection that writes to disk`,`Blocks git commands that change state — commit, push, reset, checkout`,`Blocks network requests that are not GET — no POST, PUT, PATCH, DELETE`],tryThis:`Ask your AI to edit any file. Every write is refused until you remove this pack — but reading code and answering questions still works.`}}];function Wu(e){return e?Uu.filter(t=>t.scenario===`any`||t.scenario===e):Uu}function Gu({pack:e,installed:t,state:n,expanded:r,onInstall:i,onUninstall:a,onToggleDetails:o}){let s=n!==`idle`;return(0,K.jsxs)(`div`,{className:`ss-list-row ss-list-row--pack`,style:{cursor:`default`,background:t?`linear-gradient(180deg, color-mix(in oklab, var(--color-hig-green) 8%, transparent) 0%, transparent 60%), var(--color-surface-1)`:`var(--color-surface-1)`,borderColor:t?`color-mix(in oklab, var(--color-hig-green) 28%, var(--color-line-1))`:`var(--color-line-1)`},children:[(0,K.jsxs)(`div`,{className:`ss-pack-main`,children:[(0,K.jsx)(`span`,{className:`ss-pack-emoji`,"aria-hidden":`true`,children:e.emoji}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`h3`,{className:`ss-pack-title`,children:e.title}),t&&(0,K.jsxs)(`span`,{className:`agent-badge agent-badge--detected`,title:`This pack is currently active.`,children:[(0,K.jsx)(`span`,{className:`agent-badge-dot`}),`Installed`]})]}),(0,K.jsx)(`p`,{className:`ss-pack-desc`,children:e.plainDescription}),(0,K.jsxs)(`p`,{className:`ss-pack-example`,children:[(0,K.jsx)(`span`,{className:`ss-pack-example__label`,children:`Example`}),e.example]}),(0,K.jsx)(`button`,{type:`button`,className:`ss-pack-detail-toggle`,"aria-expanded":r,onClick:()=>o(e.id),children:r?`Hide details`:t?`What this is doing →`:`What's inside →`})]}),(0,K.jsx)(`div`,{className:`ss-pack-action`,children:t?(0,K.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:`ss-btn ss-btn--secondary`,style:{height:30,padding:`0 12px`,fontSize:11},title:`Remove this pack from your machine.`,children:n===`uninstalling`?`Removing…`:`Remove`}):(0,K.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:`ss-btn ss-btn--primary`,style:{height:30,padding:`0 14px`,fontSize:11},title:`Install this guardrail pack.`,children:n===`installing`?`Installing…`:`Install`})})]}),r&&(0,K.jsxs)(`div`,{className:`ss-pack-detail`,children:[(0,K.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,K.jsx)(`span`,{className:`ss-pack-detail__label`,children:t?`Installed`:`What gets installed`}),(0,K.jsxs)(`p`,{className:`ss-pack-detail__text`,children:[(0,K.jsxs)(`code`,{children:[e.hubRulesetId,`.rules`]}),` — one plain-text rules file`,t?` now living in `:`, written to `,`your `,(0,K.jsx)(`code`,{children:`.sigmashake/rules/`}),` folder.`,` `,t?`It's active right away — no restart needed.`:`Installing adds just this one file; removing the pack deletes it.`]})]}),(0,K.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,K.jsx)(`span`,{className:`ss-pack-detail__label`,children:`What it does`}),(0,K.jsx)(`ul`,{className:`ss-pack-detail__list`,children:e.details.protects.map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`div`,{className:`ss-pack-detail__section`,children:[(0,K.jsx)(`span`,{className:`ss-pack-detail__label`,children:`See it working`}),(0,K.jsx)(`p`,{className:`ss-pack-detail__text`,children:e.details.tryThis}),(0,K.jsxs)(`p`,{className:`ss-pack-detail__hint`,children:[`Every block and approval prompt is logged on the`,` `,(0,K.jsx)(`a`,{href:`/audit`,children:`Activity`}),` page. To fire a rule on purpose without leaving the dashboard, open `,(0,K.jsx)(`a`,{href:`/try`,children:`Try It`}),`.`]})]})]})]})}function Ku(){let e=new URLSearchParams(window.location.search).get(`starter`),t=Wu(e),[n,r]=(0,_.useState)(new Set),[i,a]=(0,_.useState)({}),[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)(null);function u(e){s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}(0,_.useEffect)(()=>{let e=!1;return fetch(`/api/json/hub/installed`).then(e=>e.json()).then(t=>{e||r(new Set(t.installed))}).catch(()=>{}),()=>{e=!0}},[]);function d(e,t){l({msg:e,type:t}),setTimeout(()=>l(null),5e3)}async function f(){try{let e=await(await fetch(`/api/json/hub/installed`)).json();r(new Set(e.installed))}catch{}}async function p(e){let t=Uu.find(t=>t.id===e);if(t){a(t=>({...t,[e]:`installing`}));try{let n=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({id:t.hubRulesetId})}),i=await n.text(),a=n.headers.get(`Content-Type`)??``,o=null;if(a.includes(`application/json`))try{o=JSON.parse(i)}catch{}o?.ok?(r(e=>new Set([...e,t.hubRulesetId])),s(t=>new Set([...t,e])),d(o.already_installed?`${t.title} — already installed`:`${t.title} — installed`,`ok`)):d(o?o.error??`Could not install ${t.title}`:i.replace(/<[^>]+>/g,``).trim()||`Could not install ${t.title} (HTTP ${n.status})`,`error`)}catch(e){d(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{a(t=>({...t,[e]:`idle`})),f()}}}async function m(e){let t=Uu.find(t=>t.id===e);if(t&&window.confirm(`Remove “${t.title}”?\n\nThe rules in this pack stop applying. You can install it again any time.`)){a(t=>({...t,[e]:`uninstalling`}));try{let e=await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({id:t.hubRulesetId})}),n=await e.text(),i=e.headers.get(`Content-Type`)??``,a=null;if(i.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok||e.ok&&!a?(r(e=>{let n=new Set(e);return n.delete(t.hubRulesetId),n}),d(`${t.title} — removed`,`ok`)):d(a?a.error??`Could not remove ${t.title}`:n.replace(/<[^>]+>/g,``).trim()||`Could not remove ${t.title} (HTTP ${e.status})`,`error`)}catch(e){d(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{a(t=>({...t,[e]:`idle`})),f()}}}let h={coding:`for coding with AI`,"knowledge-work":`for email and docs`},g=t.filter(e=>n.has(e.hubRulesetId)).length;return(0,K.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,K.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid var(--color-line-1)`,background:`var(--color-surface-1)`},children:[(0,K.jsx)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:8},children:`Guardrails`}),(0,K.jsxs)(`h1`,{className:`text-[18px] font-semibold text-[var(--color-fg-0)] tracking-tight`,children:[`One-tap protection`,e&&h[e]?` ${h[e]}`:``]}),(0,K.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-1.5 leading-relaxed`,children:[`Each pack is a small set of rules that guard against a specific AI risk. Toggle them on and off — installing or removing only touches rule files in `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`.sigmashake/`}),`.`]}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-3`,children:[g,` of `,t.length,` active`]})]}),c&&(0,K.jsx)(`div`,{className:`rounded-xl px-4 py-2.5 text-[12px]`,style:{border:`1px solid ${c.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 36%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 36%, transparent)`}`,background:c.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 12%, var(--color-surface-1))`:`color-mix(in oklab, var(--color-hig-red) 12%, var(--color-surface-1))`,color:c.type===`ok`?`var(--color-hig-green)`:`var(--color-hig-red)`,backdropFilter:`saturate(180%) blur(10px)`},children:c.msg}),(0,K.jsx)(`div`,{className:`ss-list`,children:t.map(e=>(0,K.jsx)(Gu,{pack:e,installed:n.has(e.hubRulesetId),state:i[e.id]??`idle`,expanded:o.has(e.id),onInstall:p,onUninstall:m,onToggleDetails:u},e.id))}),(0,K.jsx)(`div`,{className:`rounded-xl p-4`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,K.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:[`Want more control? The`,` `,(0,K.jsx)(`a`,{href:`/hub`,className:`text-[var(--color-brand)] hover:underline`,children:`advanced library`}),` `,`has the full set of community rulesets and lets you preview every rule before installing.`]})})]})}function qu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ju(e){let t=e;if(t.endsWith(`/.sigmashake/rules`)&&(t=t.slice(0,-18)),t.endsWith(`\\.sigmashake\\rules`)&&(t=t.slice(0,-18)),t.startsWith(`/home/`)){let e=t.slice(6),n=e.indexOf(`/`);return n>=0?`~/${e.slice(n+1)}`:`~`}if(t.startsWith(`C:\\Users\\`)){let e=t.slice(9),n=e.indexOf(`\\`);return n>=0?`~\\${e.slice(n+1)}`:`~`}if(t.length>40){let e=t.split(/[/\\]/);if(e.length>2)return`…/${e[e.length-1]}`}return t}var Yu=[{value:`downloads`,label:`most downloaded`},{value:`newest`,label:`newest`},{value:`rules`,label:`most rules`}],Xu=[``,`critical`,`high`,`medium`,`low`],Zu=[``,`deny`,`ask`,`allow`,`log`];function Qu(){return(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-1)] p-4 space-y-3 shimmer`,children:[(0,K.jsx)(`div`,{className:`h-4 bg-[var(--color-surface-3)] rounded-sm w-2/3`}),(0,K.jsx)(`div`,{className:`h-3 bg-[var(--color-surface-2)] rounded-sm w-1/3`}),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(`div`,{className:`h-5 bg-[var(--color-surface-3)] rounded-sm w-14`}),(0,K.jsx)(`div`,{className:`h-5 bg-[var(--color-surface-3)] rounded-sm w-10`})]}),(0,K.jsx)(`div`,{className:`h-7 bg-[var(--color-surface-3)] rounded-sm`})]})}function $u({tech:e}){return(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border ${{typescript:`bg-sky-500/8 text-sky-300 border-sky-500/25`,ts:`bg-sky-500/8 text-sky-300 border-sky-500/25`,javascript:`bg-amber-500/8 text-amber-300 border-amber-500/25`,js:`bg-amber-500/8 text-amber-300 border-amber-500/25`,python:`bg-emerald-500/8 text-emerald-300 border-emerald-500/25`,rust:`bg-orange-500/8 text-orange-300 border-orange-500/25`,go:`bg-cyan-500/8 text-cyan-300 border-cyan-500/25`,bash:`bg-violet-500/8 text-violet-300 border-violet-500/25`}[e.toLowerCase()]??`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`}`,children:e})}function ed({install:e,onRemove:t,removing:n}){let r=Ju(e.path),i=e.in_sync?`bg-emerald-400`:`bg-amber-400 animate-pulse`;return(0,K.jsxs)(`div`,{className:`group/chip inline-flex items-center gap-1.5 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)] text-[10px] font-mono text-[var(--color-fg-2)]`,title:e.in_sync?`In sync — files present in ${e.path}`:`Drift — ${e.drift_reason??`files missing or empty`} (${e.path})`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,title:e.path,children:r}),(0,K.jsx)(`button`,{type:`button`,onClick:r=>{r.preventDefault(),r.stopPropagation(),n||t(e.path)},disabled:n,title:`Remove from this location`,"aria-label":`Uninstall from ${e.path}`,className:`shrink-0 inline-flex items-center justify-center w-4 h-4 rounded-sm text-[var(--color-fg-4)] hover:text-red-300 hover:bg-red-500/10 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`,children:n?(0,K.jsx)(`svg`,{className:`animate-spin`,width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}):(0,K.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:[(0,K.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,K.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function td({isInstalling:e,hasInstalls:t,onInstallDefault:n,onPickPath:r}){let[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!i)return;function e(e){o.current&&(o.current.contains(e.target)||a(!1))}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,K.jsxs)(`div`,{ref:o,className:`relative flex w-full`,children:[(0,K.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},disabled:e,className:`flex-1 h-7 rounded-l-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer
33
- bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30 border-r-0
34
- hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
35
- disabled:opacity-40 disabled:cursor-not-allowed`,children:e?(0,K.jsxs)(`span`,{className:`flex items-center justify-center gap-1.5`,children:[(0,K.jsx)(`svg`,{className:`animate-spin`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`installing…`]}):t?`install elsewhere`:`install`}),(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(e=>!e)},disabled:e,title:`Install to another folder`,"aria-label":`Install to a custom folder`,className:`shrink-0 w-7 h-7 rounded-r-sm flex items-center justify-center cursor-pointer
36
- bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30
37
- hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
38
- disabled:opacity-40 disabled:cursor-not-allowed`,children:(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),i&&(0,K.jsxs)(`div`,{className:`absolute z-20 bottom-full right-0 mb-1 min-w-[180px] rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-2)] shadow-lg overflow-hidden`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(!1),n()},className:`w-full text-left px-3 py-2 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:bg-[var(--color-surface-3)] cursor-pointer`,children:`default rules dir`}),(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(!1),r()},className:`w-full text-left px-3 py-2 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-1)] hover:bg-[var(--color-surface-3)] cursor-pointer border-t border-[var(--color-line-1)]`,children:`pick folder…`})]})]})}function nd({rs:e,installs:t,installingId:n,uninstallingKey:r,onInstall:i,onUninstall:a,onPickAndInstall:o,flashId:s}){let c=n===e.id,l=s===e.id,u=t.length,d=t.some(e=>!e.in_sync);return(0,K.jsxs)(`div`,{className:`group relative flex flex-col rounded-sm border bg-[var(--color-surface-1)] transition-colors overflow-hidden
39
- ${d?`border-amber-500/40 hover:border-amber-500/60`:u>0?`border-emerald-500/25 hover:border-emerald-500/40`:`border-[var(--color-line-1)] hover:border-[var(--color-line-2)]`}
40
- ${l?`ring-1 ring-emerald-500/40`:``}`,children:[u>0&&(0,K.jsxs)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 px-1.5 py-0.5 rounded-sm border text-[10px] font-mono uppercase tracking-wider
41
- ${d?`bg-amber-500/10 border-amber-500/30 text-amber-300`:`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`}`,title:d?`At least one install has drifted from the recorded files`:`All installs are in sync with the database`,children:[d?(0,K.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:[(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,K.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}):(0,K.jsx)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,children:(0,K.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),u===1?`installed`:`${u}× installed`]}),(0,K.jsxs)(`a`,{href:`/hub/${e.id}`,className:`block p-3 flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 pr-20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-[var(--color-fg-0)] leading-snug`,children:e.title}),e.tested_versions&&e.tested_versions.length>0&&(0,K.jsx)(`span`,{title:`Certified ruleset`,className:`text-[var(--color-brand)] text-[11px]`,children:`★`})]}),(0,K.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-0.5 font-mono`,children:[`@`,e.author]})]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] shrink-0 mt-0.5`,children:[`v`,e.version]})]}),e.technologies.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:[e.technologies.slice(0,4).map(e=>(0,K.jsx)($u,{tech:e},e)),e.technologies.length>4&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] self-center`,children:[`+`,e.technologies.length-4]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,K.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:e.rule_count}),(0,K.jsx)(`span`,{className:`uppercase tracking-wider text-[10px] text-[var(--color-fg-4)]`,children:`rules`})]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`polyline`,{points:`8 17 12 21 16 17`}),(0,K.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`21`}),(0,K.jsx)(`path`,{d:`M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29`})]}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:qu(e.download_count)})]})]})]}),u>0&&(0,K.jsx)(`div`,{className:`px-3 pb-2 flex flex-wrap gap-1`,children:t.map(t=>(0,K.jsx)(ed,{install:t,onRemove:t=>a(e.id,t),removing:r===`${e.id}::${t.path}`},t.path))}),(0,K.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:(0,K.jsx)(td,{isInstalling:c,hasInstalls:u>0,onInstallDefault:()=>i(e.id),onPickPath:()=>o(e.id)})})]})}function rd(){let{mode:e}=Hu();return e===`newcomer`?(0,K.jsx)(Ku,{}):(0,K.jsx)(id,{})}function id(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(`downloads`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`all`),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(0),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)({}),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),k=(0,_.useCallback)((t=0)=>{let r=new URLSearchParams({page:String(t)});return e&&r.set(`search`,e),n&&n!==`downloads`&&r.set(`sort`,n),i&&r.set(`decision`,i),o&&r.set(`severity`,o),r},[e,n,i,o]),A=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/hub/installed`);if(!e.ok)return;let t=await e.json(),n={};for(let e of t.installs??[])n[e.id]||(n[e.id]=[]),n[e.id].push(e);b(n)}catch{}},[]);(0,_.useEffect)(()=>{A()},[A]),(0,_.useEffect)(()=>{let e=!1;return v(!0),h(0),fetch(`/api/json/hub?${k(0)}`).then(e=>e.json()).then(t=>{e||(d(t.data),p(t.has_more),h(0))}).catch(()=>{}).finally(()=>{e||v(!1)}),()=>{e=!0}},[k]);async function j(){let e=m+1;v(!0);try{let t=await fetch(`/api/json/hub?${k(e)}`);if(!t.ok)return;let n=await t.json();d(e=>[...e,...n.data]),p(n.has_more),h(e)}catch{}finally{v(!1)}}async function M(){let e=await fetch(`/api/json/hub?${k(0)}`);if(!e.ok)return;let t=await e.json();d(t.data),p(t.has_more),h(0)}async function N(e,t){S(e);try{let n={id:e};t&&(n.path=t);let r=await(await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify(n)})).json();r.ok?(E(e),setTimeout(()=>E(null),2e3),O({msg:r.already_installed?`${r.title??e} — already installed${r.path?` at ${Ju(r.path)}`:``}`:`installed ${r.title??e}${r.path?` → ${Ju(r.path)}`:``}`,type:`ok`}),await Promise.all([A(),M()])):O({msg:r.error??`install failed`,type:`error`})}catch(e){O({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{S(null),setTimeout(()=>O(null),5e3)}}async function ee(e){await N(e)}async function te(e){let t=null;try{let e=await fetch(`/api/json/pick-dir`,{method:`POST`});if(e.ok){let n=await e.json();if(n.ok&&n.path)t=n.path;else if(n.reason===`user_cancelled`)return;else if(n.reason===`no_display`||n.reason===`no_picker_found`){let e=prompt(`Folder picker is unavailable on this host. Type the absolute path to install to:`);e&&e.trim()&&(t=e.trim())}else{O({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>O(null),5e3);return}}}catch{let e=prompt(`Folder picker is unavailable. Type the absolute path to install to:`);e&&e.trim()&&(t=e.trim())}t&&await N(e,t)}async function P(e,t){w(`${e}::${t}`);try{let n=await(await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...B()},body:JSON.stringify({id:e,path:t})})).json();n.ok?(O({msg:`removed ${e} from ${Ju(t)}`,type:`ok`}),await Promise.all([A(),M()])):O({msg:n.error??`uninstall failed`,type:`error`})}catch(e){O({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{w(null),setTimeout(()=>O(null),5e3)}}let F=c===`installed`?u.filter(e=>(y[e.id]?.length??0)>0):u,ne=u.filter(e=>(y[e.id]?.length??0)>0).length,re=`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-2)] text-[11px] font-mono rounded-sm px-2.5 h-8 focus:outline-none focus:border-[var(--color-brand)]/50 cursor-pointer`;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`overline text-[11px]`,children:`hub`}),(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:`install community rule packs from hub.sigmashake.com`})]}),(0,K.jsxs)(`a`,{href:`/hub/connect`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] hover:text-[var(--color-brand)] transition-colors border border-[var(--color-line-1)] hover:border-[var(--color-brand)]/40 rounded-sm px-3 h-7`,children:[(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,K.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`})}),`connect github`]})]}),D&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-3 py-2 text-[11px] font-mono border
42
- ${D.type===`ok`?`bg-emerald-500/5 border-emerald-500/25 text-emerald-300`:`bg-red-500/5 border-red-500/25 text-red-300`}`,children:[(0,K.jsxs)(`span`,{children:[D.type===`ok`?`✓ `:`✗ `,D.msg]}),(0,K.jsx)(`button`,{onClick:()=>O(null),className:`ml-3 opacity-60 hover:opacity-100 cursor-pointer`,children:`✕`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm p-0.5 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:()=>l(`all`),className:`px-3 h-6 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer
43
- ${c===`all`?`bg-[var(--color-surface-3)] text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:`all`}),(0,K.jsxs)(`button`,{onClick:()=>l(`installed`),className:`px-3 h-6 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer flex items-center gap-1.5
44
- ${c===`installed`?`bg-[var(--color-surface-3)] text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:[`installed`,ne>0&&(0,K.jsx)(`span`,{className:`text-[9px] bg-emerald-500/15 text-emerald-300 rounded-sm px-1 py-0.5 font-medium tabular-nums`,children:ne})]})]}),(0,K.jsxs)(`div`,{className:`relative flex-1 min-w-[160px]`,children:[(0,K.jsxs)(`svg`,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)]`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,K.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,K.jsx)(`input`,{type:`text`,placeholder:`search rulesets…`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-xs rounded-sm pl-8 pr-3 h-8 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,K.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:re,children:Yu.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,K.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:re,children:[(0,K.jsx)(`option`,{value:``,children:`any decision`}),Zu.filter(Boolean).map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:re,children:[(0,K.jsx)(`option`,{value:``,children:`any severity`}),Xu.filter(Boolean).map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),g&&u.length===0?(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,K.jsx)(Qu,{},t))}):F.length===0?(0,K.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] py-16 flex flex-col items-center justify-center text-center`,children:[(0,K.jsxs)(`svg`,{className:`text-[var(--color-fg-4)] mb-3`,width:`36`,height:`36`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,K.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,K.jsx)(`p`,{className:`text-xs font-mono text-[var(--color-fg-3)] uppercase tracking-wider`,children:c===`installed`?`no rulesets installed yet — browse and click install`:`no rulesets found${e?` matching "${e}"`:``}`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:F.map(e=>(0,K.jsx)(nd,{rs:e,installs:y[e.id]??[],installingId:x,uninstallingKey:C,onInstall:ee,onUninstall:P,onPickAndInstall:te,flashId:T},e.id))}),f&&c===`all`&&(0,K.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,K.jsx)(`button`,{onClick:j,disabled:g,className:`h-8 px-5 rounded-sm text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-2)] border border-[var(--color-line-1)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-2)] transition-colors cursor-pointer disabled:opacity-40`,children:g?`loading…`:`load more`})})]})]})}var ad={deny:`red`,block:`red`,ask:`amber`,allow:`green`,log:`gray`,force:`blue`};function od({id:e}){let{data:t,error:n}=V(`/api/json/hub/${e}`),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1);if(n)return(0,K.jsxs)(`div`,{className:`text-sm text-red-300 font-mono`,children:[(0,K.jsx)(`p`,{children:n}),(0,K.jsx)(`a`,{href:`/hub`,className:`text-[var(--color-brand)] hover:underline mt-3 block text-[11px] uppercase tracking-wider`,children:`← back to hub`})]});if(!t)return(0,K.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading ruleset…`});async function s(){o(!0);try{(await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({id:e})})).ok&&i(!0)}finally{o(!1)}}return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← hub`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-1.5 text-[var(--color-fg-0)]`,children:t.title}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 tabular-nums`,children:[`@`,t.author,` · v`,t.version,` · `,t.rule_count,` rule`,t.rule_count===1?``:`s`]})]}),(0,K.jsx)(X,{variant:r?`secondary`:`primary`,onClick:s,disabled:a||r,children:r?`✓ installed`:a?`installing…`:`install`})]}),t.technologies.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.technologies.map(e=>(0,K.jsx)(sr,{variant:`blue`,children:e},e))}),t.github_repo&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`source`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:t.github_repo})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`span`,{className:`overline`,children:[`rules · `,t.rules.length]})}),(0,K.jsx)(Y,{className:`space-y-4`,children:t.rules.map((e,t)=>(0,K.jsxs)(`div`,{className:t>0?`border-t border-[var(--color-line-0)] pt-4`:void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[(0,K.jsx)(sr,{variant:ad[e.decision]??`gray`,children:e.decision}),(0,K.jsx)(`code`,{className:`text-xs text-[var(--color-brand)] font-mono`,children:e.name}),e.capability&&(0,K.jsx)(sr,{variant:`gray`,children:e.capability})]}),(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-1)] mb-2`,children:e.message}),(0,K.jsx)(Cc,{children:e.raw_text})]},e.id))})]})]})}function sd(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!1);async function u(){l(!0),a(``);try{let e=await fetch(`/api/hub/device-start`,{method:`POST`,headers:{Accept:`application/json`,...B()}}),n=await e.json();if(!e.ok){let t=n;t.error===`not_configured`?(r(`not_configured`),s(t.setup_steps??[]),a(t.message??`GitHub OAuth not configured.`)):(a(n.error??`HTTP ${e.status}`),r(`error`));return}t(n),r(`polling`)}catch(e){a(e instanceof Error?e.message:`Failed to start`),r(`error`)}finally{l(!1)}}return(0,_.useEffect)(()=>{if(n!==`polling`||!e)return;let t=setInterval(async()=>{try{let n=await(await fetch(`/api/hub/device-poll?flow=${e.flow_id}`,{headers:{Accept:`application/json`}})).json();n.status===`complete`?(clearInterval(t),r(`done`),a(`connected as @${n.session?.login??`GitHub`} — you can now publish rulesets`)):(n.status===`expired`||n.status===`error`)&&(clearInterval(t),r(`error`),a(n.error??`Authentication failed`))}catch{}},3e3);return()=>clearInterval(t)},[n,e]),(0,K.jsxs)(`div`,{className:`max-w-lg mx-auto space-y-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`a`,{href:`/hub`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors`,children:[(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,K.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),`back to hub`]}),(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-2 text-[var(--color-fg-0)]`,children:`Connect GitHub`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`authenticate with github to publish rulesets to the hub`})]}),n===`not_configured`&&(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`text-amber-300 shrink-0 mt-0.5`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,K.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,K.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-[var(--color-fg-0)]`,children:`GitHub OAuth not configured`}),(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:i})]})]}),(0,K.jsxs)(`div`,{className:`border-t border-[var(--color-line-0)] pt-4`,children:[(0,K.jsx)(`div`,{className:`overline mb-3`,children:`setup steps`}),(0,K.jsx)(`ol`,{className:`space-y-2`,children:o.map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5 text-xs text-[var(--color-fg-1)]`,children:[(0,K.jsx)(`span`,{className:`shrink-0 w-5 h-5 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)] text-[var(--color-fg-3)] text-[10px] font-mono flex items-center justify-center tabular-nums`,children:t+1}),(0,K.jsx)(`span`,{className:`mt-0.5 leading-relaxed`,children:e.replace(/^\d+\.\s+/,``)})]},t))})]}),(0,K.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3`,children:[(0,K.jsx)(`div`,{className:`overline mb-1.5`,children:`quick start`}),(0,K.jsx)(`code`,{className:`text-[11px] text-[var(--color-brand)]/90 font-mono`,children:`export SSG_GITHUB_CLIENT_ID=<your-client-id>`}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1`,children:[`then restart:`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-fg-1)]`,children:`ssg serve`})]})]}),(0,K.jsx)(`a`,{href:`https://github.com/settings/applications/new`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline`,children:`create github oauth app →`})]})}),n===`idle`&&(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{children:[(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mb-4 leading-relaxed`,children:`This uses GitHub's device authorization flow — no redirect URIs needed. You'll be shown a code to enter at github.com.`}),(0,K.jsx)(X,{onClick:u,disabled:c,variant:`primary`,children:c?`starting…`:`connect with github`})]})}),e&&n===`polling`&&(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`overline mb-2`,children:`open this url in your browser`}),(0,K.jsx)(`a`,{href:e.verification_uri,target:`_blank`,rel:`noreferrer`,className:`text-sm text-[var(--color-brand)] hover:underline font-mono`,children:e.verification_uri})]}),(0,K.jsxs)(`div`,{className:`border border-[var(--color-line-1)] bg-[var(--color-surface-0)] rounded-sm py-5 text-center`,children:[(0,K.jsx)(`div`,{className:`overline mb-3`,children:`enter this code`}),(0,K.jsx)(`div`,{className:`text-4xl font-mono font-bold tracking-[0.3em] text-[var(--color-fg-0)]`,children:e.user_code})]}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] text-center flex items-center justify-center gap-2`,children:[(0,K.jsx)(`svg`,{className:`animate-spin`,width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`waiting for github authorization…`]})]})}),n===`done`&&(0,K.jsxs)(`div`,{className:`rounded-sm border border-emerald-500/25 bg-emerald-500/5 p-4 text-sm text-emerald-200 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:i})]}),(0,K.jsx)(`a`,{href:`/hub/publish`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline block mt-1`,children:`publish a ruleset →`})]}),n===`error`&&i&&(0,K.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-red-200 font-mono`,children:i}),(0,K.jsx)(`button`,{onClick:()=>{r(`idle`),a(``)},className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] mt-3 cursor-pointer uppercase tracking-wider`,children:`← try again`})]})]})}function cd(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null);async function o(t){if(t.preventDefault(),e.trim()){r(!0),a(null);try{a(await(await fetch(`/api/hub/publish`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({repo_url:e.trim()})})).json())}catch(e){a({ok:!1,error:e instanceof Error?e.message:`Unknown error`})}finally{r(!1)}}}return(0,K.jsxs)(`div`,{className:`max-w-md mx-auto space-y-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← hub`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight mt-2 text-[var(--color-fg-0)]`,children:`Publish Ruleset`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`publish a github repository containing .rules files to the hub`})]}),(0,K.jsx)(q,{children:(0,K.jsx)(Y,{children:(0,K.jsxs)(`form`,{onSubmit:o,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block overline mb-1.5`,children:`github repository url`}),(0,K.jsx)(`input`,{type:`url`,placeholder:`https://github.com/owner/repo`,value:e,onChange:e=>t(e.target.value),required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,K.jsx)(X,{type:`submit`,variant:`primary`,disabled:n,children:n?`publishing…`:`publish to hub`})]})})}),i&&(0,K.jsx)(`div`,{className:`rounded-sm border px-3 py-2 text-xs font-mono ${i.ok?`border-emerald-500/25 bg-emerald-500/5 text-emerald-300`:`border-red-500/25 bg-red-500/5 text-red-300`}`,children:i.ok?(0,K.jsxs)(K.Fragment,{children:[`✓ published!`,` `,i.id&&(0,K.jsx)(`a`,{href:`/hub/${i.id}`,className:`text-[var(--color-brand)] hover:underline uppercase tracking-wider text-[11px] ml-2`,children:`view ruleset →`})]}):i.error??`publish failed`})]})}function ld(e){return e===0?`—`:e<1e3?`${e}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(1)}ms`}function ud(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function dd(e){let t=e<1e10?e*1e3:e,n=new Date(t);return`${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}:${String(n.getSeconds()).padStart(2,`0`)}`}function fd(e){let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var pd={allow:`text-emerald-300`,block:`text-red-300`,force:`text-violet-300`,log:`text-amber-300`,ask:`text-sky-300`,shadow:`text-[var(--color-fg-3)]`},md={allow:`✓`,block:`✗`,force:`→`,log:`·`,ask:`?`,shadow:`~`};function hd({label:e,ns:t,maxNs:n}){let r=n>0?Math.min(100,t/n*100):0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] w-8 text-right font-mono uppercase tracking-wider text-[10px]`,children:e}),(0,K.jsx)(jc,{pct:r,tone:t<1e5?`green`:t<1e6?`amber`:`red`,className:`h-1 flex-1`}),(0,K.jsx)(`span`,{className:`font-mono text-[var(--color-fg-1)] tabular-nums w-14 text-right`,children:ld(t)})]})}function gd({value:e,max:t,threshold:n,breached:r}){let i=t>0?Math.min(100,e/t*100):0,a=t>0?Math.min(100,n/t*100):0;return(0,K.jsx)(jc,{pct:i,tone:r?`red`:e/t>=.6?`amber`:`green`,markerPct:a,markerTitle:`limit: ${n}`,className:`h-1`})}function _d({limitsData:e,onSaved:t}){let[n,r]=(0,_.useState)(String(e.config.cpuLimitPct)),[i,a]=(0,_.useState)(String(e.config.memoryLimitMb)),[o,s]=(0,_.useState)(e.config.breachAction),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null);async function f(){l(!0),d(null);try{let e=await fetch(`/api/json/limits`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({cpu_limit_pct:parseFloat(n),memory_limit_mb:parseFloat(i),breach_action:o})});e.ok?t():d((await e.json()).error??`save failed`)}catch{d(`network error`)}finally{l(!1)}}let p=`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5 text-[var(--color-fg-1)] font-mono text-xs focus:outline-none focus:border-[var(--color-brand)]/50`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`overline block mb-1.5`,children:`cpu limit (%)`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:100,value:n,onChange:e=>r(e.target.value),className:p})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`overline block mb-1.5`,children:`memory limit (mb)`}),(0,K.jsx)(`input`,{type:`number`,min:1,value:i,onChange:e=>a(e.target.value),className:p})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`overline block mb-1.5`,children:`on breach`}),(0,K.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:p,children:[(0,K.jsx)(`option`,{value:`warn`,children:`warn in ui only`}),(0,K.jsx)(`option`,{value:`log`,children:`warn + write to audit log`})]})]}),u&&(0,K.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:u}),(0,K.jsx)(X,{onClick:f,disabled:c,variant:`primary`,size:`sm`,children:c?`saving…`:`save limits`})]})}var vd={running:`green`,hibernating:`amber`,exhausted:`red`,stopped:`gray`,idle:`gray`};function yd(e,t){let n=e-t;if(n<=0)return`any moment`;let r=Math.round(n/1e3);if(r<60)return`in ${r}s`;let i=Math.floor(r/60);return i<60?`in ${i}m ${r%60}s`:`in ${Math.floor(i/60)}h ${i%60}m`}function bd({supervisors:e}){let[t,n]=(0,_.useState)(Date.now());return(0,_.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 overline`,children:[`supervisor health`,e.some(e=>e.state===`hibernating`||e.state===`exhausted`)&&(0,K.jsx)(sr,{variant:`amber`,children:`degraded`})]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono tabular-nums text-[var(--color-fg-4)]`,children:[e.length,` supervisor`,e.length===1?``:`s`]})]}),(0,K.jsx)(Y,{children:e.length===0?(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no supervisors registered yet`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,K.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`name`}),(0,K.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`kind`}),(0,K.jsx)(`th`,{className:`text-left font-normal pb-1.5`,children:`state`}),(0,K.jsx)(`th`,{className:`text-right font-normal pb-1.5`,children:`restarts`}),(0,K.jsx)(`th`,{className:`text-left font-normal pb-1.5 pl-4`,children:`last restart`}),(0,K.jsx)(`th`,{className:`text-left font-normal pb-1.5 pl-4`,children:`next retry`})]})}),(0,K.jsx)(`tbody`,{children:e.map(e=>(0,K.jsxs)(`tr`,{className:`border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(`td`,{className:`py-1.5 text-[var(--color-fg-1)]`,children:e.name}),(0,K.jsx)(`td`,{className:`py-1.5 text-[var(--color-fg-3)]`,children:e.kind===`single`?`single`:`tree`}),(0,K.jsx)(`td`,{className:`py-1.5`,children:(0,K.jsx)(sr,{variant:vd[e.state],children:e.state})}),(0,K.jsx)(`td`,{className:`py-1.5 text-right tabular-nums text-[var(--color-fg-1)]`,children:e.restarts}),(0,K.jsx)(`td`,{className:`py-1.5 pl-4 tabular-nums text-[var(--color-fg-3)]`,children:e.lastRestartAt>0?fd(e.lastRestartAt):`—`}),(0,K.jsx)(`td`,{className:`py-1.5 pl-4 tabular-nums text-[var(--color-fg-3)]`,children:e.nextRetryAt>0?(0,K.jsx)(`span`,{title:e.hibernateReason?`reason: ${e.hibernateReason}`:void 0,children:yd(e.nextRetryAt,t)}):`—`})]},e.name))})]})})})]})}function xd(){let e=ke([`runtime-tick`,`activity-updated`,`limits-breach`,`supervisor-changed`]),t=De(),[n,r]=(0,_.useState)(Date.now()),[i,a]=(0,_.useState)(0),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(0),[u,d]=(0,_.useState)(!1),f=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let{data:p}=V(`/api/state/runtime`,[e[`runtime-tick`]]),{data:m,refetch:h}=V(`/api/json/limits`,[e[`limits-breach`]]),{data:g}=V(`/api/state/activity-tail?after=${i}&limit=50`,[e[`activity-updated`]]),{data:v}=V(`/api/json/supervisors`,[e[`supervisor-changed`],e[`runtime-tick`]]);(0,_.useEffect)(()=>{g&&g.rows.length>0&&(a(e=>Math.max(e,g.maxId)),s(e=>{let t=new Set(e.map(e=>e.id));return[...g.rows.filter(e=>!t.has(e.id)),...e].slice(0,100)}))},[g]),(0,_.useEffect)(()=>{let e=p!==null;f.current===!1&&e&&l(e=>e+1),f.current=e},[p]);let y=p?ud(p.uptime_ms):null,b=p&&p.last_eval_at>0?fd(p.last_eval_at):null,x=m?.breaches.cpu??!1,S=m?.breaches.memory??!1,C=p?x?`text-red-300`:(p.cpu_pct??0)>=60?`text-amber-300`:`text-emerald-300`:`text-[var(--color-fg-1)]`,w=S?`text-red-300`:`text-[var(--color-fg-1)]`;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Daemon Monitor`}),(0,K.jsx)(`p`,{className:`text-[12px] font-mono text-[var(--color-fg-3)] mt-0.5`,children:`live metrics · audit tail · resource limits`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[c>0&&(0,K.jsxs)(sr,{variant:`amber`,children:[c,` restart`,c===1?``:`s`]}),(0,K.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-[var(--color-fg-3)]`,children:dd(n)})]})]}),(0,K.jsx)(Sd,{cpuPct:p?.cpu_pct??0,cpuLimit:m?.config.cpuLimitPct,memMb:p?.memory_rss_mb??0,memLimit:m?.config.memoryLimitMb,decisions:p?.decisions,latency:p?.latency,burstBuffer:t,evalsTotal:p?.evals_total??0}),m&&(x||S)&&(0,K.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/[0.06] border-l-2 border-l-red-500/70 px-3 py-2.5 flex items-start gap-2.5`,children:[(0,K.jsx)(`span`,{className:`text-red-300 shrink-0 mt-0.5`,children:(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,K.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]})}),(0,K.jsxs)(`div`,{className:`space-y-0.5 text-xs font-mono`,children:[x&&(0,K.jsxs)(`div`,{className:`text-red-200`,children:[`cpu limit exceeded: `,p?.cpu_pct??`?`,`% >`,` `,m.config.cpuLimitPct,`%`]}),S&&(0,K.jsxs)(`div`,{className:`text-red-200`,children:[`memory limit exceeded: `,p?.memory_rss_mb??`?`,`mb >`,` `,m.config.memoryLimitMb,`mb`]})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`daemon status`})}),(0,K.jsx)(Y,{children:p===null?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-500 shrink-0`}),(0,K.jsx)(`span`,{className:`text-red-300 font-mono uppercase tracking-wider text-xs`,children:`down`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] text-xs font-mono`,children:`— socket not reachable`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-5 flex-wrap text-xs font-mono`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-emerald-400 pulse-soft shrink-0`}),(0,K.jsx)(`span`,{className:`text-emerald-300 uppercase tracking-wider`,children:`up`})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`pid`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:p.pid})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`uptime`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:y})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`mem`,` `,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:[p.memory_rss_mb,`MB`]})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`cpu`,` `,(0,K.jsxs)(`span`,{className:`${C} tabular-nums`,children:[p.cpu_pct,`%`]})]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`last eval`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:b??`—`})]})]})})]}),(0,K.jsx)(bd,{supervisors:v?.supervisors??[]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 overline`,children:[`system resources`,m&&(x||S)&&(0,K.jsx)(sr,{variant:`red`,children:`limit exceeded`})]}),(0,K.jsx)(`button`,{onClick:()=>d(e=>!e),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)] transition-colors cursor-pointer`,children:u?`hide limits`:`configure limits`})]}),(0,K.jsxs)(Y,{children:[p===null?(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data — daemon not running`}):(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`cpu`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(p.history.cpu_pct.length??0)>1&&(0,K.jsx)(pr,{data:p.history.cpu_pct,width:80,height:20,color:x?`#f87171`:`#34d399`,threshold:m?.config.cpuLimitPct,maxValue:100}),(0,K.jsxs)(`span`,{className:`font-mono font-medium w-12 text-right tabular-nums ${C}`,children:[p.cpu_pct,`%`]})]})]}),(0,K.jsx)(gd,{value:p.cpu_pct,max:100,threshold:m?.config.cpuLimitPct??90,breached:x}),m&&(0,K.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`limit: `,m.config.cpuLimitPct,`%`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`memory rss`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(p.history.memory_rss_mb.length??0)>1&&(0,K.jsx)(pr,{data:p.history.memory_rss_mb,width:80,height:20,color:S?`#f87171`:`#38bdf8`,threshold:m?.config.memoryLimitMb}),(0,K.jsxs)(`span`,{className:`font-mono font-medium w-16 text-right tabular-nums ${w}`,children:[p.memory_rss_mb,`MB`]})]})]}),(0,K.jsx)(gd,{value:p.memory_rss_mb,max:Math.max(p.memory_rss_mb*1.5,m?.config.memoryLimitMb??512),threshold:m?.config.memoryLimitMb??512,breached:S}),m&&(0,K.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`limit: `,m.config.memoryLimitMb,`MB`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`heap`}),(0,K.jsxs)(`span`,{className:`font-mono text-[var(--color-fg-1)] tabular-nums`,children:[p.heap_used_mb,`MB / `,p.heap_total_mb,`MB`]})]}),(0,K.jsx)(jc,{pct:p.heap_total_mb>0?Math.min(100,p.heap_used_mb/p.heap_total_mb*100):0,tone:`blue`,className:`h-1`})]})]}),u&&m&&(0,K.jsxs)(`div`,{className:`mt-5 pt-4 border-t border-[var(--color-line-0)]`,children:[(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-3 leading-relaxed`,children:[`thresholds trigger ui warnings. values are persisted to`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-fg-1)]`,children:`.sigmashake/config.toml`}),`.`]}),(0,K.jsx)(_d,{limitsData:m,onSaved:()=>{h(),d(!1)}})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2`,children:[(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`total evals`,value:p?.evals_total??`—`,valueClassName:`text-xl font-medium tabular-nums text-[var(--color-fg-0)]`}),(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`allow`,value:p?.decisions.allow??`—`,valueClassName:`text-xl font-medium tabular-nums text-emerald-300`}),(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`block`,value:p?.decisions.block??`—`,valueClassName:`text-xl font-medium tabular-nums text-red-300`}),(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`force`,value:p?.decisions.force??`—`,valueClassName:`text-xl font-medium tabular-nums text-violet-300`}),(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`log`,value:p?.decisions.log??`—`,valueClassName:`text-xl font-medium tabular-nums text-amber-300`}),(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)]`,labelPlacement:`above`,label:`ask`,value:p?.decisions.ask??`—`,valueClassName:`text-xl font-medium tabular-nums text-sky-300`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`eval latency`}),p&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[p.latency.samples,` samples`]})]}),(0,K.jsx)(Y,{children:p===null?(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data`}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(hd,{label:`p50`,ns:p.latency.p50_ns,maxNs:p.latency.max_ns}),(0,K.jsx)(hd,{label:`p95`,ns:p.latency.p95_ns,maxNs:p.latency.max_ns}),(0,K.jsx)(hd,{label:`p99`,ns:p.latency.p99_ns,maxNs:p.latency.max_ns}),(0,K.jsx)(hd,{label:`max`,ns:p.latency.max_ns,maxNs:p.latency.max_ns})]})})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`engine`})}),(0,K.jsx)(Y,{children:p===null?(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no data`}):(0,K.jsx)(`div`,{className:`space-y-1.5 text-xs font-mono`,children:[[`native evals`,p.engine.native_evals],[`ts evals`,p.engine.ts_evals],[`native %`,`${p.engine.native_pct}%`],[`rule reloads`,p.rule_reloads],[`rate limit trips`,p.rate_limit_trips],[`loop guard blocks`,p.loop_guard_blocks],[`connection errors`,p.connection_errors]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex justify-between py-0.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:e}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums`,children:t})]},e))})})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`live event tail`}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`newest first · auto-updating`})]}),(0,K.jsx)(Y,{children:o.length===0?(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-4 py-6 text-center`,children:(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no events yet`})}):(0,K.jsx)(`div`,{className:`font-mono text-[11px] max-h-96 overflow-y-auto divide-y divide-[var(--color-line-0)]`,children:o.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] shrink-0 w-16 tabular-nums`,children:dd(e.timestamp)}),e.tool===`__daemon`?(0,K.jsxs)(`span`,{className:`text-sky-400`,children:[`daemon`,` `,(()=>{try{let t=JSON.parse(e.input??`{}`);return`${t.event??e.decision}${t.detail?` (${t.detail})`:``}`}catch{return e.decision}})()]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`shrink-0 w-16 uppercase tracking-wider text-[10px] ${pd[e.decision]??`text-[var(--color-fg-3)]`}`,children:[md[e.decision]??`·`,` `,e.decision]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] shrink-0 w-24 truncate`,children:e.tool}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] shrink-0 w-14 text-right tabular-nums`,children:ld(e.duration_ns)}),e.rule_id&&(0,K.jsx)(`a`,{href:`/rules?highlight=${encodeURIComponent(e.rule_id)}`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] truncate transition-colors`,title:e.rule_id,children:e.rule_id})]})]},e.id))})})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`ai agent debug endpoints`})}),(0,K.jsxs)(Y,{children:[(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-2.5`,children:`agents can query these endpoints directly for automated triage:`}),(0,K.jsx)(`div`,{className:`space-y-1 font-mono text-[11px]`,children:[[`/api/state/runtime`,`full metrics snapshot (cpu, memory, history, latency)`],[`/api/json/limits`,`resource limits config + breach state`],[`/api/state/activity-tail?after=0&limit=20`,`recent eval events`],[`/api/json/daemon-status`,`status, pid, log tail`],[`/healthz`,`process uptime`]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`GET`}),(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] transition-colors`,children:e}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`— `,t]})]},e))})]})]})]})}function Sd({cpuPct:e,cpuLimit:t,memMb:n,memLimit:r,decisions:i,latency:a,evalsTotal:o,burstBuffer:s}){let c=(0,_.useMemo)(()=>{if(s.length===0)return 0;let e=Date.now()-1e4;return s.filter(t=>t.ts_ms>=e).length/10},[s]);return(a?.p95_ns??0)/1e6,(a?.p50_ns??0)/1e6,(a?.p99_ns??0)/1e6,(0,K.jsxs)(`div`,{className:`grid-bleed rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,style:{contain:`layout paint`},children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-4 lg:min-h-[320px]`,children:[(0,K.jsxs)(`div`,{className:`lg:col-span-3 flex flex-col items-center justify-start gap-2 lg:max-h-[320px]`,children:[(0,K.jsx)(Gr,{mode:`ring`,value:e,max:100,warnAt:(t??90)/100*.7,critAt:(t??90)/100,display:`${e.toFixed(1)}%`,label:`cpu`,size:220,className:`max-h-[240px]`}),(0,K.jsx)(br,{value:e,width:260,height:56,windowMs:6e4,color:`#34d399`,fillColor:`rgba(52, 211, 153, 0.14)`,maxValue:100,className:`w-full`})]}),(0,K.jsxs)(`div`,{className:`lg:col-span-3 flex flex-col items-center justify-start gap-2 lg:max-h-[320px]`,children:[(0,K.jsx)(Gr,{mode:`ring`,value:n,max:r??1024,warnAt:.7,critAt:.9,display:`${n.toFixed(0)} MB`,label:`memory`,size:220,className:`max-h-[240px]`}),(0,K.jsx)(br,{value:n,width:260,height:56,windowMs:6e4,color:`#38bdf8`,fillColor:`rgba(56, 189, 248, 0.14)`,maxValue:r?r*1.1:void 0,className:`w-full`})]}),(0,K.jsx)(`div`,{className:`lg:col-span-6 lg:max-h-[320px]`,children:(0,K.jsx)(Qr,{latency:a,bursts:s,gaugeMaxMs:10,windowMs:3e4,trendWindowSec:60,gaugeSize:200})})]}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,K.jsx)(Or,{label:`Total Evals`,value:o,tone:`amber`,sub:`${c.toFixed(1)}/s`,burstRing:s}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border bg-[var(--color-surface-1)] border-[var(--color-line-1)] px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`throughput · 60 s`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[c.toFixed(1),`/s`]})]}),(0,K.jsx)(br,{value:c,width:420,height:56,windowMs:6e4,className:`w-full`})]})]}),i?(0,K.jsx)(`div`,{className:`mt-4 pt-3 border-t border-[var(--color-line-0)]`,children:(0,K.jsx)(ti,{counters:{allow:i.allow,block:i.block,ask:i.ask,log:i.log,force:i.force,shadow:i.shadow}})}):null,(0,K.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`live event stream · newest first`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:[s.length,` buffered · hover to pause`]})]}),(0,K.jsx)(wi,{variant:`decision`,bursts:s,windowSize:300,height:260})]})]})}var Cd={ok:`green`,warn:`amber`,error:`red`,unknown:`gray`},wd={ok:`OK`,warn:`Warn`,error:`Error`,unknown:`Idle`};function Td({title:e,status:t=`unknown`,statusLabel:n,className:r,children:i}){return(0,K.jsxs)(q,{className:G(`flex flex-col`,r),children:[(0,K.jsxs)(J,{children:[(0,K.jsx)(`span`,{className:`overline text-[var(--color-fg-2)]`,children:e}),(0,K.jsx)(sr,{variant:Cd[t],children:n??wd[t]})]}),(0,K.jsx)(Y,{className:`flex flex-col gap-2 text-[12px]`,children:i})]})}function Ed({label:e,value:t,mono:n=!1,tone:r}){return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-[var(--color-line-0)] last:border-b-0 py-1`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] uppercase tracking-wider text-[10px] font-mono`,children:e}),(0,K.jsx)(`span`,{className:G(n?`font-mono`:`font-sans`,`tabular-nums text-right truncate`,r===`good`?`text-emerald-300`:r===`warn`?`text-amber-300`:r===`bad`?`text-red-300`:`text-[var(--color-fg-1)]`),children:t})]})}function Dd(e){return e===0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function Od(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function kd(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Ad(e){return e?new Date(e*1e3).toLocaleString():`—`}function jd(e){if(!e||e===0)return`never`;let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function Md({children:e,className:t}){return(0,K.jsx)(`div`,{className:`overline mb-2.5 ${t??``}`,children:e})}function $({label:e,value:t,mono:n=!0,accent:r}){return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-[var(--color-fg-3)] shrink-0 font-mono`,children:e}),(0,K.jsx)(`span`,{className:`text-xs text-right truncate max-w-[65%] ${n?`font-mono tabular-nums`:``} ${r??`text-[var(--color-fg-1)]`}`,children:t})]})}function Nd({ok:e,label:t,badLabel:n}){return e?(0,K.jsx)(sr,{variant:`green`,children:t}):(0,K.jsx)(sr,{variant:`red`,children:n??t})}function Pd({pct:e,total:t,max:n}){let r=e<60?`green`:e<85?`amber`:`red`,i=e>=85?`text-red-300`:e>=60?`text-amber-300`:`text-emerald-300`;return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-mono tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[t.toLocaleString(),` / `,n.toLocaleString(),` rows`]}),(0,K.jsxs)(`span`,{className:i,children:[e,`%`]})]}),(0,K.jsx)(jc,{pct:e,tone:r,className:`h-1.5`})]})}var Fd=3e3,Id={log:`text-[var(--color-fg-1)]`,info:`text-sky-300`,warn:`text-amber-300`,error:`text-red-300`,debug:`text-[var(--color-fg-3)]`};function Ld(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function Rd(){let e=_u(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),m=(0,_.useRef)(0),h=(0,_.useRef)(!0);(0,_.useEffect)(()=>{if(h.current){h.current=!1;return}let e=p.current;if(!e)return;let t=e.parentElement;t&&(t.scrollTop=t.scrollHeight)},[a]),(0,_.useEffect)(()=>{if(e.connected)return e.sendCommand(`Runtime.enable`).catch(()=>{}),e.onEvent(`Runtime.consoleAPICalled`,e=>{let t=e;o(e=>{let n=[...e,{id:m.current++,type:t.type??`log`,args:t.args??[],timestamp:t.timestamp??Date.now()}];return n.length>500?n.slice(-500):n})})},[e.connected]),(0,_.useEffect)(()=>{e.preconfiguredTarget&&!e.connected&&!e.connecting&&e.connect(e.preconfiguredTarget.id)},[e]),(0,_.useEffect)(()=>{!e.connected||d||t||r||(f(!0),(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),setTimeout(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch{n(!1)}},Fd)}catch{}})(),e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0}).then(e=>{c(JSON.parse(e.result.value))}).catch(()=>{}))},[e.connected,d,t,r]);let g=(0,_.useCallback)(async()=>{try{await e.sendCommand(`Profiler.enable`),await e.sendCommand(`Profiler.start`),n(!0),i(null)}catch(e){console.error(`Profiler.start failed:`,e)}},[e]),v=(0,_.useCallback)(async()=>{try{let t=await e.sendCommand(`Profiler.stop`);n(!1),i(t.profile)}catch(e){console.error(`Profiler.stop failed:`,e),n(!1)}},[e]),y=(0,_.useCallback)(async()=>{u(!0);try{let t=await e.sendCommand(`Runtime.evaluate`,{expression:`JSON.stringify(process.memoryUsage())`,returnByValue:!0});c(JSON.parse(t.result.value))}catch{}finally{u(!1)}},[e]),b=(0,_.useCallback)(()=>{e.preconfiguredTarget&&e.connect(e.preconfiguredTarget.id)},[e]);return e.active?e.connected?(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono text-[var(--color-fg-2)]`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-emerald-400`}),`connected`,e.bunVersion?` · bun v${e.bunVersion}`:``]}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`})]})]}),e.error&&(0,K.jsx)(Y,{children:(0,K.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:e.error})})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`cpu profiler`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300 flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-red-400 pulse-soft`}),`recording`]}),t?(0,K.jsx)(X,{variant:`danger`,size:`sm`,onClick:v,children:`stop & render`}):(0,K.jsx)(X,{variant:`primary`,size:`sm`,onClick:g,children:`start recording`})]})]}),(0,K.jsx)(Y,{children:r?(0,K.jsx)(Nc,{profile:r,children:(0,K.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 overflow-x-hidden`,children:(0,K.jsx)(wu,{profile:r})})}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording cpu profile (auto-captures ${Fd/1e3}s)… perform actions in ssg to generate data.`:`click start recording, or wait for auto-capture on page load.`})})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`memory`}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:y,disabled:l,children:l?`…`:`refresh`})]}),(0,K.jsx)(Y,{children:s?(0,K.jsx)(Pc,{memory:s,formatValue:Od}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:d?`fetching memory metrics…`:`click refresh to fetch process.memoryUsage().`})})]}),(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`console`}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,K.jsx)(Y,{children:(0,K.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-2 h-40 overflow-y-auto font-mono text-[11px]`,children:[a.length===0?(0,K.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`console output will appear here…`}):a.map(e=>(0,K.jsxs)(`div`,{className:`py-0.5 border-b border-[var(--color-line-0)] ${Id[e.type]??`text-[var(--color-fg-1)]`}`,children:[(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] mr-2 uppercase tracking-wider`,children:[`[`,e.type,`]`]}),e.args.map(Ld).join(` `)]},e.id)),(0,K.jsx)(`div`,{ref:p})]})})]})]}):(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sr,{variant:`amber`,children:e.connecting?`connecting…`:`available`}),!e.connecting&&(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:b,children:`connect`})]})]}),(0,K.jsx)(Y,{children:(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:e.connecting?`establishing websocket connection to bun inspector…`:`inspector is active but not connected. click connect to start profiling.`})})]}):(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,K.jsx)(sr,{variant:`outline`,children:`inactive`})]}),(0,K.jsx)(Y,{children:(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[`the bun inspector is not active. restart`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg serve`}),` to enable it automatically.`]})})]})}function zd(){let[e,t]=(0,_.useState)(0),{data:n}=V(`/api/json/evald-log`,[e]),r=(0,_.useRef)(null),i=(0,_.useRef)(!0);(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),5e3);return()=>clearInterval(e)},[]),(0,_.useEffect)(()=>{if(i.current){i.current=!1;return}let e=r.current;if(!e)return;let t=e.parentElement;t&&(t.scrollTop=t.scrollHeight)},[n?.lines.length]);let a=n?.lines??[];return(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`daemon log`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] truncate max-w-[60%]`,children:[n?.path?n.path:`loading…`,` · last 200 lines · 5s refresh`]})]}),(0,K.jsxs)(Y,{children:[n?.error&&(0,K.jsx)(`p`,{className:`text-xs text-red-300 font-mono mb-2`,children:n.error}),a.length===0&&!n?.error&&(0,K.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-4 py-6 text-center`,children:(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[`no log entries yet. start the daemon with`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg serve`}),` to generate log output.`]})}),a.length>0&&(0,K.jsxs)(`pre`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm p-3 text-[10px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-all max-h-80 overflow-y-auto font-mono leading-relaxed`,children:[a.join(`
45
- `),(0,K.jsx)(`div`,{ref:r})]})]})]})}function Bd(){let e=ke([`runtime-tick`,`rules-changed`]),{data:t,refetch:n}=V(`/api/json/observability`,[e[`runtime-tick`],e[`rules-changed`]]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(Date.now()),[l,u]=(0,_.useState)(`idle`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`idle`);(0,_.useEffect)(()=>{t&&c(Date.now())},[t]);let h=(0,_.useCallback)(async()=>{u(`loading`);try{let e=await(await fetch(`/api/rules/sync-to-db`,{method:`POST`,headers:B()})).json();if(e.ok){u(`done`);let t=(e.pruned_count??0)>0?` (${e.pruned_count} orphan(s) pruned)`:``;f((e.message??`synced ${e.synced} rules`)+t),n()}else u(`error`),f(e.error??`sync failed`)}catch(e){u(`error`),f(String(e))}},[n]),g=(0,_.useCallback)(async()=>{m(`loading`);try{await fetch(`/api/rules/force-reload`,{method:`POST`,headers:B()}),m(`done`),n(),setTimeout(()=>m(`idle`),3e3)}catch{m(`idle`)}},[n]),v=t?.db,y=t?.rules,b=t?.audit,x=t?.process,S=t?.flight_recorder,C=y?.drift_detected??!1;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Observability`}),(0,K.jsx)(`p`,{className:`text-[12px] font-mono text-[var(--color-fg-3)] mt-0.5`,children:`sqlite health · rule drift · runtime profiler · diagnostics`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:[`refreshed `,jd(s)]}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:n,children:`refresh`})]})]}),(0,K.jsx)(Vd,{db:v,audit:b,proc:x,flight:S,driftDetected:C}),(0,K.jsxs)(q,{className:C?`border-red-500/30 border-l-2 border-l-red-500/70`:`border-emerald-500/20 border-l-2 border-l-emerald-500/60`,children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`rule drift detector`}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`— .rules files vs sqlite`}),(0,K.jsx)(`button`,{onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`Explain these counts`,title:`Why do these numbers differ?`,className:`text-[10px] font-mono text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 transition-colors cursor-pointer`,children:a?`× close`:`? why these numbers`})]}),y&&(C?(0,K.jsx)(sr,{variant:`red`,children:`⚠ drift detected`}):(0,K.jsx)(sr,{variant:`green`,children:`✓ in sync`}))]}),(0,K.jsxs)(Y,{children:[a&&(0,K.jsxs)(`div`,{className:`mb-4 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-3 py-2.5 space-y-2 text-[11px] font-mono leading-relaxed text-[var(--color-fg-3)]`,children:[(0,K.jsxs)(`div`,{className:`text-[var(--color-fg-2)]`,children:[(0,K.jsx)(`code`,{children:`.rules files`}),` and `,(0,K.jsx)(`code`,{children:`db rules`}),` are`,` `,(0,K.jsx)(`span`,{className:`text-amber-300`,children:`not auto-synced`}),`. A mismatch is usually expected:`]}),(0,K.jsxs)(`ul`,{className:`space-y-1 pl-3 list-disc marker:text-[var(--color-fg-4)]`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`one file can hold many rules`}),` `,`— compare `,(0,K.jsx)(`code`,{children:`db rules`}),` against`,` `,(0,K.jsx)(`code`,{children:`file_rule_count`}),`, not `,(0,K.jsx)(`code`,{children:`file_count`}),`.`]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in files`}),` `,`means unsynced edits — run`,` `,(0,K.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`}),` or click`,` `,(0,K.jsx)(`code`,{children:`↑ sync files → db`}),`.`]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in db`}),` `,`with `,(0,K.jsx)(`code`,{children:`source_file IS NULL`}),` is healthy — hub, fleet, or cloud-synced rules legitimately live only in the db.`]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`only in db`}),` `,`with `,(0,K.jsx)(`code`,{children:`source_file`}),` set means an orphan from a deleted file — `,(0,K.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`}),` `,`prunes it.`]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:`db rules`}),` `,`includes disabled rows; `,(0,K.jsx)(`code`,{children:`db_enabled_count`}),` `,`excludes them.`]})]}),(0,K.jsxs)(`div`,{className:`pt-1.5 border-t border-[var(--color-line-0)]`,children:[`full reference:`,` `,(0,K.jsx)(`a`,{href:`https://docs.sigmashake.com/rule-storage`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[var(--color-fg-2)] underline decoration-dotted underline-offset-2 hover:text-amber-300 transition-colors`,children:`docs.sigmashake.com/rule-storage ↗`})]})]}),y?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[{label:`.rules files`,value:y.file_count,sub:`${y.file_rule_count} rules total`,tone:`neutral`},{label:`db rules`,value:y.db_rule_count,sub:`${y.db_enabled_count} enabled`,tone:`neutral`},{label:`only in files`,value:y.drift_details.only_in_files.length,tone:y.drift_details.only_in_files.length>0?`amber`:`gray`},{label:`only in db`,value:y.drift_details.only_in_db.length,tone:y.drift_details.only_in_db.length>0?`red`:`gray`}].map(({label:e,value:t,sub:n,tone:r})=>(0,K.jsx)(Ac,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)]`,label:e,value:t,sub:n,tone:r,labelPlacement:`above`,subClassName:`text-[var(--color-fg-4)]`,valueClassName:`text-xl font-medium tabular-nums`},e))}),C&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{onClick:()=>i(e=>!e),className:`text-[10px] font-mono uppercase tracking-wider text-amber-300 hover:text-amber-200 flex items-center gap-1 transition-colors cursor-pointer`,children:[r?`▾`:`▸`,` view drift details`]}),r&&(0,K.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[y.drift_details.only_in_files.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-amber-300/80 mb-1.5`,children:[`in .rules files but not in db — run`,` `,(0,K.jsx)(`code`,{className:`text-amber-300`,children:`ssg sync`})]}),(0,K.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-amber-400/20 rounded-sm p-2 space-y-0.5 max-h-40 overflow-y-auto`,children:y.drift_details.only_in_files.map(e=>(0,K.jsxs)(`div`,{className:`font-mono text-[11px] text-amber-200/80`,children:[`+ `,e]},e))})]}),y.drift_details.only_in_db.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-300/80 mb-1.5`,children:`in db but not in any .rules file — orphaned rules`}),(0,K.jsx)(`div`,{className:`bg-[var(--color-surface-0)] border border-red-400/20 rounded-sm p-2 space-y-0.5 max-h-40 overflow-y-auto`,children:y.drift_details.only_in_db.map(e=>(0,K.jsxs)(`div`,{className:`font-mono text-[11px] text-red-200/80`,children:[`− `,e]},e))})]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-3 border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(X,{variant:`primary`,size:`sm`,onClick:h,disabled:l===`loading`,children:l===`loading`?`syncing…`:`↑ sync files → db`}),(0,K.jsx)(X,{variant:`ghost`,size:`sm`,onClick:g,disabled:p===`loading`,children:p===`loading`?`…`:p===`done`?`✓ reloaded`:`↻ force reload`}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] ml-auto`,children:y.db_rule_count===0?`⚠ db empty — daemon falls back to file-based loading`:`db has ${y.db_rule_count} rules — indexed queries`})]}),l===`done`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm border border-emerald-500/25 bg-emerald-500/[0.06] px-3 py-2 text-xs font-mono text-emerald-200`,children:[(0,K.jsxs)(`span`,{children:[`✓ `,d]}),(0,K.jsx)(`button`,{onClick:()=>u(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-emerald-500/30 hover:bg-emerald-500/10 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`dismiss`})]}),l===`error`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm border border-red-500/25 bg-red-500/[0.06] px-3 py-2 text-xs font-mono text-red-200`,children:[(0,K.jsxs)(`span`,{children:[`✗ `,d]}),(0,K.jsx)(`button`,{onClick:()=>u(`idle`),className:`ml-3 shrink-0 px-2 py-0.5 rounded-sm border border-red-500/30 hover:bg-red-500/10 transition-colors cursor-pointer uppercase tracking-wider text-[10px]`,children:`dismiss`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-[var(--color-fg-4)] pt-2 border-t border-[var(--color-line-0)]`,children:[(0,K.jsxs)(`span`,{children:[`rules dir:`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:y.rules_dir})]}),(0,K.jsxs)(`span`,{className:`ml-auto`,children:[`last reload:`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)]`,children:jd(y.last_reload_at)})]})]})]}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`sqlite database`}),v&&!v.error&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Nd,{ok:v.journal_mode===`wal`,label:`wal`,badLabel:`no wal`}),(0,K.jsx)(Nd,{ok:v.synchronous===`NORMAL`,label:`normal`,badLabel:v.synchronous})]})]}),(0,K.jsx)(Y,{children:v?v.error?(0,K.jsx)(`div`,{className:`text-xs text-red-300 font-mono bg-red-500/[0.06] border border-red-500/25 rounded-sm p-2`,children:v.error}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Md,{children:`storage`}),(0,K.jsx)($,{label:`file path`,value:v.path}),(0,K.jsx)($,{label:`file size`,value:Dd(v.file_size_bytes)}),(0,K.jsx)($,{label:`allocated`,value:`${Dd(v.allocated_bytes)} (${v.page_count.toLocaleString()} pages × ${v.page_size}B)`}),(0,K.jsx)(Md,{className:`mt-4`,children:`pragma configuration`}),(0,K.jsx)($,{label:`journal_mode`,value:v.journal_mode,accent:v.journal_mode===`wal`?`text-emerald-300`:`text-amber-300`}),(0,K.jsx)($,{label:`synchronous`,value:v.synchronous,accent:v.synchronous===`NORMAL`?`text-emerald-300`:`text-amber-300`}),(0,K.jsx)($,{label:`cache_size`,value:`${v.cache_size_kb.toLocaleString()} KB (${Math.round(v.cache_size_kb/1024)} MB)`}),(0,K.jsx)($,{label:`page_size`,value:`${v.page_size.toLocaleString()} B`}),v.wal_checkpoint&&(0,K.jsx)($,{label:`wal checkpoint`,value:`log ${v.wal_checkpoint.log}, checkpointed ${v.wal_checkpoint.checkpointed}, busy ${v.wal_checkpoint.busy}`}),(0,K.jsx)(Md,{className:`mt-4`,children:`table row counts`}),v.tables.map(e=>(0,K.jsx)($,{label:e.name,value:e.row_count>=0?e.row_count.toLocaleString():`error`,accent:e.row_count<0?`text-red-300`:`text-[var(--color-fg-1)]`},e.name))]}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`audit log capacity`})}),(0,K.jsx)(Y,{children:b?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(Pd,{pct:b.utilization_pct,total:b.total_rows,max:b.max_rows}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)($,{label:`total rows`,value:b.total_rows.toLocaleString()}),(0,K.jsx)($,{label:`rotation limit`,value:b.max_rows.toLocaleString()}),(0,K.jsx)($,{label:`utilization`,value:`${b.utilization_pct}%`,accent:b.utilization_pct>=85?`text-red-300`:b.utilization_pct>=60?`text-amber-300`:`text-emerald-300`}),(0,K.jsx)($,{label:`oldest entry`,value:Ad(b.oldest_timestamp)}),(0,K.jsx)($,{label:`newest entry`,value:Ad(b.newest_timestamp)})]}),b.utilization_pct>=85&&(0,K.jsx)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/[0.06] px-3 py-2 text-[11px] font-mono text-red-200`,children:`⚠ audit log nearing rotation limit. oldest entries will be purged automatically.`})]}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`process & runtime`})}),(0,K.jsx)(Y,{children:x?(0,K.jsxs)(`div`,{children:[(0,K.jsx)($,{label:`pid`,value:x.pid}),(0,K.jsx)($,{label:`uptime`,value:kd(x.uptime_ms)}),(0,K.jsx)($,{label:`memory (rss)`,value:`${x.memory_rss_mb} MB`}),(0,K.jsx)($,{label:`bun version`,value:x.bun_version}),(0,K.jsx)($,{label:`node compat`,value:x.node_version}),(0,K.jsx)($,{label:`platform`,value:`${x.platform} / ${x.arch}`})]}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`flight recorder`})}),(0,K.jsx)(Y,{children:S?(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline mb-1.5`,children:`log file`}),(0,K.jsx)(`div`,{className:`text-xs font-mono text-[var(--color-fg-1)] truncate`,children:`…${S.path.slice(-50)}`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline mb-1.5`,children:`file size`}),(0,K.jsx)(`div`,{className:`text-xs font-mono tabular-nums ${S.file_size_bytes===0?`text-[var(--color-fg-4)]`:`text-[var(--color-fg-1)]`}`,children:Dd(S.file_size_bytes)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline mb-1.5`,children:`approx. entries`}),(0,K.jsx)(`div`,{className:`text-xs font-mono tabular-nums ${S.approx_entries===0?`text-[var(--color-fg-4)]`:`text-[var(--color-fg-1)]`}`,children:S.approx_entries===0?`—`:S.approx_entries.toLocaleString()})]})]}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`loading…`})})]}),(0,K.jsx)(Rd,{}),(0,K.jsx)(zd,{}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{className:`overline`,children:`observability api`})}),(0,K.jsxs)(Y,{children:[(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mb-2.5`,children:`machine-readable endpoints for automated monitoring and ai agent triage:`}),(0,K.jsx)(`div`,{className:`space-y-1 font-mono text-[11px]`,children:[[`/api/json/observability`,`sqlite health, rule drift, process info`],[`/api/state/runtime`,`eval latency, decision counters, memory`],[`/api/state/activity-tail?after=0&limit=20`,`recent eval events (live feed)`],[`/api/json/daemon-status`,`daemon pid, status, log tail`],[`/api/json/evald-log`,`last 200 lines of evald.log (daemon stderr)`],[`/healthz`,`process liveness`],[`/readyz`,`sqlite liveness`]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`GET`}),(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-brand)]/80 hover:text-[var(--color-brand)] transition-colors`,children:e}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] hidden sm:inline`,children:[`— `,t]})]},e))})]})]})]})}function Vd({db:e,audit:t,proc:n,flight:r,driftDetected:i}){let a=e?e.error?`error`:e.journal_mode===`wal`&&e.synchronous===`NORMAL`?`ok`:`warn`:`unknown`,o=t?t.utilization_pct>=85?`error`:t.utilization_pct>=60?`warn`:`ok`:`unknown`,s=n?n.memory_rss_mb>600?`warn`:`ok`:`unknown`;return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,K.jsxs)(Td,{title:`sqlite`,status:a,statusLabel:e?.journal_mode?.toUpperCase()??`idle`,children:[(0,K.jsx)(Ed,{label:`size`,value:e?(0,K.jsx)(fr,{value:e.file_size_bytes,format:e=>Od(e)}):`—`,mono:!0}),(0,K.jsx)(Ed,{label:`journal`,value:e?.journal_mode??`—`,mono:!0}),(0,K.jsx)(Ed,{label:`sync`,value:e?.synchronous??`—`,mono:!0}),(0,K.jsx)(Ed,{label:`tables`,value:e?.tables.length??0,tone:i?`warn`:`neutral`})]}),(0,K.jsxs)(Td,{title:`audit log`,status:o,statusLabel:t?`${t.utilization_pct}%`:`idle`,children:[(0,K.jsx)(Ed,{label:`rows`,value:t?(0,K.jsx)(fr,{value:t.total_rows}):`—`}),(0,K.jsx)(Ed,{label:`capacity`,value:t?`${(t.total_rows/Math.max(1,t.max_rows)*100).toFixed(1)}%`:`—`,tone:t&&t.utilization_pct>=85?`bad`:t&&t.utilization_pct>=60?`warn`:`good`}),(0,K.jsx)(Ed,{label:`oldest`,value:Ad(t?.oldest_timestamp??null),mono:!0}),(0,K.jsx)(Ed,{label:`newest`,value:Ad(t?.newest_timestamp??null),mono:!0})]}),(0,K.jsxs)(Td,{title:`process`,status:s,statusLabel:n?`pid ${n.pid}`:`idle`,children:[(0,K.jsx)(Ed,{label:`uptime`,value:n?kd(n.uptime_ms):`—`,mono:!0}),(0,K.jsx)(Ed,{label:`rss`,value:n?(0,K.jsxs)(`span`,{children:[(0,K.jsx)(fr,{value:n.memory_rss_mb,format:e=>e.toFixed(0)}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1`,children:`MB`})]}):`—`}),(0,K.jsx)(Ed,{label:`bun`,value:n?.bun_version??`—`,mono:!0}),(0,K.jsx)(Ed,{label:`platform`,value:n?`${n.platform}/${n.arch}`:`—`,mono:!0})]}),(0,K.jsxs)(Td,{title:`flight recorder`,status:r&&r.file_size_bytes>0?`ok`:`unknown`,statusLabel:r?`${r.approx_entries.toLocaleString()} entries`:`idle`,children:[(0,K.jsx)(Ed,{label:`size`,value:r?(0,K.jsx)(fr,{value:r.file_size_bytes,format:e=>Od(e)}):`—`,mono:!0}),(0,K.jsx)(Ed,{label:`entries`,value:r?(0,K.jsx)(fr,{value:r.approx_entries}):`—`})]})]})}var Hd=900,Ud=180,Wd=320,Gd=800,Kd=4;function qd({sessionKey:e}={}){let t=Ee(),n=Oe(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(`idle`),s=(0,_.useRef)([]),c=(0,_.useRef)(-1),l=(0,_.useRef)(0),u=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!t||n===c.current||(c.current=n,t.decision!==`block`&&t.decision!==`force`)||e&&Ja(t)!==e)return;let u=Date.now(),d=s.current,f=d[0];if(f&&u-l.current<Gd){f.extra+=1,f.burst=t,f.seq=n,l.current=u;return}if(d.length>=Kd&&d.shift(),d.push({seq:n,burst:t,extra:0}),l.current=u,a===`idle`&&!r){let e=d.shift()??null;e&&(i(e),o(`in`))}},[n]),(0,_.useEffect)(()=>{if(a===`idle`)return;let e=null;return a===`in`?e=setTimeout(()=>o(`visible`),Ud):a===`visible`?e=setTimeout(()=>o(`out`),Hd):a===`out`&&(e=setTimeout(()=>{let e=s.current.shift()??null;e?(i(e),o(`in`)):(i(null),o(`idle`))},Wd)),u.current=e,()=>{e&&clearTimeout(e)}},[a]),!r)return null;let{burst:d,extra:f}=r,p=Ya[d.decision]??`#ef4444`,m=ot(),h=a===`in`||a===`visible`?1:0,g=m||a===`in`||a===`visible`?0:-8,v=d.rule_id??`rule`,y=d.decision===`block`?`BLOCKED`:`FORCED`,b=f>0?`${d.tool} · +${f} more in this burst`:`${d.tool} · ${d.client}${d.agent_id?`:${d.agent_id}`:``}`;return(0,K.jsx)(`div`,{className:e?`pointer-events-none absolute top-2 left-1/2 z-30 select-none`:`pointer-events-none fixed top-20 left-1/2 z-40 select-none`,style:{transform:`translateX(-50%) translateY(${g}px) scale(1)`,opacity:h,transition:m?`opacity ${Ud}ms ease-out`:`opacity ${Ud}ms ease-out, transform ${Ud}ms cubic-bezier(0.34, 1.56, 0.64, 1)`},"aria-live":`polite`,"aria-atomic":`true`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3 rounded-md border bg-black/95 shadow-2xl`,style:{borderColor:p},children:[(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full shrink-0`,style:{background:p,boxShadow:m?`none`:`0 0 16px ${p}`}}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`text-[11px] font-mono uppercase tracking-[0.18em]`,style:{color:p},children:[y,` BY SSG`]}),(0,K.jsx)(`div`,{className:`text-[14px] font-mono text-[var(--color-fg-1)] truncate max-w-[420px]`,children:v}),(0,K.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] truncate max-w-[420px]`,children:b})]})]})})}var Jd=(0,_.memo)(function(e){let{sessionKey:t,bursts:n,paused:r,selectedId:i,onSelect:a,burstSeq:o,isStale:s,isFadingOut:c,minHeight:l,pinned:u,minimized:d,isFullscreen:f,viewMode:p=`full`,thumbnail:m=!1,onPromote:h,activePanelCount:g=1,onTogglePin:v,onToggleMinimize:y,onToggleFullscreen:b,onClose:x,onFrameTime:S}=e,C=p===`broadcast`,w=!m&&(p===`stream`||p===`broadcast`||f)?`large`:`normal`,T=t.indexOf(`:`),E=T>=0?t.slice(0,T):t,D=T>=0?t.slice(T+1):``,O=(0,_.useRef)(null),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),N=()=>{let e=O.current;if(!e)return;let t=e.querySelector(`canvas`);t instanceof HTMLCanvasElement&&M(t.toDataURL(`image/png`))},ee=()=>{if(!j)return;let e=document.createElement(`a`),n=t.replace(/[^a-z0-9._-]+/gi,`-`);e.href=j,e.download=`ssg-graph-${n}-${Date.now()}.png`,document.body.appendChild(e),e.click(),e.remove()},te=()=>{!j||!navigator.clipboard?.write||fetch(j).then(e=>e.blob()).then(e=>{let t=new ClipboardItem({"image/png":e});return navigator.clipboard.write([t])}).catch(()=>{})},P=typeof navigator<`u`&&typeof navigator.clipboard?.write==`function`&&typeof ClipboardItem<`u`;(0,_.useEffect)(()=>{if(f){A(!0);return}let e=O.current;if(!e)return;let t=new IntersectionObserver(e=>{for(let t of e)A(t.isIntersecting)},{threshold:.01});return t.observe(e),()=>t.disconnect()},[f]);let F=n.length>0?n[n.length-1]:null,ne=F?Ya[F.decision]??`#6b7280`:`#6b7280`,re=F?.decision??null,ie=F?.tool??null,I=r||!k||d,L=(0,_.useMemo)(()=>n.length>24?n.slice(n.length-24):n,[n]);return(0,K.jsxs)(`div`,{ref:O,className:`relative flex flex-col shrink-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden${f?` flex-1 min-h-0`:``}`,style:{minHeight:d||f?void 0:l,opacity:c?0:1,transform:c?`scale(0.985)`:`scale(1)`,transformOrigin:`center center`,transition:`opacity 1100ms cubic-bezier(0.22, 1, 0.36, 1), transform 1100ms cubic-bezier(0.22, 1, 0.36, 1)`},children:[!C&&(0,K.jsxs)(`header`,{className:`group flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0 gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono min-w-0`,children:[u&&(0,K.jsx)(`span`,{className:`text-amber-300`,title:`Pinned`,children:`▲`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider`,children:E}),D&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate`,children:D})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono text-[var(--color-fg-4)]`,children:[ie&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 max-w-[180px]`,title:re?`latest: ${ie} → ${re}`:`latest: ${ie}`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:ne}}),(0,K.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:ie})]}),(0,K.jsxs)(`span`,{className:`hidden md:inline text-[var(--color-fg-4)]`,children:[n.length,`n`]}),s?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-amber-300`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-amber-400`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`idle`})]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-emerald-300`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`live`})]}),!m&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:v,className:`px-1.5 py-0.5 rounded border text-[10px] uppercase tracking-wider transition-colors ${u?`border-amber-500/60 text-amber-300`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-amber-300 hover:border-amber-500/40`}`,title:u?`Unpin`:`Pin to top`,children:`pin`}),(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:d?`Expand`:`Minimize`,children:d?`+`:`–`}),(0,K.jsx)(`button`,{type:`button`,onClick:N,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:`Preview PNG snapshot of this panel`,children:`▣`}),(0,K.jsx)(`button`,{type:`button`,onClick:b,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,title:f?`Exit fullscreen`:`Fullscreen`,children:f?`×`:`⛶`}),x&&(0,K.jsx)(`button`,{type:`button`,onClick:x,"aria-label":`Close session ${t}`,className:`px-1.5 py-0.5 rounded border border-[var(--color-line-1)] text-[10px] text-[var(--color-fg-3)] hover:text-rose-300 hover:border-rose-500/40 transition-colors`,title:`End this session on the graph`,children:`╳`})]})]})]}),!d&&!m&&!C&&(0,K.jsx)(Fs,{sessionKey:t,className:`rounded-none border-x-0 border-t-0 border-b border-[var(--color-line-1)] shrink-0`}),j&&(0,K.jsxs)(`div`,{className:`absolute inset-0 z-40 flex flex-col items-center justify-center gap-3 bg-black/80 backdrop-blur-sm p-4`,children:[(0,K.jsx)(`img`,{src:j,alt:`Panel snapshot`,className:`max-w-full max-h-[60%] rounded-sm border border-[var(--color-line-1)] object-contain`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P&&(0,K.jsx)(`button`,{type:`button`,onClick:te,className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-2)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,children:`copy`}),(0,K.jsx)(`button`,{type:`button`,onClick:ee,className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-2)] hover:text-sky-300 hover:border-sky-500/40 transition-colors`,children:`download`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`px-3 py-1.5 rounded border border-[var(--color-line-1)] text-[11px] font-mono text-[var(--color-fg-3)] hover:text-rose-300 hover:border-rose-500/40 transition-colors`,children:`close`})]})]}),!d&&(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[(0,K.jsx)(qd,{sessionKey:t}),(0,K.jsx)(Os,{bursts:L,paused:I,selectedId:i,onSelect:a,burstSeq:o,compact:!0,activePanelCount:g,labelDensity:w,onFrameTime:S}),m&&(0,K.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Promote ${E} to spotlight`,title:`Spotlight ${E}${D?` · ${D}`:``}`,className:`absolute inset-0 cursor-pointer bg-transparent hover:bg-sky-400/5 transition-colors`})]})]})}),Yd=200;function Xd(e){let t=Date.now()-e;return t<2e3?`now`:t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Zd(e){let t=e/1e6;return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.floor(t/6e4)}m${Math.floor(t%6e4/1e3)}s`}function Qd(e){let{bursts:t,selectedId:n,onSelect:r}=e,i=(0,_.useMemo)(()=>{let e=new Map;for(let n of t){if(di(n.tool))continue;let t=Ja(n),r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}let n=Array.from(e.entries());return n.sort((e,t)=>{let n=e[1][e[1].length-1]?.ts_ms??0;return(t[1][t[1].length-1]?.ts_ms??0)-n}),n},[t]);return t.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center px-4`,children:[(0,K.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`feed · idle`}),(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[260px]`,children:[`Each entry is one tool call your AI agent made.`,(0,K.jsx)(`br`,{}),`Color = the ssg rule decision.`]})]}):(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3 space-y-5`,children:i.map(([e,t])=>{let i=e.indexOf(`:`),a=i>=0?e.slice(0,i):e;i>=0&&e.slice(i+1);let o=t[t.length-1],s=o?Ya[o.decision]??`#6b7280`:`#6b7280`,c=t.slice(-Yd).reverse();return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 pb-1 border-b border-[var(--color-line-1)] text-[11px]`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:s}}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-medium`,children:ui(a)}),(0,K.jsxs)(`span`,{className:`ml-auto text-[10px] text-[var(--color-fg-4)]`,children:[t.length,` `,t.length===1?`action`:`actions`]})]}),(0,K.jsxs)(`div`,{className:`relative pl-4`,children:[(0,K.jsx)(`div`,{className:`absolute left-[7px] top-0 bottom-0 w-px`,style:{background:`${s}33`}}),(0,K.jsx)(`div`,{className:`space-y-1.5`,children:c.map(e=>{let t=e.audit_id??`${e.ts_ms}:${e.tool}`,i=t===n,a=Ya[e.decision]??`#6b7280`,o=e.input_tokens??0,s=e.output_tokens??0,c=o>0||s>0;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute -left-[9px] top-1/2 -translate-y-1/2 w-[6px] h-[6px] rounded-full border border-[var(--color-surface-1)]`,style:{background:a}}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(i?null:t),className:`w-full text-left flex items-center gap-2 px-2.5 py-1.5 rounded-sm border text-[11.5px] transition-colors ${i?`border-sky-500/50 bg-sky-500/5 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-2)] hover:bg-white/3 hover:border-[var(--color-line-2)]`}`,children:[(0,K.jsx)(`span`,{className:`flex-1 font-medium truncate text-[var(--color-fg-1)]`,title:e.tool,children:li(e.tool)}),(0,K.jsxs)(`span`,{className:`shrink-0 flex items-center gap-2 text-[9px] text-[var(--color-fg-4)]`,children:[c&&(0,K.jsxs)(`span`,{className:`font-mono`,title:`Input: ${o} tokens · Output: ${s} tokens`,children:[`↓`,Z(o),` `,`↑`,Z(s)]}),e.duration_ns>0&&(0,K.jsx)(`span`,{children:Zd(e.duration_ns)}),(0,K.jsx)(`span`,{className:`px-1.5 py-px rounded text-[9px] font-semibold tracking-wide`,style:{color:a,background:`${a}22`},children:e.decision===`allow`?`Allowed`:e.decision===`block`?`Blocked`:e.decision===`ask`?`Held`:e.decision===`force`?`Forced`:e.decision===`log`?`Logged`:e.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:Xd(e.ts_ms)})]})]})]},t)})})]})]},e)})})}var $d=200,ef=.9,tf=40,nf=32,rf=480,af=`transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease-out, fill 320ms ease-out`;function of(e){let{playback:t,bursts:n,rangeStart:r,rangeEnd:i,loading:a,onPlayhead:o,onLive:s,onPause:c,onResume:l,on24h:u}=e,d=(0,_.useRef)(null),f=(0,_.useRef)(!1),[p,m]=(0,_.useState)(null),h=Math.max(1,i-r),g=(t.playhead_ms-r)/h*100,v=Math.max(0,Math.min(100,g)),y=(0,_.useMemo)(()=>{let e=[];for(let t=0;t<$d;t++)e.push({allow:0,block:0,ask:0,other:0});for(let t of n){let n=t.ts_ms;if(n<r||n>i)continue;let a=e[Math.floor((n-r)/h*($d-1))];t.decision===`allow`?a.allow++:t.decision===`block`||t.decision===`force`?a.block++:t.decision===`ask`?a.ask++:a.other++}return e},[n,r,i,h]),b=(0,_.useCallback)(e=>{let t=d.current;if(!t)return;let n=t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(e-n.left)/n.width));if(i>=.98){s();return}o(r+i*h)},[r,h,o,s]),x=(0,_.useCallback)(e=>{let t=d.current;if(!t)return;let n=t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(e-n.left)/n.width));m({rel:i,ts:r+i*h})},[r,h]);(0,_.useEffect)(()=>{let e=e=>{f.current&&b(e.clientX)},t=()=>{f.current=!1};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[b]);let S=t.mode===`live`,C=S?`left ${rf}ms linear`:`none`;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono uppercase tracking-wider`,children:[(0,K.jsx)(`button`,{onClick:()=>S?c():l(),className:`px-2.5 py-1 rounded-sm border transition-colors cursor-pointer ${S?`border-emerald-500/40 text-emerald-300 hover:bg-emerald-500/10`:`border-amber-500/40 text-amber-300 hover:bg-amber-500/10`}`,title:S?`Pause the live stream`:`Resume updates at this playhead`,children:S?`⏸ pause`:`▶ resume`}),(0,K.jsx)(`button`,{onClick:s,disabled:S,className:`px-2.5 py-1 rounded-sm border transition-colors cursor-pointer ${S?`border-[var(--color-line-1)] text-[var(--color-fg-4)] opacity-50`:`border-sky-500/40 text-sky-300 hover:bg-sky-500/10`}`,title:`Jump to live (now)`,children:`⏭ live`}),(0,K.jsx)(`button`,{onClick:u,className:`px-2.5 py-1 rounded-sm border border-violet-500/40 text-violet-300 hover:bg-violet-500/10 transition-colors cursor-pointer`,title:`Expand to last 24h — window covers now−24h through now. Backfills audit_log so the scrubber shows all recent evals.`,children:`◉ 24h`}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`mode`}),(0,K.jsx)(`span`,{className:S?`text-emerald-300`:t.mode===`paused`?`text-amber-300`:`text-violet-300`,children:t.mode}),a&&(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] animate-pulse`,children:`· backfilling`}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`· t=`,sf(t.playhead_ms)]})]}),(0,K.jsxs)(`div`,{ref:d,className:`relative h-10 w-full rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] cursor-pointer overflow-hidden select-none`,onPointerDown:e=>{f.current=!0,e.target.setPointerCapture?.(e.pointerId),b(e.clientX)},onPointerMove:e=>x(e.clientX),onPointerLeave:()=>m(null),children:[a&&(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none opacity-40 shimmer`,"aria-hidden":!0}),(0,K.jsxs)(`svg`,{viewBox:`0 0 ${$d} ${tf}`,preserveAspectRatio:`none`,className:`absolute inset-0 w-full h-full pointer-events-none`,"aria-hidden":!0,children:[[.25,.5,.75].map(e=>(0,K.jsx)(`line`,{x1:e*$d,x2:e*$d,y1:0,y2:tf,stroke:`var(--color-line-1)`,strokeWidth:.3,strokeDasharray:`1,2`,opacity:.55},e)),y.map((e,t)=>{let n=e.allow+e.block+e.ask+e.other,r=Math.min(nf,n*3),i=n===0?0:r/nf,a=e.block>0?Ya.block:e.ask>0?Ya.ask:e.other>0&&e.allow===0?Ya.log:Ya.allow;return(0,K.jsx)(`rect`,{x:t+.05,y:tf-nf,width:ef,height:nf,rx:.3,fill:a,style:{opacity:n===0?0:.78,transform:`scaleY(${i})`,transformOrigin:`50% 100%`,transformBox:`fill-box`,transition:af}},t)})]}),p&&(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-white/15 pointer-events-none`,style:{left:`${p.rel*100}%`},"aria-hidden":!0}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 pointer-events-none`,style:{left:`${v}%`,width:`1px`,background:`linear-gradient(to bottom, rgba(125,211,252,0.85), rgba(56,189,248,1) 30%, rgba(56,189,248,0.85))`,boxShadow:`0 0 6px rgba(56,189,248,0.55)`,transition:C,willChange:`left`},children:(0,K.jsx)(`div`,{className:`absolute -top-0.5 -translate-x-1/2 w-2 h-2 rotate-45 bg-sky-300`,style:{boxShadow:`0 0 6px rgba(56,189,248,0.7)`}})}),S&&(0,K.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 pointer-events-none`,style:{width:`8px`,background:`linear-gradient(to left, rgba(74,222,128,0.55), rgba(74,222,128,0))`},"aria-hidden":!0,children:(0,K.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 w-[2px] bg-emerald-400 pulse-soft`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-mono text-[var(--color-fg-4)]`,children:[(0,K.jsx)(`span`,{children:cf(r)}),(0,K.jsx)(`span`,{className:`uppercase tracking-wider transition-colors ${p?`text-sky-300`:``}`,children:p?`↳ ${cf(p.ts)}`:`${lf(t.window_ms)} window`}),(0,K.jsx)(`span`,{children:cf(i)})]})]})}function sf(e){let t=Date.now()-e;if(Math.abs(t)<1500)return`live`;let n=Math.round(t/1e3);if(n<60)return`−${n}s`;let r=Math.floor(n/60);return r<60?`−${r}m${n%60}s`:`−${Math.floor(r/60)}h${r%60}m`}function cf(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function lf(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}var uf=320,df=8,ff=12;function pf(e){let{burst:t,anchor:n,onClose:r}=e,i=(0,_.useRef)(null),[a,o]=(0,_.useState)({left:-9999,top:-9999});if((0,_.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&r()},n=e=>{i.current&&!i.current.contains(e.target)&&r()};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,n),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,n)}},[t,r]),(0,_.useLayoutEffect)(()=>{if(!t||!n||!i.current)return;let e=i.current.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,s=e.height>0?e.height:280,c=n.x+ff+uf>r?n.x-ff-uf:n.x+ff,l=n.y+ff+s>a?n.y-ff-s:n.y+ff;c=Math.min(Math.max(df,c),r-uf-df),l=Math.min(Math.max(df,l),a-s-df),o({left:c,top:l})},[t,n]),(0,_.useEffect)(()=>{o({left:-9999,top:-9999})},[t]),!t||!n)return null;let s=Ya[t.decision]??`#6b7280`,c=t.duration_ns/1e6,l=Date.now()-t.ts_ms;return(0,K.jsxs)(`div`,{ref:i,className:`fixed z-50 flex flex-col gap-3 text-[12px] font-mono rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] shadow-2xl p-4`,style:{left:a.left,top:a.top,width:uf,maxHeight:`80vh`,overflowY:`auto`},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`node · inspect`}),(0,K.jsx)(`button`,{onClick:r,className:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] cursor-pointer`,title:`Close inspector`,children:`✕`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full`,style:{background:s},"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`uppercase tracking-wider`,style:{color:s},children:t.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:t.tool})]}),(0,K.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[11px]`,children:[(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`rule`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-all`,children:t.rule_id??`—`}),(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`client`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.client}),(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`agent`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.agent_id?(0,K.jsx)(`span`,{className:`chip text-violet-300 border-violet-500/30`,children:t.agent_id}):(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}),(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`eval duration`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:c<1?`${(c*1e3).toFixed(0)}µs`:`${c.toFixed(2)}ms`}),t.complete_duration_ms!=null&&t.complete_duration_ms>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`tool duration`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:t.complete_duration_ms>=1e3?`${(t.complete_duration_ms/1e3).toFixed(2)}s`:`${t.complete_duration_ms.toFixed(0)}ms`})]}),t.message&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`reason`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-words`,children:t.message})]}),(t.input_tokens!=null||t.output_tokens!=null)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`tokens`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:gf(t.input_tokens,t.output_tokens)})]}),(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`age`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:mf(l)}),(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)]`,children:`timestamp`}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)]`,children:new Date(t.ts_ms).toLocaleString()})]}),t.input_preview&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:`input`}),(0,K.jsx)(`pre`,{className:`bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm p-2 text-[10px] text-[var(--color-fg-2)] whitespace-pre-wrap break-all max-h-48 overflow-y-auto`,children:t.input_preview})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.audit_id&&(0,K.jsx)(`a`,{href:`/audit?id=${encodeURIComponent(t.audit_id)}`,className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:text-[var(--color-fg-1)]`,title:`Open full audit record`,children:`audit ↗`}),t.rule_id&&(0,K.jsx)(`a`,{href:`/rules#${encodeURIComponent(t.rule_id)}`,className:`chip text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:text-[var(--color-fg-1)]`,title:`Jump to rule`,children:`rule ↗`})]})]})}function mf(e){if(e<1500)return`just now`;let t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m${t%60}s ago`:`${Math.floor(n/60)}h${n%60}m ago`}function hf(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.round(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}function gf(e,t){let n=[];return e!=null&&n.push(`${hf(e)} in`),t!=null&&n.push(`${hf(t)} out`),n.length>0?n.join(` · `):`—`}function _f(e){let t=new Map;for(let n of e){let e=`${n.client}:${n.agent_id??`solo`}`,r=t.get(e);r?(r.count+=1,n.ts_ms>r.newest_ts_ms&&(r.newest_ts_ms=n.ts_ms)):t.set(e,{client:n.client,agent_id:n.agent_id??`solo`,count:1,newest_ts_ms:n.ts_ms})}return Array.from(t.values()).sort((e,t)=>t.newest_ts_ms===e.newest_ts_ms?t.count-e.count:t.newest_ts_ms-e.newest_ts_ms)}function vf(e){let{bursts:t,allBursts:n}=e,r=n??t,{toolCounts:i,decisionCounts:a,ruleCounts:o,unmatchedCount:s}=(0,_.useMemo)(()=>{let e=new Map,n=new Map,r=new Map,i=0;for(let a of t)if(e.set(a.tool,(e.get(a.tool)??0)+1),n.set(a.decision,(n.get(a.decision)??0)+1),a.rule_id){let e=r.get(a.rule_id);e?(e.count+=1,e.decisions.add(a.decision)):r.set(a.rule_id,{count:1,decisions:new Set([a.decision])})}else i+=1;return{toolCounts:Array.from(e.entries()).sort((e,t)=>t[1]-e[1]),decisionCounts:Array.from(n.entries()),ruleCounts:Array.from(r.entries()).map(([e,t])=>({id:e,count:t.count,decisions:t.decisions})).sort((e,t)=>t.count-e.count),unmatchedCount:i}},[t]),c=(0,_.useMemo)(()=>_f(r),[r]),l=i[0]?.[1]??0,u=c[0]?.count??0,d=o[0]?.count??0,f=e=>{for(let t of[`block`,`ask`,`force`,`log`,`allow`,`shadow`])if(e.has(t))return Ya[t];return`#6b7280`};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 text-[11px] font-mono`,children:[(0,K.jsx)(`div`,{className:`rounded-sm border border-[var(--color-line-0)] bg-[var(--color-surface-0)] p-2 text-[10px] text-[var(--color-fg-3)] leading-relaxed`,children:`Each dot is one tool call by an AI agent. Color encodes the ssg rule decision; lines link calls from the same agent in time order.`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`rules · `,o.length,` matched`,s>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-[var(--color-fg-4)] normal-case tracking-normal`,children:[s,` unmatched`]})]}),o.length===0?(0,K.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no rules matched in window`}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:o.slice(0,6).map(e=>{let t=d>0?e.count/d*100:0,n=f(e.decisions);return(0,K.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,title:`${e.id} — decisions: ${Array.from(e.decisions).join(`, `)}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:n},"aria-hidden":!0}),(0,K.jsx)(`a`,{href:`/rules#${encodeURIComponent(e.id)}`,className:`truncate text-[var(--color-fg-2)] hover:text-[var(--color-fg-1)]`,children:e.id}),(0,K.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full`,style:{background:n,width:`${t}%`,opacity:.6}})})]}),(0,K.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:e.count})]},e.id)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:`decisions`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[`allow`,`block`,`ask`,`log`,`force`,`shadow`].map(e=>{let t=a.find(([t])=>t===e)?.[1]??0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:Ya[e]},"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] uppercase tracking-wider`,children:e}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums`,children:t})]},e)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`agents · `,c.length,` active`,n&&n!==t&&(0,K.jsx)(`span`,{className:`ml-2 text-[var(--color-fg-4)] normal-case tracking-normal`,children:`roster: today`})]}),c.length===0?(0,K.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no agents in window`}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:c.slice(0,8).map(e=>{let t=u>0?e.count/u*100:0,n=`${e.client}:${e.agent_id}`,r=Date.now()-e.newest_ts_ms,i=r<5e3;return(0,K.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,title:`${n} — last eval ${Math.max(0,Math.round(r/1e3))}s ago`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i?(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft shrink-0`,"aria-hidden":!0}):(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-[var(--color-fg-4)]/40`,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:[e.client,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`:`,e.agent_id]})]}),(0,K.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full bg-violet-400/60`,style:{width:`${t}%`}})})]}),(0,K.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:e.count})]},n)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`overline text-[var(--color-fg-3)] mb-1`,children:[`tools · `,t.length,` in window`]}),i.length===0?(0,K.jsx)(`p`,{className:`text-[var(--color-fg-4)]`,children:`no tool activity`}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:i.slice(0,8).map(([e,t])=>{let n=l>0?t/l*100:0;return(0,K.jsxs)(`li`,{className:`grid grid-cols-[1fr_auto] items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:e}),(0,K.jsx)(`div`,{className:`flex-1 h-1 bg-[var(--color-surface-1)] rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full bg-sky-400/60`,style:{width:`${n}%`}})})]}),(0,K.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-4)]`,children:t})]},e)})})]})]})}var yf=[100,500,1e3,5e3,1e4,1e5];function bf(e){return e>=1e5||e>=1e3?`${e/1e3|0}k`:String(e)}function xf(e){let t=Math.floor(e/100),n=Math.floor(t/600),r=Math.floor(t%600/10),i=t%10;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}.${i}`}function Sf(e){let t=Math.floor(e/100);return`${Math.floor(t/10)}.${t%10}s`}function Cf({className:e,onMilestone:t,onRecord:n}){let r=(0,_.useRef)(null),i=(0,_.useRef)(null),[a,o]=(0,_.useState)(0),[s,c]=(0,_.useState)(0),[l,u]=(0,_.useState)(0),[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(0),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=Ee(),C=Oe(),w=De(),T=(0,_.useRef)(null),E=(0,_.useRef)(0),D=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(0),A=(0,_.useRef)(new Set),j=(0,_.useRef)(performance.now());(0,_.useEffect)(()=>{let e=performance.now();if(ot()){let t=setInterval(()=>{let t=performance.now();r.current&&(r.current.textContent=xf(t-e)),i.current&&(i.current.textContent=Sf(t-j.current))},1e3);return()=>clearInterval(t)}let[t]=vr(()=>{let t=performance.now();r.current&&(r.current.textContent=xf(t-e)),i.current&&(i.current.textContent=Sf(t-j.current))});return t},[]);let M=(0,_.useRef)(0);return(0,_.useEffect)(()=>{if(T.current===null){T.current=C,E.current=C;return}if(C<=E.current)return;let e=C-E.current;E.current=C,u(n=>{let r=n+e,i=yf.find(e=>e>k.current&&r>=e);return i&&(k.current=i,g(bf(i)),x(!0),t?.(),setTimeout(()=>{g(``),x(!1)},700)),r});let r=Date.now();if(r-M.current>=1e3){M.current=r;let e=w.filter(e=>r-e.ts_ms<=6e4);f(new Set(e.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size)}S?.rule_id&&A.current.add(S.rule_id),m(A.current.size),S&&(S.decision===`block`?(D.current=0,o(0),j.current=performance.now()):(D.current+=e,D.current>O.current&&(O.current=D.current,c(O.current),y(!0),n?.(),setTimeout(()=>y(!1),450)),o(D.current)))},[C,S,w,t,n]),(0,K.jsxs)(`div`,{className:G(`pointer-events-none select-none`,`flex flex-col gap-2 p-3 rounded-md`,`bg-[var(--color-bg-2,#0c0d12)]/95`,`border border-[var(--color-border-1,#1c1f26)]`,`shadow-lg shadow-black/40`,`min-w-[180px] font-mono text-[11px]`,`text-[var(--color-fg-2,#9aa1ad)]`,b&&`milestone-ring`,e),"aria-label":`Live engagement counters`,children:[(0,K.jsx)(wf,{label:`uptime`,children:(0,K.jsx)(`span`,{ref:r,className:`tabular-nums text-[var(--color-fg-0,#e6e8ed)] text-[15px] tracking-tight`,children:`00:00.0`})}),(0,K.jsx)(wf,{label:`evals`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(fr,{value:l,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`}),h&&(0,K.jsxs)(`span`,{className:`text-[10px] text-emerald-400 uppercase tracking-wide`,children:[`+`,h]})]})}),(0,K.jsx)(wf,{label:`since block`,children:(0,K.jsx)(`span`,{ref:i,className:`tabular-nums text-emerald-300 text-[15px]`,children:`0.0s`})}),(0,K.jsx)(wf,{label:`streak / best`,children:(0,K.jsxs)(`span`,{className:G(`tabular-nums text-[15px]`,v?`record-beat`:`text-[var(--color-fg-0,#e6e8ed)]`),children:[(0,K.jsx)(fr,{value:a,curve:`spring`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4,#5a6071)] mx-1`,children:`/`}),(0,K.jsx)(fr,{value:s})]})}),(0,K.jsx)(wf,{label:`agents`,children:(0,K.jsx)(fr,{value:d,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})}),(0,K.jsx)(wf,{label:`rules`,children:(0,K.jsx)(fr,{value:p,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})})]})}function wf({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`uppercase tracking-wider text-[10px] text-[var(--color-fg-4,#5a6071)]`,children:e}),t]})}var Tf=80,Ef=600,Df=Object.freeze({stop:()=>{},count:0}),Of=new Set([`allow`,`block`,`ask`,`log`,`force`,`shadow`]);function kf(e){if(!Lo()||e.length===0)return Df;let t=[],n=!1,r=0;for(let i=0;i<e.length;i++){let a=e[i];if(i>0){let t=e[i-1],n=Math.max(0,a.ts_ms-t.ts_ms),o=Tf+Math.log2(1+n)*14;r+=Math.max(Tf,Math.min(Ef,o))}let o=Of.has(a.decision)?a.decision:null;if(!o)continue;let s=setTimeout(()=>{n||Uo(o)},r);t.push(s)}return{count:t.length,stop(){if(!n){n=!0;for(let e of t)clearTimeout(e);t.length=0}}}}function Af(e){let{sessionKey:t,entries:n,loading:r,error:i,playingIndex:a}=e,o=(0,_.useRef)(null),s=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{if(a<0)return;let e=s.current.get(a);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},[a]);let c=e=>t=>{t?s.current.set(e,t):s.current.delete(e)};return(0,K.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,K.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:`audit log`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-2)] truncate`,title:t,children:t})]}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:r?`loading…`:i?`error`:`${n.length} event${n.length===1?``:`s`}`})]}),(0,K.jsxs)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto divide-y divide-[var(--color-line-1)]/40`,children:[i&&(0,K.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-rose-300`,children:i}),!i&&!r&&n.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No audit entries for this session yet.`}),n.map((e,t)=>{let n=Ya[e.decision]??`#6b7280`,r=t===a,i=e.duration_ns==null?null:e.duration_ns/1e6;return(0,K.jsxs)(`div`,{ref:c(t),className:`relative px-3 py-2 transition-colors ${r?`bg-white/[0.04] ring-1 ring-inset ring-sky-400/40`:`hover:bg-white/[0.02]`}`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`absolute left-0 top-0 bottom-0 w-1`,style:{background:n}}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] font-mono`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`uppercase tracking-wider shrink-0`,style:{color:n},children:e.decision}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate`,children:e.tool})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-[var(--color-fg-4)] tabular-nums`,children:jf(e.ts_ms)})]}),(e.rule_id||i!=null)&&(0,K.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] font-mono text-[var(--color-fg-4)]`,children:[e.rule_id&&(0,K.jsxs)(`span`,{className:`truncate`,title:e.rule_id,children:[`rule · `,e.rule_id]}),i!=null&&(0,K.jsx)(`span`,{className:`tabular-nums shrink-0`,children:i<1?`${(i*1e3).toFixed(0)}µs`:`${i.toFixed(2)}ms`})]}),e.rule_message&&(0,K.jsx)(`div`,{className:`mt-1 text-[10px] font-mono text-[var(--color-fg-3)] break-words`,children:e.rule_message}),e.input_preview&&(0,K.jsx)(`pre`,{className:`mt-1 text-[10px] text-[var(--color-fg-3)] whitespace-pre-wrap break-all bg-black/30 rounded-sm px-2 py-1 max-h-24 overflow-y-auto`,children:e.input_preview})]},e.id)})]})]})}function jf(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}`}var Mf=1200,Nf=3e4,Pf=3e3,Ff=6,If=3,Lf=`graph.panelState.v1`,Rf=14400*1e3;function zf(e,t){let n=new Map;for(let t of e){let e=Ja(t),r=n.get(e);r?r.push(t):n.set(e,[t])}for(let[e,r]of n){let i=t.get(e);i&&i.length===r.length&&i[i.length-1]===r[r.length-1]&&n.set(e,i)}return n}function Bf(){if(typeof window>`u`)return new Map;try{let e=window.localStorage.getItem(Lf);if(!e)return new Map;let t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Vf(e){if(!(typeof window>`u`))try{let t={};for(let[n,r]of e)t[n]=r;window.localStorage.setItem(Lf,JSON.stringify(t))}catch{}}function Hf(){let e=uo(),t=Oe(),n=Ee(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),s=(0,_.useCallback)((e,t)=>{i(e),o(t??null)},[]),c=Us();(0,_.useEffect)(()=>{n&&(n.decision===`block`?c.play(`block`):n.decision===`force`&&c.play(`force`))},[t]);let l=(0,_.useCallback)(()=>c.play(`milestone`),[c]),u=(0,_.useCallback)(()=>c.play(`record`),[c]),[d,f]=(0,_.useState)(()=>{if(typeof window>`u`)return`full`;try{let e=window.localStorage.getItem(`graph.viewMode.v1`);if(e===`full`||e===`feed`||e===`stream`||e===`broadcast`)return e}catch{}return`full`});(0,_.useEffect)(()=>{if(!(typeof window>`u`))try{window.localStorage.setItem(`graph.viewMode.v1`,d)}catch{}},[d]),(0,_.useEffect)(()=>{let e=e=>e===`full`?`feed`:e===`feed`?`stream`:e===`stream`?`broadcast`:`full`,t=t=>{if(t.key===`Escape`&&d!==`full`){f(`full`);return}if(t.key===`b`||t.key===`B`){let n=t.target?.tagName;if(n===`INPUT`||n===`TEXTAREA`)return;f(e)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[d]);let p=d===`broadcast`,m=d===`stream`,h=d===`feed`,g=m||p,v=p,y=m,[b,x]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`ssg.sfx.enabled`)===null}catch{return!1}}),S=(0,_.useCallback)(()=>{c.toggle(),x(!1)},[c]),[C,w]=(0,_.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 767px)`).matches);(0,_.useEffect)(()=>{let e=window.matchMedia(`(max-width: 767px)`),t=e=>w(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[T,E]=(0,_.useState)(!1),D=(0,_.useRef)(null),O=(0,_.useCallback)(async e=>{try{await fetch(`/api/json/graph/close-sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e.length>0?{session_keys:e}:{})})}catch{}E(!1),D.current&&clearTimeout(D.current)},[]),k=(0,_.useCallback)(e=>{if(!T){E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),3e3);return}O(e)},[T,O]);(0,_.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let A=(0,_.useRef)(new Map),j=(0,_.useRef)(0),[M,N]=(0,_.useState)({fps:0,active:0,hitches:0}),ee=(0,_.useCallback)((e,t)=>{A.current.set(e,t),t>33&&(j.current+=1)},[]);(0,_.useEffect)(()=>{let e=setInterval(()=>{let e=A.current,t=j.current;if(j.current=0,e.size===0){N(e=>e.active===0?e:{fps:0,active:0,hitches:0});return}let n=0;for(let t of e.values())n+=t;let r=n/e.size,i=r>0?Math.max(1,Math.round(1e3/r)):0;N(n=>n.fps===i&&n.active===e.size&&n.hitches===t?n:{fps:i,active:e.size,hitches:t})},1e3);return()=>clearInterval(e)},[]);let{bursts:te,playback:P,oldest_known_ms:F,newest_known_ms:ne,loading_backfill:re}=e.snapshot,ie=(0,_.useRef)(new Map),I=(0,_.useMemo)(()=>{let e=zf(te,ie.current);return ie.current=e,e},[te]),[L,R]=(0,_.useState)(()=>Bf()),[z,ae]=(0,_.useState)(null);(0,_.useEffect)(()=>{Vf(L)},[L]),(0,_.useEffect)(()=>{let e=Date.now(),t=!1,n=new Map(L);for(let r of I.keys())n.has(r)||(n.set(r,{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:e}),t=!0);for(let[r,i]of n)I.has(r)||i.pinned||e-i.firstSeenAt<Rf||(n.delete(r),t=!0);t&&R(n)},[I,L]);let oe=(0,_.useRef)(new Map),se=(0,_.useRef)(new Set),ce=(0,_.useRef)(new Map),[,le]=(0,_.useState)(0);(0,_.useEffect)(()=>{let e=performance.now(),t=oe.current,n=se.current,r=ce.current,i=new Set;for(let[e,n]of I)i.add(e),r.set(e,n.slice()),t.delete(e);for(let a of n)if(!i.has(a)&&!t.has(a)){let n=r.get(a)??[],i=n[n.length-1]?.ts_ms??0;t.set(a,{bursts:n,diedAt:e,newestTs:i})}for(let[n,i]of t)e-i.diedAt>=Mf&&(t.delete(n),r.delete(n));if(se.current=i,t.size>0){let n=1/0;for(let e of t.values())n=Math.min(n,e.diedAt+Mf);let r=Math.max(16,n-e+16),i=setTimeout(()=>le(e=>e+1),r);return()=>clearTimeout(i)}},[I]);let ue=(0,_.useCallback)(e=>{R(t=>{let n=new Map(t),r=n.get(e)??{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()};return n.set(e,{...r,pinned:!r.pinned,pinnedAt:r.pinned?0:Date.now()}),n})},[]),de=(0,_.useCallback)(e=>{R(t=>{let n=new Map(t),r=n.get(e)??{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()};return n.set(e,{...r,minimized:!r.minimized}),n})},[]),fe=(0,_.useCallback)(e=>{ae(t=>t===e?null:e)},[]);(0,_.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&ae(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let pe=(0,_.useRef)(null),[me,he]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!z){pe.current?.stop(),pe.current=null,he(null);return}let e=!1;he({sessionKey:z,entries:[],loading:!0,error:null});let t=`/api/json/graph/session-audit?session_key=${encodeURIComponent(z)}`;return fetch(t,{credentials:`same-origin`}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(e)return;let n=Array.isArray(t.rows)?t.rows:[];he({sessionKey:z,entries:n,loading:!1,error:null});let r=n.map(e=>({ts_ms:e.ts_ms,decision:e.decision,tool:e.tool}));pe.current?.stop(),pe.current=kf(r)}).catch(t=>{e||he({sessionKey:z,entries:[],loading:!1,error:t instanceof Error?t.message:`failed to load audit log`})}),()=>{e=!0,pe.current?.stop(),pe.current=null}},[z]);let ge=(0,_.useMemo)(()=>{let e={pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()},t=[];for(let[n,r]of I){let i=r[r.length-1]?.ts_ms??0;t.push({key:n,bursts:r,newestTs:i,fadingOutAt:null,state:L.get(n)??e})}for(let[n,r]of oe.current)I.has(n)||t.push({key:n,bursts:r.bursts,newestTs:r.newestTs,fadingOutAt:r.diedAt,state:L.get(n)??e});return t.sort((e,t)=>e.state.pinned===t.state.pinned?e.state.pinned&&t.state.pinned?e.state.pinnedAt-t.state.pinnedAt:e.state.firstSeenAt-t.state.firstSeenAt:e.state.pinned?-1:1),t},[I,L]),_e=(0,_.useMemo)(()=>{if(!r)return null;for(let e of te)if((e.audit_id??`${e.ts_ms}:${e.tool}`)===r||r.startsWith(`${e.ts_ms}:${e.tool}`))return e;return null},[te,r]),[ve,ye]=(0,_.useState)(null),be=(0,_.useRef)(null),xe=(0,_.useMemo)(()=>{if(ge.length===0)return be.current=null,null;if(ve!=null&&ge.some(e=>e.key===ve))return be.current=ve,ve;let e=ge.filter(e=>e.state.pinned);if(e.length>0)return e.sort((e,t)=>t.state.pinnedAt-e.state.pinnedAt),be.current=e[0].key,e[0].key;let t=ge[0];for(let e of ge)e.newestTs>t.newestTs&&(t=e);let n=be.current;if(n!=null&&n!==t.key){let e=ge.find(e=>e.key===n);if(e&&Date.now()-e.newestTs<Pf)return n}return be.current=t.key,t.key},[ge,ve]);(0,_.useEffect)(()=>{ve!=null&&(ge.some(e=>e.key===ve)||ye(null))},[ve,ge]),(0,_.useEffect)(()=>{ye(null)},[d]);let Se=(0,_.useMemo)(()=>{if(ge.length===0)return{hero:null,grid:[],rail:[],overflow:[]};if(d===`full`||d===`feed`)return{hero:null,grid:ge.slice(0,Ff),rail:ge.slice(Ff),overflow:[]};let e=ge.find(e=>e.key===xe)??ge[ge.length-1],t=ge.filter(t=>t.key!==e.key);return d===`broadcast`?{hero:e,grid:[],rail:[],overflow:t}:{hero:e,grid:[],rail:t.slice(0,If),overflow:t.slice(If)}},[ge,d,xe]),Ce=(0,_.useCallback)(e=>{ye(e)},[]),we=(0,_.useCallback)(()=>{ye(null)},[]),Te=(0,_.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;for(let o of ge){let s=o.key;e.set(s,()=>ue(s)),t.set(s,()=>de(s)),n.set(s,()=>fe(s)),r.set(s,()=>void O([s])),i.set(s,e=>ee(s,e)),a.set(s,()=>Ce(s))}return{onTogglePin:e,onToggleMinimize:t,onToggleFullscreen:n,onClose:r,onFrameTime:i,onPromote:a}},[ge.map(e=>e.key).join(`,`),ue,de,fe,O,ee,Ce]);(0,_.useEffect)(()=>{let e=new Set(ge.map(e=>e.key)),t=A.current;for(let n of Array.from(t.keys()))e.has(n)||t.delete(n)},[ge]);let De=(0,_.useMemo)(()=>{let e=n?.counters,t=e?.total??0,r=(e?.block??0)+(e?.force??0),i=0;if(te.length>0){let e=0,t=te.slice(-100);for(let n of t)e+=n.duration_ns;i=e/t.length/1e6}return{evals:t,blocks:r,avgMs:i,agents:ge.length}},[n,te,ge.length]),B=Math.min(F,P.playhead_ms-P.window_ms),ke=Math.max(ne,P.playhead_ms),V=Se.grid.length,Ae=C||V<=1?1:V<=4?2:3,je=Math.max(1,Math.ceil(Math.max(1,V)/Ae)),Me=V<=1||C?360:180,Ne=z?ge.find(e=>e.key===z):null,Pe=e=>e>=1e4?`${Math.round(e/1e3)}k`:e.toLocaleString();return(0,K.jsxs)(`div`,{className:`grid gap-3 md:h-[calc(100dvh-4.5rem)] md:min-h-[560px] ${g?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[auto_minmax(0,1fr)_auto]`} ${p?`bg-black`:``}`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between flex-wrap gap-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-sm font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`graph intelligence`}),!p&&(0,K.jsx)(`span`,{className:`chip text-sky-300 border-sky-500/30`,children:`real-time tool-use`}),P.mode===`live`?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`streaming`]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-amber-300`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-amber-400`}),P.mode]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-x-3 gap-y-1 flex-wrap text-[11px] font-mono text-[var(--color-fg-3)] pl-3 border-l border-[var(--color-line-1)]`,children:[(0,K.jsxs)(`span`,{title:`Total evaluations since daemon start`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`↑`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:Pe(De.evals)}),` `,(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`evals`})]}),(0,K.jsxs)(`span`,{title:`Block + force decisions — dangerous tool calls intercepted by SSG rules`,children:[(0,K.jsx)(`span`,{className:`text-rose-400`,children:`⛔`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:Pe(De.blocks)}),` `,(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`blocks`})]}),(0,K.jsxs)(`span`,{className:`hidden md:inline`,title:`Mean eval latency over the last 100 bursts`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`⏱`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:De.avgMs<1?`${(De.avgMs*1e3).toFixed(0)}µs`:`${De.avgMs.toFixed(1)}ms`})]}),(0,K.jsxs)(`span`,{title:`Concurrent agent sessions in this window`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`⌥`}),` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:De.agents}),` `,(0,K.jsxs)(`span`,{className:`hidden sm:inline`,children:[`agent`,De.agents===1?``:`s`]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!p&&(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:[te.length,`n · window `,Math.round(P.window_ms/1e3),`s`]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,title:`Average RAF interval across ${M.active} canvas${M.active===1?``:`es`}${M.hitches>0?` · ${M.hitches} hitch${M.hitches===1?``:`es`} (>33ms frames)`:``}`,children:[M.active===0?`—`:`${M.fps}fps${M.hitches>0?` (${M.hitches}h)`:``}`,` · `,M.active,`/`,ge.length]}),(0,K.jsx)(`div`,{role:`group`,"aria-label":`Graph view mode`,className:`inline-flex items-stretch rounded border border-[var(--color-line-1)] overflow-hidden text-[10px] font-mono uppercase tracking-wider`,title:`View mode — B cycles, Esc returns to full`,children:[`full`,`feed`,`stream`,`broadcast`].map(e=>{let t=d===e,n=e===`broadcast`?`cast`:e,r=e===`full`?`Full dashboard — sidebar, timeline, all controls`:e===`feed`?`Feed mode — vertical timeline of tool calls for non-technical users`:e===`stream`?`Stream mode — spotlight layout for Twitch/YouTube viewers`:`Broadcast mode — pure canvas for OBS scenes (Esc to exit)`;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":t,title:r,className:`px-2 py-0.5 transition-colors cursor-pointer ${t?e===`broadcast`?`bg-amber-500/15 text-amber-300`:e===`stream`?`bg-sky-500/15 text-sky-300`:e===`feed`?`bg-emerald-500/15 text-emerald-300`:`bg-[var(--color-fg-4)]/10 text-[var(--color-fg-1)]`:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] hover:bg-white/5`}`,children:n},e)})}),(0,K.jsx)(`button`,{type:`button`,onClick:S,className:`chip cursor-pointer transition-colors ${b&&!c.enabled?`border-amber-500/60 text-amber-300 animate-pulse`:`hover:border-sky-500/50 hover:text-sky-300`}`,title:c.enabled?`Mute stream sounds`:`Enable stream sounds`,children:c.enabled?`SFX ON`:b?`🔊 enable cues`:`SFX OFF`}),!p&&ge.length>0&&(0,K.jsx)(`div`,{"aria-live":`polite`,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":`Clear all visible graph sessions`,onClick:()=>k(ge.filter(e=>!e.fadingOutAt).map(e=>e.key)),className:`chip cursor-pointer transition-colors ${T?`border-rose-500/60 text-rose-300`:`hover:border-rose-500/40 hover:text-rose-300`}`,title:`Close all active sessions on the graph — equivalent to /clear but reflects on the graph`,children:T?`confirm clear ${ge.filter(e=>!e.fadingOutAt).length}`:`clear`})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 ${v?``:y?`lg:grid-cols-[1fr_240px]`:`lg:grid-cols-[1fr_300px]`} gap-3 min-h-0 md:overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex flex-col gap-3 min-h-0 min-w-0`,children:h?(0,K.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:(0,K.jsx)(Qd,{bursts:te,selectedId:r,onSelect:s})}):ge.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-center px-4`,style:{minHeight:240},children:[(0,K.jsx)(`p`,{className:`overline mb-2 text-[var(--color-fg-3)]`,children:`graph · idle`}),(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] max-w-[280px]`,children:`No active sessions in the current window. Each session will render as its own tree as bursts arrive.`})]}):(0,K.jsxs)(K.Fragment,{children:[Se.hero&&(z==null||z===Se.hero.key)&&(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2`,children:[ve!=null&&(0,K.jsx)(`button`,{type:`button`,onClick:we,className:`self-end chip text-amber-300 border-amber-500/40 hover:border-amber-400 cursor-pointer text-[10px]`,title:`Release manual spotlight — return to auto-follow`,children:`spotlight: locked · release ↺`}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(Jd,{sessionKey:Se.hero.key,bursts:Se.hero.bursts,paused:P.mode!==`live`||Se.hero.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Se.hero.fadingOutAt!=null||P.playhead_ms-Se.hero.newestTs>Nf,isFadingOut:Se.hero.fadingOutAt!=null,minHeight:0,pinned:Se.hero.state.pinned,minimized:Se.hero.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:1,onTogglePin:Te.onTogglePin.get(Se.hero.key),onToggleMinimize:Te.onToggleMinimize.get(Se.hero.key),onToggleFullscreen:Te.onToggleFullscreen.get(Se.hero.key),onClose:Te.onClose.get(Se.hero.key),onFrameTime:Te.onFrameTime.get(Se.hero.key)},Se.hero.key)})]}),Se.grid.length>0&&(0,K.jsx)(`div`,{className:`flex-1 grid gap-3 min-h-0 min-w-0`,style:{gridTemplateColumns:`repeat(${Ae}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${je}, minmax(180px, 1fr))`},children:Se.grid.map(e=>{let n=e.fadingOutAt!=null||P.playhead_ms-e.newestTs>Nf;return z!=null&&z!==e.key?null:(0,K.jsx)(Jd,{sessionKey:e.key,bursts:e.bursts,paused:P.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:Me,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:Se.grid.length,onTogglePin:Te.onTogglePin.get(e.key),onToggleMinimize:Te.onToggleMinimize.get(e.key),onToggleFullscreen:Te.onToggleFullscreen.get(e.key),onClose:Te.onClose.get(e.key),onFrameTime:Te.onFrameTime.get(e.key)},e.key)})}),Se.rail.length>0&&(0,K.jsxs)(`div`,{className:`shrink-0 flex flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:[(0,K.jsxs)(`span`,{children:[d===`full`?`overflow rail`:`spotlight rail`,` · `,Se.rail.length,` session`,Se.rail.length===1?``:`s`]}),Se.overflow.length>0&&(0,K.jsxs)(`span`,{title:Se.overflow.map(e=>e.key).join(`
46
- `),children:[`+`,Se.overflow.length,` more`]})]}),(0,K.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${Math.min(Se.rail.length,4)}, minmax(0, 1fr))`,gridAutoRows:`110px`},children:Se.rail.map(e=>{let n=e.fadingOutAt!=null||P.playhead_ms-e.newestTs>Nf;return z!=null&&z!==e.key?null:(0,K.jsx)(Jd,{sessionKey:e.key,bursts:e.bursts,paused:P.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:110,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,thumbnail:!0,onPromote:Te.onPromote.get(e.key),activePanelCount:Se.rail.length+1,onTogglePin:Te.onTogglePin.get(e.key),onToggleMinimize:Te.onToggleMinimize.get(e.key),onToggleFullscreen:Te.onToggleFullscreen.get(e.key),onClose:Te.onClose.get(e.key),onFrameTime:Te.onFrameTime.get(e.key)},e.key)})})]}),d===`broadcast`&&Se.overflow.length>0&&(0,K.jsxs)(`div`,{className:`shrink-0 self-end pointer-events-none chip text-[var(--color-fg-3)] border-[var(--color-line-1)]`,children:[`+`,Se.overflow.length,` more session`,Se.overflow.length===1?``:`s`,` off-screen`]})]})}),!v&&(0,K.jsxs)(`aside`,{className:`flex flex-col gap-2 min-w-0 min-h-0 overflow-y-auto`,children:[(0,K.jsx)(Cf,{onMilestone:l,onRecord:u}),!y&&(0,K.jsx)(`section`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,K.jsx)(vf,{bursts:te,allBursts:e.allBursts})}),(0,K.jsx)(pf,{burst:_e,anchor:a,onClose:()=>{i(null),o(null)}})]})]}),!g&&(0,K.jsx)(`section`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,K.jsx)(of,{playback:P,bursts:te,rangeStart:B,rangeEnd:ke,loading:re,onPlayhead:t=>e.setPlayhead(t),onLive:()=>e.jumpToLive(),onPause:()=>e.setMode(`paused`),onResume:()=>e.setMode(`scrubbing`),on24h:()=>e.jumpTo24h()})}),p&&(0,K.jsxs)(`div`,{className:`pointer-events-none fixed bottom-3 right-4 flex flex-col items-end gap-1 z-30`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-mono uppercase tracking-[0.18em] text-[var(--color-fg-3)]`,children:`sigmashake gov`}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`broadcast mode · press B or Esc to exit`})]}),Ne&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 bg-black/90 backdrop-blur-sm flex p-6 gap-4`,children:[(0,K.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:(0,K.jsx)(Jd,{sessionKey:Ne.key,bursts:Ne.bursts,paused:P.mode!==`live`||Ne.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Ne.fadingOutAt!=null||P.playhead_ms-Ne.newestTs>Nf,isFadingOut:!1,minHeight:0,pinned:Ne.state.pinned,minimized:!1,isFullscreen:!0,viewMode:d,onTogglePin:()=>ue(Ne.key),onToggleMinimize:()=>de(Ne.key),onToggleFullscreen:()=>fe(Ne.key)},`fs-${Ne.key}`)}),(0,K.jsx)(`aside`,{className:`hidden md:flex shrink-0 w-[380px] lg:w-[420px] flex-col min-h-0`,children:(0,K.jsx)(Af,{sessionKey:Ne.key,entries:me?.sessionKey===Ne.key?me.entries:[],loading:me?.sessionKey===Ne.key?me.loading:!0,error:me?.sessionKey===Ne.key?me.error:null,playingIndex:-1})})]})]})}var Uf=100,Wf={"claude-code":`bg-orange-500/15 text-orange-300 border-orange-500/30`,cursor:`bg-sky-500/15 text-sky-300 border-sky-500/30`,copilot:`bg-emerald-500/15 text-emerald-300 border-emerald-500/30`,gemini:`bg-blue-500/15 text-blue-300 border-blue-500/30`,antigravity:`bg-purple-500/15 text-purple-300 border-purple-500/30`,codex:`bg-pink-500/15 text-pink-300 border-pink-500/30`,pi:`bg-amber-500/15 text-amber-300 border-amber-500/30`,generic:`bg-slate-500/15 text-slate-300 border-slate-500/30`};function Gf(e){if(!e)return`—`;let t=new Date(e*1e3),n=new Date,r=t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1});if(t.toDateString()===n.toDateString())return`Today ${r}`;let i=new Date(n);return i.setDate(i.getDate()-1),t.toDateString()===i.toDateString()?`Yesterday ${r}`:`${t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})} ${r}`}function Kf(e){if(e<1)return`—`;if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${t}h ${n}m`:`${t}h`}function qf({client:e}){return(0,K.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide ${Wf[e]??`bg-white/5 text-[var(--color-fg-3)] border-white/10`}`,children:e})}function Jf(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(0),{data:o,loading:s,error:c,refetch:l}=V(`/api/json/sessions/list?limit=${Uf}&offset=${e}`,[i]),u=ke([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{u>0&&a(e=>e+1)},[u]);let d=o?.sessions??[],f=o?.total??0,p=(0,_.useMemo)(()=>{if(!n.trim())return d;let e=n.toLowerCase();return d.filter(t=>t.session_key.toLowerCase().includes(e)||t.client.toLowerCase().includes(e)||(t.top_tool??``).toLowerCase().includes(e)||(t.top_rule??``).toLowerCase().includes(e))},[d,n]),m=d.filter(e=>e.is_active).length,h=d.reduce((e,t)=>e+t.evals,0),g=d.reduce((e,t)=>e+t.blocked,0),v=h>0?Math.round(g/h*1e3)/10:0;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,K.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Sessions`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1`,children:`Every AI agent session recorded by the daemon. Click a row to open its inspector — graph, charts, and full audit log.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:f.toLocaleString()}),` `,`total`]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-emerald-300 font-semibold`,children:m}),` `,`active`]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:h.toLocaleString()}),` `,`evals on page`]}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsxs)(`span`,{children:[(0,K.jsxs)(`span`,{className:v>0?`text-rose-300 font-semibold`:`text-emerald-300`,children:[v,`%`]}),` `,`blocked`]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:`Filter by client, session, tool, or rule…`,className:`flex-1 bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 text-[12px] font-mono focus:outline-none focus:ring-1 focus:ring-[var(--color-hig-blue)]`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(),className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wide border border-[var(--color-line-1)] rounded-sm hover:bg-white/5`,children:`Refresh`})]})]}),(0,K.jsx)(`div`,{className:`border border-[var(--color-line-1)] rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-[12px] font-mono`,children:[(0,K.jsx)(`thead`,{className:`bg-black/30 text-[var(--color-fg-3)] uppercase tracking-wide text-[10px]`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Status`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Client`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Session`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Started`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Duration`}),(0,K.jsx)(`th`,{className:`text-right px-3 py-2`,children:`Evals`}),(0,K.jsx)(`th`,{className:`text-right px-3 py-2 text-emerald-300/80`,children:`Allowed`}),(0,K.jsx)(`th`,{className:`text-right px-3 py-2 text-rose-300/80`,children:`Blocked`}),(0,K.jsx)(`th`,{className:`text-right px-3 py-2 text-amber-300/80`,children:`Asked`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Top Tool`}),(0,K.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Top Rule`})]})}),(0,K.jsxs)(`tbody`,{className:`divide-y divide-[var(--color-line-1)]/40`,children:[s&&p.length===0&&(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-[var(--color-fg-4)]`,children:`Loading sessions…`})}),c&&(0,K.jsx)(`tr`,{children:(0,K.jsxs)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-rose-300`,children:[`Failed to load sessions: `,c]})}),!s&&!c&&p.length===0&&(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-[var(--color-fg-4)]`,children:d.length===0?`No sessions recorded yet.`:`No sessions match "${n}".`})}),p.map(e=>{let t=e.evals>0?Math.round(e.blocked/e.evals*1e3)/10:0;return(0,K.jsxs)(`tr`,{className:`hover:bg-white/[0.03] cursor-pointer`,children:[(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`a`,{href:`/sessions/${encodeURIComponent(e.session_key)}`,className:`flex items-center gap-1.5 no-underline`,children:e.is_active?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,K.jsx)(`span`,{className:`text-emerald-300 text-[10px] uppercase tracking-wide`,children:`Live`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--color-fg-4)]`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-[10px] uppercase tracking-wide`,children:`Closed`})]})})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(qf,{client:e.client})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`a`,{href:`/sessions/${encodeURIComponent(e.session_key)}`,className:`text-[var(--color-fg-1)] hover:text-[var(--color-hig-blue)] hover:underline`,children:e.agent_id})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:Gf(e.started_at)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:Kf(e.duration_s)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right font-semibold`,children:e.evals.toLocaleString()}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right text-emerald-300`,children:e.allowed.toLocaleString()}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right`,children:e.blocked>0?(0,K.jsxs)(`span`,{className:`text-rose-300`,children:[e.blocked.toLocaleString(),t>0&&(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[10px]`,children:[`(`,t,`%)`]})]}):(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`0`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right text-amber-300`,children:e.asked>0?e.asked.toLocaleString():(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`0`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-2)] max-w-[180px] truncate`,children:e.top_tool??(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-2)] max-w-[200px] truncate`,children:e.top_rule??(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})})]},e.session_key)})]})]})})}),f>Uf&&(0,K.jsxs)(`footer`,{className:`flex items-center justify-between text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsxs)(`span`,{children:[e+1,`–`,Math.min(e+Uf,f),` of`,` `,f.toLocaleString()]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:e===0,onClick:()=>t(Math.max(0,e-Uf)),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`← Prev`}),(0,K.jsx)(`button`,{type:`button`,disabled:e+Uf>=f,onClick:()=>t(e+Uf),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`Next →`})]})]})]})}var Yf={allow:`#4ade80`,block:`#f87171`,ask:`#fbbf24`,force:`#a78bfa`,log:`#7dd3fc`,shadow:`#94a3b8`},Xf=[`<1ms`,`1-10ms`,`10-100ms`,`100ms-1s`,`>1s`];function Zf(e){return e?new Date(e*1e3).toLocaleString():`—`}function Qf(e){if(e<1)return`<1s`;if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m ${e%60}s`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${t}h ${n}m`:`${t}h`}function $f({title:e,hint:t,children:n}){return(0,K.jsxs)(`section`,{className:`flex flex-col rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0`,children:[(0,K.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:t})]}),(0,K.jsx)(`div`,{className:`p-3 flex flex-col gap-2 flex-1 min-h-0`,children:n})]})}function ep({allowed:e,blocked:t,asked:n,forced:r}){let i=e+t+n+r;if(i===0)return(0,K.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No evals recorded.`});let a=[{label:`allow`,value:e,color:Yf.allow},{label:`block`,value:t,color:Yf.block},{label:`ask`,value:n,color:Yf.ask},{label:`force`,value:r,color:Yf.force}].filter(e=>e.value>0),o=2*Math.PI*32,s=0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsxs)(`svg`,{width:`92`,height:`92`,viewBox:`-46 -46 92 92`,className:`shrink-0`,children:[(0,K.jsx)(`circle`,{r:32,fill:`none`,stroke:`#222`,strokeWidth:`12`}),a.map(e=>{let t=e.value/i*o,n=(0,K.jsx)(`circle`,{r:32,fill:`none`,stroke:e.color,strokeWidth:`12`,strokeDasharray:`${t} ${o-t}`,strokeDashoffset:-s,transform:`rotate(-90)`},e.label);return s+=t,n}),(0,K.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:`14`,fontFamily:`ui-monospace, monospace`,fill:`var(--color-fg-1)`,children:i})]}),(0,K.jsx)(`ul`,{className:`flex-1 flex flex-col gap-1 text-[11px] font-mono`,children:a.map(e=>{let t=Math.round(e.value/i*1e3)/10;return(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`size-2 rounded-sm shrink-0`,style:{background:e.color}}),(0,K.jsx)(`span`,{className:`uppercase tracking-wide text-[var(--color-fg-2)] w-12`,children:e.label}),(0,K.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-1)] font-semibold`,children:e.value}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[t,`%`]})]},e.label)})})]})}function tp({rows:e,maxRows:t=10,emptyMessage:n}){if(e.length===0)return(0,K.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:n});let r=e.slice(0,t),i=Math.max(...r.map(e=>e.value),1);return(0,K.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[11px] font-mono`,children:r.map(e=>{let t=Math.max(2,e.value/i*100);return(0,K.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,title:e.label,children:e.label}),(0,K.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-1)] font-semibold shrink-0`,children:e.value})]}),(0,K.jsx)(`div`,{className:`h-1 rounded-sm bg-white/5 overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full bg-[var(--color-hig-blue)]/70`,style:{width:`${t}%`}})}),e.sublabel&&(0,K.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-4)] truncate`,title:e.sublabel,children:e.sublabel})]},e.label)})})}function np({latency:e}){let t={};for(let n of e)t[n.bucket]=n.hits;let n=Math.max(...Object.values(t),1);return Object.values(t).reduce((e,t)=>e+t,0)===0?(0,K.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No latency data.`}):(0,K.jsx)(`div`,{className:`flex items-end gap-2 h-[80px]`,children:Xf.map(e=>{let r=t[e]??0;return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-1`,children:[(0,K.jsx)(`div`,{className:`w-full bg-[var(--color-hig-blue)]/60 rounded-sm`,style:{height:`${n>0?Math.round(r/n*70):0}px`,minHeight:r>0?`4px`:`0px`},title:`${r} evals in ${e}`}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-nowrap`,children:e}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:r})]},e)})})}function rp({sessionKey:e}){let[t,n]=(0,_.useState)(0),{data:r,loading:i,error:a}=V(`/api/json/sessions/detail?session_key=${encodeURIComponent(e)}&audit_limit=500`,[t]),o=ke([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{o>0&&r?.summary.is_active&&n(e=>e+1)},[o,r?.summary.is_active]);let s=(0,_.useMemo)(()=>{if(!r)return[];let e=r.tools.top.map(e=>({label:e.tool,value:e.hits}));return r.tools.other>0&&e.push({label:`(${r.tools.other} other)`,value:r.tools.other}),e},[r]),c=(0,_.useMemo)(()=>r?r.rules.map(e=>({label:e.rule_id,sublabel:e.rule_message,value:e.hits})):[],[r]);if(a)return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,K.jsxs)(`header`,{children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Session inspector`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:e})]}),(0,K.jsxs)(`div`,{className:`rounded-sm border border-rose-500/30 bg-rose-500/5 p-4 text-[12px] font-mono text-rose-300`,children:[a.includes(`404`)?`No audit entries found for this session. It may have been pruned, or the URL is malformed.`:`Failed to load session: ${a}`,(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(`a`,{href:`/sessions`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`← Back to sessions`})})]})]});if(i&&!r)return(0,K.jsxs)(`div`,{className:`p-4 text-[12px] font-mono text-[var(--color-fg-3)]`,children:[`Loading session `,e,`…`]});if(!r)return null;let{summary:l,audit:u,latency:d}=r,f=l.evals>0?Math.round(l.blocked/l.evals*1e3)/10:0;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 h-full min-h-0`,children:[(0,K.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsx)(`a`,{href:`/sessions`,className:`hover:underline`,children:`← Sessions`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`/`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:l.agent_id})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-lg font-semibold`,children:[l.client,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] font-mono text-[14px] ml-2`,children:l.agent_id})]}),(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 break-all`,children:l.session_id??`(no session_id — solo bucket)`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] font-mono`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm border ${l.is_active?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-white/5 border-white/10 text-[var(--color-fg-3)]`}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full ${l.is_active?`bg-emerald-400 animate-pulse`:`bg-[var(--color-fg-4)]`}`}),l.is_active?`Live`:`Closed`]}),(0,K.jsx)(ip,{label:`Evals`,value:l.evals.toLocaleString()}),(0,K.jsx)(ip,{label:`Blocked`,value:l.blocked>0?`${l.blocked} (${f}%)`:`0`,color:l.blocked>0?`text-rose-300`:void 0}),(0,K.jsx)(ip,{label:`Asked`,value:l.asked.toLocaleString(),color:`text-amber-300`}),(0,K.jsx)(ip,{label:`Started`,value:Zf(l.started_at)}),(0,K.jsx)(ip,{label:`Duration`,value:Qf(l.duration_s)})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 gap-3`,children:[(0,K.jsx)($f,{title:`Decisions`,hint:`${l.evals} evals`,children:(0,K.jsx)(ep,{allowed:l.allowed,blocked:l.blocked,asked:l.asked,forced:l.forced})}),(0,K.jsx)($f,{title:`Top tools`,hint:`${r.tools.top.length+(r.tools.other>0?1:0)} buckets`,children:(0,K.jsx)(tp,{rows:s,emptyMessage:`No tool activity.`})}),(0,K.jsx)($f,{title:`Top rules`,hint:`${c.length} hit`,children:(0,K.jsx)(tp,{rows:c,emptyMessage:`No rules matched this session.`})}),(0,K.jsx)($f,{title:`Latency`,hint:`duration buckets`,children:(0,K.jsx)(np,{latency:d})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-[400px]`,children:(0,K.jsx)(Af,{sessionKey:e,entries:u,loading:i,error:null,playingIndex:-1})})]})}function ip({label:e,value:t,color:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)]`,children:e}),(0,K.jsx)(`span`,{className:`tabular-nums ${n??`text-[var(--color-fg-1)]`}`,children:t})]})}var ap=[{id:`rca`,label:`rca`,hint:`pre-computed root cause`},{id:`timeline`,label:`timeline`,hint:`recent frames across traces`},{id:`watch`,label:`watch`,hint:`subscribe to any ssg:// URI`},{id:`state`,label:`state`,hint:`daemon runtime snapshot`},{id:`metrics`,label:`metrics`,hint:`latency + counters`}];function op(){let[e,t]=(0,_.useState)(`rca`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 min-h-[70vh]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h1`,{className:`text-sm font-mono uppercase tracking-wider text-[var(--color-fg-1)]`,children:`ai-native debugger`}),(0,K.jsx)(`span`,{className:`chip text-sky-300 border-sky-500/30`,children:`ssg:// unified resolver`}),(0,K.jsx)(sp,{})]}),(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`one surface · cli · mcp · dashboard`})]}),(0,K.jsx)(`nav`,{className:`flex items-center gap-1 border-b border-[var(--color-line-1)]`,children:ap.map(n=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),title:n.hint,className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider border-b-2 transition-colors `+(e===n.id?`border-[var(--color-brand)] text-[var(--color-fg-1)]`:`border-transparent text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`),children:n.label},n.id))}),(0,K.jsxs)(`section`,{className:`flex-1 min-h-0`,children:[e===`rca`&&(0,K.jsx)(cp,{}),e===`timeline`&&(0,K.jsx)(pp,{}),e===`watch`&&(0,K.jsx)(xp,{}),e===`state`&&(0,K.jsx)(Sp,{uri:`ssg://daemon/state`}),e===`metrics`&&(0,K.jsx)(Sp,{uri:`ssg://daemon/metrics`})]})]})}function sp(){let e=ke([`debug-frame`])[`debug-frame`]??0;return(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,title:`${e} debug-frame bursts received`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`live · `,e]})}function cp(){let e=ke([`debug-frame`,`activity-updated`]),{data:t,loading:n,error:r,refetch:i}=V(`/api/json/debug?uri=ssg%3A%2F%2Frca%2Fcurrent`,[e[`debug-frame`],e[`activity-updated`]]),a=t?.data?.pack??null;return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[1fr_340px] gap-4`,children:[(0,K.jsxs)(`article`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-4 space-y-3`,children:[n&&!t&&(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`loading RCA pack…`}),r&&(0,K.jsxs)(`p`,{className:`text-sm text-rose-300`,children:[`rca fetch error: `,r]}),!n&&!a&&(0,K.jsxs)(`div`,{className:`text-sm text-[var(--color-fg-3)] space-y-2`,children:[(0,K.jsx)(`p`,{className:`font-mono`,children:`no current RCA pack`}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Packs are composed automatically when an eval errors, an ssqa finding arrives, or a daemon-level error fires. Nothing to diagnose yet — you're green.`})]}),a&&(0,K.jsx)(up,{pack:a})]}),(0,K.jsxs)(`aside`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 text-[11px] font-mono text-[var(--color-fg-4)] space-y-2`,children:[(0,K.jsx)(`p`,{className:`uppercase tracking-wider text-[var(--color-fg-2)]`,children:`how claude sees this`}),(0,K.jsxs)(`pre`,{className:`text-[10px] whitespace-pre-wrap leading-snug`,children:[`ssg debug rca --current --json`,`
47
- `,`# or via MCP:`,`
48
- `,`ssg_debug_rca(`,`{`,`auto_current:true`,`}`,`)`]}),(0,K.jsx)(`button`,{type:`button`,onClick:i,className:`w-full mt-2 px-2 py-1 border border-[var(--color-line-1)] rounded-sm hover:bg-[var(--color-surface-2)]`,children:`refresh`}),t?.snapshot_hash&&(0,K.jsxs)(`p`,{className:`text-[10px] opacity-60`,children:[`hash `,t.snapshot_hash.slice(0,12),`…`]})]})]})}function lp(e){return e===`critical`?`text-rose-400 border-rose-500/40`:e===`high`?`text-amber-300 border-amber-500/40`:e===`medium`?`text-sky-300 border-sky-500/40`:`text-[var(--color-fg-3)] border-[var(--color-line-1)]`}function up({pack:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[`rca pack · `,new Date(e.ts_ms).toLocaleTimeString()]}),(0,K.jsx)(`h2`,{className:`text-[15px] font-medium text-[var(--color-fg-1)] mt-1`,children:e.summary}),e.trace_id&&(0,K.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)] mt-1`,children:[`trace_id · `,e.trace_id]})]}),(0,K.jsx)(`span`,{className:`chip uppercase text-[10px] tracking-wider `+lp(e.severity),children:e.severity})]}),e.hypothesis&&e.hypothesis.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`hypothesis`}),(0,K.jsx)(`ol`,{className:`space-y-2`,children:e.hypothesis.map((e,t)=>(0,K.jsxs)(`li`,{className:`p-2 rounded-sm bg-[var(--color-surface-2)] border border-[var(--color-line-1)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-1)]`,children:e.cause}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`conf `,(e.confidence*100).toFixed(0),`%`]})]}),e.evidence.length>0&&(0,K.jsx)(`ul`,{className:`mt-1 pl-3 text-[11px] text-[var(--color-fg-3)] list-disc list-inside space-y-0.5`,children:e.evidence.map((e,t)=>(0,K.jsx)(`li`,{children:e},t))})]},t))})]}),e.suggested_next_actions&&e.suggested_next_actions.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`suggested next actions`}),(0,K.jsx)(`ul`,{className:`space-y-1 text-[13px] text-[var(--color-fg-2)]`,children:e.suggested_next_actions.map((e,t)=>(0,K.jsxs)(`li`,{className:`font-mono text-[12px]`,children:[`→ `,e]},t))})]}),e.state_snapshot&&e.state_snapshot.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`expand`}),(0,K.jsx)(`ul`,{className:`space-y-1 text-[11px] font-mono`,children:e.state_snapshot.map(e=>(0,K.jsxs)(`li`,{className:`text-[var(--color-fg-3)]`,children:[(0,K.jsx)(`code`,{className:`text-sky-300`,children:e.uri}),(0,K.jsxs)(`span`,{className:`opacity-50 ml-2`,children:[e.hash.slice(0,10),`…`]})]},e.uri))})]})]})}var dp=[`hook-ingress`,`parse`,`match`,`ffi-call`,`decide`,`audit`,`respond`],fp={"hook-ingress":`#6ea8ff`,parse:`#a78bfa`,match:`#60d394`,"ffi-call":`#f59e0b`,decide:`#f472b6`,audit:`#94a3b8`,respond:`#22d3ee`};function pp(){let{data:e,loading:t,error:n}=V(`/api/json/debug?uri=ssg%3A%2F%2Fframes%2Frecent%3Flimit%3D1024`,[ke([`debug-frame`])[`debug-frame`]]),r=e?.data?.frames??[],i=e?.data?.dropped??0,[a,o]=(0,_.useState)(null);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[1fr_320px] gap-4`,children:[(0,K.jsxs)(`article`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:[`frames · `,r.length,i>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-amber-300`,children:[`dropped · `,i]})]}),(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:`ssg://frames/recent`})]}),n&&(0,K.jsxs)(`p`,{className:`text-sm text-rose-300`,children:[`timeline fetch error: `,n]}),t&&r.length===0?(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`loading…`}):r.length===0?(0,K.jsx)(mp,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gp,{frames:r,onSelect:o}),(0,K.jsx)(hp,{})]})]}),(0,K.jsxs)(`aside`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,K.jsx)(`p`,{className:`uppercase tracking-wider text-[var(--color-fg-2)]`,children:`frame inspector`}),a?(0,K.jsx)(_p,{frame:a}):(0,K.jsx)(`p`,{className:`opacity-60`,children:`click a bar to inspect`})]})]})}function mp(){return(0,K.jsxs)(`div`,{className:`text-[12px] text-[var(--color-fg-3)] space-y-1 py-4`,children:[(0,K.jsx)(`p`,{children:`no frames yet`}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] font-mono`,children:`SSG_DEBUG_ENABLED=1 ssg daemon`}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`then fire an eval — frames stream in live.`})]})}function hp(){return(0,K.jsx)(`div`,{className:`flex flex-wrap gap-3 text-[10px] font-mono text-[var(--color-fg-4)]`,children:dp.map(e=>(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:fp[e]}}),e]},e))})}function gp({frames:e,onSelect:t}){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(-1),{rows:o,tMin:s,tMax:c}=(0,_.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.trace_id)??[];e.push(n),t.set(n.trace_id,e)}let n=Array.from(t.entries()).map(([e,t])=>({trace_id:e,frames:t.slice().sort((e,t)=>yp(e.ts_start_ns,t.ts_start_ns))}));n.sort((e,t)=>yp(e.frames[0].ts_start_ns,t.frames[0].ts_start_ns));let r=null,i=null;for(let t of e){let e=BigInt(t.ts_start_ns),n=BigInt(t.ts_end_ns);(r===null||e<r)&&(r=e),(i===null||n>i)&&(i=n)}return{rows:n,tMin:r??0n,tMax:i??1n}},[e]);(0,_.useEffect)(()=>{let e=n.current;if(!e)return;let t=window.devicePixelRatio||1,a=e.clientWidth,l=Math.max(120,o.length*22+24);e.width=a*t,e.height=l*t,e.style.height=`${l}px`;let u=e.getContext(`2d`);if(!u)return;u.setTransform(t,0,0,t,0,0),u.clearRect(0,0,a,l),u.strokeStyle=`rgba(255,255,255,0.04)`,u.lineWidth=1;for(let e=1;e<4;e++){let t=e*a/4;u.beginPath(),u.moveTo(t,0),u.lineTo(t,l),u.stroke()}let d=c>s?Number(c-s):1,f=a-110-8;u.font=`10px ui-monospace, monospace`,u.textBaseline=`middle`;let p=[];if(o.forEach((e,t)=>{let n=8+t*22;u.fillStyle=`rgba(255,255,255,0.55)`,u.fillText(e.trace_id.slice(0,10),6,n+18/2);for(let t of e.frames){let e=Number(BigInt(t.ts_start_ns)-s),r=Number(BigInt(t.ts_end_ns)-s),i=110+e/d*f,a=Math.max(2,(r-e)/d*f);u.fillStyle=fp[t.stage]??`#888`,u.globalAlpha=t.result===`error`?1:.82,u.fillRect(i,n,a,18),u.globalAlpha=1,t.result===`error`&&(u.strokeStyle=`#f43f5e`,u.lineWidth=1.5,u.strokeRect(i+.5,n+.5,a-1,17)),p.push({x:i,y:n,w:a,h:18,frame:t})}}),r.current=p,i>=0&&i<p.length){let e=p[i];u.strokeStyle=`#fff`,u.lineWidth=1.5,u.strokeRect(e.x+.5,e.y+.5,e.w-1,e.h-1)}},[o,s,c,i]);function l(e){let t=n.current;if(!t)return-1;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;for(let e=r.current.length-1;e>=0;e--){let t=r.current[e];if(a>=t.x&&a<=t.x+t.w&&o>=t.y&&o<=t.y+t.h)return e}return-1}return(0,K.jsx)(`canvas`,{ref:n,className:`w-full block cursor-crosshair`,onMouseMove:e=>a(l(e)),onMouseLeave:()=>a(-1),onClick:e=>{let n=l(e);t(n>=0?r.current[n].frame:null)}})}function _p({frame:e}){let t=Number(BigInt(e.ts_end_ns)-BigInt(e.ts_start_ns)),n=t>=1e6?`${(t/1e6).toFixed(2)}ms`:t>=1e3?`${(t/1e3).toFixed(1)}µs`:`${t}ns`;return(0,K.jsxs)(`dl`,{className:`space-y-1`,children:[(0,K.jsxs)(vp,{k:`stage`,children:[(0,K.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm mr-1 align-middle`,style:{background:fp[e.stage]??`#888`}}),e.stage]}),(0,K.jsx)(vp,{k:`tool`,children:e.tool}),(0,K.jsx)(vp,{k:`result`,children:(0,K.jsx)(`span`,{className:e.result===`error`?`text-rose-300`:e.result===`skip`?`text-[var(--color-fg-4)]`:`text-emerald-300`,children:e.result})}),(0,K.jsx)(vp,{k:`dur`,children:n}),e.rule_id&&(0,K.jsx)(vp,{k:`rule`,children:e.rule_id}),e.error&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vp,{k:`err.type`,children:(0,K.jsx)(`span`,{className:`text-rose-300`,children:e.error.type})}),(0,K.jsx)(vp,{k:`err.msg`,children:(0,K.jsx)(`span`,{className:`text-rose-200`,children:e.error.message})})]}),e.input_preview&&(0,K.jsx)(vp,{k:`input`,children:(0,K.jsx)(`code`,{className:`text-[10px] break-all`,children:e.input_preview})}),(0,K.jsx)(vp,{k:`trace`,children:(0,K.jsx)(`code`,{className:`text-[10px]`,children:e.trace_id})}),(0,K.jsx)(vp,{k:`frame`,children:(0,K.jsx)(`code`,{className:`text-[10px]`,children:e.frame_id})})]})}function vp({k:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex gap-2 text-[11px] leading-tight`,children:[(0,K.jsx)(`dt`,{className:`text-[var(--color-fg-4)] w-16 shrink-0 uppercase tracking-wider`,children:e}),(0,K.jsx)(`dd`,{className:`text-[var(--color-fg-2)] break-all min-w-0`,children:t})]})}function yp(e,t){let n=BigInt(e),r=BigInt(t);return n<r?-1:n>r?1:0}var bp=[`ssg://daemon/state`,`ssg://daemon/metrics`,`ssg://audit/recent?limit=10`,`ssg://frames/recent?limit=32`,`ssg://rules/list`,`ssg://rca/current`,`ssg://native/stats`];function xp(){let[e,t]=(0,_.useState)(`ssg://daemon/state`),[n,r]=(0,_.useState)(`ssg://daemon/state`);return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:bp.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>{t(e),r(e)},className:`chip text-[10px] `+(n===e?`border-[var(--color-brand)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)]`),children:e},e))}),(0,K.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:t=>{t.preventDefault(),r(e)},children:[(0,K.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),placeholder:`ssg://source/path?k=v`,className:`flex-1 px-3 py-1.5 text-[12px] font-mono rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-1)]`}),(0,K.jsx)(`button`,{type:`submit`,className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm hover:bg-[var(--color-surface-2)]`,children:`resolve`})]}),(0,K.jsx)(Sp,{uri:n})]})}function Sp({uri:e}){let t=ke([`debug-frame`,`activity-updated`,`counters-updated`]),{data:n,loading:r,error:i,refetch:a}=V(`/api/json/debug?uri=${encodeURIComponent(e)}`,[t[`debug-frame`],t[`activity-updated`],t[`counters-updated`],e]),o=n?JSON.stringify(n.data,null,2):``;return(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:e}),n?.snapshot_hash&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:[`hash `,n.snapshot_hash.slice(0,10),`…`]}),n?.stale&&(0,K.jsxs)(`span`,{className:`chip text-amber-300 border-amber-500/40 text-[10px]`,children:[`stale `,n.age_ms?`${Math.round(n.age_ms/1e3)}s`:``]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:a,className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`,children:`refresh`})]}),r&&!n&&(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-4)]`,children:`resolving…`}),i&&(0,K.jsx)(`p`,{className:`text-sm text-rose-300`,children:i}),o&&(0,K.jsx)(`pre`,{className:`text-[11px] leading-snug font-mono text-[var(--color-fg-2)] overflow-auto max-h-[60vh] whitespace-pre-wrap break-all`,children:o})]})}function Cp(e){let t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var wp={block:`var(--color-hig-red)`,ask:`var(--color-hig-orange)`,log:`var(--color-hig-blue)`,allow:`var(--color-hig-green)`,force:`var(--color-hig-purple)`};function Tp(e){switch(e){case`block`:return`Blocked`;case`ask`:return`Held for review`;case`log`:return`Logged`;case`force`:return`Force-allowed`;default:return`Allowed`}}function Ep({type:e}){let t={fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`};return e===`code`?(0,K.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,K.jsx)(`path`,{d:`M9 7l-5 5 5 5M15 7l5 5-5 5`}),(0,K.jsx)(`path`,{d:`M14 4l-4 16`,opacity:`0.55`})]}):e===`docs`?(0,K.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,K.jsx)(`path`,{d:`M5 4h9l5 5v11a1 1 0 01-1 1H5a1 1 0 01-1-1V5a1 1 0 011-1z`}),(0,K.jsx)(`path`,{d:`M14 4v5h5`}),(0,K.jsx)(`path`,{d:`M8 13h8M8 17h5`,opacity:`0.7`})]}):(0,K.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,K.jsx)(`path`,{d:`M3 12a9 9 0 109-9`}),(0,K.jsx)(`path`,{d:`M12 3v9l6 3`})]})}function Dp(){let{data:e}=V(`/api/json/counters`,[ke([`counters-updated`])[`counters-updated`]]),t=e?.evals_today??0,n=e?.blocked_today??0,r=e?.asked_today??0;return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,K.jsx)(Op,{value:t,label:`evaluated`,tone:`default`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(Op,{value:n,label:`blocked`,tone:`red`}),(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,K.jsx)(Op,{value:r,label:`held for you`,tone:`orange`}),(0,K.jsx)(`span`,{className:`text-[11px] ml-auto`,style:{color:`var(--color-fg-3)`},children:`Today`})]})}function Op({value:e,label:t,tone:n}){return(0,K.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-semibold tabular-nums`,style:{color:n===`red`?`var(--color-hig-red)`:n===`orange`?`var(--color-hig-orange)`:`var(--color-fg-0)`,fontSize:`20px`,lineHeight:1,letterSpacing:`-0.018em`},children:e.toLocaleString()}),(0,K.jsx)(`span`,{style:{color:`var(--color-fg-3)`,fontSize:`12px`,letterSpacing:`-0.005em`},children:t})]})}function kp({href:e,title:t,desc:n,tone:r,type:i,cta:a}){let o=r===`orange`?`var(--color-hig-orange)`:r===`indigo`?`var(--color-hig-indigo)`:`var(--color-hig-blue)`;return(0,K.jsx)(`a`,{href:e,className:`group block rounded-2xl px-4 py-4 transition-all`,style:{border:`0.5px solid var(--color-line-1)`,background:`var(--color-surface-1)`,textDecoration:`none`,color:`inherit`,boxShadow:`var(--hig-shadow-1)`},children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`flex items-center justify-center rounded-xl shrink-0`,style:{width:`40px`,height:`40px`,color:o,background:`color-mix(in oklab, ${o} 14%, transparent)`},children:(0,K.jsx)(Ep,{type:i})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[14px] font-semibold leading-tight`,style:{color:`var(--color-fg-0)`,letterSpacing:`-0.005em`},children:t}),(0,K.jsx)(`div`,{className:`text-[12px] mt-1 leading-snug`,style:{color:`var(--color-fg-2)`},children:n}),(0,K.jsxs)(`div`,{className:`text-[11.5px] mt-2 font-medium inline-flex items-center gap-1 transition-all`,style:{color:o},children:[a,(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-hover:translate-x-0.5`,children:`→`})]})]})]})})}function Ap(){let{data:e}=V(`/api/state/activity?limit=5`,[ke([`activity-updated`])[`activity-updated`]]),[,t]=(0,_.useState)(0);return(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),6e4);return()=>clearInterval(e)},[]),!e||e.length===0?(0,K.jsxs)(`div`,{className:`py-6 text-center`,style:{color:`var(--color-fg-3)`},children:[(0,K.jsx)(`p`,{style:{fontSize:`12.5px`,color:`var(--color-fg-2)`},children:`Waiting for your first agent action.`}),(0,K.jsx)(`p`,{style:{fontSize:`11px`,color:`var(--color-fg-3)`,marginTop:`4px`},children:`Anything your AI tries — read, write, run — will appear here in real time.`})]}):(0,K.jsx)(`div`,{children:e.slice(0,5).map((e,t)=>(0,K.jsxs)(`div`,{className:`hig-feed-row`,children:[(0,K.jsx)(`span`,{className:`hig-feed-row-dot`,style:{background:wp[e.decision]??`var(--color-fg-3)`,boxShadow:`0 0 0 3px ${e.decision===`block`?`color-mix(in oklab, var(--color-hig-red) 22%, transparent)`:e.decision===`ask`?`color-mix(in oklab, var(--color-hig-orange) 22%, transparent)`:`transparent`}`}}),(0,K.jsx)(`span`,{className:`hig-feed-row-decision`,style:{color:wp[e.decision]??`var(--color-fg-2)`},children:Tp(e.decision)}),(0,K.jsx)(`span`,{style:{color:`var(--color-fg-3)`},children:`·`}),(0,K.jsx)(`span`,{className:`hig-feed-row-tool`,title:e.tool,children:li(e.tool)}),(0,K.jsx)(`span`,{className:`hig-feed-row-time`,children:Cp(e.timestamp)})]},e.id??t))})}function jp(){return(0,K.jsx)(`div`,{className:`relative`,children:(0,K.jsxs)(`div`,{className:`relative max-w-5xl mx-auto px-2 pt-6 pb-12 space-y-6`,children:[(0,K.jsxs)(`section`,{className:`rounded-2xl px-6 py-5 relative overflow-hidden`,style:{border:`0.5px solid var(--color-line-1)`,background:`radial-gradient(120% 100% at 0% 0%, color-mix(in oklab, var(--color-accent) 14%, transparent) 0%, transparent 55%), var(--color-surface-1)`,boxShadow:`var(--hig-shadow-1)`},children:[(0,K.jsx)(`div`,{className:`hig-eyebrow mb-2`,children:`SigmaShake · Guardrails for AI`}),(0,K.jsx)(`h1`,{className:`font-semibold tracking-tight leading-tight`,style:{color:`var(--color-fg-0)`,fontSize:`26px`,letterSpacing:`-0.018em`},children:`The seatbelt for AI agents.`}),(0,K.jsx)(`p`,{className:`mt-1.5 leading-relaxed`,style:{color:`var(--color-fg-2)`,fontSize:`13.5px`,maxWidth:`52ch`},children:`Watch every move your AI makes. Approve what matters, block what doesn't — without babysitting every step.`}),(0,K.jsx)(`div`,{className:`mt-4 pt-3`,style:{borderTop:`0.5px solid var(--color-line-0)`},children:(0,K.jsx)(Dp,{})})]}),(0,K.jsx)(`section`,{children:(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,K.jsx)(kp,{href:`/guardrails?starter=coding`,tone:`orange`,type:`code`,title:`Code safely with AI`,desc:`Protect files, secrets, and git history from coding agents.`,cta:`Install pack`}),(0,K.jsx)(kp,{href:`/guardrails?starter=knowledge-work`,tone:`indigo`,type:`docs`,title:`Guard sensitive content`,desc:`Watch outbound email, file shares, and document changes.`,cta:`Install pack`}),(0,K.jsx)(kp,{href:`/audit`,tone:`blue`,type:`review`,title:`Review what your AI did`,desc:`Every action, decision, and reason — in one place.`,cta:`Open activity`})]})}),(0,K.jsxs)(`a`,{href:`/try`,className:`group flex items-center justify-between gap-3 rounded-xl px-4 py-3 transition-all`,style:{border:`0.5px solid var(--color-line-1)`,background:`linear-gradient(90deg, color-mix(in oklab, var(--color-accent) 8%, transparent) 0%, transparent 60%), var(--color-surface-1)`,textDecoration:`none`,color:`inherit`},children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-full shrink-0`,style:{background:`linear-gradient(180deg, var(--color-accent) 0%, var(--color-brand-hover) 100%)`,color:`var(--color-accent-on)`,boxShadow:`inset 0 0.5px 0 rgba(255,255,255,0.30), 0 2px 8px color-mix(in oklab, var(--color-accent) 30%, transparent)`},children:(0,K.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`polygon`,{points:`6 4 20 12 6 20`,fill:`currentColor`,stroke:`none`})})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-[13.5px] leading-tight`,style:{color:`var(--color-fg-0)`,letterSpacing:`-0.005em`},children:`Try a scenario — see SigmaShake decide`}),(0,K.jsx)(`div`,{className:`text-[12px] mt-0.5`,style:{color:`var(--color-fg-3)`},children:`30-second dry-run · nothing actually runs.`})]})]}),(0,K.jsxs)(`span`,{className:`text-[12.5px] font-medium shrink-0 inline-flex items-center gap-1 transition-all`,style:{color:`var(--color-accent)`},children:[`Try it`,(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-hover:translate-x-0.5`,children:`→`})]})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2`,children:[(0,K.jsx)(`h2`,{className:`font-semibold tracking-tight`,style:{color:`var(--color-fg-0)`,fontSize:`15px`,letterSpacing:`-0.008em`},children:`Recent activity`}),(0,K.jsx)(`a`,{href:`/audit`,style:{fontSize:`12px`,color:`var(--color-hig-blue)`,fontWeight:500},children:`View all →`})]}),(0,K.jsx)(`div`,{style:{background:`var(--color-surface-1)`,border:`0.5px solid var(--color-line-1)`,borderRadius:`14px`,padding:`4px 16px`,boxShadow:`var(--hig-shadow-1)`},children:(0,K.jsx)(Ap,{})})]})]})})}var Mp=[{id:`files`,label:`Files & folders`,blurb:`Deleting or changing things on your hard drive`},{id:`secrets`,label:`Secrets & keys`,blurb:`Reading or overwriting credentials and private files`},{id:`network`,label:`Network calls`,blurb:`Reaching out to websites and external APIs`},{id:`install`,label:`Installing software`,blurb:`Pulling new code or packages from the internet`},{id:`communication`,label:`Sending messages`,blurb:`Outgoing emails, posts, or chat messages`}],Np=[{id:`erase-folder`,label:`AI tries to erase a folder`,plainEffect:`Permanently deletes every file inside the "output" folder. Recovery is hard.`,category:`files`,emoji:`🗑️`,toolCall:{tool:`Bash`,input:{command:`find ./output -type f -delete`}},displayByOs:{windows:`Remove-Item .\\output -Recurse -Force`,macos:`find ./output -type f -delete`,linux:`find ./output -type f -delete`}},{id:`write-env`,label:`AI tries to write your .env file`,plainEffect:`Overwrites the file that holds your API keys, passwords, and other secrets.`,category:`secrets`,emoji:`⚠️`,toolCall:{tool:`Write`,input:{file_path:`.env`,content:`API_KEY=test`}}},{id:`read-ssh-key`,label:`AI tries to read your private key`,plainEffect:`Opens the SSH key that proves you are you on remote servers. Copying it is identity theft.`,category:`secrets`,emoji:`🔑`,toolCall:{tool:`Read`,input:{file_path:`~/.ssh/id_rsa`}},displayByOs:{windows:`Read C:\\Users\\You\\.ssh\\id_rsa`,macos:`Read ~/.ssh/id_rsa`,linux:`Read ~/.ssh/id_rsa`}},{id:`install-package`,label:`AI tries to install a package`,plainEffect:`Downloads code from a public registry and adds it to your project. The code runs with your permissions.`,category:`install`,emoji:`📦`,toolCall:{tool:`Bash`,input:{command:`npm install some-package --save`}}},{id:`fetch-web`,label:`AI tries to fetch a URL`,plainEffect:`Makes a web request to an outside service. Could leak data or pull in instructions.`,category:`network`,emoji:`🌐`,toolCall:{tool:`WebFetch`,input:{url:`https://api.example.com/data`,prompt:``}}},{id:`send-email`,label:`AI tries to send an email`,plainEffect:`Sends an email from your machine without your review. Anyone could end up CC’d.`,category:`communication`,emoji:`📧`,toolCall:{tool:`Bash`,input:{command:`sendmail -t < message.txt`}},displayByOs:{windows:`Send-MailMessage -To you@example.com -Subject "..." -Body (Get-Content message.txt)`,macos:`sendmail -t < message.txt`,linux:`sendmail -t < message.txt`}}],Pp=`ssg.tryit.intro-dismissed.v1`,Fp=`ssg.tryit.os.v1`,Ip={allow:{label:`Allowed`,color:`text-emerald-300`,bg:`border-emerald-500/30 bg-emerald-500/5`,icon:`✓`,headline:`SSG would let this happen.`,next:`In real life, the AI would go ahead. If you would rather it didn’t, add a rule on the Rules page.`},block:{label:`Blocked`,color:`text-red-300`,bg:`border-red-500/30 bg-red-500/5`,icon:`✕`,headline:`SSG would stop this from running.`,next:`The AI never gets to perform the action. No files change, no commands run, no requests go out.`},ask:{label:`Ask first`,color:`text-amber-300`,bg:`border-amber-500/30 bg-amber-500/5`,icon:`?`,headline:`SSG would pause and ask you first.`,next:`You’d get a prompt on the Approvals page. Nothing happens until you click Allow or Deny.`},log:{label:`Logged`,color:`text-sky-300`,bg:`border-sky-500/30 bg-sky-500/5`,icon:`≡`,headline:`SSG would allow it but write it down.`,next:`The AI proceeds, and the action gets recorded in your Activity log for later review.`},force:{label:`Force-allow`,color:`text-violet-300`,bg:`border-violet-500/30 bg-violet-500/5`,icon:`→`,headline:`A high-priority rule explicitly allows this.`,next:`A “force” rule overrides anything that would have blocked or paused this action.`}};function Lp(){if(typeof window>`u`)return`linux`;try{let e=window.localStorage.getItem(Fp);if(e===`windows`||e===`macos`||e===`linux`)return e}catch{}let e=navigator.userAgent.toLowerCase();return e.includes(`win`)?`windows`:e.includes(`mac`)?`macos`:`linux`}function Rp(e){return e===`windows`?`Windows`:e===`macos`?`Mac`:`Linux`}function zp(e){return e===`windows`?`⊞`:e===`macos`?`🍎`:`🐧`}function Bp(e,t){let n=e.displayByOs?.[t];if(n)return n;let r=e.toolCall;return r.input.command?r.input.command:r.input.file_path?r.input.file_path:r.input.url?r.input.url:JSON.stringify(r.input)}function Vp({n:e,label:t}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-full bg-[var(--color-brand)]/15 text-[var(--color-brand)] text-[10px] font-semibold shrink-0`,children:e}),(0,K.jsx)(`span`,{className:`text-[11.5px] text-[var(--color-fg-2)] truncate`,children:t})]})}function Hp({os:e,setOs:t}){return(0,K.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-full border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-0.5`,children:[`windows`,`macos`,`linux`].map(n=>(0,K.jsxs)(`button`,{onClick:()=>t(n),className:`px-2.5 py-1 rounded-full text-[10.5px] font-medium cursor-pointer transition-colors ${n===e?`bg-[var(--color-brand)]/15 text-[var(--color-brand)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Show commands as they would look on ${Rp(n)}`,children:[zp(n),` `,Rp(n)]},n))})}function Up({os:e,setOs:t,onDismiss:n}){return(0,K.jsxs)(`div`,{className:`rounded-2xl border border-[var(--color-brand)]/25 bg-[var(--color-brand)]/[0.04] p-4 sm:p-5 space-y-3.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[15px] font-semibold text-[var(--color-fg-0)] leading-tight`,children:`What SSG does — and why this page is here`}),(0,K.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-1 leading-relaxed max-w-[60ch]`,children:[`AI coding agents can run any command on your computer: delete files, read your secrets, send emails, install packages. SSG is the policy engine that decides which of those they’re actually allowed to do.`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-0)] font-medium`,children:`This sandbox shows SSG’s decisions in real time`}),`, without anything actually running. Pick a scenario, click Run, see what your guardrails would do.`]})]}),(0,K.jsx)(`button`,{onClick:n,className:`shrink-0 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] cursor-pointer text-[14px] leading-none p-1 -m-1`,"aria-label":`Dismiss intro`,title:`Hide this primer`,children:`✕`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-[11.5px]`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`Nothing executes`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`No files modified`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`No network traffic`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-[var(--color-line-1)]/60 bg-[var(--color-surface-1)]/40 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] font-semibold mb-2`,children:`How it works`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3`,children:[(0,K.jsx)(Vp,{n:1,label:`Pick a scenario below`}),(0,K.jsx)(Vp,{n:2,label:`Click Run`}),(0,K.jsx)(Vp,{n:3,label:`See the decision SSG would make`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,K.jsx)(`span`,{className:`text-[11.5px] text-[var(--color-fg-3)]`,children:`Showing commands as they look on`}),(0,K.jsx)(Hp,{os:e,setOs:t}),(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-4)]`,children:`(cosmetic — SSG’s decision is the same on every OS)`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap pt-1`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] italic max-w-[44ch] leading-snug`,children:`Every AI agent will need a policy layer. This is what one looks like.`}),(0,K.jsx)(`button`,{onClick:n,className:`text-[11.5px] font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] cursor-pointer underline-offset-2 hover:underline`,children:`Got it, hide this primer`})]})]})}function Wp({scenario:e,selected:t,os:n,onClick:r}){return(0,K.jsxs)(`button`,{onClick:r,className:`flex flex-col gap-1.5 rounded-xl border px-3.5 py-3 text-left cursor-pointer transition-all ${t?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/8 shadow-[0_0_0_3px_color-mix(in_oklab,var(--color-brand)_15%,transparent)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)] hover:border-[var(--color-line-2)] hover:bg-[var(--color-surface-2)]/40`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[18px] leading-none shrink-0`,children:e.emoji}),(0,K.jsx)(`span`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-snug flex-1 min-w-0`,children:e.label})]}),(0,K.jsx)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)] leading-snug`,children:e.plainEffect}),(0,K.jsx)(`p`,{className:`font-mono text-[10.5px] text-[var(--color-fg-4)] truncate`,children:Bp(e,n)})]})}function Gp(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(`Bash`),[f,p]=(0,_.useState)(`{"command": ""}`),[m,h]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Pp)===`1`}catch{return!1}}),[g,v]=(0,_.useState)(()=>Lp()),[y,b]=(0,_.useState)(!1);function x(e){v(e);try{window.localStorage.setItem(Fp,e)}catch{}}function S(){h(!0);try{window.localStorage.setItem(Pp,`1`)}catch{}}function C(){h(!1);try{window.localStorage.removeItem(Pp)}catch{}}let w=Np.find(t=>t.id===e),T=(0,_.useMemo)(()=>{let e=new Map;for(let t of Np){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return Mp.filter(t=>e.has(t.id)).map(t=>({...t,scenarios:e.get(t.id)}))},[]);(0,_.useEffect)(()=>{(n||o)&&window.scrollTo({top:(document.getElementById(`tryit-result`)?.offsetTop??0)-80,behavior:`smooth`})},[n,o]),(0,_.useEffect)(()=>{if(typeof window>`u`)return;let e=new URLSearchParams(window.location.search).get(`scenario`);e&&Np.some(t=>t.id===e)&&t(e)},[]),(0,_.useEffect)(()=>{if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`scenario`,e):t.searchParams.delete(`scenario`),window.history.replaceState({},``,t.toString())},[e]);function E(){if(!e)return;let t=new URL(window.location.href);t.searchParams.set(`scenario`,e),navigator.clipboard.writeText(t.toString()).then(()=>{b(!0),setTimeout(()=>b(!1),2e3)}).catch(()=>{})}async function D(e){a(!0),s(null),r(null);try{let t=await(await fetch(`/api/json/eval-dry-run`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify(e)})).json();t.error?s(t.error):r(t)}catch{s(`Could not reach the governance engine. Is SSG running?`)}finally{a(!1)}}function O(){w&&D(w.toolCall)}function k(){let e;try{e=JSON.parse(f)}catch{s(`Invalid JSON in input field.`);return}if(typeof e!=`object`||!e){s(`Input must be a JSON object.`);return}D({tool:u,input:e})}let A=n?Ip[n.decision]??Ip.allow:null;return(0,K.jsxs)(`div`,{className:`max-w-3xl mx-auto py-4 space-y-4`,children:[(0,K.jsxs)(`header`,{className:`flex items-baseline justify-between gap-4 flex-wrap`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-[22px] font-semibold text-[var(--color-fg-0)] tracking-tight leading-tight`,children:`Try it`}),(0,K.jsxs)(`p`,{className:`text-[13px] text-[var(--color-fg-2)] mt-0.5`,children:[`Your AI can run any command. SSG decides what it’s actually allowed to do.`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`Pick a scenario to see — nothing actually runs.`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[m&&(0,K.jsx)(`button`,{onClick:C,className:`text-[11.5px] font-medium text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] cursor-pointer`,title:`Show the introduction again`,children:`What is Try It? →`}),(0,K.jsx)(`a`,{href:`/guardrails`,className:`text-[11.5px] font-medium text-[var(--color-brand)] hover:underline`,children:`Install more guardrails →`})]})]}),!m&&(0,K.jsx)(Up,{os:g,setOs:x,onDismiss:S}),m&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Commands shown as on`}),(0,K.jsx)(Hp,{os:g,setOs:x})]}),(0,K.jsx)(`div`,{className:`space-y-4`,children:T.map(n=>(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2 px-1`,children:[(0,K.jsx)(`h3`,{className:`text-[11px] uppercase tracking-wide text-[var(--color-fg-3)] font-semibold`,children:n.label}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:n.blurb})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:n.scenarios.map(n=>(0,K.jsx)(Wp,{scenario:n,selected:e===n.id,os:g,onClick:()=>{t(n.id),r(null),s(null)}},n.id))})]},n.id))}),w&&(0,K.jsxs)(`div`,{className:`rounded-xl border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`text-[22px] leading-none shrink-0`,children:w.emoji}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[13.5px] font-medium text-[var(--color-fg-0)]`,children:w.label}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-0.5 leading-relaxed`,children:w.plainEffect})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-0)] bg-[var(--color-surface-0)] px-3 py-2`,children:[(0,K.jsxs)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold mb-1`,children:[`What the AI would run · `,Rp(g)]}),(0,K.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--color-fg-1)] break-all`,children:Bp(w,g)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,K.jsxs)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)]`,children:[`Click Run to see what SSG would decide.`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`The command does not actually execute.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:E,className:`inline-flex items-center gap-1 px-3 h-8 rounded-full text-[11.5px] font-medium cursor-pointer transition-colors
50
+ -d '{"confirm":"UNINSTALL_ALL_RULES"}'`})]})]})})}function am({entry:e,ruleId:t,onJump:n,onChanged:r}){return!e||!t?(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] shrink-0`,children:`no rule`}):(0,D.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:async()=>{await Gp(t,e.file,`log`),r()},title:`Soften this rule to log-only — keeps the rule running but stops blocking/asking`,className:`px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-brand)]/60 cursor-pointer transition-colors`,children:`→ log`}),(0,D.jsx)(`button`,{type:`button`,onClick:async()=>{e.rule.enabled&&(await Wp(t,e.file),r())},disabled:!e.rule.enabled,title:e.rule.enabled?`Disable this rule entirely`:`Rule is already disabled`,className:`px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-red-300 hover:border-red-400/60 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:e.rule.enabled?`disable`:`disabled`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>n(t),title:`Scroll to this rule below — clears search and filter`,className:`px-1.5 py-0.5 rounded-sm border border-[var(--color-brand)]/40 bg-[var(--color-brand)]/10 text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-0)] hover:bg-[var(--color-brand)]/20 cursor-pointer transition-colors`,children:`view`})]})}function om({triggers:e,ruleIndex:t,onJump:n,onChanged:r}){let i=Math.floor(Date.now()/1e3),a=i-24*3600,o=i-4*3600,s=(e??[]).filter(e=>e.ruleId&&zp.has(e.decision)),c=s[0]??null,l=new Map;for(let e of s){if(e.timestamp<a||!e.ruleId)continue;let t=l.get(e.ruleId);t?(t.hits++,e.timestamp>t.lastSeen&&(t.lastSeen=e.timestamp,t.sample=e)):l.set(e.ruleId,{ruleId:e.ruleId,decision:e.decision,hits:1,lastSeen:e.timestamp,sample:e})}let u=[...l.values()].filter(e=>e.hits>=3).sort((e,t)=>t.hits-e.hits).slice(0,5),d=c&&c.timestamp>=o;return d||u.length>0?(0,D.jsx)(J,{children:(0,D.jsxs)(`details`,{open:!0,children:[(0,D.jsxs)(`summary`,{className:`px-3 py-2 cursor-pointer list-none select-none flex items-center gap-3 hover:bg-[var(--color-surface-2)]/70 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent decisions`}),d&&c&&(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[`last:`,` `,(0,D.jsx)(`span`,{className:Hp[c.decision]??`text-[var(--color-fg-2)]`,children:c.decision}),` `,`· `,Xp(c.timestamp)]}),u.length>0&&(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-amber-300/80 ml-auto`,children:[u.length,` rule`,u.length===1?``:`s`,` fired ≥3× in 24h`]})]}),(0,D.jsxs)(X,{className:`py-2 space-y-3`,children:[d&&c&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`div`,{className:`overline`,children:`last decision`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider w-12 shrink-0 ${Hp[c.decision]??`text-[var(--color-fg-2)]`}`,children:c.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-2)] w-20 shrink-0 truncate`,children:c.tool}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-1)] flex-1 min-w-0 truncate`,children:c.input||`—`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-16 text-right`,children:Xp(c.timestamp)}),(0,D.jsx)(am,{entry:c.ruleId?t.get(c.ruleId):void 0,ruleId:c.ruleId,onJump:n,onChanged:r})]}),c.ruleId&&(0,D.jsxs)(`div`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] pl-14`,children:[`rule`,` `,(0,D.jsx)(`code`,{className:`text-[var(--color-fg-2)]`,children:c.ruleId})]})]}),u.length>0&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`div`,{className:`overline`,children:`top fired in 24h (≥3 hits) — soften or disable to reduce noise`}),(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:u.map(e=>{let i=t.get(e.ruleId);return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono py-1.5`,children:[(0,D.jsxs)(`span`,{className:`text-amber-300 tabular-nums shrink-0 w-10`,children:[e.hits,`×`]}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider w-12 shrink-0 ${Hp[e.decision]??`text-[var(--color-fg-2)]`}`,children:e.decision}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-0)] truncate flex-1 min-w-0`,children:e.ruleId}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate shrink-0 w-32 text-right hidden md:inline`,children:e.sample.tool}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-16 text-right`,children:Xp(e.lastSeen)}),(0,D.jsx)(am,{entry:i,ruleId:e.ruleId,onJump:n,onChanged:r})]},e.ruleId)})})]})]})]})}):(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`py-2 flex items-center gap-3 text-[11px] font-mono flex-wrap`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent decisions`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`no blocks or asks in the last 4h — search below to find any rule by id, message, or what it last blocked`})]})})}function sm(){let e=Nt(Bp)[`rules-changed`],{data:t,refetch:n}=V(`/api/json/rules`,[e]),[r,i]=(0,_.useState)(`7d`),{data:a,refetch:o}=V(`/api/json/rules-stats?window=${r}`,[e,r]),{data:s,refetch:c}=V(`/api/json/rules-performance`,[e]),{data:l,refetch:u}=V(`/api/json/rule-triggers/recent?limit=100`,[e]),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`all`),[h,g]=(0,_.useState)(new Set),[v,y]=(0,_.useState)(new Set),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(()=>new URLSearchParams(window.location.search).get(`highlight`)??``),w=(0,_.useRef)(null);(0,_.useEffect)(()=>{w.current&&w.current.scrollIntoView({behavior:`smooth`,block:`center`})},[]);let T=a?.stats??{},E=(0,_.useMemo)(()=>{let e=new Map;if(!t)return e;for(let n of t.rulesets)for(let t of n.rules)e.set(t.id,{rule:t,file:n.file});return e},[t]);function O(){n(),o(),c(),u()}function k(e){f(``),m(`all`),C(e);let t=new URL(window.location.href);t.searchParams.set(`highlight`,e),window.history.replaceState(null,``,t.toString())}if(!t)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading rules…`});if(t.rulesets.length===0)return(0,D.jsxs)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)]/50 p-10 text-center`,children:[(0,D.jsx)(`p`,{className:`text-sm text-[var(--color-fg-2)] mb-2`,children:`No .rules files found.`}),(0,D.jsx)(`a`,{href:`/hub`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)] hover:underline`,children:`→ browse hub to install rulesets`})]});let A=d.toLowerCase(),j=(()=>{let e=new Set;if(!A||!l)return e;for(let t of l.rows){if(!t.ruleId)continue;let n=(t.input??``).toLowerCase(),r=(t.tool??``).toLowerCase();(n.includes(A)||r.includes(A))&&e.add(t.ruleId)}return e})();function M(e){if(p===`enabled`&&!e.enabled||p===`disabled`&&e.enabled)return!1;let t=T[e.id]?.hits??0;return!(p===`hit`&&t===0||p===`never`&&t>0)}let N=t.rulesets.map(e=>({...e,rules:e.rules.filter(e=>A&&!e.id.toLowerCase().includes(A)&&!e.message.toLowerCase().includes(A)&&!j.has(e.id)?!1:M(e))})).filter(e=>e.rules.length>0||!A&&p===`all`),ee=t.rulesets.reduce((e,t)=>e+t.rules.length,0),te=t.rulesets.reduce((e,t)=>e+t.rules.filter(e=>e.enabled).length,0),P=new Set;for(let e of N)for(let t of e.rules)P.add(t.id);let F=[];for(let e of h){let t=E.get(e);t&&F.push({ruleId:e,file:t.file})}function ne(e){g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function re(e){g(t=>{let n=new Set(t);if(e.rules.every(e=>n.has(e.id)))for(let t of e.rules)n.delete(t.id);else for(let t of e.rules)n.add(t.id);return n})}function ie(){g(e=>{let t=new Set(e);for(let e of P)t.add(e);return t})}function I(e){y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function L(e,t){F.length!==0&&(e===`enable`?await Kp(F,!0):e===`disable`?await Kp(F,!1):e===`delete`?(await Jp(F),g(new Set)):e===`decision`&&t&&await qp(F,t),O())}return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`overline text-[11px]`,children:`rules`}),(0,D.jsxs)(`div`,{className:`flex items-baseline gap-3 mt-1`,children:[(0,D.jsxs)(`span`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:[te,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,ee]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] ml-1.5 text-[11px] uppercase tracking-wider`,children:`active`})]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--color-fg-3)] uppercase tracking-wider`,children:[t.files.length,` file`,t.files.length===1?``:`s`]})]})]}),(0,D.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`px-2 py-1 text-[11px] font-mono uppercase tracking-wider rounded-sm border border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)] hover:bg-[var(--color-brand)]/20 cursor-pointer transition-colors`,title:`Dictate or type a new rule — deterministic match, no inference cost`,children:`🎙 dictate rule`}),(0,D.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider`,children:[`all`,`enabled`,`disabled`,`hit`,`never`].map(e=>(0,D.jsx)(`button`,{onClick:()=>m(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${p===e?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e},e))}),(0,D.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm`,children:Up.map(e=>(0,D.jsx)(`button`,{onClick:()=>i(e.value),className:`px-1.5 py-0.5 cursor-pointer transition-colors ${r===e.value?`bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e.label},e.value))}),(0,D.jsx)(`input`,{type:`text`,placeholder:`search id, message, or what blocked…`,title:`Searches rule id, message, AND recent audit-log inputs/tools — paste a blocked command to find its rule`,value:d,onChange:e=>f(e.target.value),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-xs rounded-sm px-2.5 py-1.5 w-64 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]})]}),(0,D.jsx)(om,{triggers:l?.rows,ruleIndex:E,onJump:k,onChanged:O}),(0,D.jsx)($p,{perf:s}),(0,D.jsx)(em,{totalRules:ee,activeRules:te,onChanged:O}),(0,D.jsx)(Qp,{}),(0,D.jsx)(im,{}),(0,D.jsx)(nm,{selected:F,onClear:()=>g(new Set),onApply:L}),P.size>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono`,children:[(0,D.jsxs)(`button`,{onClick:ie,className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:[`select `,P.size,` visible`]}),h.size>0&&(0,D.jsx)(`button`,{onClick:()=>g(new Set),className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear selection`})]}),N.length===0&&(0,D.jsx)(`div`,{className:`rounded-sm border border-dashed border-[var(--color-line-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no rules match the current filter`}),(0,D.jsx)(`div`,{className:`space-y-3`,children:N.map(e=>{let t=e.rules.some(e=>e.id===S),n=e.rules.filter(e=>e.enabled).length,r=e.rules.length>0&&e.rules.every(e=>h.has(e.id)),i=!r&&e.rules.some(e=>h.has(e.id));return(0,D.jsx)(J,{children:(0,D.jsxs)(`details`,{open:t||!!A||p!==`all`,children:[(0,D.jsxs)(`summary`,{className:`flex items-center gap-2 px-3 py-2 cursor-pointer list-none select-none hover:bg-[var(--color-surface-2)]/70 border-b border-[var(--color-line-0)]`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:r,ref:e=>{e&&(e.indeterminate=i)},onChange:()=>re(e),onClick:e=>e.stopPropagation(),className:`accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select all rules in ${e.file}`}),(0,D.jsxs)(`svg`,{className:`text-[var(--color-fg-3)] shrink-0`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,D.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,D.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,D.jsx)(`code`,{className:`text-xs text-[var(--color-fg-0)] font-mono`,children:e.file}),(0,D.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-[var(--color-fg-3)] tabular-nums`,children:[n,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,e.rules.length]})]})]}),(0,D.jsxs)(X,{className:`py-0`,children:[e.rules.length===0?(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] py-3`,children:`no rules in this file`}):(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:e.rules.map(t=>{let n=t.id===S,r=h.has(t.id),i=T[t.id],a=v.has(t.id);return(0,D.jsx)(`div`,{ref:n?w:null,className:`py-2.5 ${n?`bg-amber-400/8 border-l-2 border-l-amber-400/60 -mx-3 px-3 -my-px`:r?`bg-sky-400/5`:``}`,children:(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0 flex-1`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>ne(t.id),className:`mt-1 accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select rule ${t.id}`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-1 flex-wrap`,children:[(0,D.jsx)(`select`,{value:t.decision,onChange:async n=>{await Gp(t.id,e.file,n.target.value),O()},className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50 ${Hp[t.decision]??`text-[var(--color-fg-2)]`}`,children:Vp.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))}),(0,D.jsx)(Gi,{ruleId:t.id,children:(0,D.jsx)(`code`,{className:`text-xs font-mono text-[var(--color-fg-0)] break-all`,children:t.id})}),i&&i.hits>0&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`·`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:i.hits}),` `,`hit`,i.hits===1?``:`s`,i.avgDurationMs>0&&(0,D.jsxs)(D.Fragment,{children:[` · `,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[i.avgDurationMs.toFixed(1),`ms`]}),` `,`avg`]}),` · `,Xp(i.lastSeen)]}),(!i||i.hits===0)&&(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:`· never fired`}),(0,D.jsx)(`button`,{onClick:()=>I(t.id),className:`ml-auto text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:a?`hide audit`:`audit`})]}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-2)] truncate`,children:t.message}),a&&(0,D.jsx)(rm,{ruleId:t.id})]})]}),(0,D.jsx)(Zp,{rule:t,file:e.file,onToggle:async()=>{await Wp(t.id,e.file),O()}})]})},t.id)})}),e.content&&(0,D.jsxs)(`details`,{className:`mt-3 pb-3`,children:[(0,D.jsx)(`summary`,{className:`overline cursor-pointer hover:text-[var(--color-fg-1)] select-none`,children:`raw source`}),(0,D.jsx)(`pre`,{className:`mt-2 p-3 bg-[var(--color-surface-0)] border border-[var(--color-line-0)] rounded-sm text-[11px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-words font-mono`,children:e.content})]})]})]})},e.file)})}),(0,D.jsx)(Pp,{open:b,onClose:()=>x(!1),onSaved:O})]})}var cm={allow:`#4ade80`,block:`#f87171`,ask:`#fbbf24`,force:`#a78bfa`,log:`#7dd3fc`,shadow:`#94a3b8`},lm=[`<1ms`,`1-10ms`,`10-100ms`,`100ms-1s`,`>1s`];function um(e){return e?new Date(e*1e3).toLocaleString():`—`}function dm(e){if(e<1)return`<1s`;if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m ${e%60}s`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${t}h ${n}m`:`${t}h`}function fm({title:e,hint:t,children:n}){return(0,D.jsxs)(`section`,{className:`flex flex-col rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] overflow-hidden`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/30 shrink-0`,children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-3)]`,children:e}),t&&(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)]`,children:t})]}),(0,D.jsx)(`div`,{className:`p-3 flex flex-col gap-2 flex-1 min-h-0`,children:n})]})}function pm({allowed:e,blocked:t,asked:n,forced:r}){let i=e+t+n+r;if(i===0)return(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No evals recorded.`});let a=[{label:`allow`,value:e,color:cm.allow},{label:`block`,value:t,color:cm.block},{label:`ask`,value:n,color:cm.ask},{label:`force`,value:r,color:cm.force}].filter(e=>e.value>0),o=2*Math.PI*32,s=0;return(0,D.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,D.jsxs)(`svg`,{width:`92`,height:`92`,viewBox:`-46 -46 92 92`,className:`shrink-0`,children:[(0,D.jsx)(`circle`,{r:32,fill:`none`,stroke:`#222`,strokeWidth:`12`}),a.map(e=>{let t=e.value/i*o,n=(0,D.jsx)(`circle`,{r:32,fill:`none`,stroke:e.color,strokeWidth:`12`,strokeDasharray:`${t} ${o-t}`,strokeDashoffset:-s,transform:`rotate(-90)`},e.label);return s+=t,n}),(0,D.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:`14`,fontFamily:`ui-monospace, monospace`,fill:`var(--color-fg-1)`,children:i})]}),(0,D.jsx)(`ul`,{className:`flex-1 flex flex-col gap-1 text-[11px] font-mono`,children:a.map(e=>{let t=Math.round(e.value/i*1e3)/10;return(0,D.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`size-2 rounded-sm shrink-0`,style:{background:e.color}}),(0,D.jsx)(`span`,{className:`uppercase tracking-wide text-[var(--color-fg-2)] w-12`,children:e.label}),(0,D.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-1)] font-semibold`,children:e.value}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[t,`%`]})]},e.label)})})]})}function mm({rows:e,maxRows:t=10,emptyMessage:n}){if(e.length===0)return(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:n});let r=e.slice(0,t),i=Math.max(...r.map(e=>e.value),1);return(0,D.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[11px] font-mono`,children:r.map(e=>{let t=Math.max(2,e.value/i*100);return(0,D.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,title:e.label,children:e.label}),(0,D.jsx)(`span`,{className:`tabular-nums text-[var(--color-fg-1)] font-semibold shrink-0`,children:e.value})]}),(0,D.jsx)(`div`,{className:`h-1 rounded-sm bg-white/5 overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full bg-[var(--color-hig-blue)]/70`,style:{width:`${t}%`}})}),e.sublabel&&(0,D.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-4)] truncate`,title:e.sublabel,children:e.sublabel})]},e.label)})})}function hm({latency:e}){let t={};for(let n of e)t[n.bucket]=n.hits;let n=Math.max(...Object.values(t),1);return Object.values(t).reduce((e,t)=>e+t,0)===0?(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No latency data.`}):(0,D.jsx)(`div`,{className:`flex items-end gap-2 h-[80px]`,children:lm.map(e=>{let r=t[e]??0;return(0,D.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-1`,children:[(0,D.jsx)(`div`,{className:`w-full bg-[var(--color-hig-blue)]/60 rounded-sm`,style:{height:`${n>0?Math.round(r/n*70):0}px`,minHeight:r>0?`4px`:`0px`},title:`${r} evals in ${e}`}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-nowrap`,children:e}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] tabular-nums`,children:r})]},e)})})}function gm({sessionKey:e}){let[t,n]=(0,_.useState)(0),{data:r,loading:i,error:a}=V(`/api/json/sessions/detail?session_key=${encodeURIComponent(e)}&audit_limit=500`,[t]),o=Nt([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{o>0&&r?.summary.is_active&&n(e=>e+1)},[o,r?.summary.is_active]);let s=(0,_.useMemo)(()=>{if(!r)return[];let e=r.tools.top.map(e=>({label:e.tool,value:e.hits}));return r.tools.other>0&&e.push({label:`(${r.tools.other} other)`,value:r.tools.other}),e},[r]),c=(0,_.useMemo)(()=>r?r.rules.map(e=>({label:e.rule_id,sublabel:e.rule_message,value:e.hits})):[],[r]);if(a)return(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,D.jsxs)(`header`,{children:[(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Session inspector`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:e})]}),(0,D.jsxs)(`div`,{className:`rounded-sm border border-rose-500/30 bg-rose-500/5 p-4 text-[12px] font-mono text-rose-300`,children:[a.includes(`404`)?`No audit entries found for this session. It may have been pruned, or the URL is malformed.`:`Failed to load session: ${a}`,(0,D.jsx)(`div`,{className:`mt-2`,children:(0,D.jsx)(`a`,{href:`/sessions`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`← Back to sessions`})})]})]});if(i&&!r)return(0,D.jsxs)(`div`,{className:`p-4 text-[12px] font-mono text-[var(--color-fg-3)]`,children:[`Loading session `,e,`…`]});if(!r)return null;let{summary:l,audit:u,latency:d}=r,f=l.evals>0?Math.round(l.blocked/l.evals*1e3)/10:0;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 h-full min-h-0`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`a`,{href:`/sessions`,className:`hover:underline`,children:`← Sessions`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`/`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:l.agent_id})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h1`,{className:`text-lg font-semibold`,children:[l.client,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] font-mono text-[14px] ml-2`,children:l.agent_id})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 break-all`,children:l.session_id??`(no session_id — solo bucket)`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] font-mono`,children:[(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm border ${l.is_active?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-white/5 border-white/10 text-[var(--color-fg-3)]`}`,children:[(0,D.jsx)(`span`,{className:`size-1.5 rounded-full ${l.is_active?`bg-emerald-400 animate-pulse`:`bg-[var(--color-fg-4)]`}`}),l.is_active?`Live`:`Closed`]}),(0,D.jsx)(_m,{label:`Evals`,value:l.evals.toLocaleString()}),(0,D.jsx)(_m,{label:`Blocked`,value:l.blocked>0?`${l.blocked} (${f}%)`:`0`,color:l.blocked>0?`text-rose-300`:void 0}),(0,D.jsx)(_m,{label:`Asked`,value:l.asked.toLocaleString(),color:`text-amber-300`}),(0,D.jsx)(_m,{label:`Started`,value:um(l.started_at)}),(0,D.jsx)(_m,{label:`Duration`,value:dm(l.duration_s)})]})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 gap-3`,children:[(0,D.jsx)(fm,{title:`Decisions`,hint:`${l.evals} evals`,children:(0,D.jsx)(pm,{allowed:l.allowed,blocked:l.blocked,asked:l.asked,forced:l.forced})}),(0,D.jsx)(fm,{title:`Top tools`,hint:`${r.tools.top.length+(r.tools.other>0?1:0)} buckets`,children:(0,D.jsx)(mm,{rows:s,emptyMessage:`No tool activity.`})}),(0,D.jsx)(fm,{title:`Top rules`,hint:`${c.length} hit`,children:(0,D.jsx)(mm,{rows:c,emptyMessage:`No rules matched this session.`})}),(0,D.jsx)(fm,{title:`Latency`,hint:`duration buckets`,children:(0,D.jsx)(hm,{latency:d})})]}),(0,D.jsx)(`div`,{className:`flex-1 min-h-[400px]`,children:(0,D.jsx)(vd,{sessionKey:e,entries:u,loading:i,error:null,playingIndex:-1})})]})}function _m({label:e,value:t,color:n}){return(0,D.jsxs)(`div`,{className:`flex flex-col`,children:[(0,D.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)]`,children:e}),(0,D.jsx)(`span`,{className:`tabular-nums ${n??`text-[var(--color-fg-1)]`}`,children:t})]})}var vm=100,ym={"claude-code":`bg-orange-500/15 text-orange-300 border-orange-500/30`,cursor:`bg-sky-500/15 text-sky-300 border-sky-500/30`,copilot:`bg-emerald-500/15 text-emerald-300 border-emerald-500/30`,gemini:`bg-blue-500/15 text-blue-300 border-blue-500/30`,antigravity:`bg-purple-500/15 text-purple-300 border-purple-500/30`,codex:`bg-pink-500/15 text-pink-300 border-pink-500/30`,pi:`bg-amber-500/15 text-amber-300 border-amber-500/30`,generic:`bg-slate-500/15 text-slate-300 border-slate-500/30`};function bm(e){if(!e)return`—`;let t=new Date(e*1e3),n=new Date,r=t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1});if(t.toDateString()===n.toDateString())return`Today ${r}`;let i=new Date(n);return i.setDate(i.getDate()-1),t.toDateString()===i.toDateString()?`Yesterday ${r}`:`${t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})} ${r}`}function xm(e){if(e<1)return`—`;if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${t}h ${n}m`:`${t}h`}function Sm({client:e}){return(0,D.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide ${ym[e]??`bg-white/5 text-[var(--color-fg-3)] border-white/10`}`,children:e})}function Cm(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(0),{data:o,loading:s,error:c,refetch:l}=V(`/api/json/sessions/list?limit=${vm}&offset=${e}`,[i]),u=Nt([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{u>0&&a(e=>e+1)},[u]);let d=o?.sessions??[],f=o?.total??0,p=(0,_.useMemo)(()=>{if(!n.trim())return d;let e=n.toLowerCase();return d.filter(t=>t.session_key.toLowerCase().includes(e)||t.client.toLowerCase().includes(e)||(t.top_tool??``).toLowerCase().includes(e)||(t.top_rule??``).toLowerCase().includes(e))},[d,n]),m=d.filter(e=>e.is_active).length,h=d.reduce((e,t)=>e+t.evals,0),g=d.reduce((e,t)=>e+t.blocked,0),v=h>0?Math.round(g/h*1e3)/10:0;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Sessions`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1`,children:`Every AI agent session recorded by the daemon. Click a row to open its inspector — graph, charts, and full audit log.`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:f.toLocaleString()}),` `,`total`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-emerald-300 font-semibold`,children:m}),` `,`active`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] font-semibold`,children:h.toLocaleString()}),` `,`evals on page`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{children:[(0,D.jsxs)(`span`,{className:v>0?`text-rose-300 font-semibold`:`text-emerald-300`,children:[v,`%`]}),` `,`blocked`]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:`Filter by client, session, tool, or rule…`,className:`flex-1 bg-[var(--color-surface-1)] border border-[var(--color-line-1)] rounded-sm px-3 py-1.5 text-[12px] font-mono focus:outline-none focus:ring-1 focus:ring-[var(--color-hig-blue)]`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>l(),className:`px-3 py-1.5 text-[11px] font-mono uppercase tracking-wide border border-[var(--color-line-1)] rounded-sm hover:bg-white/5`,children:`Refresh`})]})]}),(0,D.jsx)(`div`,{className:`border border-[var(--color-line-1)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`overflow-x-auto`,children:(0,D.jsxs)(`table`,{className:`w-full text-[12px] font-mono`,children:[(0,D.jsx)(`thead`,{className:`bg-black/30 text-[var(--color-fg-3)] uppercase tracking-wide text-[10px]`,children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Status`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Client`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Session`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Started`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Duration`}),(0,D.jsx)(`th`,{className:`text-right px-3 py-2`,children:`Evals`}),(0,D.jsx)(`th`,{className:`text-right px-3 py-2 text-emerald-300/80`,children:`Allowed`}),(0,D.jsx)(`th`,{className:`text-right px-3 py-2 text-rose-300/80`,children:`Blocked`}),(0,D.jsx)(`th`,{className:`text-right px-3 py-2 text-amber-300/80`,children:`Asked`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Top Tool`}),(0,D.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Top Rule`})]})}),(0,D.jsxs)(`tbody`,{className:`divide-y divide-[var(--color-line-1)]/40`,children:[s&&p.length===0&&(0,D.jsx)(`tr`,{children:(0,D.jsx)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-[var(--color-fg-4)]`,children:`Loading sessions…`})}),c&&(0,D.jsx)(`tr`,{children:(0,D.jsxs)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-rose-300`,children:[`Failed to load sessions: `,c]})}),!s&&!c&&p.length===0&&(0,D.jsx)(`tr`,{children:(0,D.jsx)(`td`,{colSpan:11,className:`px-3 py-6 text-center text-[var(--color-fg-4)]`,children:d.length===0?`No sessions recorded yet.`:`No sessions match "${n}".`})}),p.map(e=>{let t=e.evals>0?Math.round(e.blocked/e.evals*1e3)/10:0;return(0,D.jsxs)(`tr`,{className:`hover:bg-white/[0.03] cursor-pointer`,children:[(0,D.jsx)(`td`,{className:`px-3 py-2`,children:(0,D.jsx)(`a`,{href:`/sessions/${encodeURIComponent(e.session_key)}`,className:`flex items-center gap-1.5 no-underline`,children:e.is_active?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,D.jsx)(`span`,{className:`text-emerald-300 text-[10px] uppercase tracking-wide`,children:`Live`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--color-fg-4)]`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] text-[10px] uppercase tracking-wide`,children:`Closed`})]})})}),(0,D.jsx)(`td`,{className:`px-3 py-2`,children:(0,D.jsx)(Sm,{client:e.client})}),(0,D.jsx)(`td`,{className:`px-3 py-2`,children:(0,D.jsx)(`a`,{href:`/sessions/${encodeURIComponent(e.session_key)}`,className:`text-[var(--color-fg-1)] hover:text-[var(--color-hig-blue)] hover:underline`,children:e.agent_id})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:bm(e.started_at)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:xm(e.duration_s)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right font-semibold`,children:e.evals.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right text-emerald-300`,children:e.allowed.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right`,children:e.blocked>0?(0,D.jsxs)(`span`,{className:`text-rose-300`,children:[e.blocked.toLocaleString(),t>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[10px]`,children:[`(`,t,`%)`]})]}):(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`0`})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right text-amber-300`,children:e.asked>0?e.asked.toLocaleString():(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`0`})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-2)] max-w-[180px] truncate`,children:e.top_tool??(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-2)] max-w-[200px] truncate`,children:e.top_rule??(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})})]},e.session_key)})]})]})})}),f>vm&&(0,D.jsxs)(`footer`,{className:`flex items-center justify-between text-[11px] font-mono text-[var(--color-fg-3)]`,children:[(0,D.jsxs)(`span`,{children:[e+1,`–`,Math.min(e+vm,f),` of`,` `,f.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,disabled:e===0,onClick:()=>t(Math.max(0,e-vm)),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`← Prev`}),(0,D.jsx)(`button`,{type:`button`,disabled:e+vm>=f,onClick:()=>t(e+vm),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`Next →`})]})]})]})}function wm({status:e,className:t=``}){return(0,D.jsx)(`span`,{className:`status-dot ${e===`ok`?`bg-[var(--color-decision-allow)]`:e===`warn`?`bg-[var(--color-decision-ask)]`:e===`fail`?`bg-[var(--color-decision-block)]`:`bg-[var(--color-fg-3)]`} ${t}`})}function Tm({status:e}){let t=e===`ok`?`text-[var(--color-decision-allow)]`:e===`warn`?`text-[var(--color-decision-ask)]`:e===`fail`?`text-[var(--color-decision-block)]`:`text-[var(--color-fg-3)]`,n=e===`ok`?`OK`:e===`warn`?`Warn`:e===`fail`?`Fail`:`Skipped`;return(0,D.jsx)(`span`,{className:`text-[10.5px] font-medium uppercase tracking-wide ${t}`,children:n})}function Em(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Dm(e){if(!e)return``;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Om(e,t){return t&&e.startsWith(`${t}/`)?`~/${e.slice(t.length+1)}`:e===t?`~`:e}function km({file:e,home:t,wired:n}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 py-1 border-b border-[var(--color-line-0)] last:border-0 text-[11.5px]`,children:[(0,D.jsx)(wm,{status:e.exists?n===void 0||n?`ok`:`warn`:`skip`}),(0,D.jsx)(`code`,{className:`flex-1 truncate text-[var(--color-fg-1)]`,title:e.path,children:Om(e.path,t)}),e.exists?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:Em(e.size)}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] min-w-[60px] text-right`,children:Dm(e.modified_at)}),n===!1&&(0,D.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-[var(--color-decision-ask)]`,title:`File exists but does not appear to contain SSG wiring`,children:`no ssg`}),n===!0&&(0,D.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-[var(--color-decision-allow)]`,title:`File contains SSG hook / MCP entries`,children:`wired`})]}):(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:`missing`})]})}function Am({title:e,status:t,children:n,hint:r}){return(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded`,children:[(0,D.jsxs)(`header`,{className:`flex items-center justify-between mb-3`,children:[(0,D.jsxs)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)] flex items-center gap-2`,children:[t!==void 0&&(0,D.jsx)(wm,{status:t}),e]}),r&&(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:r})]}),(0,D.jsx)(`div`,{children:n})]})}function jm({k:e,v:t,mono:n=!1}){return(0,D.jsxs)(`div`,{className:`flex items-baseline gap-3 py-1 text-[11.5px] border-b border-[var(--color-line-0)] last:border-0`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] min-w-[110px]`,children:e}),(0,D.jsx)(`span`,{className:`flex-1 text-[var(--color-fg-1)] ${n?`font-mono text-[11px]`:``}`,children:t})]})}var Mm={"claude-code":`Claude Code`,cursor:`Cursor`,codex:`Codex CLI`,pi:`Pi Agent`,gemini:`Gemini CLI`,antigravity:`Antigravity`,copilot:`GitHub Copilot`};function Nm({adapter:e,home:t}){let n=Mm[e.id]??e.id,r=e.artifacts.filter(e=>e.exists&&e.ssg_wired).length,i=e.artifacts.filter(e=>e.exists).length;return(0,D.jsxs)(`div`,{className:`rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(wm,{status:e.status}),(0,D.jsx)(`span`,{className:`text-[12.5px] font-semibold text-[var(--color-fg-0)]`,children:n}),e.active&&(0,D.jsx)(`span`,{className:`text-[9.5px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded-sm text-[var(--color-hig-blue)] bg-[color-mix(in_oklab,var(--color-hig-blue)_14%,transparent)]`,title:`This is the adapter ssg is currently using at runtime`,children:`Active`})]}),(0,D.jsxs)(`span`,{className:`text-[10px] text-[var(--color-fg-3)]`,children:[r,`/`,e.artifacts.length,` wired`]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-2 text-[10.5px]`,children:[(0,D.jsx)(`span`,{className:e.detected?`text-[var(--color-decision-allow)]`:`text-[var(--color-fg-3)]`,children:e.detected?`● detected`:`○ not detected`}),(0,D.jsx)(`span`,{className:e.healthy?`text-[var(--color-decision-allow)]`:`text-[var(--color-fg-3)]`,children:e.healthy?`● binary healthy`:`○ binary missing`}),i===0&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`○ no config files on disk`})]}),e.artifacts.length>0&&(0,D.jsx)(`div`,{className:`border-t border-[var(--color-line-0)] pt-1`,children:e.artifacts.map(e=>(0,D.jsx)(km,{file:e,home:t,wired:e.exists?e.ssg_wired:void 0},e.path))}),e.status===`warn`&&i===0&&(0,D.jsxs)(`div`,{className:`mt-2 text-[10.5px] text-[var(--color-fg-3)]`,children:[`Wire it up with:`,` `,(0,D.jsxs)(`code`,{className:`font-mono text-[var(--color-fg-1)]`,children:[`ssg init --client=`,e.id]})]})]})}function Pm(){let{data:e,loading:t,error:n,refetch:r}=V(`/api/json/setup-status`);if(t&&!e)return(0,D.jsx)(`div`,{className:`py-12 text-center text-[var(--color-fg-3)] text-[12px]`,children:`Reading setup status…`});if(n||!e)return(0,D.jsxs)(`div`,{className:`hig-card hig-card-padded text-[12px]`,children:[(0,D.jsxs)(`p`,{className:`text-[var(--color-decision-block)] mb-2`,children:[`Could not load /api/json/setup-status: `,n??`no response`]}),(0,D.jsx)(`button`,{onClick:r,className:`hig-button hig-button-small`,children:`Retry`})]});let{summary:i,license:a,daemon:o,dashboard:s,native:c,db:l,mcp:u,rules:d,init_files:f,adapters:p,hub:m,checks:h,home:g,cwd:_}=e;return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`Setup Status`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`What `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg init`}),` wrote and whether every piece is wired up — license, hooks, MCP, native engine, daemon, rules, and hub packages.`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsxs)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:[`ssg v`,e.version]}),(0,D.jsx)(`button`,{onClick:r,className:`hig-button hig-button-small`,children:`Refresh`})]})]}),(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded flex items-center gap-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(wm,{status:i.overall,className:`!w-3 !h-3`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-[var(--color-fg-3)]`,children:`Overall`}),(0,D.jsx)(`div`,{className:`text-[14px] font-semibold text-[var(--color-fg-0)]`,children:i.overall===`ok`?`Healthy`:i.overall===`warn`?`Needs attention`:i.overall===`fail`?`Broken`:`Skipped`})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-4 text-[12px]`,children:[(0,D.jsxs)(`span`,{className:`text-[var(--color-decision-allow)]`,children:[`● `,i.ok,` ok`]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-decision-ask)]`,children:[`● `,i.warn,` warn`]}),i.fail>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-decision-block)]`,children:[`● `,i.fail,` fail`]}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`○ `,i.skip,` skipped`]})]}),(0,D.jsxs)(`div`,{className:`ml-auto text-right`,children:[(0,D.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)]`,children:`Working dir`}),(0,D.jsx)(`code`,{className:`text-[11px] text-[var(--color-fg-1)]`,title:_,children:Om(_,g)})]})]}),(0,D.jsx)(Am,{title:`Checks`,hint:`${h.length} probes`,children:(0,D.jsx)(`div`,{children:h.map(e=>(0,D.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,D.jsx)(wm,{status:e.status,className:`mt-1`}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--color-fg-0)]`,children:e.name}),(0,D.jsx)(Tm,{status:e.status})]}),(0,D.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-2)] mt-0.5 break-words`,children:e.detail}),e.fix&&(0,D.jsxs)(`div`,{className:`text-[11px] text-[var(--color-hig-blue)] font-mono mt-0.5`,children:[`→ `,e.fix]})]})]},e.name))})}),(0,D.jsxs)(Am,{title:`License & authentication`,status:a.status===`healthy`||a.status===`healthy_free`?`ok`:`warn`,children:[(0,D.jsx)(jm,{k:`Tier`,v:a.tier_label}),(0,D.jsx)(jm,{k:`Status`,v:a.status}),(0,D.jsx)(jm,{k:`Account`,v:a.email??`—`}),(0,D.jsx)(jm,{k:`Auth method`,v:a.auth_method??`—`}),(0,D.jsx)(jm,{k:`Evals today`,v:a.eval_daily_limit===null?`${a.evals_today.toLocaleString()} (unlimited)`:`${a.evals_today.toLocaleString()} / ${a.eval_daily_limit.toLocaleString()}`}),(0,D.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] mb-1`,children:`Credential files`}),(0,D.jsx)(km,{file:a.license_file,home:g}),(0,D.jsx)(km,{file:a.hosts_file,home:g})]})]}),(0,D.jsxs)(Am,{title:`Runtime processes`,status:o.alive&&s.alive?`ok`:`warn`,children:[(0,D.jsx)(jm,{k:`Daemon (evald)`,v:o.alive?`running — PID ${o.pid}`:o.pid?`stale — PID ${o.pid} in pidfile but process gone`:`not running`}),(0,D.jsx)(jm,{k:`Daemon socket`,v:o.socket_exists?`present`:`missing`,mono:!0}),(0,D.jsx)(jm,{k:`Dashboard (serve)`,v:s.alive?`running — PID ${s.pid}`:`not running`}),(0,D.jsx)(jm,{k:`Native engine`,v:c.available?`loaded — sub-ms eval available`:`unavailable — TypeScript fallback`})]}),(0,D.jsxs)(Am,{title:`Database & MCP`,status:l.status,children:[(0,D.jsx)(jm,{k:`Rules in DB`,v:l.rules.toLocaleString()}),(0,D.jsx)(jm,{k:`Audit log rows`,v:l.audit_rows.toLocaleString()}),(0,D.jsx)(jm,{k:`DB path`,v:Om(l.path,g),mono:!0}),(0,D.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] mb-1`,children:`MCP server`}),(0,D.jsx)(jm,{k:`Status`,v:u.status===`active`?`active — ${u.recent_5min.toLocaleString()} calls in last 5 min`:u.status===`configured`?`configured — ${u.total.toLocaleString()} historical calls, none recent`:`no MCP traffic recorded yet`}),(0,D.jsx)(jm,{k:`All-time calls`,v:u.total.toLocaleString()})]})]}),(0,D.jsxs)(Am,{title:`Rules directories`,status:d.local_count>0?`ok`:`warn`,children:[(0,D.jsx)(jm,{k:`Local`,v:`${d.local_count} .rules file${d.local_count===1?``:`s`}`}),(0,D.jsx)(jm,{k:`Local path`,v:Om(d.local_dir,g),mono:!0}),(0,D.jsx)(jm,{k:`Global`,v:`${d.global_count} .rules file${d.global_count===1?``:`s`}`}),(0,D.jsx)(jm,{k:`Global path`,v:Om(d.global_dir,g),mono:!0})]}),(0,D.jsx)(Am,{title:`Project init files`,hint:`${f.filter(e=>e.exists).length}/${f.length} present`,children:(0,D.jsx)(`div`,{children:f.map(e=>(0,D.jsx)(km,{file:e,home:g},e.path))})}),(0,D.jsx)(Am,{title:`Adapters, hooks & MCP files`,hint:e.active_adapter?`Active: ${Mm[e.active_adapter]??e.active_adapter}`:`No active adapter`,children:(0,D.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-1 lg:grid-cols-2`,children:p.map(e=>(0,D.jsx)(Nm,{adapter:e,home:g},e.id))})}),(0,D.jsxs)(Am,{title:`Hub-installed rulesets`,status:m.installs.length===0?`skip`:m.drift===0?`ok`:`warn`,hint:m.installs.length===0?`none installed`:`${m.in_sync} in sync${m.drift>0?`, ${m.drift} drift`:``}`,children:[(0,D.jsx)(km,{file:m.pins_file,home:g}),m.installs.length===0?(0,D.jsxs)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)] mt-2`,children:[`Install rulesets from the Hub tab. Each install is recorded per project path in `,(0,D.jsx)(`code`,{className:`font-mono`,children:`hub-pins.json`}),`.`]}):(0,D.jsx)(`div`,{className:`mt-2 space-y-2`,children:m.installs.map((e,t)=>(0,D.jsxs)(`div`,{className:`rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-2 text-[11.5px]`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,D.jsx)(wm,{status:e.in_sync?`ok`:`warn`}),(0,D.jsx)(`span`,{className:`font-semibold text-[var(--color-fg-0)]`,children:e.id}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:e.version}),(0,D.jsx)(`span`,{className:`ml-auto text-[10.5px] text-[var(--color-fg-3)]`,children:Dm(e.installed_at)})]}),(0,D.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--color-fg-2)]`,title:e.path,children:Om(e.path,g)}),e.files.length>0&&(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.files.map(e=>(0,D.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-2)] bg-[var(--color-surface-2)] border border-[var(--color-line-0)] rounded-sm px-1.5 py-0.5`,children:e},e))}),!e.in_sync&&e.drift_reason&&(0,D.jsxs)(`div`,{className:`mt-1 text-[10.5px] text-[var(--color-decision-ask)]`,children:[`Drift: `,e.drift_reason]})]},`${e.id}-${e.path}-${t}`))})]})]})}var Fm=[{id:`files`,label:`Files & folders`,blurb:`Deleting or changing things on your hard drive`},{id:`secrets`,label:`Secrets & keys`,blurb:`Reading or overwriting credentials and private files`},{id:`network`,label:`Network calls`,blurb:`Reaching out to websites and external APIs`},{id:`install`,label:`Installing software`,blurb:`Pulling new code or packages from the internet`},{id:`communication`,label:`Sending messages`,blurb:`Outgoing emails, posts, or chat messages`}],Im=[{id:`erase-folder`,label:`AI tries to erase a folder`,plainEffect:`Permanently deletes every file inside the "output" folder. Recovery is hard.`,category:`files`,emoji:`🗑️`,toolCall:{tool:`Bash`,input:{command:`find ./output -type f -delete`}},displayByOs:{windows:`Remove-Item .\\output -Recurse -Force`,macos:`find ./output -type f -delete`,linux:`find ./output -type f -delete`}},{id:`write-env`,label:`AI tries to write your .env file`,plainEffect:`Overwrites the file that holds your API keys, passwords, and other secrets.`,category:`secrets`,emoji:`⚠️`,toolCall:{tool:`Write`,input:{file_path:`.env`,content:`API_KEY=test`}}},{id:`read-ssh-key`,label:`AI tries to read your private key`,plainEffect:`Opens the SSH key that proves you are you on remote servers. Copying it is identity theft.`,category:`secrets`,emoji:`🔑`,toolCall:{tool:`Read`,input:{file_path:`~/.ssh/id_rsa`}},displayByOs:{windows:`Read C:\\Users\\You\\.ssh\\id_rsa`,macos:`Read ~/.ssh/id_rsa`,linux:`Read ~/.ssh/id_rsa`}},{id:`install-package`,label:`AI tries to install a package`,plainEffect:`Downloads code from a public registry and adds it to your project. The code runs with your permissions.`,category:`install`,emoji:`📦`,toolCall:{tool:`Bash`,input:{command:`npm install some-package --save`}}},{id:`fetch-web`,label:`AI tries to fetch a URL`,plainEffect:`Makes a web request to an outside service. Could leak data or pull in instructions.`,category:`network`,emoji:`🌐`,toolCall:{tool:`WebFetch`,input:{url:`https://api.example.com/data`,prompt:``}}},{id:`send-email`,label:`AI tries to send an email`,plainEffect:`Sends an email from your machine without your review. Anyone could end up CC’d.`,category:`communication`,emoji:`📧`,toolCall:{tool:`Bash`,input:{command:`sendmail -t < message.txt`}},displayByOs:{windows:`Send-MailMessage -To you@example.com -Subject "..." -Body (Get-Content message.txt)`,macos:`sendmail -t < message.txt`,linux:`sendmail -t < message.txt`}}],Lm=`ssg.tryit.intro-dismissed.v1`,Rm=`ssg.tryit.os.v1`,zm={allow:{label:`Allowed`,color:`text-emerald-300`,bg:`border-emerald-500/30 bg-emerald-500/5`,icon:`✓`,headline:`SSG would let this happen.`,next:`In real life, the AI would go ahead. If you would rather it didn’t, add a rule on the Rules page.`},block:{label:`Blocked`,color:`text-red-300`,bg:`border-red-500/30 bg-red-500/5`,icon:`✕`,headline:`SSG would stop this from running.`,next:`The AI never gets to perform the action. No files change, no commands run, no requests go out.`},ask:{label:`Ask first`,color:`text-amber-300`,bg:`border-amber-500/30 bg-amber-500/5`,icon:`?`,headline:`SSG would pause and ask you first.`,next:`You’d get a prompt on the Approvals page. Nothing happens until you click Allow or Deny.`},log:{label:`Logged`,color:`text-sky-300`,bg:`border-sky-500/30 bg-sky-500/5`,icon:`≡`,headline:`SSG would allow it but write it down.`,next:`The AI proceeds, and the action gets recorded in your Activity log for later review.`},force:{label:`Force-allow`,color:`text-violet-300`,bg:`border-violet-500/30 bg-violet-500/5`,icon:`→`,headline:`A high-priority rule explicitly allows this.`,next:`A “force” rule overrides anything that would have blocked or paused this action.`}};function Bm(){if(typeof window>`u`)return`linux`;try{let e=window.localStorage.getItem(Rm);if(e===`windows`||e===`macos`||e===`linux`)return e}catch{}let e=navigator.userAgent.toLowerCase();return e.includes(`win`)?`windows`:e.includes(`mac`)?`macos`:`linux`}function Vm(e){return e===`windows`?`Windows`:e===`macos`?`Mac`:`Linux`}function Hm(e){return e===`windows`?`⊞`:e===`macos`?`🍎`:`🐧`}function Um(e,t){let n=e.displayByOs?.[t];if(n)return n;let r=e.toolCall;return r.input.command?r.input.command:r.input.file_path?r.input.file_path:r.input.url?r.input.url:JSON.stringify(r.input)}function Wm({n:e,label:t}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-full bg-[var(--color-brand)]/15 text-[var(--color-brand)] text-[10px] font-semibold shrink-0`,children:e}),(0,D.jsx)(`span`,{className:`text-[11.5px] text-[var(--color-fg-2)] truncate`,children:t})]})}function Gm({os:e,setOs:t}){return(0,D.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-full border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-0.5`,children:[`windows`,`macos`,`linux`].map(n=>(0,D.jsxs)(`button`,{onClick:()=>t(n),className:`px-2.5 py-1 rounded-full text-[10.5px] font-medium cursor-pointer transition-colors ${n===e?`bg-[var(--color-brand)]/15 text-[var(--color-brand)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Show commands as they would look on ${Vm(n)}`,children:[Hm(n),` `,Vm(n)]},n))})}function Km({os:e,setOs:t,onDismiss:n}){return(0,D.jsxs)(`div`,{className:`rounded-2xl border border-[var(--color-brand)]/25 bg-[var(--color-brand)]/[0.04] p-4 sm:p-5 space-y-3.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[15px] font-semibold text-[var(--color-fg-0)] leading-tight`,children:`What SSG does — and why this page is here`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-1 leading-relaxed max-w-[60ch]`,children:[`AI coding agents can run any command on your computer: delete files, read your secrets, send emails, install packages. SSG is the policy engine that decides which of those they’re actually allowed to do.`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-0)] font-medium`,children:`This sandbox shows SSG’s decisions in real time`}),`, without anything actually running. Pick a scenario, click Run, see what your guardrails would do.`]})]}),(0,D.jsx)(`button`,{onClick:n,className:`shrink-0 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] cursor-pointer text-[14px] leading-none p-1 -m-1`,"aria-label":`Dismiss intro`,title:`Hide this primer`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-[11.5px]`,children:[(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`Nothing executes`]}),(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`No files modified`]}),(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-emerald-300`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`No network traffic`]})]}),(0,D.jsxs)(`div`,{className:`rounded-xl border border-[var(--color-line-1)]/60 bg-[var(--color-surface-1)]/40 p-3`,children:[(0,D.jsx)(`p`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] font-semibold mb-2`,children:`How it works`}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3`,children:[(0,D.jsx)(Wm,{n:1,label:`Pick a scenario below`}),(0,D.jsx)(Wm,{n:2,label:`Click Run`}),(0,D.jsx)(Wm,{n:3,label:`See the decision SSG would make`})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,D.jsx)(`span`,{className:`text-[11.5px] text-[var(--color-fg-3)]`,children:`Showing commands as they look on`}),(0,D.jsx)(Gm,{os:e,setOs:t}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-4)]`,children:`(cosmetic — SSG’s decision is the same on every OS)`})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap pt-1`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] italic max-w-[44ch] leading-snug`,children:`Every AI agent will need a policy layer. This is what one looks like.`}),(0,D.jsx)(`button`,{onClick:n,className:`text-[11.5px] font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] cursor-pointer underline-offset-2 hover:underline`,children:`Got it, hide this primer`})]})]})}function qm({scenario:e,selected:t,os:n,onClick:r}){return(0,D.jsxs)(`button`,{onClick:r,className:`flex flex-col gap-1.5 rounded-xl border px-3.5 py-3 text-left cursor-pointer transition-all ${t?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/8 shadow-[0_0_0_3px_color-mix(in_oklab,var(--color-brand)_15%,transparent)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)] hover:border-[var(--color-line-2)] hover:bg-[var(--color-surface-2)]/40`}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[18px] leading-none shrink-0`,children:e.emoji}),(0,D.jsx)(`span`,{className:`text-[13px] font-medium text-[var(--color-fg-0)] leading-snug flex-1 min-w-0`,children:e.label})]}),(0,D.jsx)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)] leading-snug`,children:e.plainEffect}),(0,D.jsx)(`p`,{className:`font-mono text-[10.5px] text-[var(--color-fg-4)] truncate`,children:Um(e,n)})]})}function Jm(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(`Bash`),[f,p]=(0,_.useState)(`{"command": ""}`),[m,h]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Lm)===`1`}catch{return!1}}),[g,v]=(0,_.useState)(()=>Bm()),[y,b]=(0,_.useState)(!1);function x(e){v(e);try{window.localStorage.setItem(Rm,e)}catch{}}function S(){h(!0);try{window.localStorage.setItem(Lm,`1`)}catch{}}function C(){h(!1);try{window.localStorage.removeItem(Lm)}catch{}}let w=Im.find(t=>t.id===e),T=(0,_.useMemo)(()=>{let e=new Map;for(let t of Im){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return Fm.filter(t=>e.has(t.id)).map(t=>({...t,scenarios:e.get(t.id)}))},[]);(0,_.useEffect)(()=>{(n||o)&&window.scrollTo({top:(document.getElementById(`tryit-result`)?.offsetTop??0)-80,behavior:`smooth`})},[n,o]),(0,_.useEffect)(()=>{if(typeof window>`u`)return;let e=new URLSearchParams(window.location.search).get(`scenario`);e&&Im.some(t=>t.id===e)&&t(e)},[]),(0,_.useEffect)(()=>{if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`scenario`,e):t.searchParams.delete(`scenario`),window.history.replaceState({},``,t.toString())},[e]);function E(){if(!e)return;let t=new URL(window.location.href);t.searchParams.set(`scenario`,e),navigator.clipboard.writeText(t.toString()).then(()=>{b(!0),setTimeout(()=>b(!1),2e3)}).catch(()=>{})}async function O(e){a(!0),s(null),r(null);try{let t=await(await fetch(`/api/json/eval-dry-run`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify(e)})).json();t.error?s(t.error):r(t)}catch{s(`Could not reach the governance engine. Is SSG running?`)}finally{a(!1)}}function k(){w&&O(w.toolCall)}function A(){let e;try{e=JSON.parse(f)}catch{s(`Invalid JSON in input field.`);return}if(typeof e!=`object`||!e){s(`Input must be a JSON object.`);return}O({tool:u,input:e})}let j=n?zm[n.decision]??zm.allow:null;return(0,D.jsxs)(`div`,{className:`max-w-3xl mx-auto py-4 space-y-4`,children:[(0,D.jsxs)(`header`,{className:`flex items-baseline justify-between gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[22px] font-semibold text-[var(--color-fg-0)] tracking-tight leading-tight`,children:`Try it`}),(0,D.jsxs)(`p`,{className:`text-[13px] text-[var(--color-fg-2)] mt-0.5`,children:[`Your AI can run any command. SSG decides what it’s actually allowed to do.`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`Pick a scenario to see — nothing actually runs.`})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[m&&(0,D.jsx)(`button`,{onClick:C,className:`text-[11.5px] font-medium text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] cursor-pointer`,title:`Show the introduction again`,children:`What is Try It? →`}),(0,D.jsx)(`a`,{href:`/guardrails`,className:`text-[11.5px] font-medium text-[var(--color-brand)] hover:underline`,children:`Install more guardrails →`})]})]}),!m&&(0,D.jsx)(Km,{os:g,setOs:x,onDismiss:S}),m&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Commands shown as on`}),(0,D.jsx)(Gm,{os:g,setOs:x})]}),(0,D.jsx)(`div`,{className:`space-y-4`,children:T.map(n=>(0,D.jsxs)(`section`,{className:`space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2 px-1`,children:[(0,D.jsx)(`h3`,{className:`text-[11px] uppercase tracking-wide text-[var(--color-fg-3)] font-semibold`,children:n.label}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:n.blurb})]}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:n.scenarios.map(n=>(0,D.jsx)(qm,{scenario:n,selected:e===n.id,os:g,onClick:()=>{t(n.id),r(null),s(null)}},n.id))})]},n.id))}),w&&(0,D.jsxs)(`div`,{className:`rounded-xl border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-4 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`span`,{className:`text-[22px] leading-none shrink-0`,children:w.emoji}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[13.5px] font-medium text-[var(--color-fg-0)]`,children:w.label}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-0.5 leading-relaxed`,children:w.plainEffect})]})]}),(0,D.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-0)] bg-[var(--color-surface-0)] px-3 py-2`,children:[(0,D.jsxs)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold mb-1`,children:[`What the AI would run · `,Vm(g)]}),(0,D.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--color-fg-1)] break-all`,children:Um(w,g)})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,D.jsxs)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)]`,children:[`Click Run to see what SSG would decide.`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`The command does not actually execute.`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsx)(`button`,{onClick:E,className:`inline-flex items-center gap-1 px-3 h-8 rounded-full text-[11.5px] font-medium cursor-pointer transition-colors
49
51
  border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-2)]
50
- hover:bg-[var(--color-surface-2)]/40 hover:text-[var(--color-fg-0)]`,title:`Copy a deep-link to this exact scenario`,children:y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M20 6L9 17l-5-5`})}),`Link copied`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.5 1.5M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.5-1.5`})}),`Copy share link`]})}),(0,K.jsx)(`button`,{onClick:O,disabled:i,className:`inline-flex items-center gap-1.5 px-4 h-8 rounded-full text-[12px] font-medium cursor-pointer transition-colors
52
+ hover:bg-[var(--color-surface-2)]/40 hover:text-[var(--color-fg-0)]`,title:`Copy a deep-link to this exact scenario`,children:y?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M20 6L9 17l-5-5`})}),`Link copied`]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.5 1.5M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.5-1.5`})}),`Copy share link`]})}),(0,D.jsx)(`button`,{onClick:k,disabled:i,className:`inline-flex items-center gap-1.5 px-4 h-8 rounded-full text-[12px] font-medium cursor-pointer transition-colors
51
53
  bg-[var(--color-brand)] text-white hover:opacity-90
52
- disabled:opacity-40 disabled:cursor-not-allowed`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`svg`,{className:`animate-spin`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`Running`]}):(0,K.jsxs)(K.Fragment,{children:[`Run simulation`,(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M5 12h14M13 5l7 7-7 7`})})]})})]})]})]}),n&&A&&(0,K.jsxs)(`div`,{id:`tryit-result`,className:`rounded-xl border p-4 ${A.bg} space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex items-center justify-center w-9 h-9 rounded-full text-lg font-bold border ${A.bg} ${A.color}`,children:A.icon}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[15px] font-semibold ${A.color}`,children:A.label}),(0,K.jsx)(`p`,{className:`text-[12.5px] mt-0.5 ${A.color} opacity-90`,children:A.headline})]})]}),(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-1)] leading-relaxed`,children:A.next}),(0,K.jsxs)(`div`,{className:`rounded-lg bg-[var(--color-surface-0)]/60 border border-[var(--color-line-0)] px-3 py-2 space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold`,children:`Why this decision`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-1)] leading-relaxed`,children:n.reason??`No specific rule matched this action — SSG defaults to allowing things that aren’t covered by a rule.`}),(0,K.jsxs)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1.5`,children:[n.rules_evaluated,` rule`,n.rules_evaluated===1?``:`s`,` checked`,n.rule_id&&(0,K.jsxs)(K.Fragment,{children:[` `,`· matched`,` `,(0,K.jsx)(`a`,{href:`/rules?focus=${encodeURIComponent(n.rule_id)}`,className:`font-mono text-[var(--color-brand)] hover:underline`,children:n.rule_id})]})]})]}),w&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-0)] bg-[var(--color-surface-0)]/60 px-3 py-2.5 flex items-start gap-2.5`,children:[(0,K.jsx)(`span`,{className:`text-[15px] leading-none mt-0.5 shrink-0`,children:n.decision===`block`?`🛡️`:n.decision===`allow`?`⚠️`:n.decision===`ask`?`⏸️`:`ℹ️`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold`,children:n.decision===`block`?`What you just avoided`:n.decision===`allow`?`What this would actually do`:n.decision===`ask`?`What you’d be asked to confirm`:`What gets recorded`}),(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-1)] leading-relaxed mt-0.5`,children:w.plainEffect})]})]}),n.decision===`allow`&&(0,K.jsxs)(`a`,{href:`/guardrails`,className:`inline-flex items-center gap-1.5 px-3.5 h-8 rounded-full text-[12px] font-medium
53
- bg-[var(--color-brand)] text-white hover:opacity-90 transition-colors`,children:[`Add a rule to block this`,(0,K.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M5 12h14M13 5l7 7-7 7`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-[11.5px] pt-1`,children:[n.decision===`block`&&(0,K.jsx)(`a`,{href:`/rules`,className:`font-medium text-[var(--color-brand)] hover:underline`,children:`See the rule that did this →`}),n.decision===`ask`&&(0,K.jsx)(`a`,{href:`/approvals`,className:`font-medium text-[var(--color-brand)] hover:underline`,children:`See where the prompt appears →`}),(0,K.jsx)(`a`,{href:`/audit`,className:`font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] hover:underline`,children:`See real decisions in your Activity log →`}),(0,K.jsx)(`a`,{href:`https://sigmashake.com`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] hover:underline`,children:`Tell a teammate about SSG ↗`})]})]}),o&&(0,K.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-red-500/5 px-4 py-3 text-[12px] text-red-300`,children:o}),(0,K.jsxs)(`div`,{className:`pt-2`,children:[(0,K.jsx)(`button`,{onClick:()=>l(e=>!e),className:`text-[11px] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] transition-colors cursor-pointer`,children:c?`▲ Hide custom input`:`▼ Advanced: write your own scenario`}),c&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-xl border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] leading-relaxed`,children:`Pick a tool the AI would call, and the input it would pass. Same idea as the scenarios above — still a simulation, still nothing actually runs.`}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:`Tool`}),(0,K.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-md px-2 h-8 focus:outline-none`,children:[`Bash`,`Read`,`Write`,`Edit`,`WebFetch`,`WebSearch`,`Agent`,`Glob`,`Grep`].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-[200px] flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:`Input JSON`}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-md px-2 h-8 focus:outline-none focus:border-[var(--color-brand)]/50`})]}),(0,K.jsx)(`button`,{onClick:k,disabled:i,className:`px-3 h-8 rounded-full text-[11px] font-medium cursor-pointer transition-colors
54
+ disabled:opacity-40 disabled:cursor-not-allowed`,children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`svg`,{className:`animate-spin`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,D.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})}),`Running`]}):(0,D.jsxs)(D.Fragment,{children:[`Run simulation`,(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M5 12h14M13 5l7 7-7 7`})})]})})]})]})]}),n&&j&&(0,D.jsxs)(`div`,{id:`tryit-result`,className:`rounded-xl border p-4 ${j.bg} space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`span`,{className:`flex items-center justify-center w-9 h-9 rounded-full text-lg font-bold border ${j.bg} ${j.color}`,children:j.icon}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[15px] font-semibold ${j.color}`,children:j.label}),(0,D.jsx)(`p`,{className:`text-[12.5px] mt-0.5 ${j.color} opacity-90`,children:j.headline})]})]}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-1)] leading-relaxed`,children:j.next}),(0,D.jsxs)(`div`,{className:`rounded-lg bg-[var(--color-surface-0)]/60 border border-[var(--color-line-0)] px-3 py-2 space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold`,children:`Why this decision`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-1)] leading-relaxed`,children:n.reason??`No specific rule matched this action — SSG defaults to allowing things that aren’t covered by a rule.`}),(0,D.jsxs)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1.5`,children:[n.rules_evaluated,` rule`,n.rules_evaluated===1?``:`s`,` checked`,n.rule_id&&(0,D.jsxs)(D.Fragment,{children:[` `,`· matched`,` `,(0,D.jsx)(`a`,{href:`/rules?focus=${encodeURIComponent(n.rule_id)}`,className:`font-mono text-[var(--color-brand)] hover:underline`,children:n.rule_id})]})]})]}),w&&(0,D.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-0)] bg-[var(--color-surface-0)]/60 px-3 py-2.5 flex items-start gap-2.5`,children:[(0,D.jsx)(`span`,{className:`text-[15px] leading-none mt-0.5 shrink-0`,children:n.decision===`block`?`🛡️`:n.decision===`allow`?`⚠️`:n.decision===`ask`?`⏸️`:`ℹ️`}),(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-4)] font-semibold`,children:n.decision===`block`?`What you just avoided`:n.decision===`allow`?`What this would actually do`:n.decision===`ask`?`What you’d be asked to confirm`:`What gets recorded`}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-1)] leading-relaxed mt-0.5`,children:w.plainEffect})]})]}),n.decision===`allow`&&(0,D.jsxs)(`a`,{href:`/guardrails`,className:`inline-flex items-center gap-1.5 px-3.5 h-8 rounded-full text-[12px] font-medium
55
+ bg-[var(--color-brand)] text-white hover:opacity-90 transition-colors`,children:[`Add a rule to block this`,(0,D.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M5 12h14M13 5l7 7-7 7`})})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-[11.5px] pt-1`,children:[n.decision===`block`&&(0,D.jsx)(`a`,{href:`/rules`,className:`font-medium text-[var(--color-brand)] hover:underline`,children:`See the rule that did this →`}),n.decision===`ask`&&(0,D.jsx)(`a`,{href:`/approvals`,className:`font-medium text-[var(--color-brand)] hover:underline`,children:`See where the prompt appears →`}),(0,D.jsx)(`a`,{href:`/audit`,className:`font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] hover:underline`,children:`See real decisions in your Activity log →`}),(0,D.jsx)(`a`,{href:`https://sigmashake.com`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-[var(--color-fg-2)] hover:text-[var(--color-fg-0)] hover:underline`,children:`Tell a teammate about SSG ↗`})]})]}),o&&(0,D.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-red-500/5 px-4 py-3 text-[12px] text-red-300`,children:o}),(0,D.jsxs)(`div`,{className:`pt-2`,children:[(0,D.jsx)(`button`,{onClick:()=>l(e=>!e),className:`text-[11px] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] transition-colors cursor-pointer`,children:c?`▲ Hide custom input`:`▼ Advanced: write your own scenario`}),c&&(0,D.jsxs)(`div`,{className:`mt-3 rounded-xl border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 space-y-2`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] leading-relaxed`,children:`Pick a tool the AI would call, and the input it would pass. Same idea as the scenarios above — still a simulation, still nothing actually runs.`}),(0,D.jsxs)(`div`,{className:`flex items-end gap-2 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(`label`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:`Tool`}),(0,D.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-md px-2 h-8 focus:outline-none`,children:[`Bash`,`Read`,`Write`,`Edit`,`WebFetch`,`WebSearch`,`Agent`,`Glob`,`Grep`].map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-[200px] flex flex-col gap-1`,children:[(0,D.jsx)(`label`,{className:`text-[10px] font-mono text-[var(--color-fg-3)]`,children:`Input JSON`}),(0,D.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-[11px] font-mono rounded-md px-2 h-8 focus:outline-none focus:border-[var(--color-brand)]/50`})]}),(0,D.jsx)(`button`,{onClick:A,disabled:i,className:`px-3 h-8 rounded-full text-[11px] font-medium cursor-pointer transition-colors
54
56
  bg-[var(--color-fg-1)] text-[var(--color-bg)] hover:opacity-90
55
- disabled:opacity-40 disabled:cursor-not-allowed`,children:`Run`})]})]})]})]})}function Kp(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}function qp(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.enabled!==i.enabled||n.toolGroups.length!==i.toolGroups.length||n.toolGroups.some((e,t)=>e!==i.toolGroups[t]))return!1}return!0}function Jp(e,t){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(`project`),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)({}),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(0),C=(0,_.useRef)(null);(0,_.useEffect)(()=>{let n=`${e}:${u}:${x}`,i=C.current!==n;C.current=n;let o=!1,c=setTimeout(()=>{i&&(s(!0),l(null));let n=new URLSearchParams({agent:e,projectDir:t,scope:u});fetch(`/api/json/adapters/toggles?${n.toString()}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(o)return;r(t.catalog);let n=t.resolved[e]??{hooks:{},mcp:{}};a(n),i&&(p({...n.hooks}),h(Object.fromEntries(Object.entries(n.mcp).map(([e,t])=>[e,{...t,toolGroups:[...t.toolGroups]}]))),s(!1))}).catch(e=>{o||i&&(l(e instanceof Error?e.message:String(e)),s(!1))})},i?0:250);return()=>{o=!0,clearTimeout(c)}},[e,t,u,x]);let w=(0,_.useCallback)(()=>S(e=>e+1),[]);return{catalog:n,loading:o,fetchError:c,scope:u,setScope:d,hooks:f,mcp:m,setHook:(0,_.useCallback)((e,t)=>{p(n=>({...n,[e]:t}))},[]),setMcpEnabled:(0,_.useCallback)((e,t)=>{h(n=>({...n,[e]:{...n[e]??{enabled:!0,toolGroups:[`core`]},enabled:t}}))},[]),setMcpToolGroups:(0,_.useCallback)((e,t)=>{h(n=>({...n,[e]:{...n[e]??{enabled:!0,toolGroups:[`core`]},toolGroups:t}}))},[]),hasChanges:i!==null&&(!Kp(f,i.hooks)||!qp(m,i.mcp)),saving:g,saveError:y,refetch:w,save:(0,_.useCallback)(async()=>{v(!0),b(null);try{let n=await(await fetch(`/api/json/adapters/toggles`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({agent:e,scope:u,projectDir:t,changes:{hooks:f,mcp:m}})})).json();if(!n.ok)b(n.error??`Save failed`);else{let e=n.resolved??{hooks:f,mcp:m};a(e),p({...e.hooks}),h(Object.fromEntries(Object.entries(e.mcp).map(([e,t])=>[e,{...t,toolGroups:[...t.toolGroups]}])))}}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e,u,t,f,m]),saveAndInstall:(0,_.useCallback)(async(t,n)=>{v(!0),b(null);try{let r=await(await fetch(`/api/json/adapters/toggles`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({agent:e,scope:u,projectDir:t,changes:{hooks:f,mcp:m}})})).json();if(!r.ok){b(r.error??`Save failed`),n?.(!1);return}a(r.resolved??{hooks:f,mcp:m});let i=await(await fetch(`/api/json/adapters/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({adapter:e,projectDir:t})})).json();i.ok?n?.(!0):(b(i.error??`Install failed`),n?.(!1))}catch(e){b(e instanceof Error?e.message:String(e)),n?.(!1)}finally{v(!1)}},[e,u,t,f,m])}}function Yp({groups:e,selected:t,onChange:n,disabled:r}){let i=(0,_.useRef)(null);function a(e){if(t.includes(e)){let r=t.filter(t=>t!==e);if(r.length>0)n(r);else{i.current&&(i.current.textContent=``,requestAnimationFrame(()=>{i.current&&(i.current.textContent=`At least one tool group must remain enabled.`)}));let t=document.getElementById(`chip-${e}`);t&&(t.classList.remove(`chip--shake-deny`),t.offsetWidth,t.classList.add(`chip--shake-deny`),t.addEventListener(`animationend`,()=>t.classList.remove(`chip--shake-deny`),{once:!0}))}}else n([...t,e])}return(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[e.map(e=>{let n=t.includes(e.id);return(0,K.jsx)(`button`,{id:`chip-${e.id}`,type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a(e.id),className:`chip${n?` chip--active`:``}`,children:e.label},e.id)}),(0,K.jsx)(`span`,{ref:i,className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`})]})}function Xp(){return(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5 mb-4`,children:[0,1,2,3].map(e=>(0,K.jsx)(`div`,{className:`shimmer agent-toggles-skeleton-row`},e))})}function Zp({agentId:e,projectDir:t,onApplied:n}){let{catalog:r,loading:i,fetchError:a,scope:o,setScope:s,hooks:c,mcp:l,setHook:u,setMcpEnabled:d,setMcpToolGroups:f,hasChanges:p,saving:m,saveError:h,saveAndInstall:g,refetch:_}=Jp(e,t);if(i)return(0,K.jsx)(Xp,{});if(a)return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-hig-red)] font-sans`,children:a}),(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--ghost`,onClick:()=>_(),children:`Retry`})]});if(!r)return null;let v=r.hookApplicability[e]??[],y=r.mcpApplicability[e]??[],b=v.length>0,x=y.length>0;if(!b&&!x)return(0,K.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-sans py-1`,children:`No configurable hooks or MCP servers for this agent yet.`});let S=r.hooks.filter(e=>v.includes(e.id)),C=r.mcp.filter(e=>y.includes(e.id)),w=p?S.filter(e=>(c[e.id]??!0)!==!0).length+C.filter(e=>{let t=l[e.id]??{enabled:!0,toolGroups:[`core`]};return!t.enabled||t.toolGroups.join()!==`core`}).length:0;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`Scope`}),(0,K.jsx)(`div`,{className:`ss-segment`,role:`tablist`,"aria-label":`Toggle scope`,children:[`project`,`global`].map(e=>(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e,className:`ss-segment-item`,onClick:()=>s(e),children:e===`project`?`This project`:`Global`},e))}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-1.5`,children:o===`project`?`Saves to .sigmashake/agent-toggles.json in this project.`:`Saves to ~/.sigmashake/agent-toggles.json (applies to all projects).`})]}),b&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`Claude Code lifecycle hooks`}),(0,K.jsx)(`div`,{className:`ss-list`,style:{margin:0},children:S.map(e=>{let t=c[e.id]??!0;return(0,K.jsxs)(`div`,{className:`ss-list-row`,style:{gap:12,cursor:`pointer`},onClick:()=>u(e.id,!t),children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`block text-[12.5px] font-medium text-[var(--color-fg-1)] mb-0.5`,children:e.label}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] m-0`,children:e.description})]}),(0,K.jsx)(fl,{checked:t,onChange:t=>u(e.id,t),disabled:m,label:e.label,size:`sm`})]},e.id)})})]}),x&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-widest text-[var(--color-fg-3)] mb-2`,children:`MCP servers`}),(0,K.jsx)(`div`,{className:`ss-list`,style:{margin:0},children:C.map(e=>{let t=l[e.id]??{enabled:!0,toolGroups:[`core`]},n=!t.enabled;return(0,K.jsxs)(`div`,{style:{padding:`10px 14px`,borderBottom:`1px solid var(--color-line-0)`},children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`span`,{className:`block text-[12.5px] font-medium text-[var(--color-fg-1)] mb-0.5`,children:e.label})}),(0,K.jsx)(fl,{checked:t.enabled,onChange:t=>d(e.id,t),disabled:m,label:e.label,size:`sm`,tone:n?`danger`:`brand`})]}),n&&(0,K.jsxs)(`p`,{className:`ss-list-row-warning`,children:[`Disconnecting will remove `,e.id,` from this agent. Hooks remain unchanged.`]}),t.enabled&&(0,K.jsxs)(`div`,{className:`mt-2`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mb-0.5`,children:`Tool groups`}),(0,K.jsx)(Yp,{groups:e.toolGroups,selected:t.toolGroups,onChange:t=>f(e.id,t),disabled:m})]})]},e.id)})})]}),p&&w>0&&(0,K.jsxs)(`p`,{className:`agent-toggles-pending`,children:[w,` change`,w===1?``:`s`,` pending — click Apply to save.`]}),h&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-hig-red)] font-sans m-0`,children:h}),(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--ghost`,onClick:()=>void g(t,e=>n?.(e)),children:`Retry`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,disabled:m||!p||!t.trim(),onClick:()=>void g(t,e=>n?.(e)),title:t.trim()?p?`Save toggle choices and re-run ssg init to update config files.`:`No changes to apply.`:`Pick a project directory above before applying.`,style:{height:34,padding:`0 16px`,fontSize:12.5,display:`inline-flex`,alignItems:`center`,gap:6},children:[m&&(0,K.jsx)(`span`,{className:`ss-spinner`,"aria-hidden":`true`}),m?`Applying…`:`Apply`]}),!p&&!m&&(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`no changes`})]})]})}var Qp=`http://www.w3.org/2000/svg`;function $p({markup:e,size:t=22}){let n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=n.current;if(!t)return;for(;t.firstChild;)t.removeChild(t.firstChild);let r=`<svg xmlns="${Qp}">${e}</svg>`,i=new DOMParser().parseFromString(r,`image/svg+xml`).documentElement;for(let e of Array.from(i.childNodes))t.appendChild(t.ownerDocument.importNode(e,!0))},[e]),(0,K.jsx)(`svg`,{ref:n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,width:t,height:t,"aria-hidden":`true`})}function em({a:e,size:t=40}){return(0,K.jsx)(`div`,{className:`agent-card-icon shrink-0`,style:{width:t,height:t,color:e.accent,background:`color-mix(in oklab, ${e.accent} 16%, var(--color-surface-2))`,borderColor:`color-mix(in oklab, ${e.accent} 38%, var(--color-line-1))`},children:(0,K.jsx)($p,{markup:e.glyph,size:Math.round(t*.55)})})}function tm({a:e}){return e.active?(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 16%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 38%, transparent)`},children:`Active`}):e.detected?(0,K.jsxs)(`span`,{className:`agent-badge agent-badge--detected`,children:[(0,K.jsx)(`span`,{className:`agent-badge-dot`}),`Detected`]}):e.recommended?(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 12%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 30%, transparent)`},children:`Recommended`}):null}function nm(){return(0,K.jsx)(`svg`,{className:`ss-list-row-chevron`,viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M5 3l5 5-5 5`})})}function rm({text:e}){let[t,n]=(0,_.useState)(!1);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`ss-btn ss-btn--secondary`,style:{height:32,padding:`0 12px`,fontSize:12},"aria-label":t?`Copied`:`Copy`,children:t?`Copied ✓`:`Copy`})}function im(e,t){return t&&e.startsWith(t)?`~`+e.slice(t.length):e}function am({agentId:e,projectDir:t}){let[n,r]=(0,_.useState)(!1);return(0,K.jsxs)(`div`,{style:{border:`1px solid var(--color-line-1)`,borderRadius:10,overflow:`hidden`,marginBottom:16},children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,width:`100%`,padding:`10px 14px`,background:`var(--color-surface-2)`,border:`none`,cursor:`pointer`,textAlign:`left`,gap:8},children:[(0,K.jsx)(`span`,{style:{fontSize:12.5,fontWeight:500,color:`var(--color-fg-1)`},children:`Configure hooks & MCP`}),(0,K.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--color-fg-3)`,transform:n?`rotate(90deg)`:`rotate(0deg)`,transition:`transform 0.15s`,flexShrink:0},"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M5 3l5 5-5 5`})})]}),(0,K.jsx)(`div`,{className:`agent-toggles-body`,"data-open":n?`true`:`false`,style:{borderTop:n?`1px solid var(--color-line-1)`:`none`},children:(0,K.jsx)(`div`,{style:{padding:`14px 14px 16px`},children:(0,K.jsx)(Zp,{agentId:e,projectDir:t})})})]})}function om({agent:e,ctx:t,onClose:n,onInstalled:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),C=`ssg init --client=${e.id}`;async function w(){b(!0),S(null);try{let e=await(await fetch(`/api/json/pick-dir`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()}})).json();e.ok?a(e.path):e.reason===`user_cancelled`||(e.reason===`no_display`?S(`No graphical session — type the path manually instead.`):e.reason===`no_picker_found`?S("Folder picker not available. Install `zenity` (Linux), or type the path manually."):S(e.error||`Folder picker failed.`))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}(0,_.useEffect)(()=>{let e=!1;return fetch(`/api/json/adapters/recent`).then(e=>e.json()).then(t=>{e||(s(t.recents??[]),!i&&t.recents&&t.recents.length>0&&a(t.recents[0].path))}).catch(()=>{}),()=>{e=!0}},[]);async function T(){if(i.trim()){l(!0),h(null),v(!1);try{let t=await(await fetch(`/api/json/adapters/install`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({adapter:e.id,projectDir:i})})).json();h(t),t.ok&&(r(),fetch(`/api/json/adapters/recent`).then(e=>e.json()).then(e=>s(e.recents??[])).catch(()=>{}))}catch(t){h({ok:!1,exitCode:-1,adapter:e.id,projectDir:i,stdout:``,stderr:``,error:t instanceof Error?t.message:String(t)})}finally{l(!1)}}}async function E(e){d(!0),p(null);try{let t=await(await fetch(`/api/json/adapters/active`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({adapter:e})})).json();t.ok?r():p(t.error??`Failed to pin adapter.`)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}let D=c||!i.trim(),O=c?`Connecting…`:i.trim()?`Connect this project`:`Pick a project directory`,k=u?`Saving…`:e.pinned?`Pinned ✓`:`Set as my agent`,A=u||e.pinned;return(0,K.jsxs)(yl,{open:!0,onClose:n,title:e.displayName,subtitle:e.vendor,size:`md`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:D,onClick:()=>void T(),title:"Run `ssg init --client` in the chosen project directory.",children:O}),(0,K.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,disabled:A,onClick:()=>void E(e.id),style:{"--tone":e.accent},title:e.pinned?`Already pinned as your default agent.`:`Pin ${e.displayName} as the default — overrides auto-detection across SSG.`,children:k})]}),children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-4`,children:[(0,K.jsx)(em,{a:e,size:56}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1.5`,children:[(0,K.jsx)(tm,{a:e}),e.pinned&&(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 14%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 36%, transparent)`},title:`You pinned this agent as your default.`,children:`Pinned`}),e.healthy&&!e.active&&(0,K.jsx)(`span`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`healthy`})]}),(0,K.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-1)] leading-relaxed`,children:e.tagline}),e.pinned&&(0,K.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>void E(null),className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] mt-2 cursor-pointer hover:underline`,children:u?`unpinning…`:`unpin & return to auto-detect`}),f&&(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-hig-red)] mt-2`,children:f})]})]}),(0,K.jsx)(`p`,{className:`ss-list-section-title`,children:`Install target`}),(0,K.jsxs)(`div`,{className:`ss-list mb-4`,children:[(0,K.jsx)(`div`,{className:`ss-list-row`,style:{cursor:`default`},onClick:e=>e.preventDefault(),children:(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[12.5px] font-medium text-[var(--color-fg-1)]`,children:`Project directory`}),(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-0.5 truncate`,children:i.trim()?im(i,t.home):`Type a path or pick from below.`})]})}),(0,K.jsxs)(`div`,{style:{padding:`10px 14px`,borderTop:`1px solid var(--color-line-0)`},children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),spellCheck:!1,placeholder:`Click Browse… or paste a path`,className:`flex-1 h-9 px-3 rounded-md text-[12px] font-mono`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-1)`,outline:`none`}}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:y,className:`ss-btn ss-btn--secondary`,style:{height:36,padding:`0 14px`,fontSize:12},title:`Open the system folder picker.`,children:y?`Opening…`:`Browse…`})]}),x&&(0,K.jsx)(`p`,{className:`text-[11px] font-mono mt-2`,style:{color:`var(--color-hig-red)`},children:x}),o.length>0&&(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:`Recent`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(e.path),className:`text-[11px] font-mono px-2 py-1 rounded-md cursor-pointer`,style:{background:i===e.path?`color-mix(in oklab, var(--color-brand) 14%, var(--color-surface-2))`:`var(--color-surface-2)`,border:`1px solid ${i===e.path?`color-mix(in oklab, var(--color-brand) 38%, var(--color-line-1))`:`var(--color-line-1)`}`,color:i===e.path?`var(--color-brand)`:`var(--color-fg-1)`},title:e.path,children:im(e.path,t.home)},e.path))})]})]})]}),(0,K.jsx)(`p`,{className:`ss-list-section-title`,children:`Or run from terminal`}),(0,K.jsxs)(`div`,{className:`ss-list mb-4 p-3 flex items-center gap-2`,style:{padding:`12px 14px`},children:[(0,K.jsxs)(`code`,{className:`flex-1 text-[12px] font-mono text-[var(--color-brand)] overflow-x-auto whitespace-nowrap`,children:[`$ `,C]}),(0,K.jsx)(rm,{text:C})]}),(0,K.jsx)(am,{agentId:e.id,projectDir:i}),m&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`ss-list-section-title`,children:m.ok?`Setup complete`:`Setup failed`}),(0,K.jsx)(sm,{result:m}),(m.stdout||m.stderr||m.error)&&(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsx)(`button`,{type:`button`,className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] cursor-pointer`,onClick:()=>v(e=>!e),children:g?`▾ Hide full log`:`▸ Show full log`}),g&&(0,K.jsx)(`pre`,{className:`text-[11px] font-mono rounded-md p-3 mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-2)`},children:m.error?`${m.error}${m.detail?`
56
- `+m.detail:``}`:[m.stdout,m.stderr].filter(Boolean).join(`
57
- `)||`Exit code: ${m.exitCode}`})]})]})]})}function sm({result:e}){return(0,K.jsx)(`ul`,{className:`ss-install-checklist`,children:(e.steps&&e.steps.length>0?e.steps:[{label:e.ok?`Setup complete`:`Setup failed`,status:e.ok?`ok`:`error`,detail:e.error??void 0}]).map((e,t)=>(0,K.jsxs)(`li`,{className:`ss-install-step ss-install-step--${e.status}`,children:[(0,K.jsx)(`span`,{className:`ss-install-step__icon`,"aria-hidden":`true`,children:e.status===`ok`?`✓`:e.status===`error`?`✗`:`–`}),(0,K.jsxs)(`div`,{className:`ss-install-step__body`,children:[(0,K.jsx)(`span`,{className:`ss-install-step__label`,children:e.label}),e.detail&&(0,K.jsx)(`span`,{className:`ss-install-step__detail`,children:e.detail})]})]},t))})}function cm({a:e,onOpen:t}){return(0,K.jsxs)(`button`,{type:`button`,className:`ss-list-row`,onClick:t,"aria-label":`Open ${e.displayName} details`,children:[(0,K.jsx)(em,{a:e,size:34}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-[13.5px] font-semibold text-[var(--color-fg-0)] truncate`,children:e.displayName}),(0,K.jsx)(tm,{a:e}),e.pinned&&!e.active&&(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:e.accent,background:`color-mix(in oklab, ${e.accent} 12%, transparent)`,borderColor:`color-mix(in oklab, ${e.accent} 30%, transparent)`},children:`Pinned`})]}),(0,K.jsx)(`p`,{className:`text-[10.5px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-0.5`,children:e.vendor})]}),(0,K.jsx)(nm,{})]})}function lm(){let{data:e,refetch:t}=V(`/api/json/adapters`),[n,r]=(0,_.useState)(`all`),[i,a]=(0,_.useState)(null),o=(0,_.useMemo)(()=>e?n===`detected`?e.adapters.filter(e=>e.detected):n===`available`?e.adapters.filter(e=>!e.detected):e.adapters:[],[e,n]);if(!e)return(0,K.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading adapters…`});let s=e.adapters.find(e=>e.active),c=e.adapters.filter(e=>e.detected).length,l=i?e.adapters.find(e=>e.id===i):null;return(0,K.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,K.jsxs)(`section`,{className:`rounded-2xl p-5 relative overflow-hidden`,style:{border:`1px solid var(--color-line-1)`,background:s?`linear-gradient(180deg, color-mix(in oklab, ${s.accent} 14%, transparent) 0%, transparent 70%), var(--color-surface-1)`:`var(--color-surface-1)`,boxShadow:s?`0 0 0 1px color-mix(in oklab, ${s.accent} 30%, transparent), 0 18px 40px color-mix(in oklab, ${s.accent} 14%, transparent)`:void 0},children:[(0,K.jsx)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:12},children:`Connected agent`}),s?(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(em,{a:s,size:56}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`h2`,{className:`text-[18px] font-semibold text-[var(--color-fg-0)] tracking-tight`,children:s.displayName}),(0,K.jsx)(tm,{a:s}),s.pinned?(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:s.accent,background:`color-mix(in oklab, ${s.accent} 14%, transparent)`,borderColor:`color-mix(in oklab, ${s.accent} 36%, transparent)`},title:`You pinned this agent as your default — auto-detection is overridden.`,children:`Pinned`}):(0,K.jsx)(`span`,{className:`agent-badge`,style:{color:`var(--color-fg-3)`,background:`var(--color-surface-2)`,borderColor:`var(--color-line-1)`},title:`SSG auto-detected this agent from process env and filesystem markers.`,children:`Auto-detected`})]}),(0,K.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-0.5`,children:s.vendor}),(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-2 leading-relaxed`,children:s.pinned?`Pinned as your default agent — SSG will treat every tool call as ${s.displayName} regardless of auto-detection.`:s.id===`generic`?`No specific AI client detected — falling back to the generic adapter. Pick the agent you actually use and hit "Set as my agent" to override.`:s.healthy?`Auto-detected from process environment. If this isn't the agent you actually use, tap any other row and hit "Set as my agent" to pin it.`:`Forced via SSG_CLIENT — adapter is in use but its config dir is missing or incomplete.`}),s.pinned&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{fetch(`/api/json/adapters/active`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({adapter:null})}).then(()=>t())},className:`text-[11px] font-mono text-[var(--color-fg-3)] hover:text-[var(--color-brand)] mt-3 cursor-pointer hover:underline`,children:`↺ reset to auto-detect`})]})]}):(0,K.jsx)(`p`,{className:`text-sm text-[var(--color-fg-2)]`,children:`No active adapter resolved.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`p`,{className:`ss-list-section-title`,style:{padding:0,marginBottom:0},children:[`All supported agents · `,e.adapters.length]}),(0,K.jsx)(`div`,{className:`ss-segment`,role:`tablist`,"aria-label":`Filter`,children:[`all`,`detected`,`available`].map(e=>(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,className:`ss-segment-item`,onClick:()=>r(e),children:e===`all`?`All`:e===`detected`?`Detected${c>0?` · ${c}`:``}`:`Available`},e))})]}),o.length>0?(0,K.jsx)(`div`,{className:`ss-list`,children:o.map(e=>(0,K.jsx)(cm,{a:e,onOpen:()=>a(e.id)},e.id))}):(0,K.jsx)(`div`,{className:`rounded-2xl p-8 text-center`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] font-mono`,children:`no agents match this filter`})}),(0,K.jsx)(`div`,{className:`rounded-xl p-4`,style:{border:`1px dashed var(--color-line-1)`,background:`color-mix(in oklab, var(--color-surface-1) 50%, transparent)`},children:(0,K.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:[`SSG picks the active adapter at runtime — either from`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`SSG_CLIENT`}),` `,`or by auto-detecting your tool. Tap any agent to wire it into a project from the dashboard, or copy the`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg init`}),` command and run it yourself.`]})}),(0,K.jsx)(um,{ctx:e.context,adapters:e.adapters}),(0,K.jsx)(fm,{}),l&&(0,K.jsx)(om,{agent:l,ctx:e.context,onClose:()=>a(null),onInstalled:()=>t()})]})}function um({ctx:e,adapters:t}){let{data:n}=V(`/api/json/adapters/recent`),r=t.find(e=>e.active)??null,i=t.filter(e=>e.detected);return(0,K.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid var(--color-line-1)`,background:`var(--color-surface-1)`},children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,K.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight text-[var(--color-fg-0)]`,children:`How SigmaShake is connected`}),(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Overview`})]}),(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] leading-relaxed mb-4`,children:`Each AI agent on your machine has its own config file. SigmaShake adds a small hook to those files so it sees every tool call before it runs.`}),(0,K.jsxs)(`ul`,{className:`space-y-2`,children:[(0,K.jsx)(dm,{label:`Daemon`,status:`on`,detail:`Running — watching tool calls in real time.`}),(0,K.jsx)(dm,{label:`Active AI agent`,status:r?`on`:`off`,detail:r?`${r.displayName} (${r.vendor})`:`Nothing detected yet — install an adapter below.`}),(0,K.jsx)(dm,{label:`Wired-in agents`,status:i.length>0?`on`:`off`,detail:i.length>0?i.map(e=>e.displayName).join(`, `):`No agents wired in yet.`})]}),n?.recents&&n.recents.length>0&&(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsxs)(`p`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)] mb-2`,children:[`Projects connected (`,n.recents.length,`)`]}),(0,K.jsx)(`ul`,{className:`space-y-1.5`,children:n.recents.map(t=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-3 py-2 text-[12px]`,style:{background:`var(--color-surface-2)`,border:`0.5px solid var(--color-line-1)`},children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:`var(--color-hig-green)`}}),(0,K.jsx)(`span`,{className:`font-mono text-[var(--color-fg-1)] truncate flex-1 min-w-0`,children:im(t.path,e.home)}),(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] shrink-0`,children:new Date(t.lastUsed).toLocaleDateString(void 0,{month:`short`,day:`numeric`})})]},t.path))})]})]})}function dm({label:e,status:t,detail:n}){return(0,K.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-3 py-2`,style:{background:`var(--color-surface-2)`,border:`0.5px solid var(--color-line-1)`},children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:t===`on`?`var(--color-hig-green)`:`var(--color-fg-4)`,boxShadow:t===`on`?`0 0 0 3px color-mix(in oklab, var(--color-hig-green) 22%, transparent)`:void 0}}),(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--color-fg-0)] w-32 shrink-0`,children:e}),(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--color-fg-2)] flex-1 min-w-0 truncate`,children:n})]})}function fm(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null);async function c(){a(!0),s(null);try{s(await(await fetch(`/api/json/uninstall-everything`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({keepData:n})})).json())}catch(e){s({ok:!1,error:`Could not reach SigmaShake`,detail:e instanceof Error?e.message:String(e)})}finally{a(!1)}}return(0,K.jsxs)(`section`,{className:`rounded-2xl p-5`,style:{border:`1px solid color-mix(in oklab, var(--color-hig-red) 28%, var(--color-line-1))`,background:`linear-gradient(180deg, color-mix(in oklab, var(--color-hig-red) 6%, transparent) 0%, transparent 100%), var(--color-surface-1)`},children:[(0,K.jsx)(`div`,{className:`flex items-baseline justify-between gap-3 flex-wrap`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[15px] font-semibold tracking-tight text-[var(--color-fg-0)]`,children:`Uninstall SigmaShake`}),(0,K.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] leading-relaxed mt-1`,children:[`Removes the SigmaShake hook from every AI-agent config file on this machine and stops the daemon.`,` `,(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`The`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg`}),` binary itself stays installed — remove it with your package manager.`]})]})]})}),!e&&!o&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors`,style:{color:`var(--color-hig-red)`,border:`1px solid color-mix(in oklab, var(--color-hig-red) 40%, transparent)`,background:`color-mix(in oklab, var(--color-hig-red) 8%, transparent)`},children:`Uninstall SigmaShake everywhere…`}),e&&!o&&(0,K.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,K.jsxs)(`label`,{className:`flex items-start gap-2 text-[12px] text-[var(--color-fg-1)] cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),className:`mt-0.5`}),(0,K.jsxs)(`span`,{children:[`Keep my activity history and license`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`(~/.sigmashake/). Uncheck to wipe everything.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void c(),disabled:i,className:`text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,style:{color:`white`,background:`var(--color-hig-red)`},children:i?`Uninstalling…`:`Yes — uninstall everywhere`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(!1),disabled:i,className:`text-[12.5px] font-medium px-4 py-2 rounded-lg cursor-pointer transition-colors`,style:{color:`var(--color-fg-1)`,background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`},children:`Cancel`})]})]}),o&&(0,K.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg px-4 py-3`,style:{border:`1px solid ${o.ok?`color-mix(in oklab, var(--color-hig-green) 38%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 38%, transparent)`}`,background:o.ok?`color-mix(in oklab, var(--color-hig-green) 6%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 6%, transparent)`},children:[(0,K.jsx)(`p`,{className:`text-[13px] font-semibold`,style:{color:o.ok?`var(--color-hig-green)`:`var(--color-hig-red)`},children:o.ok?`SigmaShake has been removed from this machine`:`Uninstall failed`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:o.ok?(0,K.jsxs)(K.Fragment,{children:[`Hooks were stripped from every AI-agent config file. The daemon has stopped.`,o.packageManagerHint&&(0,K.jsxs)(K.Fragment,{children:[` `,`To also remove the`,` `,(0,K.jsx)(`code`,{className:`text-[var(--color-brand)]`,children:`ssg`}),` `,`binary, run:`,(0,K.jsx)(`code`,{className:`block mt-2 px-2 py-1.5 rounded bg-[var(--color-surface-2)] text-[var(--color-brand)] text-[11.5px] font-mono`,children:o.packageManagerHint})]})]}):(0,K.jsxs)(K.Fragment,{children:[o.error??`Unknown error.`,` `,o.detail&&(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:o.detail})]})})]}),(o.stdout||o.stderr)&&(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{className:`text-[11px] text-[var(--color-fg-3)] cursor-pointer hover:text-[var(--color-fg-1)]`,children:`Show full log`}),(0,K.jsx)(`pre`,{className:`text-[11px] font-mono rounded-md p-3 mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all`,style:{background:`var(--color-surface-2)`,border:`1px solid var(--color-line-1)`,color:`var(--color-fg-2)`},children:[o.stdout,o.stderr].filter(Boolean).join(`
58
- `)})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{s(null),t(!1)},className:`text-[11.5px] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`↺ Close`})]})]})}function pm(){return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`Notifications`}),(0,K.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:`Things that need your attention — rule drift, audit log capacity, daemon health, noisy rules. We update this list whenever something changes.`})]}),(0,K.jsx)(Js,{showEmptyState:!0,hideHeader:!0})]})}function mm({status:e,className:t=``}){return(0,K.jsx)(`span`,{className:`status-dot ${e===`ok`?`bg-[var(--color-decision-allow)]`:e===`warn`?`bg-[var(--color-decision-ask)]`:e===`fail`?`bg-[var(--color-decision-block)]`:`bg-[var(--color-fg-3)]`} ${t}`})}function hm({status:e}){let t=e===`ok`?`text-[var(--color-decision-allow)]`:e===`warn`?`text-[var(--color-decision-ask)]`:e===`fail`?`text-[var(--color-decision-block)]`:`text-[var(--color-fg-3)]`,n=e===`ok`?`OK`:e===`warn`?`Warn`:e===`fail`?`Fail`:`Skipped`;return(0,K.jsx)(`span`,{className:`text-[10.5px] font-medium uppercase tracking-wide ${t}`,children:n})}function gm(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function _m(e){if(!e)return``;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function vm(e,t){return t&&e.startsWith(t+`/`)?`~/`+e.slice(t.length+1):e===t?`~`:e}function ym({file:e,home:t,wired:n}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-1 border-b border-[var(--color-line-0)] last:border-0 text-[11.5px]`,children:[(0,K.jsx)(mm,{status:e.exists?n===void 0||n?`ok`:`warn`:`skip`}),(0,K.jsx)(`code`,{className:`flex-1 truncate text-[var(--color-fg-1)]`,title:e.path,children:vm(e.path,t)}),e.exists?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:gm(e.size)}),(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] min-w-[60px] text-right`,children:_m(e.modified_at)}),n===!1&&(0,K.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-[var(--color-decision-ask)]`,title:`File exists but does not appear to contain SSG wiring`,children:`no ssg`}),n===!0&&(0,K.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-[var(--color-decision-allow)]`,title:`File contains SSG hook / MCP entries`,children:`wired`})]}):(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:`missing`})]})}function bm({title:e,status:t,children:n,hint:r}){return(0,K.jsxs)(`section`,{className:`hig-card hig-card-padded`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)] flex items-center gap-2`,children:[t!==void 0&&(0,K.jsx)(mm,{status:t}),e]}),r&&(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:r})]}),(0,K.jsx)(`div`,{children:n})]})}function xm({k:e,v:t,mono:n=!1}){return(0,K.jsxs)(`div`,{className:`flex items-baseline gap-3 py-1 text-[11.5px] border-b border-[var(--color-line-0)] last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)] min-w-[110px]`,children:e}),(0,K.jsx)(`span`,{className:`flex-1 text-[var(--color-fg-1)] ${n?`font-mono text-[11px]`:``}`,children:t})]})}var Sm={"claude-code":`Claude Code`,cursor:`Cursor`,codex:`Codex CLI`,pi:`Pi Agent`,gemini:`Gemini CLI`,antigravity:`Antigravity`,copilot:`GitHub Copilot`};function Cm({adapter:e,home:t}){let n=Sm[e.id]??e.id,r=e.artifacts.filter(e=>e.exists&&e.ssg_wired).length,i=e.artifacts.filter(e=>e.exists).length;return(0,K.jsxs)(`div`,{className:`rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(mm,{status:e.status}),(0,K.jsx)(`span`,{className:`text-[12.5px] font-semibold text-[var(--color-fg-0)]`,children:n}),e.active&&(0,K.jsx)(`span`,{className:`text-[9.5px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded-sm text-[var(--color-hig-blue)] bg-[color-mix(in_oklab,var(--color-hig-blue)_14%,transparent)]`,title:`This is the adapter ssg is currently using at runtime`,children:`Active`})]}),(0,K.jsxs)(`span`,{className:`text-[10px] text-[var(--color-fg-3)]`,children:[r,`/`,e.artifacts.length,` wired`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-2 text-[10.5px]`,children:[(0,K.jsx)(`span`,{className:e.detected?`text-[var(--color-decision-allow)]`:`text-[var(--color-fg-3)]`,children:e.detected?`● detected`:`○ not detected`}),(0,K.jsx)(`span`,{className:e.healthy?`text-[var(--color-decision-allow)]`:`text-[var(--color-fg-3)]`,children:e.healthy?`● binary healthy`:`○ binary missing`}),i===0&&(0,K.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`○ no config files on disk`})]}),e.artifacts.length>0&&(0,K.jsx)(`div`,{className:`border-t border-[var(--color-line-0)] pt-1`,children:e.artifacts.map(e=>(0,K.jsx)(ym,{file:e,home:t,wired:e.exists?e.ssg_wired:void 0},e.path))}),e.status===`warn`&&i===0&&(0,K.jsxs)(`div`,{className:`mt-2 text-[10.5px] text-[var(--color-fg-3)]`,children:[`Wire it up with:`,` `,(0,K.jsxs)(`code`,{className:`font-mono text-[var(--color-fg-1)]`,children:[`ssg init --client=`,e.id]})]})]})}function wm(){let{data:e,loading:t,error:n,refetch:r}=V(`/api/json/setup-status`);if(t&&!e)return(0,K.jsx)(`div`,{className:`py-12 text-center text-[var(--color-fg-3)] text-[12px]`,children:`Reading setup status…`});if(n||!e)return(0,K.jsxs)(`div`,{className:`hig-card hig-card-padded text-[12px]`,children:[(0,K.jsxs)(`p`,{className:`text-[var(--color-decision-block)] mb-2`,children:[`Could not load /api/json/setup-status: `,n??`no response`]}),(0,K.jsx)(`button`,{onClick:r,className:`hig-button hig-button-small`,children:`Retry`})]});let{summary:i,license:a,daemon:o,dashboard:s,native:c,db:l,mcp:u,rules:d,init_files:f,adapters:p,hub:m,checks:h,home:g,cwd:_}=e;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight text-[var(--color-fg-0)] leading-tight`,children:`Setup Status`}),(0,K.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`What `,(0,K.jsx)(`code`,{className:`font-mono`,children:`ssg init`}),` wrote and whether every piece is wired up — license, hooks, MCP, native engine, daemon, rules, and hub packages.`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:[`ssg v`,e.version]}),(0,K.jsx)(`button`,{onClick:r,className:`hig-button hig-button-small`,children:`Refresh`})]})]}),(0,K.jsxs)(`section`,{className:`hig-card hig-card-padded flex items-center gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(mm,{status:i.overall,className:`!w-3 !h-3`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-[var(--color-fg-3)]`,children:`Overall`}),(0,K.jsx)(`div`,{className:`text-[14px] font-semibold text-[var(--color-fg-0)]`,children:i.overall===`ok`?`Healthy`:i.overall===`warn`?`Needs attention`:i.overall===`fail`?`Broken`:`Skipped`})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-4 text-[12px]`,children:[(0,K.jsxs)(`span`,{className:`text-[var(--color-decision-allow)]`,children:[`● `,i.ok,` ok`]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-decision-ask)]`,children:[`● `,i.warn,` warn`]}),i.fail>0&&(0,K.jsxs)(`span`,{className:`text-[var(--color-decision-block)]`,children:[`● `,i.fail,` fail`]}),(0,K.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`○ `,i.skip,` skipped`]})]}),(0,K.jsxs)(`div`,{className:`ml-auto text-right`,children:[(0,K.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)]`,children:`Working dir`}),(0,K.jsx)(`code`,{className:`text-[11px] text-[var(--color-fg-1)]`,title:_,children:vm(_,g)})]})]}),(0,K.jsx)(bm,{title:`Checks`,hint:`${h.length} probes`,children:(0,K.jsx)(`div`,{children:h.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-[var(--color-line-0)] last:border-0`,children:[(0,K.jsx)(mm,{status:e.status,className:`mt-1`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--color-fg-0)]`,children:e.name}),(0,K.jsx)(hm,{status:e.status})]}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--color-fg-2)] mt-0.5 break-words`,children:e.detail}),e.fix&&(0,K.jsxs)(`div`,{className:`text-[11px] text-[var(--color-hig-blue)] font-mono mt-0.5`,children:[`→ `,e.fix]})]})]},e.name))})}),(0,K.jsxs)(bm,{title:`License & authentication`,status:a.status===`healthy`||a.status===`healthy_free`?`ok`:`warn`,children:[(0,K.jsx)(xm,{k:`Tier`,v:a.tier_label}),(0,K.jsx)(xm,{k:`Status`,v:a.status}),(0,K.jsx)(xm,{k:`Account`,v:a.email??`—`}),(0,K.jsx)(xm,{k:`Auth method`,v:a.auth_method??`—`}),(0,K.jsx)(xm,{k:`Evals today`,v:a.eval_daily_limit===null?`${a.evals_today.toLocaleString()} (unlimited)`:`${a.evals_today.toLocaleString()} / ${a.eval_daily_limit.toLocaleString()}`}),(0,K.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] mb-1`,children:`Credential files`}),(0,K.jsx)(ym,{file:a.license_file,home:g}),(0,K.jsx)(ym,{file:a.hosts_file,home:g})]})]}),(0,K.jsxs)(bm,{title:`Runtime processes`,status:o.alive&&s.alive?`ok`:`warn`,children:[(0,K.jsx)(xm,{k:`Daemon (evald)`,v:o.alive?`running — PID ${o.pid}`:o.pid?`stale — PID ${o.pid} in pidfile but process gone`:`not running`}),(0,K.jsx)(xm,{k:`Daemon socket`,v:o.socket_exists?`present`:`missing`,mono:!0}),(0,K.jsx)(xm,{k:`Dashboard (serve)`,v:s.alive?`running — PID ${s.pid}`:`not running`}),(0,K.jsx)(xm,{k:`Native engine`,v:c.available?`loaded — sub-ms eval available`:`unavailable — TypeScript fallback`})]}),(0,K.jsxs)(bm,{title:`Database & MCP`,status:l.status,children:[(0,K.jsx)(xm,{k:`Rules in DB`,v:l.rules.toLocaleString()}),(0,K.jsx)(xm,{k:`Audit log rows`,v:l.audit_rows.toLocaleString()}),(0,K.jsx)(xm,{k:`DB path`,v:vm(l.path,g),mono:!0}),(0,K.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,K.jsx)(`div`,{className:`text-[10.5px] uppercase tracking-wide text-[var(--color-fg-3)] mb-1`,children:`MCP server`}),(0,K.jsx)(xm,{k:`Status`,v:u.status===`active`?`active — ${u.recent_5min.toLocaleString()} calls in last 5 min`:u.status===`configured`?`configured — ${u.total.toLocaleString()} historical calls, none recent`:`no MCP traffic recorded yet`}),(0,K.jsx)(xm,{k:`All-time calls`,v:u.total.toLocaleString()})]})]}),(0,K.jsxs)(bm,{title:`Rules directories`,status:d.local_count>0?`ok`:`warn`,children:[(0,K.jsx)(xm,{k:`Local`,v:`${d.local_count} .rules file${d.local_count===1?``:`s`}`}),(0,K.jsx)(xm,{k:`Local path`,v:vm(d.local_dir,g),mono:!0}),(0,K.jsx)(xm,{k:`Global`,v:`${d.global_count} .rules file${d.global_count===1?``:`s`}`}),(0,K.jsx)(xm,{k:`Global path`,v:vm(d.global_dir,g),mono:!0})]}),(0,K.jsx)(bm,{title:`Project init files`,hint:`${f.filter(e=>e.exists).length}/${f.length} present`,children:(0,K.jsx)(`div`,{children:f.map(e=>(0,K.jsx)(ym,{file:e,home:g},e.path))})}),(0,K.jsx)(bm,{title:`Adapters, hooks & MCP files`,hint:e.active_adapter?`Active: ${Sm[e.active_adapter]??e.active_adapter}`:`No active adapter`,children:(0,K.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-1 lg:grid-cols-2`,children:p.map(e=>(0,K.jsx)(Cm,{adapter:e,home:g},e.id))})}),(0,K.jsxs)(bm,{title:`Hub-installed rulesets`,status:m.installs.length===0?`skip`:m.drift===0?`ok`:`warn`,hint:m.installs.length===0?`none installed`:`${m.in_sync} in sync${m.drift>0?`, ${m.drift} drift`:``}`,children:[(0,K.jsx)(ym,{file:m.pins_file,home:g}),m.installs.length===0?(0,K.jsxs)(`p`,{className:`text-[11.5px] text-[var(--color-fg-3)] mt-2`,children:[`Install rulesets from the Hub tab. Each install is recorded per project path in `,(0,K.jsx)(`code`,{className:`font-mono`,children:`hub-pins.json`}),`.`]}):(0,K.jsx)(`div`,{className:`mt-2 space-y-2`,children:m.installs.map((e,t)=>(0,K.jsxs)(`div`,{className:`rounded-md border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-2 text-[11.5px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(mm,{status:e.in_sync?`ok`:`warn`}),(0,K.jsx)(`span`,{className:`font-semibold text-[var(--color-fg-0)]`,children:e.id}),(0,K.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:e.version}),(0,K.jsx)(`span`,{className:`ml-auto text-[10.5px] text-[var(--color-fg-3)]`,children:_m(e.installed_at)})]}),(0,K.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--color-fg-2)]`,title:e.path,children:vm(e.path,g)}),e.files.length>0&&(0,K.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.files.map(e=>(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-2)] bg-[var(--color-surface-2)] border border-[var(--color-line-0)] rounded-sm px-1.5 py-0.5`,children:e},e))}),!e.in_sync&&e.drift_reason&&(0,K.jsxs)(`div`,{className:`mt-1 text-[10.5px] text-[var(--color-decision-ask)]`,children:[`Drift: `,e.drift_reason]})]},`${e.id}-${e.path}-${t}`))})]})]})}var Tm=[{value:`issue`,label:`Bug / Issue`,hint:`Something is broken`},{value:`feature_request`,label:`Feature Request`,hint:`Suggest an improvement`},{value:`question`,label:`Question`,hint:`How does X work?`},{value:`incident`,label:`Incident`,hint:`Urgent outage or data concern`}],Em=[{value:`p4`,label:`P4 — Low`},{value:`p3`,label:`P3 — Normal`},{value:`p2`,label:`P2 — High (4h SLA)`},{value:`p1`,label:`P1 — Critical (1h SLA)`}],Dm=5,Om=8*1024*1024;function km(){let[e,t]=(0,_.useState)(`issue`),[n,r]=(0,_.useState)(`p3`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(``),C=(0,_.useRef)(null);(0,_.useEffect)(()=>{fetch(`/api/json/profile`,{headers:B()}).then(e=>e.ok?e.json():null).then(e=>{e?.email&&l(e.email)}).catch(()=>{})},[]),(0,_.useEffect)(()=>{!y||g||fetch(`/api/support/diagnostics?route=${encodeURIComponent(window.location.pathname)}`).then(e=>e.ok?e.json():null).then(e=>v(e)).catch(()=>{})},[y,g]),(0,_.useEffect)(()=>{let e=new URL(window.location.href),n=e.searchParams.get(`error`),r=e.searchParams.get(`from`);if(n||r){t(`issue`);let e=r?`Page: ${r}\n\n`:``,i=n?`Error: ${n}\n\n`:``;s(t=>t||`${e}${i}`)}},[]);function w(e){e.preventDefault(),E(Array.from(e.dataTransfer.files))}function T(e){E(Array.from(e.target.files??[])),C.current&&(C.current.value=``)}function E(e){S(``);let t=e.filter(e=>e.type.startsWith(`image/`));t.length<e.length&&S(`Only image files are accepted.`);let n=Dm-u.length,r=t.slice(0,n);r.length<t.length&&S(`Maximum ${Dm} images. Some were dropped.`);let i=r.filter(e=>e.size>Om);if(i.length>0){S(`"${i[0].name}" exceeds 8 MiB.`);return}let a=r.map(e=>({file:e,preview:URL.createObjectURL(e)}));d(e=>[...e,...a])}function D(e){d(t=>(URL.revokeObjectURL(t[e].preview),t.filter((t,n)=>n!==e)))}async function O(t){t.preventDefault(),p(!0),h(null);let r=new FormData;r.append(`category`,e),r.append(`severity`,n),r.append(`subject`,i.trim()),r.append(`description`,o.trim()),r.append(`contact_email`,c.trim()),r.append(`route`,window.location.pathname);for(let{file:e}of u)r.append(`images`,e,e.name);try{let e=await(await fetch(`/api/support/feedback`,{method:`POST`,headers:B(),body:r})).json();h(e),e.ok&&(a(``),s(``),d([]))}catch(e){h({ok:!1,error:e instanceof Error?e.message:`Network error`})}finally{p(!1)}}return(0,K.jsxs)(`div`,{className:`max-w-2xl mx-auto space-y-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Support & Feedback`}),(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`report a bug, request a feature, or ask a question`})]}),m?.ok?(0,K.jsx)(q,{children:(0,K.jsx)(Y,{children:(0,K.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-emerald-400 font-mono`,children:[`✓ `,m.message??`Ticket created.`]}),m.ticket_id&&(0,K.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-mono`,children:[`Ticket ID: `,(0,K.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:m.ticket_id})]}),(0,K.jsx)(`button`,{className:`text-[12px] text-[var(--color-brand)] hover:underline font-mono`,onClick:()=>h(null),children:`Submit another`})]})})}):(0,K.jsxs)(`form`,{onSubmit:O,className:`space-y-4`,children:[(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{children:[(0,K.jsx)(`label`,{className:`block overline mb-2`,children:`type`}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Tm.map(n=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(n.value),className:`text-left px-3 py-2 rounded-sm border text-xs font-mono transition-colors ${e===n.value?`border-[var(--color-brand)]/50 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:border-[var(--color-line-0)]`}`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[var(--color-fg-1)]`,children:n.label}),(0,K.jsx)(`span`,{className:`block text-[11px] mt-0.5`,children:n.hint})]},n.value))})]})}),e===`incident`&&(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{children:[(0,K.jsx)(`label`,{className:`block overline mb-2`,children:`severity`}),(0,K.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:Em.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(e.value),className:`px-3 py-1.5 rounded-sm border text-xs font-mono transition-colors ${n===e.value?`border-[var(--color-brand)]/50 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:border-[var(--color-line-0)]`}`,children:e.label},e.value))})]})}),(0,K.jsx)(q,{children:(0,K.jsx)(Y,{children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block overline mb-1.5`,children:`subject`}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Short summary (required)`,maxLength:200,required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block overline mb-1.5`,children:`description`}),(0,K.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:`Describe the issue in detail (10–10000 characters)`,minLength:10,maxLength:1e4,required:!0,rows:6,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono resize-y`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block overline mb-1.5`,children:`contact email`}),(0,K.jsx)(`input`,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:`your@email.com`,required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]})]})})}),(0,K.jsx)(q,{children:(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`label`,{className:`block overline mb-2`,children:[`screenshots / attachments`,` `,(0,K.jsxs)(`span`,{className:`normal-case text-[var(--color-fg-4)] font-mono font-normal`,children:[`(optional, up to `,Dm,` images)`]})]}),u.length<Dm&&(0,K.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:w,onClick:()=>C.current?.click(),className:`border border-dashed border-[var(--color-line-1)] rounded-sm p-6 text-center cursor-pointer hover:border-[var(--color-brand)]/50 transition-colors`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-mono`,children:[`drag & drop images, or`,` `,(0,K.jsx)(`span`,{className:`text-[var(--color-brand)]`,children:`click to browse`})]}),(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] mt-1 font-mono`,children:`PNG · JPEG · WebP · GIF · HEIC — max 8 MiB each`})]}),(0,K.jsx)(`input`,{ref:C,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:T}),x&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 font-mono mt-2`,children:x}),u.length>0&&(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:u.map((e,t)=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`img`,{src:e.preview,alt:e.file.name,className:`h-20 w-20 object-cover rounded-sm border border-[var(--color-line-1)]`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>D(t),className:`absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-red-400 text-[10px] font-mono flex items-center justify-center`,title:`Remove`,children:`✕`}),(0,K.jsx)(`p`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] mt-0.5 max-w-[80px] truncate`,children:e.file.name})]},t))})]})}),(0,K.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] overflow-hidden`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 text-xs font-mono text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] bg-[var(--color-surface-0)] transition-colors`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`diagnostics that will be attached`}),(0,K.jsx)(`span`,{children:y?`▲`:`▼`})]}),y&&(0,K.jsx)(`div`,{className:`px-3 py-2 bg-[var(--color-surface-0)] border-t border-[var(--color-line-1)] max-h-64 overflow-auto`,children:g?(0,K.jsx)(`pre`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-pre-wrap break-all`,children:JSON.stringify(g,null,2)}):(0,K.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`Loading…`})})]}),m&&!m.ok&&(0,K.jsx)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/5 px-3 py-2 text-xs text-red-300 font-mono`,children:m.error??`Submission failed. Please try again.`}),(0,K.jsx)(X,{type:`submit`,variant:`primary`,disabled:f,children:f?`submitting…`:`submit feedback`})]})]})}var Am=`ssg-dashboard-tabs`,jm=2e3,Mm=6e3;function Nm(){return`tab-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Pm(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(!0),i=(0,_.useRef)(Nm()),a=(0,_.useRef)(new Map);return(0,_.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(Am);function n(){let e=Date.now();for(let[t,n]of a.current.entries())e-n>Mm&&a.current.delete(t);let n=a.current.size;t(n),r([...a.current.keys(),i.current].sort()[0]===i.current)}function o(e){let t=e.data;!t||t.id===i.current||(t.type===`leave`?a.current.delete(t.id):a.current.set(t.id,Date.now()),n())}e.addEventListener(`message`,o),e.postMessage({type:`join`,id:i.current});let s=setInterval(()=>{e.postMessage({type:`heartbeat`,id:i.current}),n()},jm),c=()=>{e.postMessage({type:`leave`,id:i.current})};return window.addEventListener(`beforeunload`,c),()=>{clearInterval(s),e.postMessage({type:`leave`,id:i.current}),e.removeEventListener(`message`,o),e.close(),window.removeEventListener(`beforeunload`,c)}},[]),{otherTabCount:e,isLeader:n}}var Fm=b;function Im(){(0,_.useEffect)(()=>Ce([]),[]);let e=(0,_.useSyncExternalStore)(me,he),[,t]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(e.connected||e.lastErrorAt===null)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.connected,e.lastErrorAt]);let n=Lm(e),r=n===`reconnecting`&&e.lastErrorAt!==null?Math.max(0,Math.ceil((e.lastErrorAt+e.reconnectDelayMs-Date.now())/1e3)):null,i=Math.round(Fm/1e3);if(n===`connected`)return(0,K.jsxs)(`div`,{className:`chip`,title:`Telemetry Live — SSE connected`,"data-testid":`sse-status-chip`,"data-state":`connected`,children:[(0,K.jsx)(`span`,{className:`status-dot bg-[var(--color-decision-allow)]`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Live`})]});let a=n===`reconnecting`,o=a?{color:`var(--color-hig-orange)`,background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`}:{color:`var(--color-hig-red)`,background:`color-mix(in oklab, var(--color-hig-red) 14%, transparent)`},s=a?`bg-[var(--color-hig-orange)]`:`bg-[var(--color-hig-red)]`,c=a?r===null?`Reconnecting`:`Reconnect ${r}s`:`Offline`,l=`Live paused · ${i}s poll`;return(0,K.jsxs)(`div`,{className:`chip`,style:o,title:a?`Live stream down — reconnect in ${r??`…`}s (attempt ${e.reconnectAttempts}). Dashboard is polling every ${i}s until SSE recovers.`:`Live stream disconnected. Dashboard is polling every ${i}s — data still updates, just at a coarser cadence.`,"data-testid":`sse-status-chip`,"data-state":n,role:`status`,"aria-live":`polite`,children:[(0,K.jsx)(`span`,{className:`status-dot ${s} pulse-soft`}),(0,K.jsx)(`span`,{className:`hidden md:inline`,children:l}),(0,K.jsx)(`span`,{className:`md:hidden`,children:c})]})}function Lm(e){return e.connected?`connected`:e.reconnectAttempts>0||e.lastErrorAt!==null?`reconnecting`:`disconnected`}var Rm=`ssg:ui:font-scale:v1`,zm=[{label:`S`,value:.9},{label:`M`,value:1},{label:`L`,value:1.15},{label:`XL`,value:1.3}],Bm=1;function Vm(e){if(typeof e!=`number`||!Number.isFinite(e))return Bm;let t=zm.find(t=>Math.abs(t.value-e)<.001);return t?t.value:Bm}function Hm(){if(typeof localStorage>`u`)return Bm;try{let e=localStorage.getItem(Rm);return e===null?Bm:Vm(parseFloat(e))}catch{return Bm}}function Um(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Rm,String(e))}catch{}}function Wm(e){typeof document>`u`||(document.documentElement.style.setProperty(`--ssg-font-scale`,String(e)),document.documentElement.style.fontSize=`${16*e}px`)}function Gm(){let[e,t]=(0,_.useState)(()=>{let e=Hm();return Wm(e),e});return(0,_.useEffect)(()=>{Wm(e)},[e]),{scale:e,setScale:(0,_.useCallback)(e=>{t(e),Um(e),Wm(e)},[])}}function Km(){let{scale:e,setScale:t}=Gm();return(0,K.jsx)(`div`,{role:`radiogroup`,"aria-label":`Font size`,className:`hig-segmented`,style:{height:`24px`},children:zm.map(n=>{let r=Math.abs(n.value-e)<.001;return(0,K.jsx)(`button`,{role:`radio`,"aria-checked":r,"aria-selected":r,onClick:()=>t(n.value),title:`Font size: ${n.label} (${Math.round(n.value*100)}%)`,className:r?`selected`:``,style:{height:`20px`,padding:`0 8px`,fontSize:`11px`},children:n.label},n.label)})})}var qm=`ssg:ui:theme:v1`,Jm=[{label:`System (Auto)`,value:`default`},{label:`Apple Light`,value:`apple-light`},{label:`Apple Dark`,value:`apple-dark`},{label:`Light (Legacy)`,value:`light`},{label:`Dracula`,value:`dracula`},{label:`Gruvbox Dark`,value:`gruvbox-dark`},{label:`Gruvbox Light`,value:`gruvbox-light`},{label:`Tokyo Night`,value:`tokyo-night`},{label:`Catppuccin Mocha`,value:`catppuccin-mocha`},{label:`Nord`,value:`nord`},{label:`One Dark Pro`,value:`one-dark-pro`}],Ym=new Set([`light`,`gruvbox-light`,`apple-light`]),Xm=new Set([`apple-dark`,`dracula`,`gruvbox-dark`,`tokyo-night`,`catppuccin-mocha`,`nord`,`one-dark-pro`]),Zm=`default`;function Qm(e){return typeof e==`string`&&Jm.some(t=>t.value===e)}function $m(){if(typeof localStorage>`u`)return Zm;try{let e=localStorage.getItem(qm);return Qm(e)?e:Zm}catch{return Zm}}function eh(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(qm,e)}catch{}}function th(e){typeof document>`u`||(e===Zm?(document.documentElement.removeAttribute(`data-theme`),document.documentElement.style.colorScheme=`light dark`):(document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=Ym.has(e)?`light`:Xm.has(e)?`dark`:`light dark`))}function nh(){let[e,t]=(0,_.useState)(()=>{let e=$m();return th(e),e});return(0,_.useEffect)(()=>{th(e)},[e]),{theme:e,setTheme:(0,_.useCallback)(e=>{t(e),eh(e),th(e)},[])}}function rh(){let{theme:e,setTheme:t}=nh();return(0,K.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),"aria-label":`Color theme`,title:`Color theme`,className:`hig-input cursor-pointer`,style:{height:`24px`,paddingRight:`22px`,minWidth:`90px`},children:Jm.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function ih(){let{mode:e,setMode:t}=Hu(),n=e===`newcomer`;return(0,K.jsxs)(`div`,{role:`radiogroup`,"aria-label":`UI mode`,className:`hig-segmented`,style:{height:`24px`},title:n?`Switch to advanced view`:`Switch to simple view`,children:[(0,K.jsx)(`button`,{role:`radio`,"aria-checked":n,"aria-selected":n,onClick:()=>t(`newcomer`),className:n?`selected`:``,style:{height:`20px`,padding:`0 10px`,fontSize:`11.5px`},children:`Simple`}),(0,K.jsx)(`button`,{role:`radio`,"aria-checked":!n,"aria-selected":!n,onClick:()=>t(`pro`),className:n?``:`selected`,style:{height:`20px`,padding:`0 10px`,fontSize:`11.5px`},children:`Advanced`})]})}function ah(){let[e,t]=(0,_.useState)(()=>Lo()),[n,r]=(0,_.useState)(()=>zo()),[i,a]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{Ro(e)},[e]),(0,_.useEffect)(()=>{Bo(n)},[n]),(0,K.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,K.jsxs)(`button`,{onClick:()=>t(e=>!e),onContextMenu:e=>{e.preventDefault(),a(e=>!e)},className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors`,style:e?{color:`var(--color-decision-allow)`}:void 0,title:e?`Decision chimes on · click to mute · right-click for volume`:`Decision chimes off · click to enable`,children:[(0,K.jsx)(`span`,{className:`status-dot ${e?`bg-[var(--color-decision-allow)]`:`bg-[var(--color-fg-4)]`}`}),(0,K.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Audio `,e?`on`:`off`]})]}),i&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 flex items-center gap-2 px-3 py-2 hig-card hig-card-padded shadow-[var(--hig-shadow-2)]`,onMouseLeave:()=>a(!1),children:[(0,K.jsx)(`span`,{className:`overline`,children:`Volume`}),(0,K.jsx)(`input`,{type:`range`,min:0,max:1,step:.02,value:n,onChange:e=>r(parseFloat(e.target.value)),className:`w-24`,style:{accentColor:`var(--color-accent)`}}),(0,K.jsx)(`span`,{className:`text-[11px] font-mono tabular-nums text-[var(--color-fg-2)] w-8 text-right`,children:Math.round(n*100)})]})]})}var oh={dashboard:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`9`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`5`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`14`,y:`12`,width:`7`,height:`9`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`3`,y:`16`,width:`7`,height:`5`,rx:`1.5`})]}),graph:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.4`}),(0,K.jsx)(`circle`,{cx:`18`,cy:`6`,r:`2.4`}),(0,K.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2.4`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`11`,r:`2.4`}),(0,K.jsx)(`path`,{d:`M7.5 16.5l3-4M13.5 11.5l3-3.5M13.5 12l3 4.5`})]}),rules:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M9 5h11M9 12h11M9 19h11`}),(0,K.jsx)(`path`,{d:`M4 5l1 1 2-2M4 12l1 1 2-2M4 19l1 1 2-2`})]}),hub:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M3 12h18`}),(0,K.jsx)(`path`,{d:`M12 3a14 14 0 010 18M12 3a14 14 0 000 18`})]}),audit:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`6.5`}),(0,K.jsx)(`path`,{d:`M21 21l-5-5`})]}),approvals:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M5 7h14v12a2 2 0 01-2 2H7a2 2 0 01-2-2z`}),(0,K.jsx)(`path`,{d:`M9 3v4M15 3v4`}),(0,K.jsx)(`path`,{d:`M9 13l2 2 4-4`})]}),profile:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,K.jsx)(`path`,{d:`M4 21c0-4.4 3.6-8 8-8s8 3.6 8 8`})]}),monitor:(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M3 12h3l3-7 4 14 3-7h5`})}),observability:(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M4 20h16M7 16V8M11 16V4M15 16v-6M19 16v-3`})}),debug:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`rect`,{x:`7`,y:`7`,width:`10`,height:`12`,rx:`5`}),(0,K.jsx)(`path`,{d:`M12 7V4M9 4l3 3 3-3`}),(0,K.jsx)(`path`,{d:`M5 11l2-1M5 18l2-1M19 11l-2-1M19 18l-2-1`})]}),home:(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:`M3 11l9-7 9 7v9a2 2 0 01-2 2h-3v-7H10v7H5a2 2 0 01-2-2z`})}),guardrails:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M12 3l8 3.7v6.3c0 5-3.5 9.6-8 11-4.5-1.4-8-6-8-11V6.7L12 3z`}),(0,K.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),tryit:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M9 3v6L4.5 18a2 2 0 001.7 3h11.6a2 2 0 001.7-3L15 9V3`}),(0,K.jsx)(`path`,{d:`M8 3h8`})]}),agents:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`8`,cy:`9`,r:`3`}),(0,K.jsx)(`circle`,{cx:`16`,cy:`9`,r:`3`}),(0,K.jsx)(`path`,{d:`M3 19c.7-2.5 2.6-4 5-4`}),(0,K.jsx)(`path`,{d:`M21 19c-.7-2.5-2.6-4-5-4`}),(0,K.jsx)(`path`,{d:`M9 17.5c.8-1 1.8-1.5 3-1.5s2.2.5 3 1.5`})]}),notifications:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M18 16v-5a6 6 0 1 0-12 0v5l-2 2h16z`}),(0,K.jsx)(`path`,{d:`M10 20a2 2 0 0 0 4 0`})]}),setup:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M9 12l2 2 4-4`}),(0,K.jsx)(`path`,{d:`M12 3l8 3.7v6.3c0 5-3.5 9.6-8 11-4.5-1.4-8-6-8-11V6.7L12 3z`})]}),support:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),(0,K.jsx)(`path`,{d:`M12 2.5v6M12 15.5v6M2.5 12h6M15.5 12h6`})]}),workspace:(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`14`,rx:`2`}),(0,K.jsx)(`path`,{d:`M3 9h18M8 14h2M14 14h2`}),(0,K.jsx)(`path`,{d:`M9 20h6`})]})},sh=[{title:`Overview`,items:[{path:`/`,label:`Dashboard`,icon:`dashboard`},{path:`/notifications`,label:`Notifications`,icon:`notifications`},{path:`/agents`,label:`Agents`,icon:`agents`},{path:`/graph`,label:`Graph`,icon:`graph`},{path:`/sessions`,label:`Sessions`,icon:`agents`}]},{title:`Rules`,items:[{path:`/rules`,label:`Rules`,icon:`rules`},{path:`/hub`,label:`Hub`,icon:`hub`},{path:`/approvals`,label:`Approvals`,icon:`approvals`}]},{title:`Activity`,items:[{path:`/audit`,label:`Audit`,icon:`audit`},{path:`/monitor`,label:`Monitor`,icon:`monitor`},{path:`/observability`,label:`Observability`,icon:`observability`}]},{title:`Tools`,items:[{path:`/workspace`,label:`Workspace`,icon:`workspace`},{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/debug`,label:`Debug`,icon:`debug`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}],ch=[{title:`Get Started`,items:[{path:`/`,label:`Home`,icon:`home`},{path:`/agents`,label:`Agents`,icon:`agents`},{path:`/guardrails`,label:`Guardrails`,icon:`guardrails`},{path:`/try`,label:`Try It`,icon:`tryit`}]},{title:`Activity`,items:[{path:`/notifications`,label:`Notifications`,icon:`notifications`},{path:`/audit`,label:`Activity`,icon:`audit`},{path:`/approvals`,label:`Approvals`,icon:`approvals`}]},{title:`You`,items:[{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}];function lh(e){return e===`newcomer`?ch:sh}function uh(e){let t=Math.max(0,e-Date.now()),n=Math.floor(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function dh(){let{data:e}=V(`/api/json/daemon-status`,[ke([`counters-updated`])[`counters-updated`]]),[t,n]=(0,_.useState)(!1),[,r]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(e?.status!==`degraded`||!e.hibernation)return;let t=setInterval(()=>r(e=>e+1),1e3);return()=>clearInterval(t)},[e?.status,e?.hibernation]);let i=e?.status??`starting`,a=i===`running`?`bg-[var(--color-decision-allow)]`:i===`starting`||i===`degraded`?`bg-[var(--color-decision-ask)]`:`bg-[var(--color-decision-block)]`,o=i===`starting`||i===`degraded`?`pulse-soft`:``,s=i===`degraded`&&e?.hibernation?uh(e.hibernation.nextRetryAt):null,c=i===`running`?`Daemon`:i===`starting`?`Booting`:i===`degraded`?`Retry ${s??`…`}`:i===`error`?`Error`:`Offline`;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors`,title:i===`running`?`Daemon running`:i===`starting`?`Daemon starting…`:i===`degraded`?`Daemon hibernating — retry in ${s??`…`}`:i===`error`?`Daemon error`:`Daemon stopped`,children:[(0,K.jsx)(`span`,{className:`status-dot ${a} ${o}`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:c})]}),t&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-7 z-50 w-72 hig-card hig-card-padded text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`overline`,children:`Eval Daemon`}),(0,K.jsx)(`button`,{onClick:()=>n(!1),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] cursor-pointer`,children:`✕`})]}),(0,K.jsxs)(`div`,{className:`space-y-1 text-[var(--color-fg-2)]`,children:[(0,K.jsxs)(`div`,{className:`font-mono text-[11px]`,children:[`status:`,` `,(0,K.jsx)(`span`,{className:i===`running`?`text-[var(--color-decision-allow)]`:i===`starting`||i===`degraded`?`text-[var(--color-decision-ask)]`:`text-[var(--color-decision-block)]`,children:i})]}),e?.pid&&(0,K.jsxs)(`div`,{className:`font-mono text-[11px]`,children:[`pid: `,e.pid]}),i===`degraded`&&e?.hibernation&&(0,K.jsxs)(`div`,{className:`mt-2 rounded-lg p-2 text-[11px] space-y-0.5`,style:{background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`,color:`color-mix(in oklab, var(--color-hig-orange) 90%, var(--color-fg-0))`},children:[(0,K.jsxs)(`div`,{children:[`next retry: `,(0,K.jsx)(`span`,{className:`font-medium`,children:s})]}),(0,K.jsxs)(`div`,{children:[`episode attempt: `,e.hibernation.attempt,e.hibernation.reason?` (${e.hibernation.reason})`:``]}),(0,K.jsx)(`div`,{className:`opacity-70`,children:`Slow-tier supervisor is retrying at long backoff — no manual restart required.`})]})]}),e?.logTail&&e.logTail.length>0&&(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsx)(`div`,{className:`overline mb-1`,children:`Recent log`}),(0,K.jsx)(`pre`,{className:`bg-[var(--color-surface-2)] border border-[var(--color-line-0)] rounded-md p-2 text-[10px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-all max-h-32 overflow-y-auto`,children:e.logTail.join(`
59
- `)})]})]})]})}function fh(){let{data:e}=V(`/api/state/activity-degraded`);if(!e?.degraded)return null;let t=e.since?new Date(e.since).toLocaleTimeString():`recently`;return(0,K.jsxs)(`div`,{role:`status`,className:`hig-banner hig-banner-warning`,title:e.reason??`audit-worker degraded`,children:[(0,K.jsx)(`span`,{children:`⚠`}),(0,K.jsxs)(`span`,{children:[`Audit pipeline degraded since `,t,` — entries may be missing. Run`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`ssg daemon --status`}),` to inspect.`]})]})}function ph(){let{data:e}=V(`/api/json/license`,[ke([`counters-updated`])[`counters-updated`]]);return!e||e.tier!==`unlicensed`||e.status===`needs_reauth`||e.status===`needs_login`||e.eval_daily_limit===null||e.evals_today<e.eval_daily_limit?null:(0,K.jsxs)(`div`,{role:`alert`,className:`hig-banner hig-banner-error`,title:`Free tier daily eval limit reached — rules are being bypassed until quota resets`,children:[(0,K.jsx)(`span`,{children:`●`}),(0,K.jsxs)(`span`,{children:[`Quota exhausted — `,e.evals_today.toLocaleString(),`/`,e.eval_daily_limit.toLocaleString(),` evals used today. BLOCK and ASK rules are being bypassed (fail-open) until daily reset.`,` `,(0,K.jsx)(`a`,{href:e.upgrade_url,target:`_blank`,rel:`noopener noreferrer`,className:`underline font-medium`,children:`Upgrade to Pro →`})]})]})}function mh(){let{data:e}=V(`/api/json/license`,[ke([`counters-updated`])[`counters-updated`]]);if(!e||e.status!==`needs_reauth`)return null;let t=e.detail??`License JWT invalid or expired`;return(0,K.jsxs)(`div`,{role:`alert`,className:`hig-banner hig-banner-warning`,title:`Re-authentication required — paid-tier features are paused until you re-login`,children:[(0,K.jsx)(`span`,{children:`⚠`}),(0,K.jsxs)(`span`,{children:[`Re-authentication required — `,t,`. Run`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`ssg auth login`}),` in your terminal to restore your tier.`]})]})}function hh(){let{data:e,refetch:t}=V(`/api/json/ask-mode`),[n,r]=(0,_.useState)(!1),i=e?.mode??`tty`;async function a(e){if(!(n||e===i)){r(!0);try{await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}let o=i===`tty`;return(0,K.jsxs)(`button`,{onClick:()=>a(o?`dashboard`:`tty`),disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:o?`ASK decisions prompt in the native IDE/TTY. Click to route to dashboard.`:`ASK decisions queue on /approvals. Click to route to native prompt.`,children:[(0,K.jsx)(`span`,{className:`status-dot ${o?`bg-[var(--color-hig-blue)]`:`bg-[var(--color-hig-purple)]`}`}),(0,K.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Ask · `,o?`Native`:`Dashboard`]})]})}function gh(e){let t=new Date(e);return`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}`}var _h={on:`soft`,soft:`audit`,audit:`off`,off:`on`};function vh(){let{data:e,refetch:t}=V(`/api/json/mode`,[ke([`mode-changed`])[`mode-changed`]]),[n,r]=(0,_.useState)(!1),i=e?.mode??`on`;async function a(e,i){if(!n){r(!0);try{let n={mode:e};typeof i==`number`&&i>0&&(n.forMs=i),await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify(n)}),t()}finally{r(!1)}}}let o=i===`on`?`bg-[var(--color-hig-green)]`:i===`soft`?`bg-[var(--color-hig-yellow)]`:i===`audit`?`bg-[var(--color-hig-orange)]`:`bg-[var(--color-hig-red)]`,s=e?.rearmAt!==void 0&&i!==`on`?` · until ${gh(e.rearmAt)}`:``,c=`SSG · ${i.toUpperCase()}${s}`;return(0,K.jsxs)(`button`,{onClick:e=>{e.shiftKey?a(i===`off`?`audit`:`on`):a(_h[i])},disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:i===`on`?`SSG ON — rules enforce normally. Click to cycle: On → Soft → Audit → Off.`:i===`soft`?`SSG SOFT — blocks downgraded to prompts, prompts downgraded to logs. Click for Audit; Shift+Click to resume On.`:i===`audit`?`SSG AUDIT — rules log only, nothing blocked or prompted. Click for Off; Shift+Click to resume On.`:`SSG OFF — kill switch engaged, evaluator returns allow. Click to resume On; Shift+Click for Audit.`,children:[(0,K.jsx)(`span`,{className:`status-dot ${o}`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:c})]})}function yh(){let{data:e,refetch:t}=V(`/api/json/mode`,[ke([`mode-changed`])[`mode-changed`]]),n=e?.mode??`on`;if(n===`on`)return null;let r=e?.rearmAt===void 0?``:` Auto-restores at ${gh(e.rearmAt)}.`,i=n===`off`?`SSG is OFF — kill switch engaged.`:n===`soft`?`SSG is in SOFT mode — non-blocking enforcement.`:`SSG is in AUDIT mode — log-only.`,a=n===`off`?`Every tool call is being allowed without evaluation.${r}`:n===`soft`?`Block decisions are being downgraded to prompts and prompts to logs. Workflow keeps moving; signal still surfaces in the audit log.${r}`:`Rules still match for the audit log, but nothing is being blocked or prompted.${r}`,o=n===`off`?`hig-banner hig-banner-error`:`hig-banner hig-banner-warning`;async function s(){await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({mode:`on`})}),t()}return(0,K.jsxs)(`div`,{className:o,children:[(0,K.jsxs)(`svg`,{className:`shrink-0`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,K.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),(0,K.jsxs)(`span`,{className:`flex-1`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:i}),` `,a]}),(0,K.jsx)(`button`,{onClick:s,className:`hig-button hig-button-small`,title:`Re-enable normal rule enforcement`,children:`Resume`})]})}function bh({onRefresh:e}){return(0,K.jsx)(`button`,{onClick:e,className:`hig-button`,title:`Reset page — clears stale graph state without dropping SSE`,"aria-label":`Refresh page`,children:(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,K.jsx)(`polyline`,{points:`21 3 21 9 15 9`})]})})}function xh(){return(0,K.jsx)(`button`,{onClick:()=>{try{window.location.reload()}catch{}},className:`hig-button`,title:`Reload dashboard — fetches fresh assets (use after a desktop upgrade)`,"aria-label":`Reload dashboard`,children:(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M3 12a9 9 0 1 1 3 6.7`}),(0,K.jsx)(`polyline`,{points:`3 21 3 15 9 15`}),(0,K.jsx)(`path`,{d:`M3 3v6h6`})]})})}function Sh(){let{data:e}=V(`/api/json/mcp-status`,[ke([`activity-updated`])[`activity-updated`]]),t=e?.status??`inactive`;if(t===`inactive`)return null;let n=t===`active`?`bg-[var(--color-hig-blue)]`:`bg-[var(--color-fg-3)]`,r=t===`active`?`MCP active`:`MCP idle`;return(0,K.jsxs)(`div`,{className:`chip`,title:t===`active`?`MCP server: ${e?.recentCount??0} evals in last 5 min`:`MCP server: ${e?.totalCount??0} total evals`,children:[(0,K.jsx)(`span`,{className:`status-dot ${n}`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ch(){let{data:e}=V(`/api/json/adapters`);if(!e)return null;let t=e.adapters.find(e=>e.active);if(!t)return null;let n=t.id===`generic`;return(0,K.jsxs)(`a`,{href:`/agents`,className:`chip ss-agent-chip cursor-pointer transition-all`,title:n?`No specific AI client detected — SSG is running in generic adapter mode. Click to wire one up.`:`Connected agent: ${t.displayName} (${t.vendor}). Click to manage.`,style:{"--agent-accent":t.accent},"data-generic":n?`true`:`false`,children:[(0,K.jsx)(`span`,{className:`status-dot`,style:{background:t.accent,boxShadow:`0 0 6px color-mix(in oklab, ${t.accent} 60%, transparent)`}}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:t.displayName})]})}function wh(e,t){if(e===`/`)return t===`newcomer`?(0,K.jsx)(jp,{}):(0,K.jsx)(ic,{});if(e===`/classic`)return(0,K.jsx)(dl,{});if(e===`/graph`)return(0,K.jsx)(Hf,{});if(e===`/sessions`)return(0,K.jsx)(Jf,{});if(e.startsWith(`/sessions/`)){let t=decodeURIComponent(e.slice(10));if(t)return(0,K.jsx)(rp,{sessionKey:t})}if(e===`/debug`)return(0,K.jsx)(op,{});if(e===`/rules`)return(0,K.jsx)(Wl,{});if(e===`/audit`)return(0,K.jsx)(tu,{});if(e===`/approvals`)return(0,K.jsx)(gu,{});if(e===`/profile`)return(0,K.jsx)(Pu,{});if(e===`/agents`)return(0,K.jsx)(lm,{});if(e===`/notifications`)return(0,K.jsx)(pm,{});if(e===`/setup`)return(0,K.jsx)(wm,{});if(e===`/try`)return(0,K.jsx)(Gp,{});if(e===`/guardrails`)return(0,K.jsx)(Ku,{});if(e===`/hub/connect`)return(0,K.jsx)(sd,{});if(e===`/hub/publish`)return(0,K.jsx)(cd,{});if(e.startsWith(`/hub/`)){let t=e.slice(5);if(t)return(0,K.jsx)(od,{id:t})}return e===`/hub`?(0,K.jsx)(rd,{}):e===`/monitor`?(0,K.jsx)(xd,{}):e===`/observability`?(0,K.jsx)(Bd,{}):e===`/support`?(0,K.jsx)(km,{}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-24 text-[var(--color-fg-3)]`,children:[(0,K.jsx)(`p`,{className:`overline mb-2`,children:`Error · 404`}),(0,K.jsx)(`p`,{className:`text-sm`,children:`Page not found`}),(0,K.jsx)(`a`,{href:`/`,className:`mt-4 text-[12px] text-[var(--color-hig-blue)] hover:underline`,children:`← Back to dashboard`})]})}function Th(e,t){return e===`/`?t===`newcomer`?`Home`:`Dashboard`:e===`/classic`?`Classic Dashboard`:e===`/graph`?`Graph`:e===`/sessions`?`Sessions`:e.startsWith(`/sessions/`)?`Session Inspector`:e===`/debug`?`Debug`:e===`/rules`?`Rules`:e===`/audit`?t===`newcomer`?`Activity`:`Audit`:e===`/approvals`?`Approvals`:e===`/profile`?`Profile`:e===`/agents`?`Agents`:e===`/notifications`?`Notifications`:e===`/setup`?`Setup Status`:e===`/try`?`Try It`:e===`/guardrails`?`Guardrails`:e===`/hub/connect`?`Connect Hub`:e===`/hub/publish`?`Publish to Hub`:e.startsWith(`/hub/`)||e===`/hub`?`Hub`:e===`/monitor`?`Monitor`:e===`/observability`?`Observability`:e===`/support`?`Support & Feedback`:`SigmaShake`}function Eh(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function Dh({count:e}){let[t,n]=(0,_.useState)(!1);return t||e===0?null:(0,K.jsxs)(`div`,{className:`hig-banner hig-banner-warning`,children:[(0,K.jsxs)(`svg`,{className:`shrink-0`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,K.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,K.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),(0,K.jsxs)(`span`,{className:`flex-1`,children:[(0,K.jsxs)(`span`,{className:`font-semibold`,children:[e,` other `,e===1?`tab`:`tabs`,` open.`]}),` `,`Each tab holds a live SSE connection. Browsers limit connections per origin — too many tabs will prevent this page from loading.`,` `,(0,K.jsx)(`span`,{className:`opacity-70`,children:`Close other tabs to restore full live-update functionality.`})]}),(0,K.jsx)(`button`,{onClick:()=>n(!0),className:`opacity-60 hover:opacity-100 transition-opacity shrink-0 cursor-pointer`,title:`Dismiss`,children:(0,K.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,K.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function Oh({pathname:e,navSections:t,open:n,onClose:r}){let i=t=>t===`/`?e===`/`:e.startsWith(t);return(0,K.jsxs)(`aside`,{className:`hig-sidebar ${n?`open`:``}`,"aria-label":`Primary`,children:[(0,K.jsxs)(`div`,{className:`hig-sidebar-header`,children:[(0,K.jsx)(`span`,{className:`hig-app-icon`,"aria-hidden":`true`,children:`SS`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`hig-app-name`,children:`SigmaShake`}),(0,K.jsx)(`div`,{className:`hig-app-meta`,children:`Governance`})]})]}),(0,K.jsx)(`nav`,{className:`hig-sidebar-nav`,children:t.map(e=>(0,K.jsxs)(`div`,{className:`hig-sidebar-section`,children:[(0,K.jsx)(`div`,{className:`hig-sidebar-section-title`,children:e.title}),e.items.map(e=>(0,K.jsxs)(`a`,{href:e.path,onClick:r,className:`hig-sidebar-item`,"data-active":i(e.path)?`true`:`false`,children:[(0,K.jsx)(`span`,{className:`hig-sidebar-icon`,"aria-hidden":`true`,children:oh[e.icon]}),(0,K.jsx)(`span`,{children:e.label})]},e.path))]},e.title))})]})}function kh(){let[e,t]=(0,_.useState)(window.location.pathname),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(!1),{otherTabCount:o}=Pm(),{mode:s,setMode:c}=Hu(),l=lh(s),u=Th(e,s),[d,f]=(0,_.useState)(0),p=(0,_.useMemo)(()=>({navigate:e=>Eh(e),async setSsgMode(e){await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({mode:e})})},async setAskMode(e){await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...B()},body:JSON.stringify({mode:e})})},setUiMode:e=>c(e),refresh:()=>r(e=>e+1),hardReload:()=>{try{window.location.reload()}catch{}}}),[c]);return(0,_.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.selector)return;let n=null;try{n=document.querySelector(t.selector)}catch{return}if(!n)return;n.classList.remove(`voice-nav-pulse`),n.offsetWidth,n.classList.add(`voice-nav-pulse`);let r=window.setTimeout(()=>{n?.classList.remove(`voice-nav-pulse`)},1100);return()=>window.clearTimeout(r)},t=()=>f(e=>e+1);return window.addEventListener(`ssg:voice-target`,e),window.addEventListener(`ssg:voice-page-morph`,t),()=>{window.removeEventListener(`ssg:voice-target`,e),window.removeEventListener(`ssg:voice-page-morph`,t)}},[]),(0,_.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,_.useEffect)(()=>{a(!1)},[e]),(0,_.useEffect)(()=>{let e=e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);!n||n.startsWith(`http`)||n.startsWith(`//`)||n===`/workspace`||n.startsWith(`/workspace/`)||(e.preventDefault(),Eh(n))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]),(0,K.jsxs)(`div`,{className:`hig-app`,children:[(0,K.jsx)(Oh,{pathname:e,navSections:l,open:i,onClose:()=>a(!1)}),(0,K.jsxs)(`div`,{className:`hig-window`,children:[(0,K.jsxs)(`header`,{className:`hig-toolbar`,children:[(0,K.jsx)(`button`,{"aria-label":`Toggle sidebar`,className:`md:hidden hig-button hig-button-small`,onClick:()=>a(e=>!e),children:(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 18 18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:[(0,K.jsx)(`line`,{x1:`2`,y1:`5`,x2:`16`,y2:`5`}),(0,K.jsx)(`line`,{x1:`2`,y1:`9`,x2:`16`,y2:`9`}),(0,K.jsx)(`line`,{x1:`2`,y1:`13`,x2:`16`,y2:`13`})]})}),(0,K.jsx)(`h1`,{className:`hig-toolbar-title`,children:u}),(0,K.jsx)(`div`,{className:`hig-toolbar-spacer`}),(0,K.jsxs)(`div`,{className:`hig-toolbar-controls hidden md:flex`,children:[o>0&&(0,K.jsxs)(`span`,{className:`chip`,style:{color:`var(--color-hig-orange)`,background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`},title:`${o} other tab${o===1?``:`s`} open — may cause connection issues`,children:[o+1,` tabs`]}),(0,K.jsx)(Im,{}),(0,K.jsx)(vh,{}),(0,K.jsx)(hh,{}),(0,K.jsx)(Ch,{}),(0,K.jsx)(Sh,{}),(0,K.jsx)(dh,{}),(0,K.jsx)(bh,{onRefresh:()=>r(e=>e+1)}),(0,K.jsx)(xh,{}),(0,K.jsx)(ih,{}),(0,K.jsx)(rh,{}),(0,K.jsx)(Km,{}),(0,K.jsx)(ah,{})]})]}),(0,K.jsx)(yh,{}),(0,K.jsx)(Dh,{count:o}),(0,K.jsx)(mh,{}),(0,K.jsx)(ph,{}),(0,K.jsx)(fh,{}),(0,K.jsx)(`main`,{className:`hig-content px-6 py-6`,children:wh(e,s)},n),d>0&&(0,K.jsx)(`div`,{className:`voice-page-flash`,"aria-hidden":`true`},d)]}),(0,K.jsx)(fc,{actions:p})]})}var Ah=document.getElementById(`app-root`);if(!Ah)throw Error(`Missing #app-root`);g.createRoot(Ah).render((0,K.jsx)(_.StrictMode,{children:(0,K.jsx)(kh,{})}));
57
+ disabled:opacity-40 disabled:cursor-not-allowed`,children:`Run`})]})]})]})]})}var Ym=[{value:`issue`,label:`Bug / Issue`,hint:`Something is broken`},{value:`feature_request`,label:`Feature Request`,hint:`Suggest an improvement`},{value:`question`,label:`Question`,hint:`How does X work?`},{value:`incident`,label:`Incident`,hint:`Urgent outage or data concern`}],Xm=[{value:`p4`,label:`P4 — Low`},{value:`p3`,label:`P3 — Normal`},{value:`p2`,label:`P2 — High (4h SLA)`},{value:`p1`,label:`P1 — Critical (1h SLA)`}],Zm=5,Qm=8*1024*1024;function $m(){let[e,t]=(0,_.useState)(`issue`),[n,r]=(0,_.useState)(`p3`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(``),C=(0,_.useRef)(null);(0,_.useEffect)(()=>{fetch(`/api/json/profile`,{headers:H()}).then(e=>e.ok?e.json():null).then(e=>{e?.email&&l(e.email)}).catch(()=>{})},[]),(0,_.useEffect)(()=>{!y||g||fetch(`/api/support/diagnostics?route=${encodeURIComponent(window.location.pathname)}`).then(e=>e.ok?e.json():null).then(e=>v(e)).catch(()=>{})},[y,g]),(0,_.useEffect)(()=>{let e=new URL(window.location.href),n=e.searchParams.get(`error`),r=e.searchParams.get(`from`);if(n||r){t(`issue`);let e=r?`Page: ${r}\n\n`:``,i=n?`Error: ${n}\n\n`:``;s(t=>t||`${e}${i}`)}},[]);function w(e){e.preventDefault(),E(Array.from(e.dataTransfer.files))}function T(e){E(Array.from(e.target.files??[])),C.current&&(C.current.value=``)}function E(e){S(``);let t=e.filter(e=>e.type.startsWith(`image/`));t.length<e.length&&S(`Only image files are accepted.`);let n=Zm-u.length,r=t.slice(0,n);r.length<t.length&&S(`Maximum ${Zm} images. Some were dropped.`);let i=r.filter(e=>e.size>Qm);if(i.length>0){S(`"${i[0].name}" exceeds 8 MiB.`);return}let a=r.map(e=>({file:e,preview:URL.createObjectURL(e)}));d(e=>[...e,...a])}function O(e){d(t=>(URL.revokeObjectURL(t[e].preview),t.filter((t,n)=>n!==e)))}async function k(t){t.preventDefault(),p(!0),h(null);let r=new FormData;r.append(`category`,e),r.append(`severity`,n),r.append(`subject`,i.trim()),r.append(`description`,o.trim()),r.append(`contact_email`,c.trim()),r.append(`route`,window.location.pathname);for(let{file:e}of u)r.append(`images`,e,e.name);try{let e=await(await fetch(`/api/support/feedback`,{method:`POST`,headers:H(),body:r})).json();h(e),e.ok&&(a(``),s(``),d([]))}catch(e){h({ok:!1,error:e instanceof Error?e.message:`Network error`})}finally{p(!1)}}return(0,D.jsxs)(`div`,{className:`max-w-2xl mx-auto space-y-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Support & Feedback`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] mt-1 font-mono`,children:`report a bug, request a feature, or ask a question`})]}),m?.ok?(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,D.jsxs)(`p`,{className:`text-sm text-emerald-400 font-mono`,children:[`✓ `,m.message??`Ticket created.`]}),m.ticket_id&&(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-mono`,children:[`Ticket ID:`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)]`,children:m.ticket_id})]}),(0,D.jsx)(`button`,{className:`text-[12px] text-[var(--color-brand)] hover:underline font-mono`,onClick:()=>h(null),children:`Submit another`})]})})}):(0,D.jsxs)(`form`,{onSubmit:k,className:`space-y-4`,children:[(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsx)(`label`,{className:`block overline mb-2`,children:`type`}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Ym.map(n=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(n.value),className:`text-left px-3 py-2 rounded-sm border text-xs font-mono transition-colors ${e===n.value?`border-[var(--color-brand)]/50 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:border-[var(--color-line-0)]`}`,children:[(0,D.jsx)(`span`,{className:`block font-medium text-[var(--color-fg-1)]`,children:n.label}),(0,D.jsx)(`span`,{className:`block text-[11px] mt-0.5`,children:n.hint})]},n.value))})]})}),e===`incident`&&(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsx)(`label`,{className:`block overline mb-2`,children:`severity`}),(0,D.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:Xm.map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>r(e.value),className:`px-3 py-1.5 rounded-sm border text-xs font-mono transition-colors ${n===e.value?`border-[var(--color-brand)]/50 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:border-[var(--color-line-0)]`}`,children:e.label},e.value))})]})}),(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block overline mb-1.5`,children:`subject`}),(0,D.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Short summary (required)`,maxLength:200,required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block overline mb-1.5`,children:`description`}),(0,D.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:`Describe the issue in detail (10–10000 characters)`,minLength:10,maxLength:1e4,required:!0,rows:6,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono resize-y`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block overline mb-1.5`,children:`contact email`}),(0,D.jsx)(`input`,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:`your@email.com`,required:!0,className:`w-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] text-sm rounded-sm px-3 py-2 focus:outline-none focus:border-[var(--color-brand)]/50 placeholder:text-[var(--color-fg-4)] font-mono`})]})]})})}),(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsxs)(`label`,{className:`block overline mb-2`,children:[`screenshots / attachments`,` `,(0,D.jsxs)(`span`,{className:`normal-case text-[var(--color-fg-4)] font-mono font-normal`,children:[`(optional, up to `,Zm,` images)`]})]}),u.length<Zm&&(0,D.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:w,onClick:()=>C.current?.click(),className:`border border-dashed border-[var(--color-line-1)] rounded-sm p-6 text-center cursor-pointer hover:border-[var(--color-brand)]/50 transition-colors`,children:[(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] font-mono`,children:[`drag & drop images, or`,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-brand)]`,children:`click to browse`})]}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] mt-1 font-mono`,children:`PNG · JPEG · WebP · GIF · HEIC — max 8 MiB each`})]}),(0,D.jsx)(`input`,{ref:C,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:T}),x&&(0,D.jsx)(`p`,{className:`text-xs text-red-400 font-mono mt-2`,children:x}),u.length>0&&(0,D.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:u.map((e,t)=>(0,D.jsxs)(`div`,{className:`relative group`,children:[(0,D.jsx)(`img`,{src:e.preview,alt:e.file.name,className:`h-20 w-20 object-cover rounded-sm border border-[var(--color-line-1)]`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>O(t),className:`absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-[var(--color-surface-0)] border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-red-400 text-[10px] font-mono flex items-center justify-center`,title:`Remove`,children:`✕`}),(0,D.jsx)(`p`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] mt-0.5 max-w-[80px] truncate`,children:e.file.name})]},t))})]})}),(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] overflow-hidden`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 text-xs font-mono text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] bg-[var(--color-surface-0)] transition-colors`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`diagnostics that will be attached`}),(0,D.jsx)(`span`,{children:y?`▲`:`▼`})]}),y&&(0,D.jsx)(`div`,{className:`px-3 py-2 bg-[var(--color-surface-0)] border-t border-[var(--color-line-1)] max-h-64 overflow-auto`,children:g?(0,D.jsx)(`pre`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] whitespace-pre-wrap break-all`,children:JSON.stringify(g,null,2)}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`Loading…`})})]}),m&&!m.ok&&(0,D.jsx)(`div`,{className:`rounded-sm border border-red-500/25 bg-red-500/5 px-3 py-2 text-xs text-red-300 font-mono`,children:m.error??`Submission failed. Please try again.`}),(0,D.jsx)(q,{type:`submit`,variant:`primary`,disabled:f,children:f?`submitting…`:`submit feedback`})]})]})}function eh(e){let t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var th={block:`var(--color-hig-red)`,ask:`var(--color-hig-orange)`,log:`var(--color-hig-blue)`,allow:`var(--color-hig-green)`,force:`var(--color-hig-purple)`};function nh(e){switch(e){case`block`:return`Blocked`;case`ask`:return`Held for review`;case`log`:return`Logged`;case`force`:return`Force-allowed`;default:return`Allowed`}}function rh({type:e}){let t={fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,viewBox:`0 0 24 24`};return e===`code`?(0,D.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,D.jsx)(`path`,{d:`M9 7l-5 5 5 5M15 7l5 5-5 5`}),(0,D.jsx)(`path`,{d:`M14 4l-4 16`,opacity:`0.55`})]}):e===`docs`?(0,D.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,D.jsx)(`path`,{d:`M5 4h9l5 5v11a1 1 0 01-1 1H5a1 1 0 01-1-1V5a1 1 0 011-1z`}),(0,D.jsx)(`path`,{d:`M14 4v5h5`}),(0,D.jsx)(`path`,{d:`M8 13h8M8 17h5`,opacity:`0.7`})]}):(0,D.jsxs)(`svg`,{...t,width:`22`,height:`22`,children:[(0,D.jsx)(`path`,{d:`M3 12a9 9 0 109-9`}),(0,D.jsx)(`path`,{d:`M12 3v9l6 3`})]})}function ih(){let{data:e}=V(`/api/json/counters`,[Nt([`counters-updated`])[`counters-updated`]]),t=e?.evals_today??0,n=e?.blocked_today??0,r=e?.asked_today??0;return(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,D.jsx)(ah,{value:t,label:`evaluated`,tone:`default`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(ah,{value:n,label:`blocked`,tone:`red`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(ah,{value:r,label:`held for you`,tone:`orange`}),(0,D.jsx)(`span`,{className:`text-[11px] ml-auto`,style:{color:`var(--color-fg-3)`},children:`Today`})]})}function ah({value:e,label:t,tone:n}){return(0,D.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,D.jsx)(`span`,{className:`font-semibold tabular-nums`,style:{color:n===`red`?`var(--color-hig-red)`:n===`orange`?`var(--color-hig-orange)`:`var(--color-fg-0)`,fontSize:`20px`,lineHeight:1,letterSpacing:`-0.018em`},children:e.toLocaleString()}),(0,D.jsx)(`span`,{style:{color:`var(--color-fg-3)`,fontSize:`12px`,letterSpacing:`-0.005em`},children:t})]})}function oh({href:e,title:t,desc:n,tone:r,type:i,cta:a}){let o=r===`orange`?`var(--color-hig-orange)`:r===`indigo`?`var(--color-hig-indigo)`:`var(--color-hig-blue)`;return(0,D.jsx)(`a`,{href:e,className:`group block rounded-2xl px-4 py-4 transition-all`,style:{border:`0.5px solid var(--color-line-1)`,background:`var(--color-surface-1)`,textDecoration:`none`,color:`inherit`,boxShadow:`var(--hig-shadow-1)`},children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`span`,{className:`flex items-center justify-center rounded-xl shrink-0`,style:{width:`40px`,height:`40px`,color:o,background:`color-mix(in oklab, ${o} 14%, transparent)`},children:(0,D.jsx)(rh,{type:i})}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-[14px] font-semibold leading-tight`,style:{color:`var(--color-fg-0)`,letterSpacing:`-0.005em`},children:t}),(0,D.jsx)(`div`,{className:`text-[12px] mt-1 leading-snug`,style:{color:`var(--color-fg-2)`},children:n}),(0,D.jsxs)(`div`,{className:`text-[11.5px] mt-2 font-medium inline-flex items-center gap-1 transition-all`,style:{color:o},children:[a,(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-hover:translate-x-0.5`,children:`→`})]})]})]})})}function sh(){let{data:e}=V(`/api/state/activity?limit=5`,[Nt([`activity-updated`])[`activity-updated`]]),[,t]=(0,_.useState)(0);return(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),6e4);return()=>clearInterval(e)},[]),!e||e.length===0?(0,D.jsxs)(`div`,{className:`py-6 text-center`,style:{color:`var(--color-fg-3)`},children:[(0,D.jsx)(`p`,{style:{fontSize:`12.5px`,color:`var(--color-fg-2)`},children:`Waiting for your first agent action.`}),(0,D.jsx)(`p`,{style:{fontSize:`11px`,color:`var(--color-fg-3)`,marginTop:`4px`},children:`Anything your AI tries — read, write, run — will appear here in real time.`})]}):(0,D.jsx)(`div`,{children:e.slice(0,5).map((e,t)=>(0,D.jsxs)(`div`,{className:`hig-feed-row`,children:[(0,D.jsx)(`span`,{className:`hig-feed-row-dot`,style:{background:th[e.decision]??`var(--color-fg-3)`,boxShadow:`0 0 0 3px ${e.decision===`block`?`color-mix(in oklab, var(--color-hig-red) 22%, transparent)`:e.decision===`ask`?`color-mix(in oklab, var(--color-hig-orange) 22%, transparent)`:`transparent`}`}}),(0,D.jsx)(`span`,{className:`hig-feed-row-decision`,style:{color:th[e.decision]??`var(--color-fg-2)`},children:nh(e.decision)}),(0,D.jsx)(`span`,{style:{color:`var(--color-fg-3)`},children:`·`}),(0,D.jsx)(`span`,{className:`hig-feed-row-tool`,title:e.tool,children:ha(e.tool)}),(0,D.jsx)(`span`,{className:`hig-feed-row-time`,children:eh(e.timestamp)})]},e.id??t))})}function ch(){return(0,D.jsx)(`div`,{className:`relative`,children:(0,D.jsxs)(`div`,{className:`relative max-w-5xl mx-auto px-2 pt-6 pb-12 space-y-6`,children:[(0,D.jsxs)(`section`,{className:`rounded-2xl px-6 py-5 relative overflow-hidden`,style:{border:`0.5px solid var(--color-line-1)`,background:`radial-gradient(120% 100% at 0% 0%, color-mix(in oklab, var(--color-accent) 14%, transparent) 0%, transparent 55%), var(--color-surface-1)`,boxShadow:`var(--hig-shadow-1)`},children:[(0,D.jsx)(`div`,{className:`hig-eyebrow mb-2`,children:`SigmaShake · Guardrails for AI`}),(0,D.jsx)(`h1`,{className:`font-semibold tracking-tight leading-tight`,style:{color:`var(--color-fg-0)`,fontSize:`26px`,letterSpacing:`-0.018em`},children:`The seatbelt for AI agents.`}),(0,D.jsx)(`p`,{className:`mt-1.5 leading-relaxed`,style:{color:`var(--color-fg-2)`,fontSize:`13.5px`,maxWidth:`52ch`},children:`Watch every move your AI makes. Approve what matters, block what doesn't — without babysitting every step.`}),(0,D.jsx)(`div`,{className:`mt-4 pt-3`,style:{borderTop:`0.5px solid var(--color-line-0)`},children:(0,D.jsx)(ih,{})})]}),(0,D.jsx)(`section`,{children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(oh,{href:`/guardrails?starter=coding`,tone:`orange`,type:`code`,title:`Code safely with AI`,desc:`Protect files, secrets, and git history from coding agents.`,cta:`Install pack`}),(0,D.jsx)(oh,{href:`/guardrails?starter=knowledge-work`,tone:`indigo`,type:`docs`,title:`Guard sensitive content`,desc:`Watch outbound email, file shares, and document changes.`,cta:`Install pack`}),(0,D.jsx)(oh,{href:`/audit`,tone:`blue`,type:`review`,title:`Review what your AI did`,desc:`Every action, decision, and reason — in one place.`,cta:`Open activity`})]})}),(0,D.jsxs)(`a`,{href:`/try`,className:`group flex items-center justify-between gap-3 rounded-xl px-4 py-3 transition-all`,style:{border:`0.5px solid var(--color-line-1)`,background:`linear-gradient(90deg, color-mix(in oklab, var(--color-accent) 8%, transparent) 0%, transparent 60%), var(--color-surface-1)`,textDecoration:`none`,color:`inherit`},children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,D.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-full shrink-0`,style:{background:`linear-gradient(180deg, var(--color-accent) 0%, var(--color-brand-hover) 100%)`,color:`var(--color-accent-on)`,boxShadow:`inset 0 0.5px 0 rgba(255,255,255,0.30), 0 2px 8px color-mix(in oklab, var(--color-accent) 30%, transparent)`},children:(0,D.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`polygon`,{points:`6 4 20 12 6 20`,fill:`currentColor`,stroke:`none`})})}),(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`font-semibold text-[13.5px] leading-tight`,style:{color:`var(--color-fg-0)`,letterSpacing:`-0.005em`},children:`Try a scenario — see SigmaShake decide`}),(0,D.jsx)(`div`,{className:`text-[12px] mt-0.5`,style:{color:`var(--color-fg-3)`},children:`30-second dry-run · nothing actually runs.`})]})]}),(0,D.jsxs)(`span`,{className:`text-[12.5px] font-medium shrink-0 inline-flex items-center gap-1 transition-all`,style:{color:`var(--color-accent)`},children:[`Try it`,(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-hover:translate-x-0.5`,children:`→`})]})]}),(0,D.jsxs)(`section`,{children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2`,children:[(0,D.jsx)(`h2`,{className:`font-semibold tracking-tight`,style:{color:`var(--color-fg-0)`,fontSize:`15px`,letterSpacing:`-0.008em`},children:`Recent activity`}),(0,D.jsx)(`a`,{href:`/audit`,style:{fontSize:`12px`,color:`var(--color-hig-blue)`,fontWeight:500},children:`View all →`})]}),(0,D.jsx)(`div`,{style:{background:`var(--color-surface-1)`,border:`0.5px solid var(--color-line-1)`,borderRadius:`14px`,padding:`4px 16px`,boxShadow:`var(--hig-shadow-1)`},children:(0,D.jsx)(sh,{})})]})]})})}var lh={dashboard:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`9`,rx:`1.5`}),(0,D.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`5`,rx:`1.5`}),(0,D.jsx)(`rect`,{x:`14`,y:`12`,width:`7`,height:`9`,rx:`1.5`}),(0,D.jsx)(`rect`,{x:`3`,y:`16`,width:`7`,height:`5`,rx:`1.5`})]}),graph:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.4`}),(0,D.jsx)(`circle`,{cx:`18`,cy:`6`,r:`2.4`}),(0,D.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2.4`}),(0,D.jsx)(`circle`,{cx:`12`,cy:`11`,r:`2.4`}),(0,D.jsx)(`path`,{d:`M7.5 16.5l3-4M13.5 11.5l3-3.5M13.5 12l3 4.5`})]}),rules:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M9 5h11M9 12h11M9 19h11`}),(0,D.jsx)(`path`,{d:`M4 5l1 1 2-2M4 12l1 1 2-2M4 19l1 1 2-2`})]}),hub:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,D.jsx)(`path`,{d:`M3 12h18`}),(0,D.jsx)(`path`,{d:`M12 3a14 14 0 010 18M12 3a14 14 0 000 18`})]}),audit:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`6.5`}),(0,D.jsx)(`path`,{d:`M21 21l-5-5`})]}),approvals:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M5 7h14v12a2 2 0 01-2 2H7a2 2 0 01-2-2z`}),(0,D.jsx)(`path`,{d:`M9 3v4M15 3v4`}),(0,D.jsx)(`path`,{d:`M9 13l2 2 4-4`})]}),profile:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,D.jsx)(`path`,{d:`M4 21c0-4.4 3.6-8 8-8s8 3.6 8 8`})]}),monitor:(0,D.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M3 12h3l3-7 4 14 3-7h5`})}),observability:(0,D.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M4 20h16M7 16V8M11 16V4M15 16v-6M19 16v-3`})}),debug:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`rect`,{x:`7`,y:`7`,width:`10`,height:`12`,rx:`5`}),(0,D.jsx)(`path`,{d:`M12 7V4M9 4l3 3 3-3`}),(0,D.jsx)(`path`,{d:`M5 11l2-1M5 18l2-1M19 11l-2-1M19 18l-2-1`})]}),home:(0,D.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,D.jsx)(`path`,{d:`M3 11l9-7 9 7v9a2 2 0 01-2 2h-3v-7H10v7H5a2 2 0 01-2-2z`})}),guardrails:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M12 3l8 3.7v6.3c0 5-3.5 9.6-8 11-4.5-1.4-8-6-8-11V6.7L12 3z`}),(0,D.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),tryit:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M9 3v6L4.5 18a2 2 0 001.7 3h11.6a2 2 0 001.7-3L15 9V3`}),(0,D.jsx)(`path`,{d:`M8 3h8`})]}),agents:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`8`,cy:`9`,r:`3`}),(0,D.jsx)(`circle`,{cx:`16`,cy:`9`,r:`3`}),(0,D.jsx)(`path`,{d:`M3 19c.7-2.5 2.6-4 5-4`}),(0,D.jsx)(`path`,{d:`M21 19c-.7-2.5-2.6-4-5-4`}),(0,D.jsx)(`path`,{d:`M9 17.5c.8-1 1.8-1.5 3-1.5s2.2.5 3 1.5`})]}),notifications:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M18 16v-5a6 6 0 1 0-12 0v5l-2 2h16z`}),(0,D.jsx)(`path`,{d:`M10 20a2 2 0 0 0 4 0`})]}),setup:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M9 12l2 2 4-4`}),(0,D.jsx)(`path`,{d:`M12 3l8 3.7v6.3c0 5-3.5 9.6-8 11-4.5-1.4-8-6-8-11V6.7L12 3z`})]}),support:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),(0,D.jsx)(`path`,{d:`M12 2.5v6M12 15.5v6M2.5 12h6M15.5 12h6`})]}),workspace:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`14`,rx:`2`}),(0,D.jsx)(`path`,{d:`M3 9h18M8 14h2M14 14h2`}),(0,D.jsx)(`path`,{d:`M9 20h6`})]})},uh=[{title:`Overview`,items:[{path:`/`,label:`Dashboard`,icon:`dashboard`},{path:`/notifications`,label:`Notifications`,icon:`notifications`},{path:`/agents`,label:`Agents`,icon:`agents`},{path:`/graph`,label:`Graph`,icon:`graph`},{path:`/sessions`,label:`Sessions`,icon:`agents`}]},{title:`Rules`,items:[{path:`/rules`,label:`Rules`,icon:`rules`},{path:`/hub`,label:`Hub`,icon:`hub`},{path:`/approvals`,label:`Approvals`,icon:`approvals`}]},{title:`Activity`,items:[{path:`/audit`,label:`Audit`,icon:`audit`},{path:`/monitor`,label:`Monitor`,icon:`monitor`},{path:`/observability`,label:`Observability`,icon:`observability`}]},{title:`Tools`,items:[{path:`/workspace`,label:`Workspace`,icon:`workspace`},{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/debug`,label:`Debug`,icon:`debug`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}],dh=[{title:`Get Started`,items:[{path:`/`,label:`Home`,icon:`home`},{path:`/agents`,label:`Agents`,icon:`agents`},{path:`/guardrails`,label:`Guardrails`,icon:`guardrails`},{path:`/try`,label:`Try It`,icon:`tryit`}]},{title:`Activity`,items:[{path:`/notifications`,label:`Notifications`,icon:`notifications`},{path:`/audit`,label:`Activity`,icon:`audit`},{path:`/approvals`,label:`Approvals`,icon:`approvals`}]},{title:`You`,items:[{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}];function fh(e){return e===`newcomer`?dh:uh}function ph(e){let t=Math.max(0,e-Date.now()),n=Math.floor(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function mh(){let{data:e}=V(`/api/json/daemon-status`,[Nt([`counters-updated`])[`counters-updated`]]),[t,n]=(0,_.useState)(!1),[,r]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(e?.status!==`degraded`||!e.hibernation)return;let t=setInterval(()=>r(e=>e+1),1e3);return()=>clearInterval(t)},[e?.status,e?.hibernation]);let i=e?.status??`starting`,a=i===`running`?`bg-[var(--color-decision-allow)]`:i===`starting`||i===`degraded`?`bg-[var(--color-decision-ask)]`:`bg-[var(--color-decision-block)]`,o=i===`starting`||i===`degraded`?`pulse-soft`:``,s=i===`degraded`&&e?.hibernation?ph(e.hibernation.nextRetryAt):null,c=i===`running`?`Daemon`:i===`starting`?`Booting`:i===`degraded`?`Retry ${s??`…`}`:i===`error`?`Error`:`Offline`;return(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors`,title:i===`running`?`Daemon running`:i===`starting`?`Daemon starting…`:i===`degraded`?`Daemon hibernating — retry in ${s??`…`}`:i===`error`?`Daemon error`:`Daemon stopped`,children:[(0,D.jsx)(`span`,{className:`status-dot ${a} ${o}`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:c})]}),t&&(0,D.jsxs)(`div`,{className:`absolute right-0 top-7 z-50 w-72 hig-card hig-card-padded text-xs`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`Eval Daemon`}),(0,D.jsx)(`button`,{onClick:()=>n(!1),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] cursor-pointer`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`space-y-1 text-[var(--color-fg-2)]`,children:[(0,D.jsxs)(`div`,{className:`font-mono text-[11px]`,children:[`status:`,` `,(0,D.jsx)(`span`,{className:i===`running`?`text-[var(--color-decision-allow)]`:i===`starting`||i===`degraded`?`text-[var(--color-decision-ask)]`:`text-[var(--color-decision-block)]`,children:i})]}),e?.pid&&(0,D.jsxs)(`div`,{className:`font-mono text-[11px]`,children:[`pid: `,e.pid]}),i===`degraded`&&e?.hibernation&&(0,D.jsxs)(`div`,{className:`mt-2 rounded-lg p-2 text-[11px] space-y-0.5`,style:{background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`,color:`color-mix(in oklab, var(--color-hig-orange) 90%, var(--color-fg-0))`},children:[(0,D.jsxs)(`div`,{children:[`next retry: `,(0,D.jsx)(`span`,{className:`font-medium`,children:s})]}),(0,D.jsxs)(`div`,{children:[`episode attempt: `,e.hibernation.attempt,e.hibernation.reason?` (${e.hibernation.reason})`:``]}),(0,D.jsx)(`div`,{className:`opacity-70`,children:`Slow-tier supervisor is retrying at long backoff — no manual restart required.`})]})]}),e?.logTail&&e.logTail.length>0&&(0,D.jsxs)(`div`,{className:`mt-3`,children:[(0,D.jsx)(`div`,{className:`overline mb-1`,children:`Recent log`}),(0,D.jsx)(`pre`,{className:`bg-[var(--color-surface-2)] border border-[var(--color-line-0)] rounded-md p-2 text-[10px] text-[var(--color-fg-2)] overflow-x-auto whitespace-pre-wrap break-all max-h-32 overflow-y-auto`,children:e.logTail.join(`
58
+ `)})]})]})]})}function hh(){let{data:e}=V(`/api/state/activity-degraded`);if(!e?.degraded)return null;let t=e.since?new Date(e.since).toLocaleTimeString():`recently`;return(0,D.jsxs)(`div`,{role:`status`,className:`hig-banner hig-banner-warning`,title:e.reason??`audit-worker degraded`,children:[(0,D.jsx)(`span`,{children:`⚠`}),(0,D.jsxs)(`span`,{children:[`Audit pipeline degraded since `,t,` — entries may be missing. Run`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg daemon --status`}),` to inspect.`]})]})}function gh(){let{data:e}=V(`/api/json/license`,[Nt([`counters-updated`])[`counters-updated`]]);return!e||e.tier!==`unlicensed`||e.status===`needs_reauth`||e.status===`needs_login`||e.eval_daily_limit===null||e.evals_today<e.eval_daily_limit?null:(0,D.jsxs)(`div`,{role:`alert`,className:`hig-banner hig-banner-error`,title:`Free tier daily eval limit reached — rules are being bypassed until quota resets`,children:[(0,D.jsx)(`span`,{children:`●`}),(0,D.jsxs)(`span`,{children:[`Quota exhausted — `,e.evals_today.toLocaleString(),`/`,e.eval_daily_limit.toLocaleString(),` evals used today. BLOCK and ASK rules are being bypassed (fail-open) until daily reset.`,` `,(0,D.jsx)(`a`,{href:e.upgrade_url,target:`_blank`,rel:`noopener noreferrer`,className:`underline font-medium`,children:`Upgrade to Pro →`})]})]})}function _h(){let{data:e}=V(`/api/json/license`,[Nt([`counters-updated`])[`counters-updated`]]);if(!e||e.status!==`needs_reauth`)return null;let t=e.detail??`License JWT invalid or expired`;return(0,D.jsxs)(`div`,{role:`alert`,className:`hig-banner hig-banner-warning`,title:`Re-authentication required — paid-tier features are paused until you re-login`,children:[(0,D.jsx)(`span`,{children:`⚠`}),(0,D.jsxs)(`span`,{children:[`Re-authentication required — `,t,`. Run`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg auth login`}),` in your terminal to restore your tier.`]})]})}function vh(){let{data:e,refetch:t}=V(`/api/json/ask-mode`),[n,r]=(0,_.useState)(!1),i=e?.mode??`tty`;async function a(e){if(!(n||e===i)){r(!0);try{await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}let o=i===`tty`;return(0,D.jsxs)(`button`,{onClick:()=>a(o?`dashboard`:`tty`),disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:o?`ASK decisions prompt in the native IDE/TTY. Click to route to dashboard.`:`ASK decisions queue on /approvals. Click to route to native prompt.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${o?`bg-[var(--color-hig-blue)]`:`bg-[var(--color-hig-purple)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Ask · `,o?`Native`:`Dashboard`]})]})}function yh(e){let t=new Date(e);return`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}`}var bh={on:`soft`,soft:`audit`,audit:`off`,off:`on`};function xh(){let{data:e,refetch:t}=V(`/api/json/mode`,[Nt([`mode-changed`])[`mode-changed`]]),[n,r]=(0,_.useState)(!1),i=e?.mode??`on`;async function a(e,i){if(!n){r(!0);try{let n={mode:e};typeof i==`number`&&i>0&&(n.forMs=i),await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify(n)}),t()}finally{r(!1)}}}let o=i===`on`?`bg-[var(--color-hig-green)]`:i===`soft`?`bg-[var(--color-hig-yellow)]`:i===`audit`?`bg-[var(--color-hig-orange)]`:`bg-[var(--color-hig-red)]`,s=e?.rearmAt!==void 0&&i!==`on`?` · until ${yh(e.rearmAt)}`:``,c=`SSG · ${i.toUpperCase()}${s}`;return(0,D.jsxs)(`button`,{onClick:e=>{e.shiftKey?a(i===`off`?`audit`:`on`):a(bh[i])},disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:i===`on`?`SSG ON — rules enforce normally. Click to cycle: On → Soft → Audit → Off.`:i===`soft`?`SSG SOFT — blocks downgraded to prompts, prompts downgraded to logs. Click for Audit; Shift+Click to resume On.`:i===`audit`?`SSG AUDIT — rules log only, nothing blocked or prompted. Click for Off; Shift+Click to resume On.`:`SSG OFF — kill switch engaged, evaluator returns allow. Click to resume On; Shift+Click for Audit.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${o}`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:c})]})}function Sh(){let{data:e,refetch:t}=V(`/api/json/mode`,[Nt([`mode-changed`])[`mode-changed`]]),n=e?.mode??`on`;if(n===`on`)return null;let r=e?.rearmAt===void 0?``:` Auto-restores at ${yh(e.rearmAt)}.`,i=n===`off`?`SSG is OFF — kill switch engaged.`:n===`soft`?`SSG is in SOFT mode — non-blocking enforcement.`:`SSG is in AUDIT mode — log-only.`,a=n===`off`?`Every tool call is being allowed without evaluation.${r}`:n===`soft`?`Block decisions are being downgraded to prompts and prompts to logs. Workflow keeps moving; signal still surfaces in the audit log.${r}`:`Rules still match for the audit log, but nothing is being blocked or prompted.${r}`,o=n===`off`?`hig-banner hig-banner-error`:`hig-banner hig-banner-warning`;async function s(){await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({mode:`on`})}),t()}return(0,D.jsxs)(`div`,{className:o,children:[(0,D.jsxs)(`svg`,{className:`shrink-0`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,D.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),(0,D.jsxs)(`span`,{className:`flex-1`,children:[(0,D.jsx)(`span`,{className:`font-semibold`,children:i}),` `,a]}),(0,D.jsx)(`button`,{onClick:s,className:`hig-button hig-button-small`,title:`Re-enable normal rule enforcement`,children:`Resume`})]})}function Ch({onRefresh:e}){return(0,D.jsx)(`button`,{onClick:e,className:`hig-button`,title:`Reset page — clears stale graph state without dropping SSE`,"aria-label":`Refresh page`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,D.jsx)(`polyline`,{points:`21 3 21 9 15 9`})]})})}function wh(){return(0,D.jsx)(`button`,{onClick:()=>{try{window.location.reload()}catch{}},className:`hig-button`,title:`Reload dashboard — fetches fresh assets (use after a desktop upgrade)`,"aria-label":`Reload dashboard`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M3 12a9 9 0 1 1 3 6.7`}),(0,D.jsx)(`polyline`,{points:`3 21 3 15 9 15`}),(0,D.jsx)(`path`,{d:`M3 3v6h6`})]})})}function Th(){let{data:e}=V(`/api/json/mcp-status`,[Nt([`activity-updated`])[`activity-updated`]]),t=e?.status??`inactive`;if(t===`inactive`)return null;let n=t===`active`?`bg-[var(--color-hig-blue)]`:`bg-[var(--color-fg-3)]`,r=t===`active`?`MCP active`:`MCP idle`;return(0,D.jsxs)(`div`,{className:`chip`,title:t===`active`?`MCP server: ${e?.recentCount??0} evals in last 5 min`:`MCP server: ${e?.totalCount??0} total evals`,children:[(0,D.jsx)(`span`,{className:`status-dot ${n}`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Eh(){let{data:e}=V(`/api/json/adapters`);if(!e)return null;let t=e.adapters.find(e=>e.active);if(!t)return null;let n=t.id===`generic`;return(0,D.jsxs)(`a`,{href:`/agents`,className:`chip ss-agent-chip cursor-pointer transition-all`,title:n?`No specific AI client detected — SSG is running in generic adapter mode. Click to wire one up.`:`Connected agent: ${t.displayName} (${t.vendor}). Click to manage.`,style:{"--agent-accent":t.accent},"data-generic":n?`true`:`false`,children:[(0,D.jsx)(`span`,{className:`status-dot`,style:{background:t.accent,boxShadow:`0 0 6px color-mix(in oklab, ${t.accent} 60%, transparent)`}}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:t.displayName})]})}function Dh(e,t){if(e===`/`)return t===`newcomer`?(0,D.jsx)(ch,{}):(0,D.jsx)(su,{});if(e===`/classic`)return(0,D.jsx)(Yu,{});if(e===`/graph`)return(0,D.jsx)(pf,{});if(e===`/sessions`)return(0,D.jsx)(Cm,{});if(e.startsWith(`/sessions/`)){let t=decodeURIComponent(e.slice(10));if(t)return(0,D.jsx)(gm,{sessionKey:t})}if(e===`/debug`)return(0,D.jsx)(Zu,{});if(e===`/rules`)return(0,D.jsx)(sm,{});if(e===`/audit`)return(0,D.jsx)(Ra,{});if(e===`/approvals`)return(0,D.jsx)(sa,{});if(e===`/profile`)return(0,D.jsx)(Mp,{});if(e===`/agents`)return(0,D.jsx)(an,{});if(e===`/notifications`)return(0,D.jsx)(Jf,{});if(e===`/setup`)return(0,D.jsx)(Pm,{});if(e===`/try`)return(0,D.jsx)(Jm,{});if(e===`/guardrails`)return(0,D.jsx)(bf,{});if(e===`/hub/connect`)return(0,D.jsx)(mf,{});if(e===`/hub/publish`)return(0,D.jsx)(Nf,{});if(e.startsWith(`/hub/`)){let t=e.slice(5);if(t)return(0,D.jsx)(gf,{id:t})}return e===`/hub`?(0,D.jsx)(jf,{}):e===`/monitor`?(0,D.jsx)(Kf,{}):e===`/observability`?(0,D.jsx)(xp,{}):e===`/support`?(0,D.jsx)($m,{}):(0,D.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-24 text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`p`,{className:`overline mb-2`,children:`Error · 404`}),(0,D.jsx)(`p`,{className:`text-sm`,children:`Page not found`}),(0,D.jsx)(`a`,{href:`/`,className:`mt-4 text-[12px] text-[var(--color-hig-blue)] hover:underline`,children:`← Back to dashboard`})]})}function Oh(e,t){return e===`/`?t===`newcomer`?`Home`:`Dashboard`:e===`/classic`?`Classic Dashboard`:e===`/graph`?`Graph`:e===`/sessions`?`Sessions`:e.startsWith(`/sessions/`)?`Session Inspector`:e===`/debug`?`Debug`:e===`/rules`?`Rules`:e===`/audit`?t===`newcomer`?`Activity`:`Audit`:e===`/approvals`?`Approvals`:e===`/profile`?`Profile`:e===`/agents`?`Agents`:e===`/notifications`?`Notifications`:e===`/setup`?`Setup Status`:e===`/try`?`Try It`:e===`/guardrails`?`Guardrails`:e===`/hub/connect`?`Connect Hub`:e===`/hub/publish`?`Publish to Hub`:e.startsWith(`/hub/`)||e===`/hub`?`Hub`:e===`/monitor`?`Monitor`:e===`/observability`?`Observability`:e===`/support`?`Support & Feedback`:`SigmaShake`}function kh(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function Ah({count:e}){let[t,n]=(0,_.useState)(!1);return t||e===0?null:(0,D.jsxs)(`div`,{className:`hig-banner hig-banner-warning`,children:[(0,D.jsxs)(`svg`,{className:`shrink-0`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`}),(0,D.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,D.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),(0,D.jsxs)(`span`,{className:`flex-1`,children:[(0,D.jsxs)(`span`,{className:`font-semibold`,children:[e,` other `,e===1?`tab`:`tabs`,` open.`]}),` `,`Each tab holds a live SSE connection. Browsers limit connections per origin — too many tabs will prevent this page from loading.`,` `,(0,D.jsx)(`span`,{className:`opacity-70`,children:`Close other tabs to restore full live-update functionality.`})]}),(0,D.jsx)(`button`,{onClick:()=>n(!0),className:`opacity-60 hover:opacity-100 transition-opacity shrink-0 cursor-pointer`,title:`Dismiss`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,D.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function jh({pathname:e,navSections:t,open:n,onClose:r}){let i=t=>t===`/`?e===`/`:e.startsWith(t);return(0,D.jsxs)(`aside`,{className:`hig-sidebar ${n?`open`:``}`,"aria-label":`Primary`,children:[(0,D.jsxs)(`div`,{className:`hig-sidebar-header`,children:[(0,D.jsx)(`span`,{className:`hig-app-icon`,"aria-hidden":`true`,children:`SS`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`hig-app-name`,children:`SigmaShake`}),(0,D.jsx)(`div`,{className:`hig-app-meta`,children:`Governance`})]})]}),(0,D.jsx)(`nav`,{className:`hig-sidebar-nav`,children:t.map(e=>(0,D.jsxs)(`div`,{className:`hig-sidebar-section`,children:[(0,D.jsx)(`div`,{className:`hig-sidebar-section-title`,children:e.title}),e.items.map(e=>(0,D.jsxs)(`a`,{href:e.path,onClick:r,className:`hig-sidebar-item`,"data-active":i(e.path)?`true`:`false`,children:[(0,D.jsx)(`span`,{className:`hig-sidebar-icon`,"aria-hidden":`true`,children:lh[e.icon]}),(0,D.jsx)(`span`,{children:e.label})]},e.path))]},e.title))})]})}function Mh(){let[e,t]=(0,_.useState)(window.location.pathname),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(!1),{otherTabCount:o}=Rt(),{mode:s,setMode:c}=se(),l=fh(s),u=Oh(e,s),[d,f]=(0,_.useState)(0),p=(0,_.useMemo)(()=>({navigate:e=>kh(e),async setSsgMode(e){await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({mode:e})})},async setAskMode(e){await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...H()},body:JSON.stringify({mode:e})})},setUiMode:e=>c(e),refresh:()=>r(e=>e+1),hardReload:()=>{try{window.location.reload()}catch{}}}),[c]);return(0,_.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.selector)return;let n=null;try{n=document.querySelector(t.selector)}catch{return}if(!n)return;n.classList.remove(`voice-nav-pulse`),n.offsetWidth,n.classList.add(`voice-nav-pulse`);let r=window.setTimeout(()=>{n?.classList.remove(`voice-nav-pulse`)},1100);return()=>window.clearTimeout(r)},t=()=>f(e=>e+1);return window.addEventListener(`ssg:voice-target`,e),window.addEventListener(`ssg:voice-page-morph`,t),()=>{window.removeEventListener(`ssg:voice-target`,e),window.removeEventListener(`ssg:voice-page-morph`,t)}},[]),(0,_.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,_.useEffect)(()=>{a(!1)},[]),(0,_.useEffect)(()=>{let e=e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);!n||n.startsWith(`http`)||n.startsWith(`//`)||n===`/workspace`||n.startsWith(`/workspace/`)||(e.preventDefault(),kh(n))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]),(0,D.jsxs)(`div`,{className:`hig-app`,children:[(0,D.jsx)(jh,{pathname:e,navSections:l,open:i,onClose:()=>a(!1)}),(0,D.jsxs)(`div`,{className:`hig-window`,children:[(0,D.jsxs)(`header`,{className:`hig-toolbar`,children:[(0,D.jsx)(`button`,{"aria-label":`Toggle sidebar`,className:`md:hidden hig-button hig-button-small`,onClick:()=>a(e=>!e),children:(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 18 18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:[(0,D.jsx)(`line`,{x1:`2`,y1:`5`,x2:`16`,y2:`5`}),(0,D.jsx)(`line`,{x1:`2`,y1:`9`,x2:`16`,y2:`9`}),(0,D.jsx)(`line`,{x1:`2`,y1:`13`,x2:`16`,y2:`13`})]})}),(0,D.jsx)(`h1`,{className:`hig-toolbar-title`,children:u}),(0,D.jsx)(`div`,{className:`hig-toolbar-spacer`}),(0,D.jsxs)(`div`,{className:`hig-toolbar-controls hidden md:flex`,children:[o>0&&(0,D.jsxs)(`span`,{className:`chip`,style:{color:`var(--color-hig-orange)`,background:`color-mix(in oklab, var(--color-hig-orange) 14%, transparent)`},title:`${o} other tab${o===1?``:`s`} open — may cause connection issues`,children:[o+1,` tabs`]}),(0,D.jsx)(St,{}),(0,D.jsx)(xh,{}),(0,D.jsx)(vh,{}),(0,D.jsx)(Eh,{}),(0,D.jsx)(Th,{}),(0,D.jsx)(mh,{}),(0,D.jsx)(Ch,{onRefresh:()=>r(e=>e+1)}),(0,D.jsx)(wh,{}),(0,D.jsx)(ce,{}),(0,D.jsx)(re,{}),(0,D.jsx)(O,{}),(0,D.jsx)(ke,{})]})]}),(0,D.jsx)(Sh,{}),(0,D.jsx)(Ah,{count:o}),(0,D.jsx)(_h,{}),(0,D.jsx)(gh,{}),(0,D.jsx)(hh,{}),(0,D.jsx)(`main`,{className:`hig-content px-6 py-6`,children:Dh(e,s)},n),d>0&&(0,D.jsx)(`div`,{className:`voice-page-flash`,"aria-hidden":`true`},d)]}),(0,D.jsx)(jt,{actions:p})]})}var Nh=document.getElementById(`app-root`);if(!Nh)throw Error(`Missing #app-root`);g.createRoot(Nh).render((0,D.jsx)(_.StrictMode,{children:(0,D.jsx)(Mh,{})}));