@sigmashake/ssg 0.29.140 → 0.29.142

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.
@@ -5,28 +5,28 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
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{me=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?pe(n):``}function ge(e,t){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe(`Lazy`);case 13:return e.child!==t&&t!==null?pe(`Suspense Fallback`):pe(`Suspense`);case 19:return pe(`SuspenseList`);case 0:case 15:return he(e.type,!1);case 11:return he(e.type.render,!1);case 1:return he(e.type,!0);case 31:return pe(`Activity`);default:return``}}function _e(e){try{var t=``,n=null;do t+=ge(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 ve=Object.prototype.hasOwnProperty,ye=t.unstable_scheduleCallback,be=t.unstable_cancelCallback,xe=t.unstable_shouldYield,Se=t.unstable_requestPaint,Ce=t.unstable_now,we=t.unstable_getCurrentPriorityLevel,Te=t.unstable_ImmediatePriority,V=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,De=t.unstable_LowPriority,Oe=t.unstable_IdlePriority,ke=t.log,Ae=t.unstable_setDisableYieldValue,H=null,je=null;function Me(e){if(typeof ke==`function`&&Ae(e),je&&typeof je.setStrictMode==`function`)try{je.setStrictMode(H,e)}catch{}}var Ne=Math.clz32?Math.clz32:Ie,Pe=Math.log,Fe=Math.LN2;function Ie(e){return e>>>=0,e===0?32:31-(Pe(e)/Fe|0)|0}var Le=256,Re=262144,ze=4194304;function Be(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 Ve(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=Be(n))):i=Be(o):i=Be(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Be(n))):i=Be(o)):i=Be(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 He(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ue(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 We(){var e=ze;return ze<<=1,!(ze&62914560)&&(ze=4194304),e}function U(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ge(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ke(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-Ne(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&&qe(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function qe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ne(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Je(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ne(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ye(e,t){var n=t&-t;return n=n&42?1:Xe(n),(n&(e.suspendedLanes|t))===0?n:0}function Xe(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 Ze(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Qe(){var e=I.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function $e(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var et=Math.random().toString(36).slice(2),tt=`__reactFiber$`+et,nt=`__reactProps$`+et,rt=`__reactContainer$`+et,it=`__reactEvents$`+et,at=`__reactListeners$`+et,ot=`__reactHandles$`+et,st=`__reactResources$`+et,ct=`__reactMarker$`+et;function lt(e){delete e[tt],delete e[nt],delete e[it],delete e[at],delete e[ot]}function ut(e){var t=e[tt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[rt]||n[tt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[tt])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function dt(e){if(e=e[tt]||e[rt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ft(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function pt(e){var t=e[st];return t||=e[st]={hoistableStyles:new Map,hoistableScripts:new Map},t}function mt(e){e[ct]=!0}var ht=new Set,gt={};function _t(e,t){vt(e,t),vt(e+`Capture`,t)}function vt(e,t){for(gt[e]=t,e=0;e<t.length;e++)ht.add(t[e])}var yt=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]*$`),bt={},xt={};function St(e){return ve.call(xt,e)?!0:ve.call(bt,e)?!1:yt.test(e)?xt[e]=!0:(bt[e]=!0,!1)}function Ct(e,t,n){if(St(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 wt(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 Tt(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 Et(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Dt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ot(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 kt(e){if(!e._valueTracker){var t=Dt(e)?`checked`:`value`;e._valueTracker=Ot(e,t,``+e[t])}}function At(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Dt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function jt(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 Mt=/[\n"\\]/g;function Nt(e){return e.replace(Mt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Pt(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=``+Et(t)):e.value!==``+Et(t)&&(e.value=``+Et(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):It(e,o,Et(n)):It(e,o,Et(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=``+Et(s):e.removeAttribute(`name`)}function Ft(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)){kt(e);return}n=n==null?``:``+Et(n),t=t==null?n:``+Et(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),kt(e)}function It(e,t,n){t===`number`&&jt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Lt(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=``+Et(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 Rt(e,t,n){if(t!=null&&(t=``+Et(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Et(n)}function zt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(P(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Et(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),kt(e)}function Bt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Vt=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 Ht(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||Vt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ut(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&&Ht(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ht(e,o,t[o])}function Wt(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 Gt=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`]]),Kt=/^[\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 qt(e){return Kt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Jt(){}var Yt=null;function Xt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zt=null,Qt=null;function $t(e){var t=dt(e);if(t&&(e=t.stateNode)){var n=e[nt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Pt(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="`+Nt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[nt]||null;if(!a)throw Error(i(90));Pt(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&&At(r)}break a;case`textarea`:Rt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Lt(e,!!n.multiple,t,!1)}}}var en=!1;function tn(e,t,n){if(en)return e(t,n);en=!0;try{return e(t)}finally{if(en=!1,(Zt!==null||Qt!==null)&&(vu(),Zt&&(t=Zt,e=Qt,Qt=Zt=null,$t(t),e)))for(t=0;t<e.length;t++)$t(e[t])}}function W(e,t){var n=e.stateNode;if(n===null)return null;var r=n[nt]||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 nn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),rn=!1;if(nn)try{var an={};Object.defineProperty(an,`passive`,{get:function(){rn=!0}}),window.addEventListener(`test`,an,an),window.removeEventListener(`test`,an,an)}catch{rn=!1}var on=null,sn=null,cn=null;function ln(){if(cn)return cn;var e,t=sn,n=t.length,r,i=`value`in on?on.value:on.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 cn=i.slice(e,1<r?1-r:void 0)}function un(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 dn(){return!0}function fn(){return!1}function pn(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)?dn:fn,this.isPropagationStopped=fn,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=dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=dn)},persist:function(){},isPersistent:dn}),t}var mn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hn=pn(mn),gn=h({},mn,{view:0,detail:0}),_n=pn(gn),vn,yn,bn,xn=h({},gn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mn,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!==bn&&(bn&&e.type===`mousemove`?(vn=e.screenX-bn.screenX,yn=e.screenY-bn.screenY):yn=vn=0,bn=e),vn)},movementY:function(e){return`movementY`in e?e.movementY:yn}}),Sn=pn(xn),Cn=pn(h({},xn,{dataTransfer:0})),wn=pn(h({},gn,{relatedTarget:0})),Tn=pn(h({},mn,{animationName:0,elapsedTime:0,pseudoElement:0})),En=pn(h({},mn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Dn=pn(h({},mn,{data:0})),On={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},kn={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`},An={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function jn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=An[e])?!!t[e]:!1}function Mn(){return jn}var Nn=pn(h({},gn,{key:function(e){if(e.key){var t=On[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=un(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?kn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mn,charCode:function(e){return e.type===`keypress`?un(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?un(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Pn=pn(h({},xn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Fn=pn(h({},gn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mn})),In=pn(h({},mn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=pn(h({},xn,{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=pn(h({},mn,{newState:0,oldState:0})),zn=[9,13,27,32],Bn=nn&&`CompositionEvent`in window,Vn=null;nn&&`documentMode`in document&&(Vn=document.documentMode);var Hn=nn&&`TextEvent`in window&&!Vn,Un=nn&&(!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=ln(),cn=sn=on=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){Zt?Qt?Qt.push(r):Qt=[r]:Zt=r,t=Td(t,`onChange`),0<t.length&&(n=new hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var er=null,tr=null;function nr(e){vd(e,0)}function rr(e){if(At(ft(e)))return e}function ir(e,t){if(e===`change`)return t}var ar=!1;if(nn){var or;if(nn){var sr=`oninput`in document;if(!sr){var cr=document.createElement(`div`);cr.setAttribute(`oninput`,`return;`),sr=typeof cr.oninput==`function`}or=sr}else or=!1;ar=or&&(!document.documentMode||9<document.documentMode)}function lr(){er&&(er.detachEvent(`onpropertychange`,ur),tr=er=null)}function ur(e){if(e.propertyName===`value`&&rr(tr)){var t=[];$n(t,tr,e,Xt(e)),tn(nr,t)}}function dr(e,t,n){e===`focusin`?(lr(),er=t,tr=n,er.attachEvent(`onpropertychange`,ur)):e===`focusout`&&lr()}function fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return rr(tr)}function pr(e,t){if(e===`click`)return rr(t)}function mr(e,t){if(e===`input`||e===`change`)return rr(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(!ve.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=jt(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=jt(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=nn&&`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!==jt(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 hn(`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={};nn&&(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 Hr(e,t){Br.set(e,t),_t(t,[e])}var Ur=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)},Wr=[],Gr=0,Kr=0;function qr(){for(var e=Gr,t=Kr=Gr=0;t<e;){var n=Wr[t];Wr[t++]=null;var r=Wr[t];Wr[t++]=null;var i=Wr[t];Wr[t++]=null;var a=Wr[t];if(Wr[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&&Zr(n,i,a)}}function Jr(e,t,n,r){Wr[Gr++]=e,Wr[Gr++]=t,Wr[Gr++]=n,Wr[Gr++]=r,Kr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Yr(e,t,n,r){return Jr(e,t,n,r),Qr(e)}function Xr(e,t){return Jr(e,null,null,t),Qr(e)}function Zr(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-Ne(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 $r={};function ei(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 ti(e,t,n,r){return new ei(e,t,n,r)}function ni(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ri(e,t){var n=e.alternate;return n===null?(n=ti(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 ii(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 ai(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ni(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,re.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=ti(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return oi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=ti(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=ti(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=ti(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=ti(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function oi(e,t,n,r){return e=ti(7,e,r,t),e.lanes=n,e}function si(e,t,n){return e=ti(6,e,null,t),e.lanes=n,e}function ci(e){var t=ti(18,null,null,0);return t.stateNode=e,t}function li(e,t,n){return t=ti(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ui=new WeakMap;function di(e,t){if(typeof e==`object`&&e){var n=ui.get(e);return n===void 0?(t={value:e,source:t,stack:_e(t)},ui.set(e,t),t):n}return{value:e,source:t,stack:_e(t)}}var fi=[],pi=0,mi=null,hi=0,K=[],gi=0,q=null,J=1,Y=``;function _i(e,t){fi[pi++]=hi,fi[pi++]=mi,mi=e,hi=t}function vi(e,t,n){K[gi++]=J,K[gi++]=Y,K[gi++]=q,q=e;var r=J;e=Y;var i=32-Ne(r)-1;r&=~(1<<i),n+=1;var a=32-Ne(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,J=1<<32-Ne(t)+i|n<<i|r,Y=a+e}else J=1<<a|n<<i|r,Y=e}function yi(e){e.return!==null&&(_i(e,1),vi(e,1,0))}function bi(e){for(;e===mi;)mi=fi[--pi],fi[pi]=null,hi=fi[--pi],fi[pi]=null;for(;e===q;)q=K[--gi],K[gi]=null,Y=K[--gi],K[gi]=null,J=K[--gi],K[gi]=null}function xi(e,t){K[gi++]=J,K[gi++]=Y,K[gi++]=q,J=t.id,Y=t.overflow,q=e}var Si=null,Ci=null,wi=!1,Ti=null,Ei=!1,Di=Error(i(519));function Oi(e){throw Pi(di(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Di}function ki(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[tt]=e,t[nt]=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),Ft(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),zt(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=Jt),t=!0):t=!1,t||Oi(e,!0)}function Ai(e){for(Si=e.return;Si;)switch(Si.tag){case 5:case 31:case 13:Ei=!1;return;case 27:case 3:Ei=!0;return;default:Si=Si.return}}function ji(e){if(e!==Si)return!1;if(!wi)return Ai(e),wi=!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&&Ci&&Oi(e),Ai(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ci=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ci=uf(e)}else t===27?(t=Ci,Zd(e.type)?(e=lf,lf=null,Ci=e):Ci=t):Ci=Si?cf(e.stateNode.nextSibling):null;return!0}function Mi(){Ci=Si=null,wi=!1}function Ni(){var e=Ti;return e!==null&&(Yl===null?Yl=e:Yl.push.apply(Yl,e),Ti=null),e}function Pi(e){Ti===null?Ti=[e]:Ti.push(e)}var Fi=R(null),Ii=null,Li=null;function Ri(e,t,n){B(Fi,t._currentValue),t._currentValue=n}function zi(e){e._currentValue=Fi.current,z(Fi)}function Bi(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 Vi(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),Bi(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),Bi(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 Hi(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===oe.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&&Vi(t,e,n,r),t.flags|=262144}function Ui(e){for(e=e.firstContext;e!==null;){if(!gr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wi(e){Ii=e,Li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gi(e){return qi(Ii,e)}function Ki(e,t){return Ii===null&&Wi(e),qi(e,t)}function qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Li===null){if(e===null)throw Error(i(308));Li=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Li=Li.next=t;return n}var Ji=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()})}},Yi=t.unstable_scheduleCallback,Xi=t.unstable_NormalPriority,Zi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qi(){return{controller:new Ji,data:new Map,refCount:0}}function $i(e){e.refCount--,e.refCount===0&&Yi(Xi,function(){e.controller.abort()})}var ea=null,ta=0,na=0,ra=null;function ia(e,t){if(ea===null){var n=ea=[];ta=0,na=ud(),ra={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ta++,t.then(aa,aa),t}function aa(){if(--ta===0&&ea!==null){ra!==null&&(ra.status=`fulfilled`);var e=ea;ea=null,na=0,ra=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function oa(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 sa=F.S;F.S=function(e,t){Ql=Ce(),typeof t==`object`&&t&&typeof t.then==`function`&&ia(e,t),sa!==null&&sa(e,t)};var ca=R(null);function la(){var e=ca.current;return e===null?Fl.pooledCache:e}function ua(e,t){t===null?B(ca,ca.current):B(ca,t.pool)}function da(){var e=la();return e===null?null:{parent:Zi._currentValue,pool:e}}var fa=Error(i(460)),pa=Error(i(474)),ma=Error(i(542)),ha={then:function(){}};function ga(e){return e=e.status,e===`fulfilled`||e===`rejected`}function _a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Jt,Jt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e;default:if(typeof t.status==`string`)t.then(Jt,Jt);else{if(e=Fl,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,xa(e),e}throw ya=t,fa}}function va(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ya=e,fa):e}}var ya=null;function ba(){if(ya===null)throw Error(i(459));var e=ya;return ya=null,e}function xa(e){if(e===fa||e===ma)throw Error(i(483))}var Sa=null,Ca=0;function wa(e){var t=Ca;return Ca+=1,Sa===null&&(Sa=[]),_a(Sa,e,t)}function Ta(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ea(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 Da(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=ri(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=si(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&&va(i)===t.type)?(t=a(t,n.props),Ta(t,n),t.return=e,t):(t=ai(n.type,n.key,n.props,null,e.mode,r),Ta(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=li(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=oi(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=si(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ai(t.type,t.key,t.props,null,e.mode,n),Ta(n,t),n.return=e,n;case v:return t=li(t,e.mode,n),t.return=e,t;case O:return t=va(t),f(e,t,n)}if(P(t)||j(t))return t=oi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,wa(t),n);if(t.$$typeof===C)return f(e,Ki(e,t),n);Ea(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=va(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,wa(n),r);if(n.$$typeof===C)return p(e,t,Ki(e,n),r);Ea(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=va(r),m(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,wa(r),i);if(r.$$typeof===C)return m(e,t,n,Ki(t,r),i);Ea(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),wi&&_i(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 wi&&_i(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)}),wi&&_i(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),wi&&_i(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 wi&&_i(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)}),wi&&_i(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&&va(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ta(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=oi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ai(o.type,o.key,o.props,null,e.mode,c),Ta(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=li(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=va(o),b(e,r,o,c)}if(P(o))return h(e,r,o,c);if(j(o)){if(l=j(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,wa(o),c);if(o.$$typeof===C)return b(e,r,Ki(e,o),c);Ea(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=si(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ca=0;var i=b(e,t,n,r);return Sa=null,i}catch(t){if(t===fa||t===ma)throw t;var a=ti(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Oa=Da(!0),ka=Da(!1),Aa=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ma(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 Na(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Pa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Pl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Qr(e),Zr(e,null,n),t}return Jr(e,r,t,n),Qr(e)}function Fa(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,Je(e,n)}}function Ia(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 La=!1;function Ra(){if(La){var e=ra;if(e!==null)throw e}}function za(e,t,n,r){La=!1;var i=e.updateQueue;Aa=!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?(Q&f)===f:(r&f)===f){f!==0&&f===na&&(La=!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:Aa=!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 Ba(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Va(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ba(n[e],t)}var Ha=R(null),Ua=R(0);function Wa(e,t){e=Vl,B(Ua,e),B(Ha,t),Vl=e|t.baseLanes}function Ga(){B(Ua,Vl),B(Ha,Ha.current)}function Ka(){Vl=Ua.current,z(Ha),z(Ua)}var qa=R(null),Ja=null;function Ya(e){var t=e.alternate;B(eo,eo.current&1),B(qa,e),Ja===null&&(t===null||Ha.current!==null||t.memoizedState!==null)&&(Ja=e)}function Xa(e){B(eo,eo.current),B(qa,e),Ja===null&&(Ja=e)}function Za(e){e.tag===22?(B(eo,eo.current),B(qa,e),Ja===null&&(Ja=e)):Qa(e)}function Qa(){B(eo,eo.current),B(qa,qa.current)}function $a(e){z(qa),Ja===e&&(Ja=null),z(eo)}var eo=R(0);function to(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 no=0,X=null,ro=null,io=null,ao=!1,oo=!1,so=!1,co=0,lo=0,uo=null,fo=0;function po(){throw Error(i(321))}function mo(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 ho(e,t,n,r,i,a){return no=a,X=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?Ms:Ns,so=!1,a=n(r,i),so=!1,oo&&(a=_o(t,n,r,i)),go(e),a}function go(e){F.H=js;var t=ro!==null&&ro.next!==null;if(no=0,io=ro=X=null,ao=!1,lo=0,uo=null,t)throw Error(i(300));e===null||Xs||(e=e.dependencies,e!==null&&Ui(e)&&(Xs=!0))}function _o(e,t,n,r){X=e;var a=0;do{if(oo&&(uo=null),lo=0,oo=!1,25<=a)throw Error(i(301));if(a+=1,io=ro=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}F.H=Ps,o=t(n,r)}while(oo);return o}function vo(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?To(t):t,e=e.useState()[0],(ro===null?null:ro.memoizedState)!==e&&(X.flags|=1024),t}function yo(){var e=co!==0;return co=0,e}function bo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function xo(e){if(ao){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ao=!1}no=0,io=ro=X=null,oo=!1,lo=co=0,uo=null}function So(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return io===null?X.memoizedState=io=e:io=io.next=e,io}function Co(){if(ro===null){var e=X.alternate;e=e===null?null:e.memoizedState}else e=ro.next;var t=io===null?X.memoizedState:io.next;if(t!==null)io=t,ro=e;else{if(e===null)throw X.alternate===null?Error(i(467)):Error(i(310));ro=e,e={memoizedState:ro.memoizedState,baseState:ro.baseState,baseQueue:ro.baseQueue,queue:ro.queue,next:null},io===null?X.memoizedState=io=e:io=io.next=e}return io}function wo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function To(e){var t=lo;return lo+=1,uo===null&&(uo=[]),e=_a(uo,e,t),t=X,(io===null?t.memoizedState:io.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?Ms:Ns),e}function Eo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return To(e);if(e.$$typeof===C)return Gi(e)}throw Error(i(438,String(e)))}function Do(e){var t=null,n=X.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=X.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=wo(),X.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]=ee;return t.index++,n}function Oo(e,t){return typeof t==`function`?t(e):t}function ko(e){return Ao(Co(),ro,e)}function Ao(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?(no&f)===f:(Q&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===na&&(d=!0);else if((no&p)===p){u=u.next,p===na&&(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,X.lanes|=p,Ul|=p;f=u.action,so&&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,X.lanes|=f,Ul|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!gr(o,e.memoizedState)&&(Xs=!0,d&&(n=ra,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 jo(e){var t=Co(),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)||(Xs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Mo(e,t,n){var r=X,a=Co(),o=wi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!gr((ro||a).memoizedState,n);if(s&&(a.memoizedState=n,Xs=!0),a=a.queue,rs(Fo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||io!==null&&io.memoizedState.tag&1){if(r.flags|=2048,Qo(9,{destroy:void 0},Po.bind(null,r,a,n,t),null),Fl===null)throw Error(i(349));o||no&127||No(r,t,n)}return n}function No(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=X.updateQueue,t===null?(t=wo(),X.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Po(e,t,n,r){t.value=n,t.getSnapshot=r,Io(t)&&Lo(e)}function Fo(e,t,n){return n(function(){Io(t)&&Lo(e)})}function Io(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!gr(e,n)}catch{return!0}}function Lo(e){var t=Xr(e,2);t!==null&&pu(t,e,2)}function Ro(e){var t=So();if(typeof e==`function`){var n=e;if(e=n(),so){Me(!0);try{n()}finally{Me(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:e},t}function zo(e,t,n,r){return e.baseState=n,Ao(e,ro,typeof r==`function`?r:Oo)}function Bo(e,t,n,r,a){if(Os(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)}};F.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Vo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Vo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),Ho(e,t,s)}catch(n){Wo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),Ho(e,t,a)}catch(n){Wo(e,t,n)}}function Ho(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Uo(e,t,n)},function(n){return Wo(e,t,n)}):Uo(e,t,n)}function Uo(e,t,n){t.status=`fulfilled`,t.value=n,Go(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Vo(e,n)))}function Wo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Go(t),t=t.next;while(t!==r)}e.action=null}function Go(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ko(e,t){return t}function qo(e,t){if(wi){var n=Fl.formState;if(n!==null){a:{var r=X;if(wi){if(Ci){b:{for(var i=Ci,a=Ei;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){Ci=cf(i.nextSibling),r=i.data===`F!`;break a}}Oi(r)}r=!1}r&&(t=n[0])}}return n=So(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ko,lastRenderedState:t},n.queue=r,n=Ts.bind(null,X,r),r.dispatch=n,r=Ro(!1),a=Ds.bind(null,X,!1,r.queue),r=So(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Bo.bind(null,X,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Jo(e){return Yo(Co(),ro,e)}function Yo(e,t,n){if(t=Ao(e,t,Ko)[0],e=ko(Oo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=To(t)}catch(e){throw e===fa?ma:e}else r=t;t=Co();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(X.flags|=2048,Qo(9,{destroy:void 0},Xo.bind(null,i,n),null)),[r,a,e]}function Xo(e,t){e.action=t}function Zo(e){var t=Co(),n=ro;if(n!==null)return Yo(t,n,e);Co(),t=t.memoizedState,n=Co();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Qo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=X.updateQueue,t===null&&(t=wo(),X.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 $o(){return Co().memoizedState}function es(e,t,n,r){var i=So();X.flags|=e,i.memoizedState=Qo(1|t,{destroy:void 0},n,r===void 0?null:r)}function ts(e,t,n,r){var i=Co();r=r===void 0?null:r;var a=i.memoizedState.inst;ro!==null&&r!==null&&mo(r,ro.memoizedState.deps)?i.memoizedState=Qo(t,a,n,r):(X.flags|=e,i.memoizedState=Qo(1|t,a,n,r))}function ns(e,t){es(8390656,8,e,t)}function rs(e,t){ts(2048,8,e,t)}function is(e){X.flags|=4;var t=X.updateQueue;if(t===null)t=wo(),X.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function as(e){var t=Co().memoizedState;return is({ref:t,nextImpl:e}),function(){if(Pl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function os(e,t){return ts(4,2,e,t)}function ss(e,t){return ts(4,4,e,t)}function cs(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 ls(e,t,n){n=n==null?null:n.concat([e]),ts(4,4,cs.bind(null,t,e),n)}function us(){}function ds(e,t){var n=Co();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&mo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function fs(e,t){var n=Co();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&mo(t,r[1]))return r[0];if(r=e(),so){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r}function ps(e,t,n){return n===void 0||no&1073741824&&!(Q&261930)?e.memoizedState=t:(e.memoizedState=n,e=fu(),X.lanes|=e,Ul|=e,n)}function ms(e,t,n,r){return gr(n,t)?n:Ha.current===null?!(no&42)||no&1073741824&&!(Q&261930)?(Xs=!0,e.memoizedState=n):(e=fu(),X.lanes|=e,Ul|=e,t):(e=ps(e,n,r),gr(e,t)||(Xs=!0),e)}function hs(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,Ds(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Es(e,t,oa(c,r),du(e)):Es(e,t,r,du(e))}catch(n){Es(e,t,{then:function(){},status:`rejected`,reason:n},du())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function gs(){}function _s(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=vs(e).queue;hs(e,a,t,L,n===null?gs:function(){return ys(e),n(r)})}function vs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ys(e){var t=vs(e);t.next===null&&(t=e.alternate.memoizedState),Es(e,t.next.queue,{},du())}function bs(){return Gi(Qf)}function xs(){return Co().memoizedState}function Ss(){return Co().memoizedState}function Cs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=du();e=Na(n);var r=Pa(t,e,n);r!==null&&(pu(r,t,n),Fa(r,t,n)),t={cache:Qi()},e.payload=t;return}t=t.return}}function ws(e,t,n){var r=du();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Os(e)?ks(t,n):(n=Yr(e,t,n,r),n!==null&&(pu(n,e,r),As(n,t,r)))}function Ts(e,t,n){Es(e,t,n,du())}function Es(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Os(e))ks(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 Jr(e,t,i,0),Fl===null&&qr(),!1}catch{}if(n=Yr(e,t,i,r),n!==null)return pu(n,e,r),As(n,t,r),!0}return!1}function Ds(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Os(e)){if(t)throw Error(i(479))}else t=Yr(e,n,r,2),t!==null&&pu(t,e,2)}function Os(e){var t=e.alternate;return e===X||t!==null&&t===X}function ks(e,t){oo=ao=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function As(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Je(e,n)}}var js={readContext:Gi,use:Eo,useCallback:po,useContext:po,useEffect:po,useImperativeHandle:po,useLayoutEffect:po,useInsertionEffect:po,useMemo:po,useReducer:po,useRef:po,useState:po,useDebugValue:po,useDeferredValue:po,useTransition:po,useSyncExternalStore:po,useId:po,useHostTransitionStatus:po,useFormState:po,useActionState:po,useOptimistic:po,useMemoCache:po,useCacheRefresh:po};js.useEffectEvent=po;var Ms={readContext:Gi,use:Eo,useCallback:function(e,t){return So().memoizedState=[e,t===void 0?null:t],e},useContext:Gi,useEffect:ns,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),es(4194308,4,cs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return es(4194308,4,e,t)},useInsertionEffect:function(e,t){es(4,2,e,t)},useMemo:function(e,t){var n=So();t=t===void 0?null:t;var r=e();if(so){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=So();if(n!==void 0){var i=n(t);if(so){Me(!0);try{n(t)}finally{Me(!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=ws.bind(null,X,e),[r.memoizedState,e]},useRef:function(e){var t=So();return e={current:e},t.memoizedState=e},useState:function(e){e=Ro(e);var t=e.queue,n=Ts.bind(null,X,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:us,useDeferredValue:function(e,t){return ps(So(),e,t)},useTransition:function(){var e=Ro(!1);return e=hs.bind(null,X,e.queue,!0,!1),So().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=X,a=So();if(wi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Fl===null)throw Error(i(349));Q&127||No(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ns(Fo.bind(null,r,o,e),[e]),r.flags|=2048,Qo(9,{destroy:void 0},Po.bind(null,r,o,n,t),null),n},useId:function(){var e=So(),t=Fl.identifierPrefix;if(wi){var n=Y,r=J;n=(r&~(1<<32-Ne(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=co++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=fo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:bs,useFormState:qo,useActionState:qo,useOptimistic:function(e){var t=So();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ds.bind(null,X,!0,n),n.dispatch=t,[e,t]},useMemoCache:Do,useCacheRefresh:function(){return So().memoizedState=Cs.bind(null,X)},useEffectEvent:function(e){var t=So(),n={impl:e};return t.memoizedState=n,function(){if(Pl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ns={readContext:Gi,use:Eo,useCallback:ds,useContext:Gi,useEffect:rs,useImperativeHandle:ls,useInsertionEffect:os,useLayoutEffect:ss,useMemo:fs,useReducer:ko,useRef:$o,useState:function(){return ko(Oo)},useDebugValue:us,useDeferredValue:function(e,t){return ms(Co(),ro.memoizedState,e,t)},useTransition:function(){var e=ko(Oo)[0],t=Co().memoizedState;return[typeof e==`boolean`?e:To(e),t]},useSyncExternalStore:Mo,useId:xs,useHostTransitionStatus:bs,useFormState:Jo,useActionState:Jo,useOptimistic:function(e,t){return zo(Co(),ro,e,t)},useMemoCache:Do,useCacheRefresh:Ss};Ns.useEffectEvent=as;var Ps={readContext:Gi,use:Eo,useCallback:ds,useContext:Gi,useEffect:rs,useImperativeHandle:ls,useInsertionEffect:os,useLayoutEffect:ss,useMemo:fs,useReducer:jo,useRef:$o,useState:function(){return jo(Oo)},useDebugValue:us,useDeferredValue:function(e,t){var n=Co();return ro===null?ps(n,e,t):ms(n,ro.memoizedState,e,t)},useTransition:function(){var e=jo(Oo)[0],t=Co().memoizedState;return[typeof e==`boolean`?e:To(e),t]},useSyncExternalStore:Mo,useId:xs,useHostTransitionStatus:bs,useFormState:Zo,useActionState:Zo,useOptimistic:function(e,t){var n=Co();return ro===null?(n.baseState=e,[e,n.queue.dispatch]):zo(n,ro,e,t)},useMemoCache:Do,useCacheRefresh:Ss};Ps.useEffectEvent=as;function Fs(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 Is={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=du(),i=Na(r);i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(pu(t,e,r),Fa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=du(),i=Na(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(pu(t,e,r),Fa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=du(),r=Na(n);r.tag=2,t!=null&&(r.callback=t),t=Pa(e,r,n),t!==null&&(pu(t,e,n),Fa(t,e,n))}};function Ls(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 Rs(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&&Is.enqueueReplaceState(t,t.state,null)}function zs(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 Bs(e){Ur(e)}function Vs(e){console.error(e)}function Hs(e){Ur(e)}function Us(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Ws(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 Gs(e,t,n){return n=Na(n),n.tag=3,n.payload={element:null},n.callback=function(){Us(e,t)},n}function Ks(e){return e=Na(e),e.tag=3,e}function qs(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(){Ws(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Ws(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 Js(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Hi(t,n,a,!0),n=qa.current,n!==null){switch(n.tag){case 31:case 13:return Ja===null?Tu():n.alternate===null&&Hl===0&&(Hl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ha?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===ha?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(wi)return t=qa.current,t===null?(r!==Di&&(t=Error(i(423),{cause:r}),Pi(di(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=di(r,n),a=Gs(e.stateNode,r,a),Ia(e,a),Hl!==4&&(Hl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Di&&(e=Error(i(422),{cause:r}),Pi(di(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=di(o,n),Jl===null?Jl=[o]:Jl.push(o),Hl!==4&&(Hl=2),t===null)return!0;r=di(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Gs(n.stateNode,r,e),Ia(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=Ks(a),qs(a,e,n,r),Ia(n,a),!1}n=n.return}while(n!==null);return!1}var Ys=Error(i(461)),Xs=!1;function Zs(e,t,n,r){t.child=e===null?ka(t,null,n,r):Oa(t,e.child,n,r)}function Qs(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 Wi(t),r=ho(e,t,n,o,a,i),s=yo(),e!==null&&!Xs?(bo(e,t,i),Sc(e,t,i)):(wi&&s&&yi(t),t.flags|=1,Zs(e,t,r,i),t.child)}function $s(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ni(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,ec(e,t,a,r,i)):(e=ai(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Cc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?_r:n,n(o,r)&&e.ref===t.ref)return Sc(e,t,i)}return t.flags|=1,e=ri(a,r),e.ref=t.ref,e.return=t,t.child=e}function ec(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(_r(a,r)&&e.ref===t.ref)if(Xs=!1,t.pendingProps=r=a,Cc(e,i))e.flags&131072&&(Xs=!0);else return t.lanes=e.lanes,Sc(e,t,i)}return cc(e,t,n,r,i)}function tc(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 rc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ua(t,a===null?null:a.cachePool),a===null?Ga():Wa(t,a),Za(t);else return r=t.lanes=536870912,rc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ua(t,null),Ga(),Qa(t)):(ua(t,a.cachePool),Wa(t,a),Qa(t),t.memoizedState=null);return Zs(e,t,i,n),t.child}function nc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function rc(e,t,n,r,i){var a=la();return a=a===null?null:{parent:Zi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ua(t,null),Ga(),Za(t),e!==null&&Hi(e,t,r,!0),t.childLanes=i,null}function ic(e,t){return t=_c({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ac(e,t,n){return Oa(t,e.child,null,n),e=ic(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function oc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(wi){if(r.mode===`hidden`)return e=ic(t,r),t.lanes=536870912,nc(null,e);if(Xa(t),(e=Ci)?(e=rf(e,Ei),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:q===null?null:{id:J,overflow:Y},retryLane:536870912,hydrationErrors:null},n=ci(e),n.return=t,t.child=n,Si=t,Ci=null)):e=null,e===null)throw Oi(t);return t.lanes=536870912,null}return ic(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Xa(t),a)if(t.flags&256)t.flags&=-257,t=ac(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Xs||Hi(e,t,n,!1),a=(n&e.childLanes)!==0,Xs||a){if(r=Fl,r!==null&&(s=Ye(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Xr(e,s),pu(r,e,s),Ys;Tu(),t=ac(e,t,n)}else e=o.treeContext,Ci=cf(s.nextSibling),Si=t,wi=!0,Ti=null,Ei=!1,e!==null&&xi(t,e),t=ic(t,r),t.flags|=4096;return t}return e=ri(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function sc(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 cc(e,t,n,r,i){return Wi(t),n=ho(e,t,n,r,void 0,i),r=yo(),e!==null&&!Xs?(bo(e,t,i),Sc(e,t,i)):(wi&&r&&yi(t),t.flags|=1,Zs(e,t,n,i),t.child)}function lc(e,t,n,r,i,a){return Wi(t),t.updateQueue=null,n=_o(t,r,n,i),go(e),r=yo(),e!==null&&!Xs?(bo(e,t,a),Sc(e,t,a)):(wi&&r&&yi(t),t.flags|=1,Zs(e,t,n,a),t.child)}function uc(e,t,n,r,i){if(Wi(t),t.stateNode===null){var a=$r,o=n.contextType;typeof o==`object`&&o&&(a=Gi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Is,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ja(t),o=n.contextType,a.context=typeof o==`object`&&o?Gi(o):$r,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Fs(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&&Is.enqueueReplaceState(a,a.state,null),za(t,r,a,i),Ra(),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=zs(n,s);a.props=c;var l=a.context,u=n.contextType;o=$r,typeof u==`object`&&u&&(o=Gi(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)&&Rs(t,a,r,o),Aa=!1;var f=t.memoizedState;a.state=f,za(t,r,a,i),Ra(),l=t.memoizedState,s||f!==l||Aa?(typeof d==`function`&&(Fs(t,n,d,r),l=t.memoizedState),(c=Aa||Ls(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,Ma(e,t),o=t.memoizedProps,u=zs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=$r,typeof l==`object`&&l&&(c=Gi(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)&&Rs(t,a,r,c),Aa=!1,f=t.memoizedState,a.state=f,za(t,r,a,i),Ra();var p=t.memoizedState;o!==d||f!==p||Aa||e!==null&&e.dependencies!==null&&Ui(e.dependencies)?(typeof s==`function`&&(Fs(t,n,s,r),p=t.memoizedState),(u=Aa||Ls(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ui(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,sc(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=Oa(t,e.child,null,i),t.child=Oa(t,null,n,i)):Zs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Sc(e,t,i),e}function dc(e,t,n,r){return Mi(),t.flags|=256,Zs(e,t,n,r),t.child}var fc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function pc(e){return{baseLanes:e,cachePool:da()}}function mc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Kl),e}function hc(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:(eo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(wi){if(a?Ya(t):Qa(t),(e=Ci)?(e=rf(e,Ei),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:q===null?null:{id:J,overflow:Y},retryLane:536870912,hydrationErrors:null},n=ci(e),n.return=t,t.child=n,Si=t,Ci=null)):e=null,e===null)throw Oi(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Qa(t),a=t.mode,c=_c({mode:`hidden`,children:c},a),r=oi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=pc(n),r.childLanes=mc(e,s,n),t.memoizedState=fc,nc(null,r)):(Ya(t),gc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ya(t),t.flags&=-257,t=vc(e,t,n)):t.memoizedState===null?(Qa(t),c=r.fallback,a=t.mode,r=_c({mode:`visible`,children:r.children},a),c=oi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Oa(t,e.child,null,n),r=t.child,r.memoizedState=pc(n),r.childLanes=mc(e,s,n),t.memoizedState=fc,t=nc(null,r)):(Qa(t),t.child=e.child,t.flags|=128,t=null);else if(Ya(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,Pi({value:r,source:null,stack:null}),t=vc(e,t,n)}else if(Xs||Hi(e,t,n,!1),s=(n&e.childLanes)!==0,Xs||s){if(s=Fl,s!==null&&(r=Ye(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Xr(e,r),pu(s,e,r),Ys;af(c)||Tu(),t=vc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ci=cf(c.nextSibling),Si=t,wi=!0,Ti=null,Ei=!1,e!==null&&xi(t,e),t=gc(t,r.children),t.flags|=4096);return t}return a?(Qa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ri(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=oi(c,a,n,null),c.flags|=2):c=ri(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,nc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=pc(n):(a=c.cachePool,a===null?a=da():(l=Zi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=mc(e,s,n),t.memoizedState=fc,nc(e.child,r)):(Ya(t),n=e.child,e=n.sibling,n=ri(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 gc(e,t){return t=_c({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function _c(e,t){return e=ti(22,e,null,t),e.lanes=0,e}function vc(e,t,n){return Oa(t,e.child,null,n),e=gc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function yc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Bi(e.return,t,n)}function bc(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 xc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=eo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,B(eo,o),Zs(e,t,r,n),r=wi?hi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&yc(e,n,t);else if(e.tag===19)yc(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&&to(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),bc(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&&to(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}bc(t,!0,n,null,a,r);break;case`together`:bc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Sc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Hi(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=ri(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ri(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Cc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Ui(e))):!0}function wc(e,t,n){switch(t.tag){case 3:se(t,t.stateNode.containerInfo),Ri(t,Zi,e.memoizedState.cache),Mi();break;case 27:case 5:le(t);break;case 4:se(t,t.stateNode.containerInfo);break;case 10:Ri(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Xa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ya(t),e=Sc(e,t,n),e===null?null:e.sibling):hc(e,t,n):(Ya(t),t.flags|=128,null);Ya(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Hi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return xc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),B(eo,eo.current),r)break;return null;case 22:return t.lanes=0,tc(e,t,n,t.pendingProps);case 24:Ri(t,Zi,e.memoizedState.cache)}return Sc(e,t,n)}function Tc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Xs=!0;else{if(!Cc(e,n)&&!(t.flags&128))return Xs=!1,wc(e,t,n);Xs=!!(e.flags&131072)}else Xs=!1,wi&&t.flags&1048576&&vi(t,hi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=va(t.elementType),t.type=e,typeof e==`function`)ni(e)?(r=zs(e,r),t.tag=1,t=uc(null,t,e,r,n)):(t.tag=0,t=cc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Qs(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=$s(null,t,e,r,n);break a}}throw t=N(e)||e,Error(i(306,t,``))}}return t;case 0:return cc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=zs(r,t.pendingProps),uc(e,t,r,a,n);case 3:a:{if(se(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ma(e,t),za(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ri(t,Zi,r),r!==o.cache&&Vi(t,[Zi],n,!0),Ra(),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=dc(e,t,r,n);break a}else if(r!==a){a=di(Error(i(424)),t),Pi(a),t=dc(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(Ci=cf(e.firstChild),Si=t,wi=!0,Ti=null,Ei=!0,n=ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Mi(),r===a){t=Sc(e,t,n);break a}Zs(e,t,r,n)}t=t.child}return t;case 26:return sc(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:wi||(n=t.type,e=t.pendingProps,r=Bd(ae.current).createElement(n),r[tt]=t,r[nt]=e,Pd(r,n,e),mt(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return le(t),e===null&&wi&&(r=t.stateNode=ff(t.type,t.pendingProps,ae.current),Si=t,Ei=!0,a=Ci,Zd(t.type)?(lf=a,Ci=cf(r.firstChild)):Ci=a),Zs(e,t,t.pendingProps.children,n),sc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&wi&&((a=r=Ci)&&(r=tf(r,t.type,t.pendingProps,Ei),r===null?a=!1:(t.stateNode=r,Si=t,Ci=cf(r.firstChild),Ei=!1,a=!0)),a||Oi(t)),le(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=ho(e,t,vo,null,null,n),Qf._currentValue=a),sc(e,t),Zs(e,t,r,n),t.child;case 6:return e===null&&wi&&((e=n=Ci)&&(n=nf(n,t.pendingProps,Ei),n===null?e=!1:(t.stateNode=n,Si=t,Ci=null,e=!0)),e||Oi(t)),null;case 13:return hc(e,t,n);case 4:return se(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Oa(t,null,r,n):Zs(e,t,r,n),t.child;case 11:return Qs(e,t,t.type,t.pendingProps,n);case 7:return Zs(e,t,t.pendingProps,n),t.child;case 8:return Zs(e,t,t.pendingProps.children,n),t.child;case 12:return Zs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ri(t,t.type,r.value),Zs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Wi(t),a=Gi(a),r=r(a),t.flags|=1,Zs(e,t,r,n),t.child;case 14:return $s(e,t,t.type,t.pendingProps,n);case 15:return ec(e,t,t.type,t.pendingProps,n);case 19:return xc(e,t,n);case 31:return oc(e,t,n);case 22:return tc(e,t,n,t.pendingProps);case 24:return Wi(t),r=Gi(Zi),e===null?(a=la(),a===null&&(a=Fl,o=Qi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ja(t),Ri(t,Zi,a)):((e.lanes&n)!==0&&(Ma(e,t),za(t,null,null,n),Ra()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ri(t,Zi,r),r!==a.cache&&Vi(t,[Zi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ri(t,Zi,r))),Zs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Ec(e){e.flags|=4}function Dc(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 ya=ha,pa}else e.flags&=-16777217}function Oc(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 ya=ha,pa}function kc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:We(),e.lanes|=t,ql|=t)}function Ac(e,t){if(!wi)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 jc(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 Mc(e,t,n){var r=t.pendingProps;switch(bi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jc(t),null;case 1:return jc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),zi(Zi),ce(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ji(t)?Ec(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ni())),jc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Ec(t),o===null?(jc(t),Dc(t,a,null,r,n)):(jc(t),Oc(t,o))):o?o===e.memoizedState?(jc(t),t.flags&=-16777217):(Ec(t),jc(t),Oc(t,o)):(e=e.memoizedProps,e!==r&&Ec(t),jc(t),Dc(t,a,e,r,n)),null;case 27:if(ue(t),n=ae.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return jc(t),null}e=re.current,ji(t)?ki(t,e):(e=ff(a,r,n),t.stateNode=e,Ec(t))}return jc(t),null;case 5:if(ue(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return jc(t),null}if(o=re.current,ji(t))ki(t,o);else{var s=Bd(ae.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[tt]=t,o[nt]=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&&Ec(t)}}return jc(t),Dc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ae.current,ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Si,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[tt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Oi(t,!0)}else e=Bd(e).createTextNode(r),e[tt]=t,t.stateNode=e}return jc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ji(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[tt]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jc(t),e=!1}else n=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if(t.flags&128)throw Error(i(558))}return jc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ji(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[tt]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jc(t),a=!1}else a=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?($a(t),t):($a(t),null)}return $a(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),kc(t,t.updateQueue),jc(t),null);case 4:return ce(),e===null&&xd(t.stateNode.containerInfo),jc(t),null;case 10:return zi(t.type),jc(t),null;case 19:if(z(eo),r=t.memoizedState,r===null)return jc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Ac(r,!1);else{if(Hl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=to(e),o!==null){for(t.flags|=128,Ac(r,!1),e=o.updateQueue,t.updateQueue=e,kc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ii(n,e),n=n.sibling;return B(eo,eo.current&1|2),wi&&_i(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ce()>$l&&(t.flags|=128,a=!0,Ac(r,!1),t.lanes=4194304)}else{if(!a)if(e=to(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,kc(t,e),Ac(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!wi)return jc(t),null}else 2*Ce()-r.renderingStartTime>$l&&n!==536870912&&(t.flags|=128,a=!0,Ac(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?(jc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ce(),e.sibling=null,n=eo.current,B(eo,a?n&1|2:n&1),wi&&_i(t,r.treeForkCount),e);case 22:case 23:return $a(t),Ka(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(jc(t),t.subtreeFlags&6&&(t.flags|=8192)):jc(t),n=t.updateQueue,n!==null&&kc(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&&z(ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zi(Zi),jc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Nc(e,t){switch(bi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zi(Zi),ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ue(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return z(eo),null;case 4:return ce(),null;case 10:return zi(t.type),null;case 22:case 23:return $a(t),Ka(),e!==null&&z(ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zi(Zi),null;case 25:return null;default:return null}}function Pc(e,t){switch(bi(t),t.tag){case 3:zi(Zi),ce();break;case 26:case 27:case 5:ue(t);break;case 4:ce();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:z(eo);break;case 10:zi(t.type);break;case 22:case 23:$a(t),Ka(),e!==null&&z(ca);break;case 24:zi(Zi)}}function Fc(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 Ic(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 Lc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Va(t,n)}catch(t){Uu(e,e.return,t)}}}function Rc(e,t,n){n.props=zs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Uu(e,t,n)}}function zc(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 Bc(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 Vc(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 Hc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[nt]=t}catch(t){Uu(e,e.return,t)}}function Uc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Wc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Uc(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 Gc(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=Jt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),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,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(Kc(e,t,n),e=e.sibling;e!==null;)Kc(e,t,n),e=e.sibling}function qc(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[tt]=e,t[nt]=n}catch(t){Uu(e,e.return,t)}}var Jc=!1,Yc=!1,Xc=!1,Zc=typeof WeakSet==`function`?WeakSet:Set,Qc=null;function $c(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,Qc=t;Qc!==null;)if(t=Qc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Qc=e;else for(;Qc!==null;){switch(t=Qc,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=zs(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,Qc=e;break}Qc=t.return}}function el(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:hl(e,n),r&4&&Fc(5,n);break;case 1:if(hl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Uu(n,n.return,e)}else{var i=zs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Uu(n,n.return,e)}}r&64&&Lc(n),r&512&&zc(n,n.return);break;case 3:if(hl(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{Va(e,t)}catch(e){Uu(n,n.return,e)}}break;case 27:t===null&&r&4&&qc(n);case 26:case 5:hl(e,n),t===null&&r&4&&Vc(n),r&512&&zc(n,n.return);break;case 12:hl(e,n);break;case 31:hl(e,n),r&4&&ol(e,n);break;case 13:hl(e,n),r&4&&sl(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||Jc,!r){t=t!==null&&t.memoizedState!==null||Yc,i=Jc;var a=Yc;Jc=r,(Yc=t)&&!a?_l(e,n,(n.subtreeFlags&8772)!=0):hl(e,n),Jc=i,Yc=a}break;case 30:break;default:hl(e,n)}}function tl(e){var t=e.alternate;t!==null&&(e.alternate=null,tl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&lt(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 nl=null,rl=!1;function il(e,t,n){for(n=n.child;n!==null;)al(e,t,n),n=n.sibling}function al(e,t,n){if(je&&typeof je.onCommitFiberUnmount==`function`)try{je.onCommitFiberUnmount(H,n)}catch{}switch(n.tag){case 26:Yc||Bc(n,t),il(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Yc||Bc(n,t);var r=nl,i=rl;Zd(n.type)&&(nl=n.stateNode,rl=!1),il(e,t,n),pf(n.stateNode),nl=r,rl=i;break;case 5:Yc||Bc(n,t);case 6:if(r=nl,i=rl,nl=null,il(e,t,n),nl=r,rl=i,nl!==null)if(rl)try{(nl.nodeType===9?nl.body:nl.nodeName===`HTML`?nl.ownerDocument.body:nl).removeChild(n.stateNode)}catch(e){Uu(n,t,e)}else try{nl.removeChild(n.stateNode)}catch(e){Uu(n,t,e)}break;case 18:nl!==null&&(rl?(e=nl,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(nl,n.stateNode));break;case 4:r=nl,i=rl,nl=n.stateNode.containerInfo,rl=!0,il(e,t,n),nl=r,rl=i;break;case 0:case 11:case 14:case 15:Ic(2,n,t),Yc||Ic(4,n,t),il(e,t,n);break;case 1:Yc||(Bc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Rc(n,t,r)),il(e,t,n);break;case 21:il(e,t,n);break;case 22:Yc=(r=Yc)||n.memoizedState!==null,il(e,t,n),Yc=r;break;default:il(e,t,n)}}function ol(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 sl(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 cl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Zc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Zc),t;default:throw Error(i(435,e.tag))}}function ll(e,t){var n=cl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ju.bind(null,e,t);t.then(r,r)}})}function ul(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)){nl=c.stateNode,rl=!1;break a}break;case 5:nl=c.stateNode,rl=!1;break a;case 3:case 4:nl=c.stateNode.containerInfo,rl=!0;break a}c=c.return}if(nl===null)throw Error(i(160));al(o,s,a),nl=null,rl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)fl(t,e),t=t.sibling}var dl=null;function fl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ul(t,e),pl(e),r&4&&(Ic(3,e,e.return),Fc(3,e),Ic(5,e,e.return));break;case 1:ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),r&64&&Jc&&(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=dl;if(ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(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[ct]||o[tt]||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[tt]=e,mt(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[tt]=e,mt(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&&Hc(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:ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),n!==null&&r&4&&Hc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),e.flags&32){a=e.stateNode;try{Bt(a,``)}catch(t){Uu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Hc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Xc=!0);break;case 6:if(ul(t,e),pl(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=dl,dl=gf(t.containerInfo),ul(t,e),dl=a,pl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Uu(e,e.return,t)}Xc&&(Xc=!1,ml(e));break;case 4:r=dl,dl=gf(e.stateNode.containerInfo),ul(t,e),pl(e),dl=r;break;case 12:ul(t,e),pl(e);break;case 31:ul(t,e),pl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 13:ul(t,e),pl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Zl=Ce()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Jc,d=Yc;if(Jc=u||a,Yc=d||l,ul(t,e),Yc=d,Jc=u,pl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Jc||Yc||gl(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,ll(e,n))));break;case 19:ul(t,e),pl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 30:break;case 21:break;default:ul(t,e),pl(e)}}function pl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Uc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Kc(e,Wc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Bt(o,``),n.flags&=-33),Kc(e,Wc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Gc(e,Wc(e),s);break;default:throw Error(i(161))}}catch(t){Uu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ml(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;ml(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function hl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)el(e,t.alternate,t),t=t.sibling}function gl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Ic(4,t,t.return),gl(t);break;case 1:Bc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Rc(t,t.return,n),gl(t);break;case 27:pf(t.stateNode);case 26:case 5:Bc(t,t.return),gl(t);break;case 22:t.memoizedState===null&&gl(t);break;case 30:gl(t);break;default:gl(t)}e=e.sibling}}function _l(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:_l(i,a,n),Fc(4,a);break;case 1:if(_l(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++)Ba(c[i],s)}catch(e){Uu(r,r.return,e)}}n&&o&64&&Lc(a),zc(a,a.return);break;case 27:qc(a);case 26:case 5:_l(i,a,n),n&&r===null&&o&4&&Vc(a),zc(a,a.return);break;case 12:_l(i,a,n);break;case 31:_l(i,a,n),n&&o&4&&ol(i,a);break;case 13:_l(i,a,n),n&&o&4&&sl(i,a);break;case 22:a.memoizedState===null&&_l(i,a,n),zc(a,a.return);break;case 30:break;default:_l(i,a,n)}t=t.sibling}}function vl(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&&$i(n))}function yl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e))}function bl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)xl(e,t,n,r),t=t.sibling}function xl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:bl(e,t,n,r),i&2048&&Fc(9,t);break;case 1:bl(e,t,n,r);break;case 3:bl(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&&$i(e)));break;case 12:if(i&2048){bl(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 bl(e,t,n,r);break;case 31:bl(e,t,n,r);break;case 13:bl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?bl(e,t,n,r):(a._visibility|=2,Sl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?bl(e,t,n,r):Cl(e,t),i&2048&&vl(o,t);break;case 24:bl(e,t,n,r),i&2048&&yl(t.alternate,t);break;default:bl(e,t,n,r)}}function Sl(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:Sl(a,o,s,c,i),Fc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Sl(a,o,s,c,i)):u._visibility&2?Sl(a,o,s,c,i):Cl(a,o),i&&l&2048&&vl(o.alternate,o);break;case 24:Sl(a,o,s,c,i),i&&l&2048&&yl(o.alternate,o);break;default:Sl(a,o,s,c,i)}t=t.sibling}}function Cl(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:Cl(n,r),i&2048&&vl(r.alternate,r);break;case 24:Cl(n,r),i&2048&&yl(r.alternate,r);break;default:Cl(n,r)}t=t.sibling}}var wl=8192;function Tl(e,t,n){if(e.subtreeFlags&wl)for(e=e.child;e!==null;)El(e,t,n),e=e.sibling}function El(e,t,n){switch(e.tag){case 26:Tl(e,t,n),e.flags&wl&&e.memoizedState!==null&&Gf(n,dl,e.memoizedState,e.memoizedProps);break;case 5:Tl(e,t,n);break;case 3:case 4:var r=dl;dl=gf(e.stateNode.containerInfo),Tl(e,t,n),dl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=wl,wl=16777216,Tl(e,t,n),wl=r):Tl(e,t,n));break;default:Tl(e,t,n)}}function Dl(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 Ol(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Qc=r,jl(r,e)}Dl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)kl(e),e=e.sibling}function kl(e){switch(e.tag){case 0:case 11:case 15:Ol(e),e.flags&2048&&Ic(9,e,e.return);break;case 3:Ol(e);break;case 12:Ol(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Al(e)):Ol(e);break;default:Ol(e)}}function Al(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Qc=r,jl(r,e)}Dl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Ic(8,t,t.return),Al(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Al(t));break;default:Al(t)}e=e.sibling}}function jl(e,t){for(;Qc!==null;){var n=Qc;switch(n.tag){case 0:case 11:case 15:Ic(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:$i(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Qc=r;else a:for(n=e;Qc!==null;){r=Qc;var i=r.sibling,a=r.return;if(tl(r),r===n){Qc=null;break a}if(i!==null){i.return=a,Qc=i;break a}Qc=a}}}var Ml={getCacheForType:function(e){var t=Gi(Zi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Gi(Zi).controller.signal}},Nl=typeof WeakMap==`function`?WeakMap:Map,Pl=0,Fl=null,Z=null,Q=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 Pl&2&&Q!==0?Q&-Q:F.T===null?Qe():ud()}function fu(){if(Kl===0)if(!(Q&536870912)||wi){var e=Re;Re<<=1,!(Re&3932160)&&(Re=262144),Kl=e}else Kl=536870912;return e=qa.current,e!==null&&(e.flags|=32),Kl}function pu(e,t,n){(e===Fl&&(Il===2||Il===9)||e.cancelPendingCommit!==null)&&(bu(e,0),_u(e,Q,Kl,!1)),Ge(e,n),(!(Pl&2)||e!==Fl)&&(e===Fl&&(!(Pl&2)&&(Wl|=n),Hl===4&&_u(e,Q,Kl,!1)),nd(e))}function mu(e,t,n){if(Pl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||He(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-Ce(),10<a)){if(_u(r,t,Kl,!Rl),Ve(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:Jt},El(t,a,d);var m=(a&62914560)===a?Zl-Ce():(a&4194048)===a?Ql-Ce():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-Ne(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&qe(e,n,t)}function vu(){return Pl&6?!0:(rd(0,!1),!1)}function yu(){if(Z!==null){if(Il===0)var e=Z.return;else e=Z,Li=Ii=null,xo(e),Sa=null,Ca=0,e=Z;for(;e!==null;)Pc(e.alternate,e),e=e.return;Z=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(),Fl=e,Z=n=ri(e.current,null),Q=t,Il=0,Ll=null,Rl=!1,zl=He(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-Ne(r),a=1<<i;t|=e[i],r&=~a}return Vl=t,qr(),n}function xu(e,t){X=null,F.H=js,t===fa||t===ma?(t=ba(),Il=3):t===pa?(t=ba(),Il=4):Il=t===Ys?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ll=t,Z===null&&(Hl=1,Us(e,di(t,e.current)))}function Su(){var e=qa.current;return e===null?!0:(Q&4194048)===Q?Ja===null:(Q&62914560)===Q||Q&536870912?e===Ja:!1}function Cu(){var e=F.H;return F.H=js,e===null?js:e}function wu(){var e=F.A;return F.A=Ml,e}function Tu(){Hl=4,Rl||(Q&4194048)!==Q&&qa.current!==null||(zl=!0),!(Ul&134217727)&&!(Wl&134217727)||Fl===null||_u(Fl,Q,Kl,!1)}function Eu(e,t,n){var r=Pl;Pl|=2;var i=Cu(),a=wu();(Fl!==e||Q!==t)&&(eu=null,bu(e,t)),t=!1;var o=Hl;a:do try{if(Il!==0&&Z!==null){var s=Z,c=Ll;switch(Il){case 8:yu(),o=6;break a;case 3:case 2:case 9:case 6:qa.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++,Li=Ii=null,Pl=r,F.H=i,F.A=a,Z===null&&(Fl=null,Q=0,qr()),o}function Du(){for(;Z!==null;)Au(Z)}function Ou(e,t){var n=Pl;Pl|=2;var r=Cu(),a=wu();Fl!==e||Q!==t?(eu=null,$l=Ce()+500,bu(e,t)):zl=He(e,t);a:do try{if(Il!==0&&Z!==null){t=Z;var o=Ll;b:switch(Il){case 1:Il=0,Ll=null,Mu(e,t,o,1);break;case 2:case 9:if(ga(o)){Il=0,Ll=null,ju(t);break}t=function(){Il!==2&&Il!==9||Fl!==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:ga(o)?(Il=0,Ll=null,ju(t)):(Il=0,Ll=null,Mu(e,t,o,7));break;case 5:var s=null;switch(Z.tag){case 26:s=Z.memoizedState;case 5:case 27:var c=Z;if(s?Wf(s):c.stateNode.complete){Il=0,Ll=null;var l=c.sibling;if(l!==null)Z=l;else{var u=c.return;u===null?Z=null:(Z=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 Li=Ii=null,F.H=r,F.A=a,Pl=n,Z===null?(Fl=null,Q=0,qr(),Hl):0}function ku(){for(;Z!==null&&!xe();)Au(Z)}function Au(e){var t=Tc(e.alternate,e,Vl);e.memoizedProps=e.pendingProps,t===null?Nu(e):Z=t}function ju(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=lc(n,t,t.pendingProps,t.type,void 0,Q);break;case 11:t=lc(n,t,t.pendingProps,t.type.render,t.ref,Q);break;case 5:xo(t);default:Pc(n,t),t=Z=ii(t,Vl),t=Tc(n,t,Vl)}e.memoizedProps=e.pendingProps,t===null?Nu(e):Z=t}function Mu(e,t,n,r){Li=Ii=null,xo(t),Sa=null,Ca=0;var i=t.return;try{if(Js(e,i,t,n,Q)){Hl=1,Us(e,di(n,e.current)),Z=null;return}}catch(t){if(i!==null)throw Z=i,t;Hl=1,Us(e,di(n,e.current)),Z=null;return}t.flags&32768?(wi||r===1?e=!0:zl||Q&536870912?e=!1:(Rl=e=!0,(r===2||r===9||r===3||r===6)&&(r=qa.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=Mc(t.alternate,t,Vl);if(n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);Hl===0&&(Hl=5)}function Pu(e,t){do{var n=Nc(e.alternate,e);if(n!==null){n.flags&=32767,Z=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Z=e;return}Z=e=n}while(e!==null);Hl=6,Z=null}function Fu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Bu();while(nu!==0);if(Pl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Kr,Ke(e,n,o,s,c,l),e===Fl&&(Z=Fl=null,Q=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(Ee,function(){return Vu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,a=I.p,I.p=2,s=Pl,Pl|=4;try{$c(e,t,n)}finally{Pl=s,I.p=a,F.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=F.T,F.T=null;var r=I.p;I.p=2;var i=Pl;Pl|=4;try{fl(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{Pl=i,I.p=r,F.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=F.T,F.T=null;var r=I.p;I.p=2;var i=Pl;Pl|=4;try{el(e,t.alternate,t)}finally{Pl=i,I.p=r,F.T=n}}nu=3}}function Ru(){if(nu===4||nu===3){nu=0,Se();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),Ze(n),t=t.stateNode,je&&typeof je.onCommitFiberRoot==`function`)try{je.onCommitFiberRoot(H,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.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{F.T=t,I.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,$i(t)))}function Bu(){return Iu(),Lu(),Ru(),Vu()}function Vu(){if(nu!==5)return!1;var e=ru,t=ou;ou=0;var n=Ze(au),r=F.T,a=I.p;try{I.p=32>n?32:n,F.T=null,n=su,su=null;var o=ru,s=au;if(nu=0,iu=ru=null,au=0,Pl&6)throw Error(i(331));var c=Pl;if(Pl|=4,kl(o.current),xl(o,o.current,s,n),Pl=c,rd(0,!1),je&&typeof je.onPostCommitFiberRoot==`function`)try{je.onPostCommitFiberRoot(H,o)}catch{}return!0}finally{I.p=a,F.T=r,zu(e,t)}}function Hu(e,t,n){t=di(n,t),t=Gs(e.stateNode,t,2),e=Pa(e,t,2),e!==null&&(Ge(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=di(n,e),n=Ks(2),r=Pa(t,n,2),r!==null&&(qs(n,r,t,e),Ge(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Nl;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,Fl===e&&(Q&n)===n&&(Hl===4||Hl===3&&(Q&62914560)===Q&&300>Ce()-Zl?!(Pl&2)&&bu(e,0):Gl|=n,ql===Q&&(ql=0)),nd(e)}function Ku(e,t){t===0&&(t=We()),e=Xr(e,t),e!==null&&(Ge(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 ye(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-Ne(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=Q,a=Ve(r,r===Fl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||He(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=Ce(),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-Ne(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ue(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Fl,n=Q,n=Ve(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&&be(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||He(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&be(r),Ze(n)){case 2:case 8:n=V;break;case 32:n=Ee;break;case 268435456:n=Oe;break;default:n=Ee}return r=sd.bind(null,e),n=ye(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&be(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=Q;return r=Ve(e,e===Fl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(mu(e,r,t),od(e,Ce()),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(){Pl&6?ye(Te,id):ad()})}function ud(){if(td===0){var e=na;e===0&&(e=Le,Le<<=1,!(Le&261888)&&(Le=256)),td=e}return td}function dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:qt(``+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[nt]||null).action),o=r.submitter;o&&(t=(t=o[nt]||null)?dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new hn(`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);_s(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),_s(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];Hr(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}Hr(Nr,`onAnimationEnd`),Hr(Pr,`onAnimationIteration`),Hr(Fr,`onAnimationStart`),Hr(`dblclick`,`onDoubleClick`),Hr(`focusin`,`onFocus`),Hr(`focusout`,`onBlur`),Hr(Ir,`onTransitionRun`),Hr(Lr,`onTransitionStart`),Hr(Rr,`onTransitionCancel`),Hr(zr,`onTransitionEnd`),vt(`onMouseEnter`,[`mouseout`,`mouseover`]),vt(`onMouseLeave`,[`mouseout`,`mouseover`]),vt(`onPointerEnter`,[`pointerout`,`pointerover`]),vt(`onPointerLeave`,[`pointerout`,`pointerover`]),_t(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),_t(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),_t(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),_t(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),_t(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),_t(`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){Ur(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){Ur(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[it];n===void 0&&(n=t[it]=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,ht.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,!rn||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=ut(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}tn(function(){var r=a,i=Xt(n),s=[];a:{var c=Br.get(e);if(c!==void 0){var l=hn,u=e;switch(e){case`keypress`:if(un(n)===0)break a;case`keydown`:case`keyup`:l=Nn;break;case`focusin`:u=`focus`,l=wn;break;case`focusout`:u=`blur`,l=wn;break;case`beforeblur`:case`afterblur`:l=wn;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=Sn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Cn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Fn;break;case Nr:case Pr:case Fr:l=Tn;break;case zr:l=In;break;case`scroll`:case`scrollend`:l=_n;break;case`wheel`:l=Ln;break;case`copy`:case`cut`:case`paste`:l=En;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Pn;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=W(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!==Yt&&(u=n.relatedTarget||n.fromElement)&&(ut(u)||u[rt]))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?ut(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=Sn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Pn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ft(l),h=u==null?c:ft(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ut(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?ft(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=ir;else if(Qn(c))if(ar)v=mr;else{v=fr;var y=dr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Wt(r.elementType)&&(v=ir):v=pr;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&&It(c,`number`,c.value)}switch(y=r?ft(r):window,e){case`focusin`:(Qn(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(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=ln()):(on=i,sn=`value`in on?on.value:on.textContent,Jn=!0)),y=Td(r,x),0<y.length&&(x=new Dn(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=Td(r,`onBeforeInput`),0<x.length&&(y=new Dn(`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=W(e,n),i!=null&&r.unshift(wd(e,i,a)),i=W(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=W(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=W(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===``||Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Bt(e,``+r);break;case`className`:wt(e,`class`,r);break;case`tabIndex`:wt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:wt(e,n,r);break;case`style`:Ut(e,r,o);break;case`data`:if(t!==`object`){wt(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=qt(``+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=qt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Jt);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=qt(``+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),Ct(e,`popover`,r);break;case`xlinkActuate`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ct(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=Gt.get(n)||n,Ct(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Ut(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`?Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Bt(e,``+r);break;case`onScroll`:r!=null&&$(`scroll`,e);break;case`onScrollEnd`:r!=null&&$(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Jt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!gt.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[nt]||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,``):Ct(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)}}Ft(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&&Lt(e,!!r,n,!0):Lt(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)}zt(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(Wt(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)}}Pt(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?Lt(e,!!n,n?[]:``,!1):Lt(e,!!n,t,!0)):Lt(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)}Rt(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(Wt(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[ct]||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),lt(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[ct])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]);lt(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=I.d;I.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=dt(e);t!==null&&t.tag===5&&t.type===`form`?ys(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=Nt(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),mt(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="`+Nt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Nt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Nt(n.imageSizes)+`"]`)):i+=`[href="`+Nt(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),mt(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="`+Nt(r)+`"][href="`+Nt(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),mt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=pt(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`);mt(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=pt(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`),mt(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=pt(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`),mt(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=ae.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=pt(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=pt(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=pt(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="`+Nt(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),mt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Nt(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~="`+Nt(n.href)+`"]`);if(r)return t.instance=r,mt(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`),mt(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,mt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),mt(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,mt(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),mt(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[ct]||a[tt]||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,mt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),mt(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:L,_currentValue2:L,_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=U(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=U(0),this.hiddenUpdates=U(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=ti(3,null,null,t),e.current=a,a.stateNode=e,t=Qi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ja(a),e}function tp(e){return e?(e=$r,e):$r}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Na(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Pa(e,r,t),n!==null&&(pu(n,e,t),Fa(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=Xr(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=Xe(t);var n=Xr(e,t);n!==null&&pu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,up(e,t,n,r)}finally{I.p=a,F.T=i}}function lp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,up(e,t,n,r)}finally{I.p=a,F.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=dt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Be(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ne(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Pl&6)&&($l=Ce()+500,rd(0,!1))}}break;case 31:case 13:s=Xr(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=Xt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ut(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(we()){case Te:return 2;case V:return 8;case Ee:case De:return 32;case Oe: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=dt(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=ut(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,$e(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,$e(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);Yt=r,n.target.dispatchEvent(r),Yt=null}else return t=dt(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=dt(n);a!==null&&(e.splice(t,3),t-=3,_s(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[nt]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[nt]||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[rt]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Qe();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`));I.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:F,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{H=zp.inject(Rp),je=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Bs,s=Vs,c=Hs;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[rt]=t.current,xd(e),new Fp(t)}})),g=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()})),_=c(u(),1),v=c(g(),1);function y(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}var b=[{id:`nav:/`,label:`Home`,hint:`/`,group:`Pages`,keywords:`dashboard overview start`,run:()=>y(`/`)},{id:`nav:/approvals`,label:`Approvals`,hint:`/approvals`,group:`Pages`,keywords:`pending approve deny gate`,run:()=>y(`/approvals`)},{id:`nav:/rules`,label:`Rules`,hint:`/rules`,group:`Pages`,keywords:`guardrails policy dsl`,run:()=>y(`/rules`)},{id:`nav:/hub`,label:`Hub`,hint:`/hub`,group:`Pages`,keywords:`rulesets marketplace community`,run:()=>y(`/hub`)},{id:`nav:/audit`,label:`Audit log`,hint:`/audit`,group:`Pages`,keywords:`history activity log evals`,run:()=>y(`/audit`)},{id:`nav:/agents`,label:`Agents`,hint:`/agents`,group:`Pages`,keywords:`adapters clients claude cursor`,run:()=>y(`/agents`)},{id:`nav:/graph`,label:`Graph`,hint:`/graph`,group:`Pages`,keywords:`sessions timeline chart`,run:()=>y(`/graph`)},{id:`nav:/sessions`,label:`Sessions`,hint:`/sessions`,group:`Pages`,keywords:`history transcripts`,run:()=>y(`/sessions`)},{id:`nav:/observability`,label:`Observability`,hint:`/observability`,group:`Pages`,keywords:`metrics latency telemetry`,run:()=>y(`/observability`)},{id:`nav:/monitor`,label:`Monitor`,hint:`/monitor`,group:`Pages`,keywords:`live tail watch`,run:()=>y(`/monitor`)},{id:`nav:/notifications`,label:`Notifications`,hint:`/notifications`,group:`Pages`,keywords:`alerts inbox`,run:()=>y(`/notifications`)},{id:`nav:/plugins`,label:`Plugins`,hint:`/plugins`,group:`Pages`,keywords:`extensions marketplace`,run:()=>y(`/plugins`)},{id:`nav:/setup`,label:`Setup`,hint:`/setup`,group:`Pages`,keywords:`wizard onboarding install`,run:()=>y(`/setup`)},{id:`nav:/profile`,label:`Profile`,hint:`/profile`,group:`Pages`,keywords:`settings account license`,run:()=>y(`/profile`)},{id:`nav:/debug`,label:`Debug`,hint:`/debug`,group:`Pages`,keywords:`inspector internals`,run:()=>y(`/debug`)},{id:`nav:/support`,label:`Support`,hint:`/support`,group:`Pages`,keywords:`help ticket feedback`,run:()=>y(`/support`)}];function x(){let e=document.cookie.match(/ssg_token=([^;]+)/)?.[1];return e?decodeURIComponent(e):null}async function S(e,t){let n=x(),r={"Content-Type":`application/json`};n&&(r[`X-SigmaShake-Token`]=n),await fetch(e,{method:`POST`,headers:r,body:t?JSON.stringify(t):void 0,credentials:`same-origin`}).catch(()=>{})}var C=[{id:`act:mode:ask`,label:`Set mode → Ask`,hint:`every tool call prompts`,group:`Actions`,keywords:`mode ask gate prompt`,run:()=>S(`/api/json/mode`,{mode:`ask`})},{id:`act:mode:allow`,label:`Set mode → Allow`,hint:`auto-allow everything`,group:`Actions`,keywords:`mode allow auto bypass`,run:()=>S(`/api/json/mode`,{mode:`allow`})},{id:`act:mode:deny`,label:`Set mode → Deny`,hint:`block everything (panic)`,group:`Actions`,keywords:`mode deny panic block`,run:()=>S(`/api/json/mode`,{mode:`deny`})},{id:`act:rules:sync`,label:`Sync rule files → DB`,hint:`POST /api/rules/sync-to-db`,group:`Actions`,keywords:`rules sync drift`,run:()=>S(`/api/rules/sync-to-db`)},{id:`act:rules:reload`,label:`Force-reload rules from disk`,hint:`POST /api/rules/force-reload`,group:`Actions`,keywords:`reload refresh rules`,run:()=>S(`/api/rules/force-reload`)},{id:`act:plugins:reload`,label:`Reload plugin registry`,hint:`POST /api/json/plugins/reload`,group:`Actions`,keywords:`plugins reload`,run:()=>S(`/api/json/plugins/reload`)},{id:`act:hard-reload`,label:`Hard reload dashboard`,hint:`window.location.reload()`,group:`Actions`,keywords:`refresh reload cache bust`,run:()=>window.location.reload()},{id:`act:theme:toggle`,label:`Toggle light / dark theme`,hint:`html[data-theme]`,group:`Actions`,keywords:`theme dark light mode`,run:()=>{let e=document.documentElement,t=(e.getAttribute(`data-theme`)||`light`)===`dark`?`light`:`dark`;e.setAttribute(`data-theme`,t);try{localStorage.setItem(`ssg.theme`,t)}catch{}}},{id:`act:copy-url`,label:`Copy current page URL`,hint:`clipboard`,group:`Actions`,keywords:`copy url link share`,run:()=>{navigator.clipboard?.writeText(location.href).catch(()=>{})}},{id:`act:docs:open`,label:`Open SigmaShake docs`,hint:`docs.sigmashake.com`,group:`External`,keywords:`docs help reference`,run:()=>window.open(`https://docs.sigmashake.com`,`_blank`)},{id:`act:hub:open`,label:`Open SigmaShake Hub`,hint:`hub.sigmashake.com`,group:`External`,keywords:`hub rulesets browse`,run:()=>window.open(`https://hub.sigmashake.com`,`_blank`)}];function w(e,t){if(!e)return 0;let n=e.toLowerCase(),r=t.toLowerCase(),i=r.indexOf(n);if(i===0)return 1e3;if(i>0)return 600-i;let a=0,o=-1,s=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(o>=0&&(s+=e-o-1),o=e,a++);return a<n.length?-1:200-s}function T(e,t){if(!e)return 1;let n=w(e,t.label),r=w(e,t.hint),i=t.keywords?w(e,t.keywords):-1;return Math.max(n,r,i)}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[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(0),[o,s]=(0,_.useState)([]),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null);(0,_.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))}function n(e){r(e.detail?.query??``),t(!0)}function i(e){let t=e.detail?.id;t&&[...b,...C].find(e=>e.id===t)?.run()}return window.addEventListener(`keydown`,e),window.addEventListener(`sigmashake:open-palette`,n),window.addEventListener(`sigmashake:run-command`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`sigmashake:open-palette`,n),window.removeEventListener(`sigmashake:run-command`,i)}},[]),(0,_.useEffect)(()=>{if(!e||o.length>0)return;let t=x();fetch(`/api/json/rules`,{headers:t?{"X-SigmaShake-Token":t}:{},credentials:`same-origin`}).then(e=>e.ok?e.json():[]).then(e=>{Array.isArray(e)&&s(e)}).catch(()=>{})},[e,o.length]);let d=(0,_.useMemo)(()=>o.slice(0,200).map(e=>({id:`rule:${e.id}`,label:e.id,hint:e.message?e.message.slice(0,72):e.decision??`rule`,group:`Rules`,keywords:`${e.decision??``} ${e.enabled?`enabled`:`disabled`}`,run:()=>y(`/rules?focus=${encodeURIComponent(e.id)}`)})),[o]),f=(0,_.useMemo)(()=>[...b,...C,...d],[d]),p=(0,_.useMemo)(()=>{let e=n.trim();return f.map(t=>({it:t,s:T(e,t)})).filter(e=>e.s>=0).sort((e,t)=>t.s-e.s).slice(0,80).map(e=>e.it)},[f,n]),m=(0,_.useMemo)(()=>{if(n.trim())return[{group:`Matches`,items:p}];let e=[`Pages`,`Actions`,`External`,`Rules`],t=new Map;for(let e of p){let n=t.get(e.group)??[];n.push(e),t.set(e.group,n)}return e.filter(e=>t.has(e)).map(e=>({group:e,items:t.get(e)??[]}))},[p,n]),h=(0,_.useMemo)(()=>m.flatMap(e=>e.items),[m]);if((0,_.useEffect)(()=>{if(!e)return;a(0);let t=requestAnimationFrame(()=>c.current?.focus());return()=>cancelAnimationFrame(t)},[e]),(0,_.useEffect)(()=>a(0),[n]),(0,_.useEffect)(()=>{if(!e)return;let t=u.current;t&&t.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,e]),!e)return null;let g=e=>{e&&(t(!1),e.run())},v=-1;return(0,D.jsx)(`div`,{className:`cmdk-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,D.jsxs)(`div`,{className:`cmdk-panel`,children:[(0,D.jsx)(`input`,{ref:c,className:`cmdk-input`,placeholder:`Search pages, actions, rules…`,value:n,"aria-label":`Search`,"aria-controls":`cmdk-listbox`,"aria-activedescendant":h[i]?`cmdk-opt-${h[i].id}`:void 0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Escape`?t(!1):e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,h.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Home`?(e.preventDefault(),a(0)):e.key===`End`?(e.preventDefault(),a(Math.max(h.length-1,0))):e.key===`PageDown`?(e.preventDefault(),a(e=>Math.min(e+8,h.length-1))):e.key===`PageUp`?(e.preventDefault(),a(e=>Math.max(e-8,0))):e.key===`Enter`&&(e.preventDefault(),g(h[i]))}}),(0,D.jsx)(`div`,{ref:l,id:`cmdk-listbox`,className:`cmdk-list`,role:`listbox`,"aria-label":`Results`,children:h.length===0?(0,D.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`}):m.map(e=>(0,D.jsxs)(`div`,{className:`cmdk-group`,children:[(0,D.jsx)(`div`,{className:`cmdk-group-label`,children:e.group}),(0,D.jsx)(`div`,{className:`cmdk-group-list`,children:e.items.map(e=>{v+=1;let t=v===i,n=v;return(0,D.jsxs)(`div`,{id:`cmdk-opt-${e.id}`,ref:t?u:null,role:`option`,"aria-selected":t,tabIndex:-1,className:`cmdk-item${t?` cmdk-item--active`:``}`,onMouseEnter:()=>a(n),onMouseDown:t=>{t.preventDefault(),g(e)},children:[(0,D.jsx)(`span`,{className:`cmdk-item-label`,children:e.label}),(0,D.jsx)(`span`,{className:`cmdk-hint`,children:e.hint})]},e.id)})})]},e.group))}),(0,D.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,D.jsx)(`span`,{children:`↑↓ navigate`}),(0,D.jsx)(`span`,{children:`↵ open`}),(0,D.jsx)(`span`,{children:`PgUp/PgDn jump`}),(0,D.jsx)(`span`,{children:`esc close`})]})]})})}var k=2e3,ee=200,A=3e3,j=1e3,M=3e4,N=Object.freeze({counters:Object.freeze({}),latestBurst:null,burstRing:Object.freeze([]),burstSeq:0,lifecycleRing:Object.freeze([]),connectionSeq:0,connected:!1,reconnectAttempts:0,lastErrorAt:null,reconnectDelayMs:j,desktopUpdate:null}),P=new Set,F={},I=[],L=[],te=[],ne=!1,R=!1,z=null,B=null,re=null,ie=null,ae=!1,oe=typeof localStorage<`u`&&localStorage.getItem(`DEBUG_SSE`)===`1`;function se(e,t){oe&&(t?console.debug(`[ssg-sse] ${e}`,t):console.debug(`[ssg-sse] ${e}`))}function ce(){ae||(ae=!0,queueMicrotask(le))}function le(){ae=!1;let e=Object.keys(F),t=I,n=L,r=te,i=ne,a=z!==null||B!==null||re!==null,o=ie!==null;if(e.length===0&&t.length===0&&n.length===0&&r.length===0&&!i&&!a&&!o)return;let s=N.counters;if(e.length>0){let t={...N.counters};for(let n of e)t[n]=(t[n]??0)+(F[n]??0);s=Object.freeze(t),F={}}let c=N.burstRing,l=N.latestBurst,u=N.burstSeq;if(t.length>0){let e=N.burstRing.length+t.length>k?[...N.burstRing,...t].slice(-k):[...N.burstRing,...t];c=Object.freeze(e),l=t[t.length-1]??l,u=N.burstSeq+t.length,I=[]}if(n.length>0){let e=new Map;for(let t of n)e.set(t.tool_use_id,t);let t=!1,r=c.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&&(c=Object.freeze(r),u=N.burstSeq+1),L=[]}let d=N.lifecycleRing;if(r.length>0){let e=N.lifecycleRing.length+r.length>ee?[...N.lifecycleRing,...r].slice(-ee):[...N.lifecycleRing,...r];d=Object.freeze(e),te=[]}let f=N.connected,p=N.connectionSeq;i&&(f=R,p=N.connectionSeq+1,ne=!1);let m=N.reconnectAttempts,h=N.lastErrorAt,g=N.reconnectDelayMs;z!==null&&(m=z,z=null),B!==null&&(h=B,B=null),re!==null&&(g=re,re=null);let _=N.desktopUpdate;o&&ie&&(_=ie,ie=null),N=Object.freeze({counters:s,latestBurst:l,burstRing:c,burstSeq:u,lifecycleRing:d,connectionSeq:p,connected:f,reconnectAttempts:m,lastErrorAt:h,reconnectDelayMs:g,desktopUpdate:_});for(let e of P)e()}var ue=null,de=0,fe=new Set,pe=new Map,me=null,he=j,ge=null;function _e(e,t){if(e===`eval-burst`){try{let e=JSON.parse(t.data);Array.isArray(e?.bursts)&&(I.push(...e.bursts),ce())}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}:{}};L.push(t),ce()}}catch{}return}if(e===`desktop-update-ready`){try{let e=JSON.parse(t.data);if(e&&typeof e.hash==`string`&&e.hash.length>0&&typeof e.version==`string`&&e.version.length>0){let t=typeof e.ts_ms==`number`&&Number.isFinite(e.ts_ms)&&e.ts_ms>0?e.ts_ms:Date.now();ie={hash:e.hash,version:e.version,tsMs:t},ce()}}catch{}return}if(e===`session-lifecycle`){try{let e=JSON.parse(t.data);Array.isArray(e?.events)&&e.events.length>0&&(te.push(...e.events),ce())}catch{}return}F[e]=(F[e]??0)+1,ce()}function ve(e){if(!ue||pe.has(e))return;let t=t=>_e(e,t);ue.addEventListener(e,t),pe.set(e,t)}var ye=0,be=0,xe=2e3;function Se(){if(ue)return;se(`opening EventSource`,{url:`/api/events`}),be=Date.now();let e=new EventSource(`/api/events`);ue=e,pe.clear();for(let e of fe)ve(e);e.onopen=()=>{let e=N.lastErrorAt!==null;he=j,ye=0,z=0,re=j,ne=!0,R=!0,ce(),e&&je(`reconnect`),se(`connected`)},e.onerror=()=>{e.close(),ue=null,pe.clear(),ne=!0,R=!1,B=Date.now(),ce(),ye===0&&Date.now()-be<xe?se(`first-open interrupted (page-load race) — reconnect in ${he}ms`):console.warn(`[ssg-sse] EventSource error — reconnect in ${he}ms (attempt ${ye+1})`),de>0&&(me=setTimeout(()=>{me=null,de>0&&Se()},he),ye++,z=ye,he=Math.min(he*2,M),re=he,ce())}}function Ce(){me&&=(clearTimeout(me),null),ue?.close(),ue=null,pe.clear(),he=j,ye=0,z=0,re=j,ne=!0,R=!1,ce()}typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&de!==0&&(ue||(me&&=(clearTimeout(me),null),se(`visibilitychange → reconnecting`),Se()))});function we(){for(let e of fe)e!==`eval-burst`&&(F[e]=(F[e]??0)+1);ce()}function Te(e){return P.add(e),()=>{P.delete(e)}}function V(){return N}var Ee=2e3,De=1e4,Oe=1440*60*1e3,ke=500,Ae=0,H=null;function je(e){let t=Date.now();if(t-Ae<De){se(`hydrate skipped (cooldown)`,{reason:e});return}if(H)return;let n=t-Oe,r=N.burstRing[N.burstRing.length-1],i=N.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;Ae=t;let s=new AbortController;H=s,se(`hydrate start`,{reason:e,since:a,until:o,ringLen:N.burstRing.length}),(async()=>{let t=a,n=0;try{for(;n<Ee&&t<o&&!s.signal.aborted;){let r=Math.min(ke,Ee-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||(I.push(...a.bursts),ce(),n+=a.bursts.length,se(`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}se(`hydrate done`,{reason:e,fetched:n})}catch(t){t.name!==`AbortError`&&console.warn(`[ssg-sse] ring hydration failed (${e})`,t)}finally{H=null}})()}function Me(e){for(let t of e)fe.add(t),ve(t);return de++,de===1&&(je(`initial`),Se(),ge=setInterval(we,A)),()=>{de--,de===0&&(Ce(),ge&&=(clearInterval(ge),null))}}function Ne(){let e=(0,_.useSyncExternalStore)(Te,V);return(0,_.useEffect)(()=>Me([`desktop-update-ready`]),[]),e.desktopUpdate}var Pe=`ssg:desktop-update:dismissed-hash`;function Fe(){let e=Ne(),[t,n]=(0,_.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage?.getItem(Pe)??``}catch{return``}});return(0,_.useEffect)(()=>{if(e&&e.hash!==t)try{window.localStorage?.removeItem(Pe)}catch{}},[e,t]),!e||e.hash===t?null:(0,D.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`hig-banner hig-banner-info`,title:`Update hash ${e.hash.slice(0,12)}`,children:[(0,D.jsx)(`span`,{children:`↑`}),(0,D.jsxs)(`span`,{children:[`SigmaShake Desktop v`,e.version,` is downloaded — open the tray and choose `,(0,D.jsx)(`strong`,{children:`Restart to apply`}),`.`]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":`Dismiss update banner`,className:`hig-banner-dismiss`,onClick:()=>{n(e.hash);try{window.localStorage?.setItem(Pe,e.hash)}catch{}},style:{marginLeft:`auto`,background:`transparent`,color:`inherit`,border:`none`,padding:`0 0.25rem`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1},children:`×`})]})}var Ie=`ssg:ui:font-scale:v1`,Le=[{label:`S`,value:.9},{label:`M`,value:1},{label:`L`,value:1.15},{label:`XL`,value:1.3}],Re=1;function ze(e){if(typeof e!=`number`||!Number.isFinite(e))return Re;let t=Le.find(t=>Math.abs(t.value-e)<.001);return t?t.value:Re}function Be(){if(typeof localStorage>`u`)return Re;try{let e=localStorage.getItem(Ie);return e===null?Re:ze(parseFloat(e))}catch{return Re}}function Ve(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Ie,String(e))}catch{}}function He(e){typeof document>`u`||(document.documentElement.style.setProperty(`--ssg-font-scale`,String(e)),document.documentElement.style.fontSize=`${16*e}px`)}function Ue(){let[e,t]=(0,_.useState)(()=>{let e=Be();return He(e),e});return(0,_.useEffect)(()=>{He(e)},[e]),{scale:e,setScale:(0,_.useCallback)(e=>{t(e),Ve(e),He(e)},[])}}function We(){let{scale:e,setScale:t}=Ue();return(0,D.jsx)(`div`,{role:`radiogroup`,"aria-label":`Font size`,className:`hig-segmented`,style:{height:`24px`},children:Le.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)})})}function U(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}}function Ge(e){let t=(0,_.useSyncExternalStore)(Te,V);(0,_.useEffect)(()=>Me(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 Ke=`ssg:active-project:v1`,qe=`ssg:active-project-change`;function Je(){try{let e=localStorage.getItem(Ke);return e&&e.length>0?e:`all`}catch{return`all`}}function Ye(e){try{localStorage.setItem(Ke,e)}catch{}}function Xe(e){window.dispatchEvent(new CustomEvent(qe,{detail:e}))}function Ze(){let[e,t]=(0,_.useState)(()=>Je());return(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;typeof n==`string`&&t(n)};return window.addEventListener(qe,e),()=>window.removeEventListener(qe,e)},[]),{activeProject:e,setActiveProject:(0,_.useCallback)(e=>{t(e),Ye(e),Xe(e)},[])}}function Qe(e,t){return!t||t===`all`?e:`${e}${e.includes(`?`)?`&`:`?`}project=${encodeURIComponent(t)}`}var $e=`ssg:hidden-projects:v1`,et=`ssg:hidden-projects-change`;function tt(){try{let e=localStorage.getItem($e);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?[...new Set(t.filter(e=>typeof e==`string`&&e.length>0))]:[]}catch{return[]}}function nt(e){try{localStorage.setItem($e,JSON.stringify(e))}catch{}}function rt(e){window.dispatchEvent(new CustomEvent(et,{detail:e}))}function it(){let[e,t]=(0,_.useState)(()=>tt());(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;Array.isArray(n)&&t(n)};return window.addEventListener(et,e),()=>window.removeEventListener(et,e)},[]);let n=(0,_.useCallback)(e=>{t(e),nt(e),rt(e)},[]),r=(0,_.useCallback)(t=>{!t||e.includes(t)||n([...e,t])},[e,n]),i=(0,_.useCallback)(t=>{e.includes(t)&&n(e.filter(e=>e!==t))},[e,n]),a=(0,_.useCallback)(()=>{e.length!==0&&n([])},[e,n]);return{hidden:(0,_.useMemo)(()=>new Set(e),[e]),hideProject:r,restoreProject:i,restoreAll:a}}function at({label:e,count:t,activeCount:n=0,selected:r,title:i,onClick:a}){return(0,D.jsxs)(`button`,{type:`button`,onClick:a,title:i,"data-active":r?`true`:`false`,className:`group flex shrink-0 items-center gap-1.5 rounded-sm border px-2.5 py-1 text-[11px] font-mono transition-colors ${r?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`,children:[n>0&&(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,D.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e}),(0,D.jsx)(`span`,{className:`tabular-nums ${r?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:t})]})}function ot({project:e,selected:t,onSelect:n,onRemove:r}){return(0,D.jsxs)(`div`,{"data-active":t?`true`:`false`,title:e.cwd??e.label,className:`group/tab relative flex shrink-0 items-center rounded-sm border py-1 pl-2.5 pr-6 text-[11px] font-mono transition-colors ${t?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1.5 outline-none`,children:[e.active_count>0&&(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,D.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.label}),(0,D.jsx)(`span`,{className:`tabular-nums ${t?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:e.session_count})]}),(0,D.jsx)(`button`,{type:`button`,onClick:r,title:`Remove “${e.label}” from the switcher`,"aria-label":`Remove ${e.label} from the switcher`,className:`absolute right-1 top-1/2 flex size-3.5 -translate-y-1/2 items-center justify-center rounded-full text-[12px] leading-none text-[var(--color-fg-4)] opacity-0 transition hover:bg-rose-500/20 hover:text-rose-300 focus:opacity-100 group-hover/tab:opacity-100`,children:`×`})]})}function st(){let{activeProject:e,setActiveProject:t}=Ze(),{hidden:n,hideProject:r,restoreProject:i,restoreAll:a}=it(),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),{data:u}=U(`/api/json/projects`,[o]),d=Ge([`activity-updated`,`session-lifecycle`]),f=(d[`activity-updated`]??0)+(d[`session-lifecycle`]??0);(0,_.useEffect)(()=>{f>0&&s(e=>e+1)},[f]);let p=u?.projects??[],m=u?.total_sessions??0,h=p.filter(e=>!n.has(e.id)),g=p.filter(e=>n.has(e.id));return(0,_.useEffect)(()=>{e!==`all`&&n.has(e)&&t(`all`)},[e,n,t]),(0,_.useEffect)(()=>{e!==`all`&&p.length>0&&!p.some(t=>t.id===e)&&t(`all`)},[e,p,t]),h.length<=1&&g.length===0?null:(0,D.jsxs)(`div`,{"data-tutorial":`project-tabs`,className:`flex items-center gap-1.5 overflow-x-auto border-b border-[var(--color-line-1)] bg-[var(--color-surface-1)]/40 px-4 py-1.5`,children:[(0,D.jsx)(`span`,{className:`shrink-0 pr-1 text-[10px] uppercase tracking-wide text-[var(--color-fg-4)]`,children:`Project`}),(0,D.jsx)(at,{label:`All projects`,count:m,selected:e===`all`,onClick:()=>t(`all`)}),h.map(n=>(0,D.jsx)(ot,{project:n,selected:e===n.id,onSelect:()=>t(n.id),onRemove:()=>r(n.id)},n.id)),g.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,title:`Projects you've removed from the switcher — add them back`,className:`shrink-0 rounded-sm border border-dashed border-[var(--color-line-1)] px-2 py-1 text-[11px] font-mono text-[var(--color-fg-4)] transition hover:border-[var(--color-hig-blue)]/50 hover:text-[var(--color-fg-2)]`,children:c?`− hide list`:`+ ${g.length} hidden`}),c&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[var(--color-line-1)]`}),g.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:`Add “${e.label}” back to the switcher`,className:`flex shrink-0 items-center gap-1 rounded-sm border border-dashed border-[var(--color-line-1)] px-2 py-1 text-[11px] font-mono text-[var(--color-fg-4)] transition hover:border-emerald-400/50 hover:text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:`+`}),(0,D.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.label})]},e.id)),g.length>1&&(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 px-1.5 py-1 text-[11px] font-mono text-[var(--color-fg-4)] underline-offset-2 transition hover:text-[var(--color-fg-2)] hover:underline`,children:`Restore all`})]})]})]})}var ct=`ssg:ui:theme:v1`,lt=[{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`}],ut=new Set([`light`,`gruvbox-light`,`apple-light`]),dt=new Set([`apple-dark`,`dracula`,`gruvbox-dark`,`tokyo-night`,`catppuccin-mocha`,`nord`,`one-dark-pro`]),ft=`default`;function pt(e){return typeof e==`string`&&lt.some(t=>t.value===e)}function mt(){if(typeof localStorage>`u`)return ft;try{let e=localStorage.getItem(ct);return pt(e)?e:ft}catch{return ft}}function ht(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ct,e)}catch{}}function gt(e){typeof document>`u`||(e===ft?(document.documentElement.removeAttribute(`data-theme`),document.documentElement.style.colorScheme=`light dark`):(document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=ut.has(e)?`light`:dt.has(e)?`dark`:`light dark`))}function _t(){let[e,t]=(0,_.useState)(()=>{let e=mt();return gt(e),e});return(0,_.useEffect)(()=>{gt(e)},[e]),{theme:e,setTheme:(0,_.useCallback)(e=>{t(e),ht(e),gt(e)},[])}}function vt(){let{theme:e,setTheme:t}=_t();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:lt.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function yt(){return{target:`[data-tutorial="app-tutorial-btn"]`,title:`Replay anytime`,body:`That's the tour. Reopen this walkthrough whenever you need it from the Tutorial button — every page has its own.`,placement:`bottom`}}function bt(){return{target:`[data-tutorial="app-sidebar"]`,title:`Move around`,body:`The sidebar groups every dashboard area — Overview, Rules, Activity and Tools. Your current page stays highlighted. Tip: press ⌘K (Ctrl+K) to jump to any page instantly.`,placement:`right`}}var xt={"home-pro":{id:`home-pro`,title:`Dashboard`,steps:[{title:`Welcome to SigmaShake`,body:`SigmaShake governs what your AI coding agents are allowed to do. Anything waiting on your decision surfaces at the top of this Dashboard — review those first; the live panels below show the full picture.`},{target:`[data-tutorial="cb-grid"]`,title:`Live panels`,body:`These panels stream straight from the governance engine: eval counters, the allow/block/ask decision mix, a telemetry feed and system vitals. They refresh on their own — no reload needed.`},{target:`[data-tutorial="cb-layout"]`,title:`Make it yours`,body:`Use the layout controls to enter edit mode, then drag and resize panels or swap layout presets. SigmaShake remembers the arrangement on this device.`,placement:`bottom`},{target:`[data-tutorial="app-mode"]`,title:`Enforcement mode`,body:`This pill controls how hard SigmaShake enforces. Cycle On → Soft → Audit → Off when you need to temporarily loosen the guardrails.`,placement:`bottom`},bt(),yt()]},"home-newcomer":{id:`home-newcomer`,title:`Home`,steps:[{title:`Welcome to SigmaShake`,body:`SigmaShake is a seatbelt for AI coding agents — it checks every action your agent takes and stops the risky ones. Here's the quick tour.`},{target:`[data-tutorial="wh-hero"]`,title:`Today at a glance`,body:`These counters show how many actions your AI agent took today and how SigmaShake responded to each one.`,placement:`bottom`},{target:`[data-tutorial="wh-actions"]`,title:`Start here`,body:`These cards are your shortcuts — connect an AI agent, choose guardrails, and review activity. Work through them top to bottom.`},{target:`[data-tutorial="wh-try"]`,title:`Try it risk-free`,body:`The sandbox lets you watch SigmaShake judge realistic scenarios without touching your real machine. Great for building intuition.`},bt(),yt()]},graph:{id:`graph`,title:`Graph`,steps:[{title:`The live Graph`,body:`Watch tool calls flow through the governance engine in real time. Each node is a decision; the graph redraws as your agent works.`},{target:`[data-tutorial="graph-panels"]`,title:`Session panels`,body:`Every active agent session gets its own panel. The busiest session takes the larger hero slot up top.`},{target:`[data-tutorial="graph-views"]`,title:`View modes`,body:`Switch between full, feed, stream and broadcast layouts depending on whether you're inspecting, demoing or streaming.`,placement:`bottom`},{target:`[data-tutorial="graph-timeline"]`,title:`Scrub time`,body:`The timeline lets you rewind and replay what happened — pause the live feed and drag to any moment.`,placement:`top`},{target:`[data-tutorial="graph-inspector"]`,title:`Inspect a node`,body:`Click any node and its details — tool, rule, latency, decision — appear in this side panel.`,placement:`left`},{target:`[data-tutorial="graph-clear"]`,title:`Clear the canvas`,body:`Reset the view when it gets crowded. This only clears the display — your audit log keeps everything.`,placement:`bottom`},yt()]},sessions:{id:`sessions`,title:`Sessions`,steps:[{title:`Agent sessions`,body:`Every run of an AI agent is grouped into a session. This page lists them all with per-session counts and outcomes.`},{target:`[data-tutorial="sessions-table"]`,title:`The session list`,body:`Each row is one session — client, action counts and decision mix. Click a row to open its full inspector.`},{target:`[data-tutorial="sessions-filter"]`,title:`Find a session`,body:`Filter by client, agent id or session key when the list gets long.`,placement:`bottom`},{target:`[data-tutorial="sessions-refresh"]`,title:`Refresh`,body:`Sessions update as agents run — tap refresh to pull the very latest.`,placement:`bottom`},yt()]},"session-detail":{id:`session-detail`,title:`Session Inspector`,steps:[{title:`Session inspector`,body:`A deep dive into one agent session — its decision breakdown, busiest tools and rules, latency profile and full audit trail.`},{target:`[data-tutorial="sd-back"]`,title:`Back to the list`,body:`This breadcrumb returns you to every session. Each row over there links to its own inspector.`,placement:`bottom`},{target:`[data-tutorial="sd-audit"]`,title:`Every action`,body:`The audit panel lists each tool call in this session in order, with the rule that decided it and why.`,placement:`top`},yt()]},debug:{id:`debug`,title:`Debug`,steps:[{title:`AI-native debugger`,body:`When a rule misfires, start here. The debugger surfaces root-cause analysis, eval timelines and live daemon state.`},{target:`[data-tutorial="debug-tabs"]`,title:`Pick a lens`,body:`Each tab is a different debugging view — RCA pack, eval flame chart, ssg:// watch, raw state and metrics.`,placement:`bottom`},{target:`[data-tutorial="debug-pane"]`,title:`The active view`,body:`The selected lens renders here. The RCA pack is the fastest way to understand a misbehaving evaluation.`,placement:`top`},yt()]},rules:{id:`rules`,title:`Rules`,steps:[{title:`Your rules`,body:`Rules are the policy SigmaShake enforces. This page is where you see, tune and monitor every one of them.`},{target:`[data-tutorial="rules-firewall"]`,title:`Firewall controls`,body:`The firewall card is the master switch — see how many rules are active and toggle enforcement in bulk.`},{target:`[data-tutorial="rules-stats"]`,title:`Performance at a glance`,body:`This bar shows how often rules fired and how fast the engine ran over your chosen time window.`},{target:`[data-tutorial="rules-top"]`,title:`Busiest rules`,body:`The chart ranks rules by how often they triggered. Click a bar to jump straight to that rule.`},{target:`[data-tutorial="rules-activity"]`,title:`Blocks & holds`,body:`See which rules are actually stopping or pausing your agent — the ones doing the real work.`},{target:`[data-tutorial="rules-recent"]`,title:`Latest decisions`,body:`A live strip of the most recent rule hits, so you can spot a noisy or misfiring rule fast.`},yt()]},audit:{id:`audit`,title:`Audit`,steps:[{title:`The audit log`,body:`Every action your AI agent attempted — and exactly what SigmaShake decided — is recorded here, in full.`},{target:`[data-tutorial="audit-filters"]`,title:`Narrow it down`,body:`Filter by decision, AI agent or tool to focus on just the activity you care about.`,placement:`bottom`},{target:`#audit-search`,title:`Search this page`,body:`Full-text search across the current page of results — tool names, rule ids, commands and file paths.`,placement:`bottom`},{target:`[data-tutorial="audit-config"]`,title:`Storage budget`,body:`Tune how many rows the audit log keeps before it rotates — right where you read the data.`},{target:`[data-tutorial="audit-sinks"]`,title:`Forward your logs`,body:`Stream audit events to a central logging destination for long-term retention or SIEM analysis.`},yt()]},approvals:{id:`approvals`,title:`Approvals`,steps:[{title:`Approvals`,body:`When a rule decides ASK, the action pauses here for your call. This page is your review queue.`},{target:`[data-tutorial="appr-stats"]`,title:`Queue health`,body:`A quick read on how many actions are waiting and how you've been responding to them.`,placement:`bottom`},{target:`.ss-noisy-card`,title:`Tame noisy rules`,body:`If a rule asks too often, silence it from here instead of letting it interrupt every run.`},{target:`[data-tutorial="appr-pending"]`,title:`Decide`,body:`Each pending card shows the tool call and the rule that held it. Approve to let it through, deny to block it.`},{target:`[data-tutorial="appr-history"]`,title:`Past decisions`,body:`Everything you've already approved or denied, searchable, so you can revisit any call.`},yt()]},profile:{id:`profile`,title:`Profile`,steps:[{title:`Performance profile`,body:`Two tools in one: an eval profiler that finds governance bottlenecks, and a runtime inspector for the dashboard process itself.`},{target:`[data-tutorial="profile-tabs"]`,title:`Switch tools`,body:`Toggle between the eval profile and the runtime inspector here.`,placement:`bottom`},{target:`[data-tutorial="profile-metrics"]`,title:`The numbers`,body:`Headline latency and throughput metrics for rule evaluation — your baseline for spotting regressions.`},yt()]},agents:{id:`agents`,title:`Agents`,steps:[{title:`AI agents`,body:`SigmaShake works with many AI coding tools. This page connects them and shows which are wired up.`},{target:`[data-tutorial="agents-active"]`,title:`Connected agent`,body:`The agent SigmaShake currently detects sits up top, with its live connection status.`},{target:`[data-tutorial="agents-filter"]`,title:`Browse adapters`,body:`Filter the list to see every supported agent, just the detected ones, or what's available to add.`,placement:`bottom`},{target:`[data-tutorial="agents-list"]`,title:`Wire one up`,body:`Pick an agent to install the SigmaShake hook into it. Each row opens its setup details.`},{target:`[data-tutorial="agents-connections"]`,title:`Where it's installed`,body:`An overview of which projects each agent is governing.`},yt()]},notifications:{id:`notifications`,title:`Notifications`,steps:[{title:`Notifications`,body:`One place to answer "is anything wrong?" — rule drift, audit capacity, daemon health and noisy rules.`},{target:`[data-tutorial="notif-list"]`,title:`What needs attention`,body:`Each item is something SigmaShake noticed. An empty list means everything is healthy.`},bt(),yt()]},setup:{id:`setup`,title:`Setup Status`,steps:[{title:`Setup status`,body:`A full health check of your SigmaShake install — license, daemon, native engine, rules directories and per-agent wiring.`},{target:`[data-tutorial="setup-summary"]`,title:`Overall status`,body:`The top card is the verdict. Green means you're fully set up; warnings point you at what's left.`},{target:`[data-tutorial="setup-checks"]`,title:`The checklist`,body:`Each probe verifies one piece of the install. Expand any that aren't passing to see the fix.`},yt()]},simulator:{id:`simulator`,title:`Try It`,steps:[{title:`Try it`,body:`A safe sandbox: run realistic scenarios past your rules and see what SigmaShake would allow, block, ask or log — nothing actually executes.`},{target:`[data-tutorial="try-scenarios"]`,title:`Pick a scenario`,body:`Scenarios are grouped by category. Choose one to load a realistic command.`},{target:`[data-tutorial="try-detail"]`,title:`Review & run`,body:`The selected scenario shows the exact command. Hit Run simulation to get a verdict.`},{target:`#tryit-result`,title:`The verdict`,body:`SigmaShake explains its decision here — what it decided, why, and what would have happened.`,placement:`top`},{target:`[data-tutorial="try-advanced"]`,title:`Custom input`,body:`Drop in your own tool call to test an edge case the preset scenarios don't cover.`},yt()]},guardrails:{id:`guardrails`,title:`Guardrails`,steps:[{title:`Guardrails`,body:`Starter packs are bundles of rules curated for a job. Install one and you're protected in a tap — no rule writing.`},{target:`[data-tutorial="guard-hero"]`,title:`One-tap protection`,body:`Pick the pack that matches what you're worried about — SigmaShake handles the rest.`},{target:`[data-tutorial="guard-packs"]`,title:`Browse the packs`,body:`Each row is a pack. Expand it to see exactly which rules it adds before you install.`},{target:`[data-tutorial="guard-advanced"]`,title:`Go further`,body:`Ready for more control? Flip to Advanced mode for the full rule library, audit log, graph, and per-rule controls.`},yt()]},hub:{id:`hub`,title:`Hub`,steps:[{title:`Rules hub`,body:`A marketplace of community governance rulesets. Find one that fits, install it, and it joins your rules.`},{target:`[data-tutorial="hub-search"]`,title:`Search`,body:`Search rulesets by name or keyword.`,placement:`bottom`},{target:`[data-tutorial="hub-filters"]`,title:`Filter & sort`,body:`Narrow by decision type or severity, and sort to surface the most relevant or popular packs.`,placement:`bottom`},{target:`[data-tutorial="hub-grid"]`,title:`Browse rulesets`,body:`Each card is an installable ruleset. Open one to read its rules before committing.`},{target:`[data-tutorial="hub-tabs"]`,title:`All vs installed`,body:`Flip between the whole catalog and just what you've already installed.`,placement:`bottom`},{target:`[data-tutorial="hub-connect"]`,title:`Publish your own`,body:`Connect a GitHub account to publish your own rulesets back to the hub.`,placement:`bottom`},yt()]},"hub-connect":{id:`hub-connect`,title:`Connect Hub`,steps:[{title:`Connect GitHub`,body:`Publishing rulesets to the hub needs a GitHub account. This page runs the secure device-code sign-in.`},{title:`The device-code flow`,body:`Start the flow, then enter the short code shown on this page at GitHub's verification page. The dashboard polls until you approve it — no password ever touches SigmaShake.`},yt()]},"hub-publish":{id:`hub-publish`,title:`Publish to Hub`,steps:[{title:`Publish a ruleset`,body:`Share a governance ruleset you keep in a GitHub repo with the whole SigmaShake community.`},{target:`[data-tutorial="hubpub-input"]`,title:`Point at your repo`,body:`Paste the GitHub URL of the repo holding your .rules files.`},{title:`Submit for review`,body:`Publish sends the ruleset to the hub. Once accepted it appears in the marketplace for everyone to install.`},yt()]},"hub-detail":{id:`hub-detail`,title:`Hub Ruleset`,steps:[{title:`Ruleset details`,body:`Everything about one hub ruleset — what it does, which technologies it covers, and every rule inside.`},{title:`Install it`,body:`The install button adds this ruleset to your local rules. You can disable individual rules afterwards on the Rules page.`},{title:`Read before you install`,body:`Scroll the rule list to see the actual policy — each rule's decision and trigger — so there are no surprises.`},yt()]},monitor:{id:`monitor`,title:`Monitor`,steps:[{title:`Daemon monitor`,body:`Live vitals for the evaluation daemon — the background process that judges every tool call.`},{target:`[data-tutorial="monitor-counters"]`,title:`Eval counters`,body:`Running totals of evaluations by outcome, straight from the daemon.`},{target:`[data-tutorial="monitor-resources"]`,title:`Resource limits`,body:`Watch CPU and memory, and set the limits that keep the daemon from running away.`},{target:`[data-tutorial="monitor-tail"]`,title:`Live event tail`,body:`The most recent daemon events scroll here — the fastest way to confirm it's healthy.`,placement:`top`},yt()]},observability:{id:`observability`,title:`Observability`,steps:[{title:`Observability`,body:`Deep system health — database integrity, rule drift, the flight recorder and the daemon log, all in one place.`},{target:`[data-tutorial="observ-drift"]`,title:`Rule drift`,body:`The most important card: it flags when a rule in the database has diverged from its .rules file source. Sync it back from here.`},{target:`[data-tutorial="observ-capacity"]`,title:`Audit capacity`,body:`Track how full the audit log is and when it will next rotate.`},{title:`Dig deeper`,body:`Further down: SQLite health, the flight recorder, the runtime profiler and a live daemon log tail — scroll for the full picture.`},yt()]},plugins:{id:`plugins`,title:`Plugins`,steps:[{title:`Plugin marketplace`,body:`Plugins extend the dashboard with new pages and features. Browse, install and manage them here.`},{target:`[data-tutorial="plugins-tabs"]`,title:`Three views`,body:`Browse the marketplace, manage what you've Installed, or see the Built-in features that ship with SigmaShake.`,placement:`bottom`},{target:`[data-tutorial="plugins-search"]`,title:`Find a plugin`,body:`Search the marketplace by name or keyword.`,placement:`bottom`},{target:`[data-tutorial="plugins-categories"]`,title:`Filter by category`,body:`Category chips narrow the marketplace to one kind of plugin.`,placement:`bottom`},{target:`[data-tutorial="plugins-featured"]`,title:`Editor's picks`,body:`Hand-picked plugins worth a look if you're not sure where to start.`},yt()]},"plugin-publish":{id:`plugin-publish`,title:`Publish a Plugin`,steps:[{title:`Publish a plugin`,body:`Built something useful? This page walks you through getting it onto the marketplace.`},{title:`Three commands`,body:`It's a CLI flow: ssg plugins init scaffolds the plugin, build bundles and signs it, and publish cuts the release.`},{target:`[data-tutorial="pubplug-submit"]`,title:`Submit to the hub`,body:`After building, this link opens the hub submission form to finish your listing.`},yt()]},support:{id:`support`,title:`Support`,steps:[{title:`Support & feedback`,body:`Hit a bug, want a feature, or have a question? Send it straight to the SigmaShake team from here.`},{target:`[data-tutorial="support-subject"]`,title:`Subject`,body:`A short summary. Pick the category above first so it routes to the right place.`},{target:`[data-tutorial="support-desc"]`,title:`Describe it`,body:`The detail. For bugs, what you did and what you expected helps most — diagnostics are attached automatically.`},{target:`[data-tutorial="support-attach"]`,title:`Add a screenshot`,body:`Drag in an image — a screenshot of the problem is worth a thousand words.`},yt()]}};function St(e,t){return e===`/`?t===`newcomer`?xt[`home-newcomer`]:xt[`home-pro`]:e===`/graph`?xt.graph:e===`/sessions`?xt.sessions:e.startsWith(`/sessions/`)?xt[`session-detail`]:e===`/debug`?xt.debug:e===`/rules`?xt.rules:e===`/audit`?xt.audit:e===`/approvals`?xt.approvals:e===`/profile`?xt.profile:e===`/agents`?xt.agents:e===`/notifications`?xt.notifications:e===`/setup`?xt.setup:e===`/try`?xt.simulator:e===`/guardrails`?xt.guardrails:e===`/hub/connect`?xt[`hub-connect`]:e===`/hub/publish`?xt[`hub-publish`]:e.startsWith(`/hub/`)?xt[`hub-detail`]:e===`/hub`?xt.hub:e===`/monitor`?xt.monitor:e===`/observability`?xt.observability:e===`/plugins`?xt.plugins:e===`/publish-plugin`?xt[`plugin-publish`]:e===`/support`?xt.support:null}var Ct=m(),wt=344,Tt=8,Et=16,Dt=14;function Ot(e){if(!e)return null;let t=null;try{t=document.querySelector(e)}catch{return null}if(!t)return null;let n=t.getBoundingClientRect();return n.width<1||n.height<1?null:{top:n.top,left:n.left,width:n.width,height:n.height}}function kt(e,t,n,r){let i=window.innerWidth,a=window.innerHeight;if(!e||t===`center`)return{top:Math.max(Dt,(a-r)/2),left:Math.max(Dt,(i-n)/2),side:`center`};let o={top:e.top-Tt,left:e.left-Tt,right:e.left+e.width+Tt,bottom:e.top+e.height+Tt,cx:e.left+e.width/2,cy:e.top+e.height/2},s={bottom:a-o.bottom>=r+Et+Dt,top:o.top>=r+Et+Dt,right:i-o.right>=n+Et+Dt,left:o.left>=n+Et+Dt},c=(t===`auto`?[`bottom`,`top`,`right`,`left`]:[t,`bottom`,`top`,`right`,`left`]).find(e=>s[e])??`bottom`,l=0,u=0;return c===`bottom`?(l=o.bottom+Et,u=o.cx-n/2):c===`top`?(l=o.top-Et-r,u=o.cx-n/2):c===`right`?(u=o.right+Et,l=o.cy-r/2):(u=o.left-Et-n,l=o.cy-r/2),u=Math.min(Math.max(Dt,u),i-n-Dt),l=Math.min(Math.max(Dt,l),a-r-Dt),{top:l,left:u,side:c}}function At({tutorial:e,onClose:t}){let[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)({top:-9999,left:-9999,side:`center`}),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=e.steps.length,d=e.steps[n],f=n>=u-1,p=n===0,m=(0,_.useCallback)(()=>{n>=e.steps.length-1?t():r(e=>e+1)},[n,e.steps.length,t]),h=(0,_.useCallback)(()=>{r(e=>Math.max(0,e-1))},[]);if((0,_.useEffect)(()=>{let e=d?.target;if(a(Ot(e)),!e)return;let t=null;try{t=document.querySelector(e)}catch{t=null}if(!t)return;t.scrollIntoView({block:`center`,inline:`nearest`,behavior:`smooth`});let n=window.setTimeout(()=>a(Ot(e)),380);return()=>window.clearTimeout(n)},[d]),(0,_.useEffect)(()=>{let e=d?.target;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a(Ot(e)))};return window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[d]),(0,_.useLayoutEffect)(()=>{let e=c.current,t=e?.offsetWidth??wt,n=e?.offsetHeight??220;s(kt(i,d?.placement??`auto`,t,n))},[i,d]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.preventDefault(),t()):e.key===`ArrowRight`?(e.preventDefault(),m()):e.key===`ArrowLeft`&&(e.preventDefault(),h())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,h,t]),(0,_.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[n]),!d)return null;let g=i!==null;return(0,Ct.createPortal)((0,D.jsxs)(`div`,{className:`ssg-tut-root`,role:`presentation`,children:[(0,D.jsx)(`div`,{className:`ssg-tut-catcher${g?``:` ssg-tut-catcher--dim`}`}),g&&i&&(0,D.jsx)(`div`,{className:`ssg-tut-spot`,"aria-hidden":`true`,style:{top:i.top-Tt,left:i.left-Tt,width:i.width+Tt*2,height:i.height+Tt*2}}),(0,D.jsxs)(`div`,{ref:c,className:`ssg-tut-card ssg-tut-card--${o.side}`,style:{top:o.top,left:o.left},role:`dialog`,"aria-modal":`true`,"aria-label":`${e.title} tutorial`,children:[(0,D.jsx)(`button`,{type:`button`,className:`ssg-tut-close`,onClick:t,"aria-label":`Close tutorial`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`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.jsxs)(`div`,{className:`ssg-tut-eyebrow`,children:[(0,D.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M12 3l2.5 5.5L20 11l-5.5 2.5L12 19l-2.5-5.5L4 11l5.5-2.5z`})}),(0,D.jsxs)(`span`,{children:[`Tutorial · `,e.title]})]}),(0,D.jsxs)(`div`,{className:`ssg-tut-counter`,children:[`Step `,n+1,` of `,u]}),(0,D.jsx)(`h2`,{className:`ssg-tut-title`,children:d.title}),(0,D.jsx)(`p`,{className:`ssg-tut-body`,children:d.body}),(0,D.jsx)(`div`,{className:`ssg-tut-dots`,role:`tablist`,"aria-label":`Tutorial steps`,children:e.steps.map((e,t)=>(0,D.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,"aria-label":`Step ${t+1}: ${e.title}`,className:`ssg-tut-dot${t===n?` ssg-tut-dot--on`:``}${t<n?` ssg-tut-dot--done`:``}`,onClick:()=>r(t)},e.title))}),(0,D.jsxs)(`div`,{className:`ssg-tut-actions`,children:[!f&&(0,D.jsx)(`button`,{type:`button`,className:`hig-button hig-button-plain hig-button-small`,onClick:t,children:`Skip tour`}),(0,D.jsx)(`span`,{className:`ssg-tut-actions-spacer`}),(0,D.jsx)(`button`,{type:`button`,className:`hig-button hig-button-small`,onClick:h,disabled:p,children:`Back`}),(0,D.jsx)(`button`,{ref:l,type:`button`,className:`hig-button hig-button-primary hig-button-small`,onClick:m,children:f?`Finish`:`Next`})]})]},n)]}),document.body)}var jt=`ssg.tutorial.seen.`;function Mt(e){try{return localStorage.getItem(jt+e)===`1`}catch{return!0}}function Nt(e){try{localStorage.setItem(jt+e,`1`)}catch{}}function Pt({pathname:e,mode:t}){let n=St(e,t),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!0);(0,_.useEffect)(()=>{i(!1),o(n?Mt(n.id):!0)},[n]);let s=(0,_.useCallback)(()=>{n&&(Nt(n.id),o(!0),i(!0))},[n]);return n?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`button`,{type:`button`,"data-tutorial":`app-tutorial-btn`,className:`hig-button hig-button-small ssg-tut-launch`,onClick:s,title:`Take the ${n.title} tutorial`,"aria-label":`Take the ${n.title} tutorial`,children:[(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,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`})]}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`Tutorial`}),!a&&(0,D.jsx)(`span`,{className:`ssg-tut-launch-hint`,"aria-hidden":`true`})]}),r&&(0,D.jsx)(At,{tutorial:n,onClose:()=>i(!1)})]}):null}var Ft=`ssg:ui:mode:v1`,It=`ssg:ui:mode:seeded`,Lt=`ssg:ui-mode-change`,Rt=new Set([`professional`,`enterprise`,`agent-dev`]);function zt(){try{let e=localStorage.getItem(Ft);if(e===`newcomer`||e===`pro`)return e}catch{}return null}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}async function Vt(){if(zt()===null){try{if(localStorage.getItem(It))return;localStorage.setItem(It,`1`)}catch{return}try{let e=await fetch(`/api/json/wizard-state`);if(!e.ok){Bt(`newcomer`);return}let t=await e.json(),n=Rt.has(t.profile??``)?`pro`:`newcomer`;Bt(n),window.dispatchEvent(new CustomEvent(Lt,{detail:n}))}catch{Bt(`newcomer`)}}}function Ht(){let[e,t]=(0,_.useState)(()=>zt()??`newcomer`);return(0,_.useEffect)(()=>{Vt().then(()=>{let n=zt();n&&n!==e&&t(n)});let n=e=>{let n=e.detail;(n===`newcomer`||n===`pro`)&&t(n)};return window.addEventListener(Lt,n),()=>window.removeEventListener(Lt,n)},[e]),{mode:e,setMode:(0,_.useCallback)(e=>{t(e),Bt(e),window.dispatchEvent(new CustomEvent(Lt,{detail:e}))},[])}}function Ut(){let{mode:e,setMode:t}=Ht(),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 Wt=A;function Gt(){(0,_.useEffect)(()=>Me([]),[]);let e=(0,_.useSyncExternalStore)(Te,V),[,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=Kt(e),r=n===`reconnecting`&&e.lastErrorAt!==null?Math.max(0,Math.ceil((e.lastErrorAt+e.reconnectDelayMs-Date.now())/1e3)):null,i=Math.round(Wt/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 Kt(e){return e.connected?`connected`:e.reconnectAttempts>0||e.lastErrorAt!==null?`reconnecting`:`disconnected`}var qt=[{id:`voice-navigator`,name:`Voice Navigator`,description:`Hands-free dashboard control. Tap the orb or press Ctrl/Cmd+Shift+V, then speak to navigate pages (“go to rules”), run actions (“set mode to ask”), or dictate a .rules file (“block any command containing curl”). Replies are spoken back. Uses your browser's built-in speech engine — nothing to download.`,icon:`🎙`}],Jt=`ssg:builtin-features:v1`,Yt=`ssg:builtin-features-change`,Xt={"voice-navigator":!0};function Zt(){try{let e=localStorage.getItem(Jt);if(!e)return{...Xt};let t=JSON.parse(e);if(typeof t!=`object`||!t)return{...Xt};let n={...Xt};for(let e of Object.keys(Xt)){let r=t[e];typeof r==`boolean`&&(n[e]=r)}return n}catch{return{...Xt}}}function Qt(e){try{localStorage.setItem(Jt,JSON.stringify(e))}catch{}}function $t(e){window.dispatchEvent(new CustomEvent(Yt,{detail:e}))}function en(){let[e,t]=(0,_.useState)(()=>Zt());return(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;n&&t(n)};return window.addEventListener(Yt,e),()=>window.removeEventListener(Yt,e)},[]),{features:e,setFeature:(0,_.useCallback)((n,r)=>{let i={...e,[n]:r};t(i),Qt(i),$t(i)},[e])}}function tn(e){let{features:t}=en();return t[e]}function W(){let e=document.querySelector(`meta[name="ssg-csrf"]`)?.content??``;return e?{"X-SigmaShake-Token":e}:{}}function nn(){return window.SpeechRecognition??window.webkitSpeechRecognition??null}function rn(){return nn()!==null}function an(){return typeof window<`u`&&`speechSynthesis`in window}function on(){try{return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var sn=null;function cn(){if(!an())return null;if(sn)return sn;let e=window.speechSynthesis.getVoices();if(e.length===0)return null;let t=e.filter(e=>e.lang.toLowerCase().startsWith(`en`)),n=t.length>0?t:e;return sn=n.find(e=>/google|samantha|daniel|aria|natural|neural/i.test(e.name))??n[0]??null,sn}function ln(e,t={}){let n=t.onEnd;if(t.muted||!an()||!e){n?.();return}try{let t=window.speechSynthesis;t.cancel();let r=new SpeechSynthesisUtterance(e),i=cn();i&&(r.voice=i),r.rate=1.05,r.pitch=1,r.volume=1,n&&(r.onend=()=>n(),r.onerror=()=>n()),t.speak(r)}catch{n?.()}}function un(){if(an())try{window.speechSynthesis.cancel()}catch{}}function dn(){if(an())try{cn(),window.speechSynthesis.addEventListener?.(`voiceschanged`,()=>{sn=null,cn()})}catch{}}var fn=new Set(`the.a.an.to.go.goto.open.show.me.my.please.take.navigate.jump.switch.bring.up.page.screen.view.let.lets.hey.sigma.sigmashake.shake.assistant.navi.can.you.i.want.would.like.of.for.from.and.on.into.tab.section.over.there.now.then.just.gimme.give.get.head`.split(`.`)),pn={"nav:/":[`home`,`dashboard`,`overview`,`main`],"nav:/approvals":[`approvals`,`approval`,`pending`,`queue`,`decisions`],"nav:/rules":[`rules`,`rule`,`guardrails`,`guardrail`,`policy`,`policies`],"nav:/hub":[`hub`,`marketplace`,`rulesets`],"nav:/audit":[`audit`,`activity`,`log`,`logs`,`history`],"nav:/agents":[`agents`,`agent`,`adapters`,`clients`],"nav:/graph":[`graph`,`chart`,`timeline`],"nav:/sessions":[`sessions`,`session`,`transcripts`],"nav:/observability":[`observability`,`metrics`,`telemetry`,`latency`],"nav:/monitor":[`monitor`,`watch`,`tail`,`live`],"nav:/notifications":[`notifications`,`notification`,`alerts`,`inbox`],"nav:/plugins":[`plugins`,`plugin`,`extensions`,`marketplace`],"nav:/setup":[`setup`,`wizard`,`onboarding`,`install`],"nav:/profile":[`profile`,`settings`,`account`,`license`],"nav:/debug":[`debug`,`inspector`,`internals`],"nav:/support":[`support`,`help`,`ticket`,`feedback`],"act:mode:ask":[`ask`],"act:mode:allow":[`allow`,`allowing`],"act:mode:deny":[`deny`,`panic`,`lockdown`],"act:rules:sync":[`sync`],"act:rules:reload":[`reload`,`refresh`],"act:plugins:reload":[`plugins`],"act:hard-reload":[`reload`,`dashboard`],"act:theme:toggle":[`theme`,`dark`,`light`],"act:copy-url":[`copy`,`url`,`link`],"act:docs:open":[`docs`,`documentation`],"act:hub:open":[`hub`]};function mn(e){return e.length>3&&e.endsWith(`s`)?e.slice(0,-1):e}function hn(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,` `).split(/\s+/).filter(Boolean).map(mn)}function gn(e){let t=new Set,n=new Set;for(let n of hn(e.label))n.length>=2&&!fn.has(n)&&n!==`set`&&t.add(n);let r=e.hint.startsWith(`/`)?e.hint.slice(1):``;r&&/^[a-z]+$/.test(r)&&t.add(mn(r));for(let t of hn(e.keywords??``))t.length>=2&&n.add(t);for(let n of pn[e.id]??[])t.add(mn(n));for(let e of t)n.delete(e);return{strong:t,weak:n}}var _n=/\b(block|blocks|deny|denies|denied|forbid|forbids|prevent|prevents|disallow|warn|allow only|ask before|require)\b/,vn=/^(create|add|make|write|new|draft|set up|setup)\s+(a\s+|an\s+)?(rule|guardrail|policy)\b/;function yn(e){return e.replace(vn,``).replace(/^\s*(that|which|to|saying)\s+/i,``).trim()}function bn(e){let t=e.trim();if(!t)return{kind:`unknown`,transcript:t};let n=t.toLowerCase(),r=hn(t),i=new Set(r);if(r.length<=3){if(/^(stop|stop listening|cancel listening|that's all|thats all|nevermind|never mind)$/.test(n))return{kind:`control`,control:`stop`};if(/^(cancel|discard|forget it|scratch that)$/.test(n))return{kind:`control`,control:`cancel`};if(/^(save|save it|yes|confirm|do it|apply)$/.test(n))return{kind:`control`,control:`confirm`};if(/^(overwrite|replace|replace it)$/.test(n))return{kind:`control`,control:`overwrite`};if(/^(no|don't|dont|stop that)$/.test(n))return{kind:`control`,control:`discard`};if(/^(help|what can you do|commands|options)$/.test(n))return{kind:`control`,control:`help`}}if((vn.test(n)||_n.test(n))&&!/\bmode\b/.test(n)){let e=yn(t);if(e.length>=4)return{kind:`rule`,ruleText:e}}let a=[...b.map(e=>({kind:`nav`,item:e})),...C.map(e=>({kind:`action`,item:e}))],o=null,s=0;for(let e of a){let{strong:t,weak:n}=gn(e.item),r=0;for(let e of t)i.has(e)&&(r+=3);for(let e of n)i.has(e)&&(r+=1);r>s&&(s=r,o=e)}return o&&s>=3?{kind:o.kind,item:o.item}:{kind:`unknown`,transcript:t}}var xn=`voice-navigator`,Sn=`ssg:voice:muted`,Cn=[`go to rules`,`open the audit log`,`set mode to ask`,`block any command containing curl`];function wn(e){let t=e;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}function Tn(){let e=tn(xn),t=rn(),[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(()=>{try{return localStorage.getItem(Sn)===`1`}catch{return!1}}),m=(0,_.useRef)(null),h=(0,_.useRef)(`idle`),g=(0,_.useRef)(f),v=(0,_.useRef)(!1),b=(0,_.useRef)(!1),x=on();(0,_.useEffect)(()=>{h.current=n},[n]),(0,_.useEffect)(()=>{g.current=f;try{localStorage.setItem(Sn,f?`1`:`0`)}catch{}},[f]),(0,_.useEffect)(()=>{e&&an()&&dn()},[e]);let S=(0,_.useCallback)((e,t)=>{ln(e,{muted:g.current,onEnd:t})},[]),C=(0,_.useCallback)(()=>{let e=m.current;if(e){try{e.onresult=null,e.onend=null,e.onerror=null,e.abort()}catch{}m.current=null}},[]),w=(0,_.useCallback)(async(e,t)=>{r(`thinking`);try{let n=await(await fetch(`/api/rules/dictate/save`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({args:e,overwrite:t})})).json();n.ok?(d(null),b.current=!1,l(`Saved rule “${e.name}”.`),r(`speaking`),S(`Saved the rule ${e.name}.`,()=>r(`idle`)),y(`/rules?focus=${encodeURIComponent(e.name)}`)):n.error===`exists`&&!t?(b.current=!0,l(`A rule named “${e.name}” already exists. Say “overwrite”, or use the buttons.`),r(`confirm`),S(`A rule named ${e.name} already exists. Say overwrite to replace it, or cancel.`)):(l(`Could not save: ${n.error??`unknown error`}`),r(`error`),S(`I couldn't save that rule.`,()=>r(`idle`)))}catch(e){l(`Save failed: ${e instanceof Error?e.message:String(e)}`),r(`error`),S(`Saving the rule failed.`,()=>r(`idle`))}},[S]),T=(0,_.useCallback)(async e=>{r(`thinking`),l(`Drafting a rule from “${e}”…`);try{let t=await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({transcript:e})})).json(),n=t.missingSlots??[];if(!t.matched||!t.args){l(`I couldn't turn that into a rule. Try: “block any command containing curl”.`),r(`error`),S(`I couldn't turn that into a rule. Try saying, block any command containing, and then the text.`,()=>r(`idle`));return}if(n.length>0){l(`I need a bit more: ${n.join(`, `)}.`),r(`error`),S(`I need more detail for: ${n.join(`, `)}.`,()=>r(`idle`));return}b.current=!1,d(t),a(!0),l(`Drafted “${t.args.name}”. Say “save” to apply, or “cancel”.`),r(`confirm`),S(`I drafted a rule that ${t.args.decision}s ${t.args.target||`the target`}. Say save to apply, or cancel.`)}catch(e){l(`Dictation failed: ${e instanceof Error?e.message:String(e)}`),r(`error`),S(`Rule dictation failed.`,()=>r(`idle`))}},[S]),E=(0,_.useCallback)(e=>{let t=bn(e);switch(t.kind){case`nav`:case`action`:t.item.run(),l(`→ ${t.item.label}`),r(`speaking`),S(`${t.kind===`nav`?`Opening`:`Running`} ${t.item.label}.`,()=>r(`idle`));return;case`rule`:T(t.ruleText);return;case`control`:if(t.control===`help`){a(!0),l(`Try one of the examples below.`),r(`speaking`),S(`You can say things like, go to rules, set mode to ask, or create a rule that blocks a command.`,()=>r(`idle`));return}if(t.control===`stop`){l(`Stopped listening.`),r(`idle`);return}if(u?.args){t.control===`confirm`||t.control===`overwrite`?w(u.args,b.current):(d(null),b.current=!1,l(`Discarded the draft rule.`),r(`speaking`),S(`Discarded.`,()=>r(`idle`)));return}l(`Nothing to confirm.`),r(`idle`);return;default:l(`I didn't catch a command in “${e}”.`),a(!0),r(`error`),S(`I didn't catch a command. Say help to hear what I can do.`,()=>r(`idle`))}},[T,w,S,u]),O=(0,_.useCallback)(()=>{if(!t){a(!0),l(`Speech recognition isn't available in this browser. Use Chrome, or the Voice Dictation plugin.`),r(`error`);return}if(h.current===`listening`)return;let e=nn();if(!e)return;un(),C();let n=new e;n.lang=`en-US`,n.continuous=!1,n.interimResults=!0,n.maxAlternatives=1,v.current=!1,m.current=n,n.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r],a=i[0];a&&(i.isFinal?n+=a.transcript:t+=a.transcript)}n?(s(n.trim()),v.current||(v.current=!0,E(n.trim()))):s(t)},n.onerror=e=>{e.error===`no-speech`?l(`I didn't hear anything — try again.`):e.error===`not-allowed`||e.error===`service-not-allowed`?l(`Microphone access was blocked. Allow the mic for this site, then try again.`):e.error!==`aborted`&&l(`Voice error: ${e.error}`),e.error!==`aborted`&&r(`error`)},n.onend=()=>{m.current=null,!v.current&&h.current===`listening`&&r(`idle`)};try{n.start(),s(``),l(`Listening…`),a(!0),r(`listening`)}catch{m.current=null,r(`idle`)}},[t,C,E]),k=(0,_.useCallback)(()=>{C(),h.current===`listening`&&(r(`idle`),l(`Stopped.`))},[C]),ee=(0,_.useCallback)(()=>{h.current===`listening`?k():O()},[O,k]);if((0,_.useEffect)(()=>{if(!e)return;function t(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`v`&&!wn(e.target)){e.preventDefault(),ee();return}e.key===`Escape`&&h.current===`listening`&&k()}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,ee,k]),(0,_.useEffect)(()=>{if(!e)return;let t=()=>O();return window.addEventListener(`sigmashake:voice-activate`,t),()=>window.removeEventListener(`sigmashake:voice-activate`,t)},[e,O]),(0,_.useEffect)(()=>(e||(C(),un(),r(`idle`),a(!1)),()=>{C(),un()}),[e,C]),!e)return null;let A=n===`listening`,j=A||n===`thinking`||n===`speaking`;return(0,D.jsxs)(`div`,{className:`voicenav`,"data-phase":n,"data-reduce-motion":x?`true`:`false`,children:[i&&(0,D.jsxs)(`div`,{className:`voicenav-panel`,role:`dialog`,"aria-label":`Voice Navigator`,children:[(0,D.jsxs)(`div`,{className:`voicenav-panel-head`,children:[(0,D.jsxs)(`span`,{className:`voicenav-title`,children:[(0,D.jsx)(`span`,{className:`voicenav-dot`,"aria-hidden":`true`}),`Voice Navigator`]}),(0,D.jsxs)(`div`,{className:`voicenav-panel-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voicenav-iconbtn`,"aria-pressed":f,title:f?`Unmute spoken replies`:`Mute spoken replies`,onClick:()=>p(e=>!e),children:f?`🔇`:`🔊`}),(0,D.jsx)(`button`,{type:`button`,className:`voicenav-iconbtn`,title:`Close`,"aria-label":`Close voice navigator panel`,onClick:()=>{k(),a(!1)},children:`×`})]})]}),(0,D.jsx)(`div`,{className:`voicenav-status`,"aria-live":`polite`,children:c||(t?`Tap the orb or press Ctrl+Shift+V, then speak.`:`Voice input isn't supported here.`)}),(o||A)&&(0,D.jsx)(`div`,{className:`voicenav-transcript`,"data-empty":!o,children:o||`…`}),u?.preview&&(0,D.jsxs)(`div`,{className:`voicenav-rule`,children:[(0,D.jsx)(`pre`,{className:`voicenav-rule-preview`,children:u.preview}),(0,D.jsxs)(`div`,{className:`voicenav-rule-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voicenav-btn voicenav-btn--primary`,onClick:()=>u.args&&void w(u.args,b.current),children:b.current?`Overwrite`:`Save rule`}),(0,D.jsx)(`button`,{type:`button`,className:`voicenav-btn`,onClick:()=>{d(null),b.current=!1,l(`Discarded the draft rule.`),r(`idle`)},children:`Discard`})]})]}),(0,D.jsx)(`div`,{className:`voicenav-examples`,children:Cn.map(e=>(0,D.jsx)(`button`,{type:`button`,className:`voicenav-chip`,title:`Run as if spoken`,onClick:()=>E(e),children:e},e))})]}),(0,D.jsxs)(`button`,{type:`button`,className:`voicenav-orb`,"data-active":j,"data-listening":A,"aria-label":A?`Stop voice navigator`:`Start voice navigator`,title:t?`Voice Navigator (Ctrl/Cmd+Shift+V)`:`Voice Navigator — open panel`,onClick:()=>{i||a(!0),ee()},children:[(0,D.jsx)(`span`,{className:`voicenav-orb-ring`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`voicenav-orb-ring voicenav-orb-ring--2`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`voicenav-orb-core`,"aria-hidden":`true`,children:(0,D.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z`}),(0,D.jsx)(`path`,{d:`M5 11a7 7 0 0 0 14 0`}),(0,D.jsx)(`path`,{d:`M12 18v3`})]})}),A&&(0,D.jsxs)(`span`,{className:`voicenav-wave`,"aria-hidden":`true`,children:[(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{})]})]})]})}var En=`ssg:self-protection-changed`;function Dn(){let{data:e,loading:t,refetch:n}=U(`/api/json/self-protection`),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=()=>n();return window.addEventListener(En,e),()=>window.removeEventListener(En,e)},[n]);let a=(0,_.useCallback)(async e=>{i(!0);try{await fetch(`/api/json/self-protection`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({enabled:e})}),window.dispatchEvent(new Event(En))}finally{i(!1)}},[]);return{enabled:e?.enabled??!1,present:e?.present??!1,ruleCount:e?.ruleCount??0,loading:t,saving:r,setEnabled:a,refetch:n}}var On=`ssg-dashboard-tabs`,kn=2e3,An=6e3;function jn(){return`tab-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Mn(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(!0),i=(0,_.useRef)(jn()),a=(0,_.useRef)(new Map);return(0,_.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(On);function n(){let e=Date.now();for(let[t,n]of a.current.entries())e-n>An&&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()},kn),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 Nn(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 Pn(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 Fn(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&&(!Nn(f,i.hooks)||!Pn(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`,...W()},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`,...W()},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`,...W()},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 In({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 Ln({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 Rn(){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 zn({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:_}=Fn(e,t);if(i)return(0,D.jsx)(Rn,{});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)(In,{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)(In,{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)(Ln,{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 Bn({open:e,onClose:t,title:n,subtitle:r,children:i,footer:a,size:o=`md`}){let s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(t);return l.current=t,(0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement;let t=document.body.style.overflow;document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&(e.preventDefault(),l.current())};return document.addEventListener(`keydown`,n),s.current?.focus(),()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=t,c.current?.focus?.()}},[e]),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 Vn=`http://www.w3.org/2000/svg`;function Hn({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="${Vn}">${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 Un({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)(Hn,{markup:e.glyph,size:Math.round(t*.55)})})}function Wn({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 Gn(){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 Kn({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 qn(e,t){return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}function Jn({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)(zn,{agentId:e,projectDir:t})})})]})}function Yn({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`,...W()}})).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`,...W()},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`,...W()},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`,ee=u?`Saving…`:e.pinned?`Pinned ✓`:`Set as my agent`,A=u||e.pinned;return(0,D.jsxs)(Bn,{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: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:ee})]}),children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-4 mb-4`,children:[(0,D.jsx)(Un,{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)(Wn,{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()?qn(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:qn(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)(Kn,{text:C})]}),(0,D.jsx)(Jn,{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)(Xn,{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 Xn({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 Zn({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)(Un,{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)(Wn,{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)(Gn,{})]})}function Qn(){let{data:e,refetch:t}=U(`/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-6xl mx-auto`,children:[(0,D.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3 lg:items-start`,children:[(0,D.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,D.jsxs)(`section`,{"data-tutorial":`agents-active`,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)(Un,{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)(Wn,{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`,...W()},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`,{"data-tutorial":`agents-filter`,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`,{"data-tutorial":`agents-list`,className:`ss-list`,children:o.map(e=>(0,D.jsx)(Zn,{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.jsxs)(`div`,{className:`space-y-6`,children:[(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)($n,{ctx:e.context,adapters:e.adapters}),(0,D.jsx)(tr,{})]})]}),l&&(0,D.jsx)(Yn,{agent:l,ctx:e.context,onClose:()=>a(null),onInstalled:()=>t()})]})}function $n({ctx:e,adapters:t}){let{data:n}=U(`/api/json/adapters/recent`),r=t.find(e=>e.active)??null,i=t.filter(e=>e.detected);return(0,D.jsxs)(`section`,{"data-tutorial":`agents-connections`,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)(er,{label:`Daemon`,status:`on`,detail:`Running — watching tool calls in real time.`}),(0,D.jsx)(er,{label:`Active AI agent`,status:r?`on`:`off`,detail:r?`${r.displayName} (${r.vendor})`:`Nothing detected yet — install an adapter below.`}),(0,D.jsx)(er,{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:qn(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 er({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 tr(){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`,...W()},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 nr(e,t){if(!e)return;let n=typeof e;if(n===`string`||n===`number`||n===`bigint`){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)nr(n,t);return}if(n===`object`)for(let[n,r]of Object.entries(e))r&&t.push(n)}function rr(...e){let t=[];for(let n of e)nr(n,t);return t.join(` `)}function ir(e,t){return n=>{let r=[e],i=t?.variants;if(i){let e=i,a=t?.defaultVariants??{},o=n??{};for(let[t,n]of Object.entries(e)){let e=o[t]??a[t];typeof e==`string`&&r.push(n[e])}}return r.push(n?.class,n?.className),rr(...r)}}var ar={block:`display`,"inline-block":`display`,inline:`display`,flex:`display`,"inline-flex":`display`,table:`display`,"inline-table":`display`,grid:`display`,"inline-grid":`display`,contents:`display`,hidden:`display`,"flow-root":`display`,"list-item":`display`,"sr-only":`display`,"not-sr-only":`display`,static:`position`,fixed:`position`,absolute:`position`,relative:`position`,sticky:`position`,"flex-row":`flex-direction`,"flex-row-reverse":`flex-direction`,"flex-col":`flex-direction`,"flex-col-reverse":`flex-direction`,"flex-wrap":`flex-wrap`,"flex-wrap-reverse":`flex-wrap`,"flex-nowrap":`flex-wrap`,"flex-1":`flex`,"flex-auto":`flex`,"flex-initial":`flex`,"flex-none":`flex`,grow:`flex-grow`,"grow-0":`flex-grow`,shrink:`flex-shrink`,"shrink-0":`flex-shrink`,"box-border":`box-sizing`,"box-content":`box-sizing`,visible:`visibility`,invisible:`visibility`,collapse:`visibility`,isolate:`isolation`,"isolation-auto":`isolation`,"text-left":`text-align`,"text-center":`text-align`,"text-right":`text-align`,"text-justify":`text-align`,"text-start":`text-align`,"text-end":`text-align`,uppercase:`text-transform`,lowercase:`text-transform`,capitalize:`text-transform`,"normal-case":`text-transform`,italic:`font-style`,"not-italic":`font-style`,underline:`text-decoration`,overline:`text-decoration`,"line-through":`text-decoration`,"no-underline":`text-decoration`,truncate:`text-overflow`,"text-ellipsis":`text-overflow`,"text-clip":`text-overflow`,antialiased:`font-smoothing`,"subpixel-antialiased":`font-smoothing`,"font-sans":`font-family`,"font-serif":`font-family`,"font-mono":`font-family`,"whitespace-normal":`whitespace`,"whitespace-nowrap":`whitespace`,"whitespace-pre":`whitespace`,"whitespace-pre-line":`whitespace`,"whitespace-pre-wrap":`whitespace`,"whitespace-break-spaces":`whitespace`,"pointer-events-none":`pointer-events`,"pointer-events-auto":`pointer-events`,border:`border-w`,"border-solid":`border-style`,"border-dashed":`border-style`,"border-dotted":`border-style`,"border-double":`border-style`,"border-hidden":`border-style`,"border-none":`border-style`,"border-collapse":`border-collapse`,"border-separate":`border-collapse`,"object-contain":`object-fit`,"object-cover":`object-fit`,"object-fill":`object-fit`,"object-none":`object-fit`,"object-scale-down":`object-fit`,rounded:`rounded`,shadow:`shadow`,transition:`transition`},or=new Set([`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`7xl`,`8xl`,`9xl`]),sr=new Set([`t`,`r`,`b`,`l`,`tl`,`tr`,`br`,`bl`,`s`,`e`,`ss`,`se`,`ee`,`es`]),cr=new Set([`x`,`y`,`t`,`r`,`b`,`l`,`s`,`e`]);function lr(e){let t=e;if(t.startsWith(`!`)&&(t=t.slice(1)),t.endsWith(`!`)&&(t=t.slice(0,-1)),t.startsWith(`-`)&&(t=t.slice(1)),t===``)return null;let n=ar[t];if(n)return n;let r=t.indexOf(`-`);if(r===-1)return null;let i=t.slice(0,r),a=t.slice(r+1),o=a.split(`-`)[0]??``;switch(i){case`p`:case`px`:case`py`:case`pt`:case`pr`:case`pb`:case`pl`:case`ps`:case`pe`:return`pad-${i}`;case`m`:case`mx`:case`my`:case`mt`:case`mr`:case`mb`:case`ml`:case`ms`:case`me`:return`mar-${i}`;case`w`:return`width`;case`h`:return`height`;case`size`:return`size`;case`min`:return o===`w`?`min-width`:o===`h`?`min-height`:null;case`max`:return o===`w`?`max-width`:o===`h`?`max-height`:null;case`gap`:return o===`x`?`gap-x`:o===`y`?`gap-y`:`gap`;case`z`:return`z-index`;case`opacity`:return`opacity`;case`order`:return`order`;case`basis`:return`flex-basis`;case`aspect`:return`aspect`;case`cursor`:return`cursor`;case`leading`:return`line-height`;case`tracking`:return`letter-spacing`;case`rounded`:return sr.has(o)?`rounded-${o}`:`rounded`;case`shadow`:return`shadow`;case`items`:return`align-items`;case`justify`:return o===`items`?`justify-items`:o===`self`?`justify-self`:`justify-content`;case`self`:return`align-self`;case`content`:return`align-content`;case`transition`:return`transition`;case`duration`:return`duration`;case`delay`:return`delay`;case`ease`:return`ease`;case`top`:return`top`;case`right`:return`right`;case`bottom`:return`bottom`;case`left`:return`left`;case`inset`:return o===`x`?`inset-x`:o===`y`?`inset-y`:`inset`;case`overflow`:return o===`x`?`overflow-x`:o===`y`?`overflow-y`:`overflow`;case`font`:return`font-weight`;case`text`:return ur(a);case`bg`:return`bg-color`;case`border`:return dr(a);case`col`:return o===`span`?`col-span`:`col-start-end`;case`row`:return o===`span`?`row-span`:`row-start-end`;case`grid`:return`grid-${o}`;default:return null}}function ur(e){return or.has(e)||e.startsWith(`[`)&&/^\[(length:|[\d.]+(px|rem|em|vh|vw|ch|ex|%))/.test(e)?`font-size`:`text-color`}function dr(e){let t=e.split(`-`)[0]??``;return cr.has(t)?`border-w-${t}`:/^\d+$/.test(t)?`border-w`:t===`spacing`?`border-spacing`:`border-color`}function fr(e){let t=0,n=-1;for(let r=0;r<e.length;r++){let i=e[r];i===`[`||i===`(`?t++:i===`]`||i===`)`?t--:i===`:`&&t===0&&(n=r)}return n===-1?{variants:``,base:e}:{variants:e.slice(0,n),base:e.slice(n+1)}}function pr(e){let t=e.split(/\s+/).filter(Boolean),n=new Set,r=[];for(let e=t.length-1;e>=0;e--){let i=t[e],{variants:a,base:o}=fr(i),s=lr(o),c=s===null?`raw:${i}`:`${a}|${s}`;n.has(c)||(n.add(c),r.push(i))}return r.reverse(),r.join(` `)}function mr(...e){return pr(rr(e))}function hr(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 gr(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 _r(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=ir(`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 G({className:e,variant:t,...n}){return(0,D.jsx)(`span`,{className:mr(vr({variant:t,className:e})),...n})}var yr=e=>e,br=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}),xr=br(2),Sr=br(3),Cr=br(4),wr=br(5),Tr={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},Er={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},Dr={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 Or(e=1.70158){let t=e;return e=>e*e*((t+1)*e-t)}function kr(e=1.70158){let t=e;return e=>{let n=e-1;return n*n*((t+1)*n+t)+1}}function Ar(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 jr(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 Mr(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 Nr(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 Pr=7.5625,Fr=2.75,Ir=e=>{if(e<1/Fr)return Pr*e*e;if(e<2/Fr){let t=e-1.5/Fr;return Pr*t*t+.75}if(e<2.5/Fr){let t=e-2.25/Fr;return Pr*t*t+.9375}let t=e-2.625/Fr;return Pr*t*t+.984375},Lr=e=>1-Ir(1-e),Rr=e=>e<.5?(1-Ir(1-2*e))/2:(1+Ir(2*e-1))/2;function zr(e){let t=Math.max(1,Math.floor(e));return e=>e>=1?1:e<=0?0:Math.floor(e*t)/t}function Br(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 Vr(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 Hr={linear:yr,inQuad:xr.in,outQuad:xr.out,inOutQuad:xr.inOut,inCubic:Sr.in,outCubic:Sr.out,inOutCubic:Sr.inOut,inQuart:Cr.in,outQuart:Cr.out,inOutQuart:Cr.inOut,inQuint:wr.in,outQuint:wr.out,inOutQuint:wr.inOut,inSine:Tr.in,outSine:Tr.out,inOutSine:Tr.inOut,inExpo:Er.in,outExpo:Er.out,inOutExpo:Er.inOut,inCirc:Dr.in,outCirc:Dr.out,inOutCirc:Dr.inOut,inBack:Or(),outBack:kr(),inOutBack:Ar(),inElastic:Mr(),outElastic:jr(),inOutElastic:Nr(),inBounce:Lr,outBounce:Ir,inOutBounce:Rr};function Ur(e){if(typeof e==`function`)return e;if(e===void 0)return Hr.outCubic;let t=Hr[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 jr(t[0],t[1]);case`inElastic`:return Mr(t[0],t[1]);case`inOutElastic`:return Nr(t[0],t[1]);case`outBack`:return kr(t[0]);case`inBack`:return Or(t[0]);case`inOutBack`:return Ar(t[0]);case`steps`:return zr(t[0]??4);case`cubicBezier`:return t.length>=4?Br(t[0],t[1],t[2],t[3]):Hr.outCubic;default:return Hr.outCubic}}return Hr.outCubic}function Wr(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 Gr(e,t={}){let n=t.start??0,r=t.direction===`reverse`;return(i,a)=>{if(a<=0)return n;let o=Wr(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 Kr=new Set([`duration`,`delay`,`ease`,`loop`,`alternate`,`onBegin`,`onUpdate`,`onComplete`]);function qr(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 Jr(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 Yr(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Xr=/^(-?\d*\.?\d+)([a-z%]*)$/i;function Zr(e){if(typeof e==`number`)return{value:e,unit:``};let t=e.trim().match(Xr);return t?{value:parseFloat(t[1]),unit:t[2]??``}:{value:0,unit:``}}function Qr(e){return e.unit===``?`${e.value}`:`${e.value}${e.unit}`}var $r=new Set([`translate`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`]),ei=new WeakMap;function ti(e){let t=ei.get(e);return t||(t={values:{}},ei.set(e,t)),t}function ni(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 ri(e,t,n){if($r.has(t)){let r=ti(e);r.values[t]=n,e.style.transform=ni(r);return}if(t===`opacity`){e.style.opacity=`${n.value}`;return}e.style.setProperty(t,Qr(n))}function ii(e,t){return $r.has(t)?ti(e).values[t]||{value:+!!t.startsWith(`scale`),unit:``}:Zr(e.style.getPropertyValue(t)||(typeof window<`u`?window.getComputedStyle(e).getPropertyValue(t):``)||(t===`opacity`?`1`:`0`))}function ai(e,t,n){return e+(t-e)*n}function oi(e,t,n){return e===void 0?0:typeof e==`number`?e:e(t,n)}function si(e){if(e&&typeof e==`object`&&`spring`in e){let t=Vr(e.spring);return{ease:t.fn,duration:t.duration}}return{ease:Ur(e),duration:null}}var ci=0,li=new Set;function ui(e){for(let t of li){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)ri(n.el,e.name,di(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&&ri(n.el,e.name,di(e.from,e.to,t))}n.el!==null&&r.onUpdate?.(d,n.el,n.index)}for(let e of[...li])e.done&&li.delete(e);if(li.size===0){ci=0;return}ci=requestAnimationFrame(ui)}function di(e,t,n){let r=e.unit||t.unit;return{value:ai(e.value,t.value,n),unit:r}}function fi(){ci===0&&(typeof requestAnimationFrame>`u`||(ci=requestAnimationFrame(ui)))}function pi(e,t){let n=Jr(e),r=n.length,i=Object.keys(t).filter(e=>!Kr.has(e)),a=Yr(),{ease:o,duration:s}=si(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=qr(r);if(i===null)continue;let s,c;Array.isArray(i)?(s=Zr(i[0]),c=Zr(i[1])):(s=ii(e,n),c=Zr(i)),a.push({name:n,from:s,to:c,ease:o})}return{el:e,index:n,props:a,duration:c,delay:oi(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)ri(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)ri(r,e.name,e.from);let s={target:i,start:o,options:t,done:!1};l.push(s),li.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,li.delete(e)}},finished:Promise.all(u).then(()=>void 0),get done(){return p||l.every(e=>e.done)}}}var mi=ir(`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 hi(e,t){if(Yr())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),pi(i,{scale:[0,1],opacity:[.22,0],duration:540,ease:`outExpo`,onComplete:()=>{i.remove()}})}var K=_.forwardRef(({className:e,variant:t,size:n,onMouseDown:r,onClick:i,...a},o)=>(0,D.jsx)(`button`,{ref:o,className:mr(mi({variant:t,size:n,className:e})),onMouseDown:e=>{hi(e.currentTarget,e),r?.(e)},onClick:i,...a}));K.displayName=`Button`;var gi=ir(`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,D.jsx)(`div`,{className:mr(gi({variant:t,className:e})),...n})}function J({className:e,...t}){return(0,D.jsx)(`div`,{className:mr(`flex items-center justify-between gap-2 px-4 pt-3 pb-2 shrink-0`,e),...t})}function Y({className:e,...t}){return(0,D.jsx)(`div`,{className:mr(`px-4 py-3 flex-1 min-h-0 overflow-auto`,e),...t})}function _i({className:e,children:t,...n}){return(0,D.jsx)(`pre`,{className:mr(`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 yi(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 bi=220,xi=90;function Si({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),yi(e).then(e=>{e&&o(e)});let t=vi.get(e);t&&t.status===`ok`&&o(t.data)},bi)},[e,p,f]),h=(0,_.useCallback)(()=>{f(),d.current=setTimeout(()=>{i(!1)},xi)},[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)(Ci,{data:a}):(0,D.jsx)(`span`,{className:`ss-rule-popover__loading`,children:`loading rule…`})})]})}function Ci({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 wi={dashboard:`dashboard`,native:`native`,tty:`tty`,cli:`cli`},Ti={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},Ei=[`all`,`allow`,`block`,`ask`,`force`,`log`],Di={allow:`text-emerald-300`,block:`text-red-300`,ask:`text-sky-300`,force:`text-amber-300`,log:`text-[var(--color-fg-3)]`},Oi=[`allow`,`ask`,`block`,`disable`],ki={allow:{label:`Always allow`,blurb:`Auto-approve matching tool calls — no prompt.`,toast:`Now always allowing`,tone:`#3fb950`},ask:{label:`Ask every time`,blurb:`Pause and wait for a manual approval each time.`,toast:`Now asking before`,tone:`#58a6ff`},block:{label:`Always block`,blurb:`Auto-deny matching tool calls — no prompt.`,toast:`Now always blocking`,tone:`#ff6f6f`},disable:{label:`Disable rule`,blurb:`Turn the rule off — it stops evaluating entirely.`,toast:`Disabled`,tone:`#8b949e`}};function Ai(e){return new Date(e*1e3).toLocaleString()}function ji(e,t){if(!t)return``;let n=t-e;return n<60?`${n}s`:`${Math.round(n/60)}m`}async function Mi(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:W()})}async function Ni(e,t){try{return await(await fetch(`/api/rules/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,enabled:t})})).json()}catch(e){return{error:String(e)}}}async function Pi(e,t,n){try{let r=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t,decision:n})}),i=await r.json().catch(()=>({}));return r.ok?{ok:i.ok!==!1,error:i.error}:{ok:!1,error:i.error??`HTTP ${r.status}`}}catch(e){return{ok:!1,error:String(e)}}}function Fi(e,t){return e===`disable`?{decision:t.decision,enabled:!1}:{decision:e,enabled:!0}}function Ii(e){return e.enabled?e.decision===`allow`?`allow`:e.decision===`ask`?`ask`:e.decision===`block`?`block`:null:`disable`}function Li(e,t){if(e===`disable`)return`This rule will stop evaluating tool calls.`;let n=[];return t.decision!==e&&n.push(`decision ${t.decision} → ${e}`),t.enabled||n.push(`rule switched back on`),n.length?n.join(` · `):`No change.`}function Ri(e){try{let t=JSON.parse(e).input;return t&&typeof t==`object`?_r(``,JSON.stringify(t)):_r(``,e)}catch{return e.slice(0,80)}}function zi(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 Bi({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 Vi(){return(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)(`line`,{x1:`4`,y1:`21`,x2:`4`,y2:`14`}),(0,D.jsx)(`line`,{x1:`4`,y1:`10`,x2:`4`,y2:`3`}),(0,D.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`3`}),(0,D.jsx)(`line`,{x1:`20`,y1:`21`,x2:`20`,y2:`16`}),(0,D.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`3`}),(0,D.jsx)(`line`,{x1:`1`,y1:`14`,x2:`7`,y2:`14`}),(0,D.jsx)(`line`,{x1:`9`,y1:`8`,x2:`15`,y2:`8`}),(0,D.jsx)(`line`,{x1:`17`,y1:`16`,x2:`23`,y2:`16`})]})}function Hi(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 Ui(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 Wi({toast:e,ruleMessage:t,ruleId:n,onDismiss:r,onUndo:i}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>(s.current=setTimeout(r,6e3),()=>{s.current&&clearTimeout(s.current)}),[r]),(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:[e,` `,(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-0)]`,children:t})]}),(0,D.jsx)(`button`,{type:`button`,disabled:a,onClick:async()=>{o(!0),await i(),r()},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 change to ${n}`,children:a?`undoing…`:`undo`}),(0,D.jsx)(`button`,{type:`button`,onClick:r,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 Gi({target:e,current:t,rulesLoaded:n,onClose:r,onConfirm:i}){let[a,o]=(0,_.useState)(e?.suggest??null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);if(!e)return null;let d=t?Ii(t):null,f=a!==null&&a===d,p=a!==null&&t!==null&&!f&&!s,m=null;return e.pendingId&&a&&!f&&(m=a===`allow`?`The tool call waiting on this rule will be approved.`:a===`ask`?`The waiting tool call stays pending for you to decide.`:`The tool call waiting on this rule will be denied.`),(0,D.jsxs)(Bn,{open:!!e,onClose:r,size:`sm`,title:`Adjust this rule`,subtitle:`Change what this rule does when it matches — or switch it off. Every change here is reversible.`,footer:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:s,onClick:r,children:`Cancel`}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,style:{"--tone":a&&!f?ki[a].tone:`var(--color-brand)`},disabled:!p,onClick:async()=>{if(!a||!t)return;c(!0),u(null);let n=await i(e,t,a);if(c(!1),!n.ok){u(n.message??`Could not apply the change.`);return}r()},children:s?`Applying…`:a&&!f?ki[a].label:`Confirm`})]}),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.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 flex-wrap`,children:[(0,D.jsx)(Si,{ruleId:e.ruleId,children:(0,D.jsx)(`code`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] break-all`,children:e.ruleId})}),t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(G,{variant:Ti[t.decision]??`gray`,children:t.decision}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:t.enabled?`enabled`:`disabled`})]})]})]})}),(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.`]})]})})]}),n?t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-4 mb-2`,children:`what should it do?`}),(0,D.jsx)(`div`,{role:`radiogroup`,"aria-label":`Choose what this rule does`,className:`space-y-1.5`,children:Oi.map(e=>{let t=ki[e],n=e===d,r=e===a;return(0,D.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:n||s,onClick:()=>o(e),className:`w-full flex items-start gap-3 px-3 py-2.5 rounded-md border text-left transition-colors ${r?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/8`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)]`} ${n?`opacity-55 cursor-not-allowed`:`cursor-pointer hover:border-[var(--color-line-2)]`}`,children:[(0,D.jsx)(`span`,{className:`mt-0.5 shrink-0 flex items-center justify-center w-3.5 h-3.5 rounded-full border ${r?`border-[var(--color-brand)]`:`border-[var(--color-fg-4)]`}`,children:r&&(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-[var(--color-brand)]`})}),(0,D.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium`,style:{color:t.tone},children:t.label}),n&&(0,D.jsx)(G,{variant:`gray`,children:`current`})]}),(0,D.jsx)(`span`,{className:`block text-xs text-[var(--color-fg-3)] mt-0.5`,children:t.blurb})]})]},e)})}),a&&!f&&(0,D.jsx)(`p`,{className:`mt-3 text-xs font-mono text-[var(--color-fg-2)]`,children:Li(a,t)}),f&&(0,D.jsx)(`p`,{className:`mt-3 text-xs text-[var(--color-fg-3)]`,children:`The rule is already set this way — pick a different option.`}),m&&(0,D.jsx)(`p`,{className:`mt-1.5 text-xs text-[var(--color-fg-3)]`,children:m})]}):(0,D.jsx)(`p`,{className:`mt-3 text-xs text-amber-300`,role:`alert`,children:`This rule is no longer present in your ruleset, so it can't be adjusted. It may have been deleted.`}):(0,D.jsx)(`p`,{className:`mt-3 text-xs text-[var(--color-fg-3)]`,children:`Loading this rule's current state…`}),(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-3 leading-relaxed`,children:[`Reversible — undo straight after, or open`,` `,(0,D.jsx)(`a`,{href:`/rules`,className:`text-[var(--color-brand)] hover:underline`,children:`Rules`}),` `,`anytime.`]}),l&&(0,D.jsx)(`p`,{className:`mt-3 text-xs text-red-300`,role:`alert`,children:l})]})}function Ki(){let e=Ge([`pending-changed`,`rules-changed`]),{data:t,refetch:n}=U(`/api/json/pending`,[e[`pending-changed`]]),{data:r}=U(`/api/json/approvals`,[e[`pending-changed`]]),{data:i,refetch:a}=U(`/api/json/rules`,[e[`rules-changed`]]),[o,s]=(0,_.useState)(`all`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(new Set),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),g=(0,_.useMemo)(()=>{let e=new Map;for(let t of i?.rulesets??[])for(let n of t.rules??[])e.has(n.id)||e.set(n.id,{decision:n.decision,enabled:n.enabled,file:t.file});return e},[i]),v=i!=null,y=(0,_.useMemo)(()=>Hi(r??[],t??[]),[r,t]),b=(0,_.useMemo)(()=>{let e=new Map;for(let t of y)e.set(t.ruleId,t.count);return e},[y]),x=Math.floor(Date.now()/1e3),S=(r??[]).filter(e=>e.created_at>=x-86400).length,C=(r??[]).reduce((e,t)=>(e[t.decision]=(e[t.decision]??0)+1,e),{}),w=(r??[]).filter(e=>{if(o!==`all`&&e.decision!==o)return!1;if(c){let t=c.toLowerCase(),n=Ri(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 T(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function E(e,t,r){let i=Fi(r,t),o={decision:t.decision,enabled:t.enabled};if(i.decision!==t.decision){let n=await Pi(e.ruleId,t.file,i.decision);if(!n.ok)return{ok:!1,message:n.error??`Could not change the rule decision.`}}if(i.enabled!==t.enabled){let t=await Ni(e.ruleId,i.enabled);if(t.error||t.ok===!1)return{ok:!1,message:t.error??`Could not change the rule state.`}}if(e.pendingId)try{r===`allow`?await Mi(e.pendingId,`allow`):r!==`ask`&&await Mi(e.pendingId,`block`)}catch{}return h({ruleId:e.ruleId,ruleMessage:e.ruleMessage,file:t.file,action:r,prior:o,end:i}),n(),a(),{ok:!0}}async function O(e){e.end.decision!==e.prior.decision&&await Pi(e.ruleId,e.file,e.prior.decision),e.end.enabled!==e.prior.enabled&&await Ni(e.ruleId,e.prior.enabled),n(),a()}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 · adjust or disable noisy rules`})]}),(0,D.jsxs)(`div`,{"data-tutorial":`appr-stats`,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)(Bi,{label:`pending`,value:t?.length??0,tone:`text-amber-300`}),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),[`allow`,`block`,`ask`,`force`,`log`].map(e=>(0,D.jsx)(Bi,{label:e,value:C[e]??0,tone:Di[e]},e)),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),(0,D.jsx)(Bi,{label:`last 24h`,value:S})]}),y.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`]}),y.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)(Si,{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 `,Ui(e.lastSeen)]})]}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill`,onClick:()=>p({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:e.count,suggest:`disable`}),"aria-label":`Adjust rule ${e.ruleId}`,children:[(0,D.jsx)(Vi,{}),`Adjust`]})]},e.ruleId))]}),t&&t.length>0&&(0,D.jsxs)(`section`,{"data-tutorial":`appr-pending`,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=b.get(e.ruleId)??0;return(0,D.jsxs)(q,{className:`border-l-2 border-l-amber-400/60`,children:[(0,D.jsxs)(J,{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)(K,{size:`sm`,variant:`primary`,onClick:async()=>{await Mi(e.id,`allow`),n()},children:`approve`}),(0,D.jsx)(K,{size:`sm`,variant:`danger`,onClick:async()=>{await Mi(e.id,`block`),n()},children:`deny`}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill`,onClick:()=>p({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:t||1,pendingId:e.id}),"aria-label":`Adjust rule ${e.ruleId}`,children:[(0,D.jsx)(Vi,{}),`Adjust rule`]})]})]}),(0,D.jsxs)(Y,{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)(Si,{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)(_i,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id)})})]}),(0,D.jsxs)(`section`,{"data-tutorial":`appr-history`,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:Ei.map(e=>(0,D.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${o===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:c,onChange:e=>l(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`}):w.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)(q,{children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:w.map(e=>{let t=u.has(e.id),n=Ri(e.input),r=ji(e.created_at,e.resolved_at);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`button`,{onClick:()=>T(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:Ai(e.resolved_at??e.created_at)}),(0,D.jsx)(G,{variant:Ti[e.decision]??`gray`,children:e.decision}),e.source&&(0,D.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)]`,title:`Approval source: ${e.source}`,children:wi[e.source]??e.source}),(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)(Si,{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:Ai(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:Ai(e.resolved_at)})]}),e.rule_id&&(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill ml-auto`,onClick:()=>p({ruleId:e.rule_id,ruleMessage:e.rule_message||e.rule_id,fireCount:b.get(e.rule_id)??1}),"aria-label":`Adjust rule ${e.rule_id}`,children:[(0,D.jsx)(Vi,{}),`Adjust 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)(_i,{children:zi(e.input)})]})]},e.id)})})})]}),(0,D.jsx)(Gi,{target:f,current:f?g.get(f.ruleId)??null:null,rulesLoaded:v,onClose:()=>p(null),onConfirm:E},f?.ruleId??`closed`),m&&(0,D.jsx)(Wi,{toast:ki[m.action].toast,ruleMessage:m.ruleMessage,ruleId:m.ruleId,onDismiss:()=>h(null),onUndo:()=>O(m)})]})}function qi(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 Ji(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 Yi(){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=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/audit-config`);if(!e.ok)return;let n=await e.json();t(n),a(String(n.config.maxRows)),s(String(n.config.absoluteMaxRows)),l(String(n.config.minRetentionHours)),d(n.config.maxBytes==null?``:String(Math.round(n.config.maxBytes/(1024*1024))))}catch{}},[]);(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&&` · ${qi(e.usage.bytes)}`,v!=null&&` · spans ${Ji(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 Xi={"http-json":`HTTP webhook (generic JSON)`,"splunk-hec":`Splunk HEC`,datadog:`Datadog logs`,"file-jsonl":`Local JSONL file`};function Zi(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 Qi(){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:Xi[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 ee=`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,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:ee,children:e.sinks.length===0?`no destinations`:`${e.sinks.filter(e=>e.enabled).length} of ${e.sinks.length} active`})]}),(0,D.jsx)(`span`,{className:ee,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:Xi[e.type]})]}),(0,D.jsxs)(`div`,{className:`${ee} truncate`,children:[e.endpoint??e.path??``,t&&(0,D.jsxs)(D.Fragment,{children:[` · `,`sent: `,t.last_status??`—`,` · last:`,` `,Zi(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:M,children:e.enabled?`disable`:`enable`}),(0,D.jsx)(`button`,{onClick:()=>S(e),disabled:f,className:M,children:`edit`}),(0,D.jsx)(`button`,{onClick:()=>E(e.id),disabled:f,className:`${M} 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:ee,children:`add destination:`}),(e.sinkTypes??[]).map(e=>(0,D.jsxs)(`button`,{onClick:()=>x(e),className:M,children:[`+ `,Xi[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,` · `,Xi[o.type]]}),(0,D.jsx)(`button`,{onClick:()=>l(e=>!e),className:M,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:j,children:`Display name`}),(0,D.jsx)(`input`,{type:`text`,value:o.name,onChange:e=>s({...o,name:e.target.value}),className:`${A} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,children:`Endpoint URL`}),(0,D.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,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,children:`File path`}),(0,D.jsx)(`input`,{type:`text`,value:o.path??``,onChange:e=>s({...o,path:e.target.value}),className:`${A} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} 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:j,children:`Token`}),(0,D.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,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} 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:j,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:`${A} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} w-full`})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,D.jsxs)(`label`,{className:j,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:`${A} w-full leading-snug`})]})]}),c&&(0,D.jsx)(`textarea`,{value:u,rows:20,onChange:e=>d(e.target.value),className:`${A} 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:M,children:`send test event`}),(0,D.jsx)(`button`,{onClick:C,disabled:f,className:M,children:`cancel`})]})]})]})]})}var $i={__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 ea(e){return e?$i[e.toLowerCase()]||`Use the ${e.replace(/^_+/,``)} tool`:`Take an action`}function ta(e){return e?{"claude-code":`Claude Code`,claudecode:`Claude Code`,cursor:`Cursor`,copilot:`GitHub Copilot`,codex:`OpenAI Codex`,"codex-desktop":`Codex Desktop`,gemini:`Gemini`,antigravity:`Antigravity`,pi:`Pi`,generic:`AI agent`,daemon:`SigmaShake`}[e.toLowerCase()]??e:`AI agent`}function na(e){return e?e.startsWith(`__`):!1}function ra(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 ia(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 aa(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 oa(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 la(e,t){let n=e??``,r=n.toLowerCase(),i=ea(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=ia(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=ra(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=ra(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=ra(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=aa(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=aa(a)??ra(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=oa(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=aa(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 ua({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 da({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)(ua,{val:t})})]},e))})}var fa={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},pa={allow:`Allowed`,block:`Blocked`,force:`Forced`,ask:`Held`,log:`Logged`},ma={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 ha(e){return e==null?null:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}function ga({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 _a({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 va({row:e}){let[t,n]=(0,_.useState)(`idle`);return(0,D.jsx)(`button`,{type:`button`,disabled:t===`saving`||t===`done`,title:`Allow this blocked action through from now on — writes a high-priority allow rule that overrides the block. Reversible from Rules.`,onClick:async r=>{if(r.stopPropagation(),!(t===`saving`||t===`done`)){n(`saving`);try{n((await fetch(`/api/autopilot/allow-through`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({tool:e.tool,input:e.input,rule_id:e.rule_id})})).ok?`done`:`error`)}catch{n(`error`)}}},className:`inline-flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider rounded-sm px-2 py-1 transition-colors cursor-pointer disabled:cursor-default ${t===`done`?`border border-emerald-500/40 text-emerald-300 bg-emerald-500/10`:t===`error`?`border border-red-500/40 text-red-300 hover:bg-red-500/10`:`border border-emerald-500/30 text-emerald-300/90 bg-emerald-500/5 hover:text-emerald-200 hover:border-emerald-500/50 hover:bg-emerald-500/10`}`,children:t===`done`?`✓ allowed through`:t===`saving`?`allowing…`:t===`error`?`failed — retry`:`Allow through`})}function ya({row:e,defaultExpanded:t=!1}){let[n,r]=(0,_.useState)(t),i=(0,_.useRef)(null),a=(0,_.useRef)(!0),o=_r(e.tool,e.input),s=o&&o.length>0?o:e.input&&e.input!==`{}`&&e.input!==``?e.input:`—`,c=fa[e.decision]??`gray`,l=ma[e.decision]??`border-l-[var(--color-line-2)]`,u=gr(e.timestamp),d=ha(e.duration_ns),f=la(e.tool,e.input),p=e.decision===`block`||e.decision===`deny`;(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(Yr()){e.style.maxHeight=n?`none`:`0`,e.style.opacity=n?`1`:`0`;return}if(n){let t=e.scrollHeight;pi(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;pi(e,{"max-height":[`${t}px`,`0px`],opacity:[1,0],duration:180,ease:`outCubic`})}}},[n]);let m=(()=>{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:hr(e.timestamp)}),(0,D.jsx)(G,{variant:c,className:`shrink-0 w-20 justify-center`,children:pa[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}),!na(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:ta(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},"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)(ga,{label:`When`,value:u}),(0,D.jsx)(ga,{label:`Decision`,children:(0,D.jsx)(G,{variant:c,children:pa[e.decision]??e.decision})}),(0,D.jsx)(ga,{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)(ga,{label:`AI agent`,value:ta(e.client)}),e.rule_id&&(0,D.jsx)(ga,{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)(ga,{label:`Source File`,value:e.source_file,mono:!0}),d&&(0,D.jsx)(ga,{label:`Latency`,value:d,mono:!0}),e.rules_evaluated!=null&&(0,D.jsx)(ga,{label:`Rules Evaluated`,value:`${e.rules_evaluated}`,mono:!0})]}),e.rule_message&&(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:`Rule reason`}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-1)] leading-relaxed break-words`,children:e.rule_message})]}),(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)(da,{inputJson:e.input})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p&&(0,D.jsx)(va,{row:e}),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)(_a,{text:m})]})]})})]})}var ba=[``,`allow`,`block`,`force`,`ask`,`log`],xa=[``,`claude-code`,`gemini`,`antigravity`,`cursor`,`copilot`,`codex`,`pi`,`generic`],Sa=[50,100,250,500],Ca=100;function wa(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(Ca),[u,d]=(0,_.useState)(0),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),{activeProject:y}=Ze();Ge([`activity-updated`]),(0,_.useEffect)(()=>{d(0)},[y]),(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`),y&&y!==`all`&&r.set(`project`,y),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,y]);let b=e=>t=>{e(t.target.value),d(0)},x=(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]),S=f?.total??0,C=Math.floor(u/c)+1,w=Math.max(1,Math.ceil(S/c)),T=S===0?0:u+1,E=Math.min(u+(f?.rows.length??0),S),O=`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`,k=`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:[`· `,S.toLocaleString(),` action`,S===1?``:`s`,` on record`]})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`audit-filters`,className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`select`,{id:`audit-filter-decision`,value:e,onChange:b(t),className:O,children:ba.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:b(a),className:O,children:xa.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:b(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:O,title:`Rows per page`,children:Sa.map(e=>(0,D.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]})]}),(0,D.jsx)(`div`,{"data-tutorial":`audit-config`,children:(0,D.jsx)(Yi,{})}),(0,D.jsx)(`div`,{"data-tutorial":`audit-sinks`,children:(0,D.jsx)(Qi,{})}),(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&&x.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.`:S===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`})]}),x.length>0&&(0,D.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,D.jsx)(ya,{row:e},e.id))}),f&&S>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 `,T.toLocaleString(),`–`,E.toLocaleString(),` `,`of `,S.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{onClick:()=>d(0),disabled:u===0,className:k,children:`⟪ first`}),(0,D.jsx)(`button`,{onClick:()=>d(Math.max(0,u-c)),disabled:u===0,className:k,children:`‹ prev`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`page `,C,` / `,w]}),(0,D.jsx)(`button`,{onClick:()=>d(f.nextOffset==null?u:f.nextOffset),disabled:f.nextOffset==null,className:k,children:`next ›`}),(0,D.jsx)(`button`,{onClick:()=>d((w-1)*c),disabled:f.nextOffset==null,className:k,children:`last ⟫`})]})]})]})}function Ta(e){return e?e.added+e.updated+e.removed:0}function Ea(){let[e,t]=(0,_.useState)(!0),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`merge`),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1);async function O(){l(!0),d(null);try{let t=new URLSearchParams;e||t.set(`config`,`0`),n||t.set(`presets`,`0`),i||t.set(`hub`,`0`),o.trim()&&t.set(`label`,o.trim());let r=await fetch(`/api/json/config/export?${t.toString()}`,{headers:W()});if(!r.ok)throw Error(`HTTP ${r.status}`);let a=await r.text(),s=JSON.parse(a),c=new Blob([a],{type:`application/json`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=`ssg-config-bundle.json`,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(l),d({kind:`ok`,text:`Downloaded ${s.rules.length} rule(s), ${s.presets.length} preset(s)${s.config?`, config.toml`:``}.`})}catch(e){d({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}}async function k(e){let t=e.target.files?.[0];t&&(h(t.name),b(null),S(null),p(await t.text()))}async function ee(){E(!0),S(null);try{let e=await(await fetch(`/api/json/pick-file`,{method:`POST`,headers:W()})).json();if(e.ok&&typeof e.content==`string`){b(null),h(e.name??`bundle.json`),p(e.content);return}if(e.reason===`user_cancelled`)return;if(e.reason===`no_picker_found`||e.reason===`no_display`){S({kind:`err`,text:`No native file picker available — drop the bundle below or paste its JSON.`});return}S({kind:`err`,text:e.error??`Could not open the file picker.`})}catch(e){S({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{E(!1)}}async function A(e){if(!f.trim())return S({kind:`err`,text:`Choose a bundle file first.`}),null;w(!0),S(null);try{let t=await fetch(`/api/json/config/import`,{method:`POST`,headers:{"content-type":`application/json`,...W()},body:JSON.stringify({text:f,mode:g,dryRun:e})}),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);return n}catch(e){return S({kind:`err`,text:e instanceof Error?e.message:String(e)}),null}finally{w(!1)}}async function j(){let e=await A(!0);e&&(b(e),Ta(e.counts)===0&&S({kind:`ok`,text:`Already up to date — nothing to apply.`}))}async function M(){let e=await A(!1);if(!e)return;b(null),p(``),h(``);let t=e.counts;S({kind:`ok`,text:`Imported: ${t?.added??0} added, ${t?.updated??0} updated, ${t?.removed??0} removed.${e.backupDir?` Backup → ${e.backupDir}`:``}`})}let N=y?.plan?.filter(e=>e.action!==`skip`)??[];return(0,D.jsxs)(`div`,{className:`p-4 space-y-4 max-w-3xl`,children:[(0,D.jsxs)(`header`,{children:[(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Export & Import`}),(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Share your configuration and rules with teammates, or restore them on another machine. Secrets (tokens, license, audit log) are never included.`})]}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`h2`,{className:`font-medium`,children:`Export your settings`})}),(0,D.jsxs)(Y,{className:`space-y-3`,children:[(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Bundles config.toml, every rule file, presets, and your installed hub rulesets into one JSON file.`}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),` `,`Include config.toml`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` `,`Include presets`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),` `,`Include hub-ruleset list`]})]}),(0,D.jsx)(`input`,{className:`hig-input w-full`,placeholder:`Optional label (e.g. Acme team baseline)`,value:o,onChange:e=>s(e.target.value)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(K,{onClick:O,disabled:c,children:c?`Exporting…`:`Download bundle`}),u&&(0,D.jsx)(`span`,{className:u.kind===`ok`?`text-sm text-emerald-500`:`text-sm text-red-500`,children:u.text})]})]})]}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`h2`,{className:`font-medium`,children:`Import a shared bundle`})}),(0,D.jsxs)(Y,{className:`space-y-3`,children:[(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Apply a bundle from a teammate. Overwritten files are backed up first. Preview the changes before applying.`}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(K,{onClick:ee,disabled:T,children:T?`Opening…`:`Choose bundle file…`}),(0,D.jsxs)(`label`,{className:`text-sm opacity-70 cursor-pointer underline decoration-dotted`,children:[`or browse`,(0,D.jsx)(`input`,{type:`file`,accept:`application/json,.json`,onChange:k,className:`hidden`})]}),m&&(0,D.jsxs)(`span`,{className:`text-sm opacity-70`,children:[`Loaded: `,m]})]}),(0,D.jsxs)(`details`,{className:`text-sm`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer opacity-70 select-none`,children:`Or paste the bundle JSON`}),(0,D.jsx)(`textarea`,{className:`hig-input w-full mt-2 font-mono text-xs`,rows:5,placeholder:`{"rules":[…],"presets":[…],"config":"…"}`,value:f,onChange:e=>{p(e.target.value),h(e.target.value.trim()?`(pasted)`:``),b(null),S(null)}})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`radio`,name:`import-mode`,checked:g===`merge`,onChange:()=>v(`merge`)}),` `,`Merge (keep my local-only rules)`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`radio`,name:`import-mode`,checked:g===`replace`,onChange:()=>v(`replace`)}),` `,`Replace (mirror the bundle)`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(K,{variant:`secondary`,onClick:j,disabled:C||!f,children:`Preview changes`}),(0,D.jsx)(K,{variant:g===`replace`?`danger`:`primary`,onClick:M,disabled:C||!y,children:`Apply`}),x&&(0,D.jsx)(`span`,{className:x.kind===`ok`?`text-sm text-emerald-500`:`text-sm text-red-500`,children:x.text})]}),N.length>0&&(0,D.jsx)(`pre`,{className:`text-xs bg-black/20 rounded p-2 overflow-auto max-h-64`,children:N.map(e=>`${e.action.padEnd(7)} ${e.kind===`config`?``:`${e.kind}/`}${e.name}`).join(`
12
- `)})]})]})]})}var Da=Object.freeze([`eval-burst`,`eval-burst-complete`,`counters-updated`]);function Oa(){(0,_.useEffect)(()=>Me(Da),[])}function ka(){return Oa(),(0,_.useSyncExternalStore)(Te,V).latestBurst}function Aa(){return Oa(),(0,_.useSyncExternalStore)(Te,V).burstRing}function ja(){return Oa(),(0,_.useSyncExternalStore)(Te,V).burstSeq}function Ma(e){return`${e.client}:${e.agent_id??`solo`}`}var Na=Object.freeze({allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`}),Pa=5*6e4,Fa=1200,Ia=30*6e4,La=1.4;function Ra(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 6;let n=6+Math.log2(1+t/50)*La;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)*La/10;return n<=0?0:n>=1?1:n}function Ba(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function Va(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 Ha=new Set([`compact`,`end`,`stop`,`subagent-stop`,`close`]),Ua=Object.freeze([`session-lifecycle`]);function Wa(e){(0,_.useEffect)(()=>Me(Ua),[]);let t=(0,_.useSyncExternalStore)(Te,V),[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,Ga(n,r)},[t.lifecycleRing]);let a=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{!e||e===a.current||(a.current=e,Ga(e,r))},[e]),{closedAt:n,isBurstActive(e,t){let r=n.get(e);return r===void 0||t>r}}}function Ga(e,t){let n=e.filter(e=>Ha.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 Ka=1440*60*1e3,qa=1800*1e3,Ja=3e3;function Ya(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=Xa(o);n.has(s)||(n.add(s),r.push(o))}for(;i<e.length;i++){let t=e[i],a=Xa(t);n.has(a)||(n.add(a),r.push(t))}for(;a<t.length;a++){let e=t[a],i=Xa(e);n.has(i)||(n.add(i),r.push(e))}return r}function Xa(e){return e.audit_id??`${e.ts_ms}:${e.tool}:${e.client}`}function Za(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 Qa(e,t,n,r=200,i=Ia,a=12){let o=new Map,s=new Map;for(let r of e){if(r.ts_ms>n)break;if(na(r.tool))continue;let e=Ma(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 $a(e={}){let t=e.windowMs??12e4,n=Aa(),[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)(()=>Ya(a,n),[a,n]),h=(0,_.useMemo)(()=>m.filter(e=>!na(e.tool)),[m]),{isBurstActive:g}=Wa(s),v=(0,_.useMemo)(()=>Qa(m,g,r.playhead_ms),[m,g,r.playhead_ms]),y=m.length>0?m[0].ts_ms:r.playhead_ms,b=m.length>0?m[m.length-1].ts_ms:r.playhead_ms,x=(0,_.useCallback)(async e=>{if(f.current)return;let t=y,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=Ya(e,i.bursts);return t.length>Ja?t.slice(-Ja):t}),Array.isArray(i.lifecycle)&&i.lifecycle.length>0&&c(e=>Za(e,i.lifecycle)),d.current=n}catch(e){e.name!==`AbortError`&&console.warn(`[graph] backfill failed`,e)}finally{f.current=null,u(!1)}},[y]);(0,_.useEffect)(()=>{r.playhead_ms-y<r.window_ms*.5&&x(Pa)},[r.playhead_ms,r.window_ms,y,x]);let S=(0,_.useRef)(!1);(0,_.useEffect)(()=>{S.current||(S.current=!0,x(qa))},[x]),(0,_.useEffect)(()=>()=>{f.current?.abort(),f.current=null},[]);let C=(0,_.useCallback)(e=>{i(t=>e===`live`?{...t,mode:`live`}:{...t,mode:e})},[]),w=(0,_.useCallback)(e=>{i(t=>({...t,mode:t.mode===`live`?`scrubbing`:t.mode,playhead_ms:e}))},[]),T=(0,_.useCallback)(e=>{i(t=>({...t,window_ms:Math.max(1e3,e)}))},[]),E=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now()}))},[]),D=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now(),window_ms:Ka})),x(Ka)},[x]);return{snapshot:(0,_.useMemo)(()=>({bursts:v,playback:r,oldest_known_ms:y,newest_known_ms:b,loading_backfill:l}),[v,r,y,b,l]),allBursts:h,setMode:C,setPlayhead:w,setWindow:T,jumpToLive:E,requestBackfill:x,jumpTo24h:D}}var eo=`SSG_AUDIO`,to=`SSG_AUDIO_VOLUME`,no=12,X=null,ro=null,io=!1,ao=.18,oo=[],so=!1;function co(){if(typeof localStorage>`u`)return{enabled:!1,volume:.18};let e=localStorage.getItem(eo)===`1`,t=localStorage.getItem(to);return{enabled:e,volume:t?Math.max(0,Math.min(1,parseFloat(t))):.18}}function lo(){if(typeof window>`u`)return null;if(X)return X;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;try{X=new e,ro=X.createGain(),ro.gain.value=ao,ro.connect(X.destination),typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{X&&(document.visibilityState===`hidden`?X.suspend():X.resume())})}catch{X=null,ro=null}return X}function uo(){if(so)return;so=!0;let{enabled:e,volume:t}=co();io=e,ao=t}function fo(){return uo(),io}function po(e){for(;oo.length>0&&e-oo[0]>1e3;)oo.shift();return oo.length>=no?!1:(oo.push(e),!0)}var mo={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 ho(e){if(uo(),!io||typeof document<`u`&&document.visibilityState===`hidden`)return;let t=lo();if(!t||!ro)return;t.state===`suspended`&&t.resume().catch(()=>{});let n=t.currentTime;if(!po(performance.now()))return;let r=mo[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(ro),i.start(n),i.stop(n+r.durationMs/1e3+.05),i.onended=()=>{try{i.disconnect(),a.disconnect()}catch{}}}function go(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 _o={"claude-code":`C`,"claude-code-ide":`C`,cursor:`>`,copilot:`H`,codex:`X`,pi:`P`,gemini:`G`,antigravity:`A`};function vo(e){return _o[e.toLowerCase()]??`.`}function yo(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 bo(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=yo(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 xo(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 So=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,Co=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,wo=new Map,To=256;function Eo(e,t){let n=wo.get(t);if(n!==void 0)return n;let r=e.measureText(t).width;if(wo.size>=To){let e=wo.keys().next().value;e!==void 0&&wo.delete(e)}return wo.set(t,r),r}function Do(e,t,n,r,i,a,o){let s=(r.split(`:`)[0]??r).slice(0,18),c=vo(s),l=yo(r),u=Na[o]??`#6b7280`;e.save(),e.textAlign=`center`;let d=`[${c}] ${s}`,f=`${i.length>14?i.slice(0,14):i} · ${a}`;e.font=Co;let p=Eo(e,d);e.font=So;let m=Eo(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=Co,e.fillText(d,t,n+10),e.globalAlpha=.72,e.fillStyle=u,e.font=So,e.fillText(f,t,n+21),e.restore()}var Oo=`bold 13px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,ko=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;function Ao(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 jo(e,t,n,r,i){e.save(),e.textAlign=`center`,e.font=ko,e.globalAlpha=.7,e.fillStyle=`hsla(${i},78%,72%,0.55)`,e.fillText(`uptime`,t,n),e.font=Oo,e.globalAlpha=.96,e.fillStyle=`hsla(${i},78%,82%,1)`,e.fillText(Ao(r),t,n+13),e.restore()}function Mo(e,t,n,r){e.save(),e.textAlign=`right`,e.font=ko,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(Ao(r),t,n+16),e.restore()}function No(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 Po={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 Fo(e){if(!e)return`·`;let t=e.lastIndexOf(`__`);return Po[t>=0?e.slice(t+2):e]??Po[e]??`·`}var Io=2*Math.PI/6e4,Lo=2.3999632297286535,Ro=16,zo=22,Bo=.4,Vo=14,Ho=8,Uo=24;function Wo(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)-Uo,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(zo,(i-Ro)/Math.max(1,s-1))),l=Ro,u=Ro+c,d=(l*l+u*u-Vo*Vo)/(2*l*u),f=Math.max(Bo,Math.acos(Math.min(1,Math.max(-1,d))));if(o<=Ho)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=Ro+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(zo,(i-Ro)/Math.max(1,e.length-1)));for(let n=0;n<e.length;n++){let r=e[n];r&&(r.slotPhi=n*Lo,r.slotR=Ro+n*t)}}}function Go(e,t,n,r){for(let i of e)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 Ko(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 qo(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 Jo=new Set,Yo=0,Xo=0;function Zo(){for(let e of Jo)e();Jo.size>0&&(Yo=requestAnimationFrame(Zo))}function Qo(e){let t=Xo++;return Jo.add(e),Jo.size===1&&(Yo=requestAnimationFrame(Zo)),[()=>{Jo.delete(e),Jo.size===0&&(cancelAnimationFrame(Yo),Yo=0)},t]}var $o=820,es=e=>Math.min(1,e),ts=620,ns=e=>1-(1-e)**3,rs=Vr({stiffness:120,damping:22,mass:1}),is=1800;function as(e){return e<=2?Math.min(window.devicePixelRatio,2):e<=4?Math.min(window.devicePixelRatio,1.5):Math.min(window.devicePixelRatio,1)}function os(e){return e<=2?1:e<=4?2:3}function ss(e){return e<=2?24:e<=4?12:6}function cs(e){return e<=4}var ls=!1,us=!1;function ds(){if(us||typeof window>`u`)return;us=!0;let e=navigator;typeof e.getBattery==`function`&&e.getBattery().then(e=>{let t=()=>{ls=!e.charging&&e.level<.2};t(),e.addEventListener(`chargingchange`,t),e.addEventListener(`levelchange`,t)}).catch(()=>{})}function fs(){return typeof window>`u`?!1:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||navigator.connection?.saveData?!0:ls}var ps=typeof window<`u`&&new URLSearchParams(window.location.search).get(`fullrate`)===`1`,ms=typeof window<`u`&&new URLSearchParams(window.location.search).get(`rotate`)!==`0`,hs=typeof window<`u`&&new URLSearchParams(window.location.search).get(`probe`)===`1`;function gs(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=go(s.ts_ms^e),i=n*.6+(t()-.5)*60,a=r/2+(t()-.5)*40,l=Ma(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 _s(e){let{bursts:t,paused:n,selectedId:r,onSelect:i,compact:a=!1,activePanelCount:o=1,labelDensity:s=`normal`,onFrameTime:c}=e,l=(0,_.useRef)(c);l.current=c;let u=(0,_.useRef)(s);u.current=s;let d=(0,_.useRef)(null),f=(0,_.useRef)([]),p=(0,_.useRef)([]),m=(0,_.useRef)(null),h=(0,_.useRef)(null),g=(0,_.useRef)(0),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(new Map),x=(0,_.useRef)(new Set),S=(0,_.useRef)(new Set),C=(0,_.useRef)(new Set),[w,T]=(0,_.useState)({w:0,h:0}),E=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(null),ee=(0,_.useRef)(Date.now()),A=(0,_.useRef)(new Map),j=(0,_.useRef)({frame:0,cache:null});(0,_.useLayoutEffect)(()=>{let e=d.current?.parentElement;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&T({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||T({w:Math.max(40,e),h:Math.max(40,n)})}});return n.observe(e),()=>n.disconnect()},[]),(0,_.useEffect)(()=>{if(w.w<=0||w.h<=0)return;j.current.frame=0;let e=new Map;for(let t of f.current)e.set(t.id,t);f.current=gs(f.current,t,w.w,w.h),Wo(f.current,w.w/2,w.h/2);let n=ms&&!Yr()?performance.now()*Io:0;for(let t of f.current){if(t.slotR==null||t.slotPhi==null)continue;let r=w.w/2+t.slotR*Math.cos(t.slotPhi+n),i=w.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(p.current=qo(f.current,1/0),!Yr())for(let t=0;t<f.current.length;t++){let n=f.current[t];!n||e.has(n.id)||ho(n.burst.decision)}let r=f.current.reduce((e,t)=>t.ts_ms>e?t.ts_ms:e,0);v.current=Math.max(performance.now()+$o,performance.now()+Fa,r+1500),g.current=performance.now()},[t,w.w,w.h]),(0,_.useEffect)(()=>{let e=d.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;ds();let i=performance.now(),s=0,c=0,h=0,_=.1,[T,D]=Qo(()=>{let d=performance.now();if(!ps&&fs()){if(s^=1,s===1)return}else s!==0&&(s=0);if(!ps){let e=os(o);if(e>1&&(O.current=(O.current+1)%e,O.current!==0))return}let T=performance.now(),E=T<v.current,D=T-g.current<200,M=T-y.current>500,N=Yr(),P=ms&&!N;if(!P&&!E&&!D&&!M)return;y.current=T;let F=d,I=Math.min(50,F-i);i=F;let L=f.current,te=p.current,ne=P?performance.now()*Io:0;Go(L,w.w/2,w.h/2,ne);for(let e of L)e.age<1&&(e.age=Math.min(1,e.age+I/$o));let R=typeof window<`u`?as(o):1,z=w.w,B=w.h;(e.width!==z*R||e.height!==B*R)&&(e.width=z*R,e.height=B*R,e.style.width=`${z}px`,e.style.height=`${B}px`,t.scale(R,R)),t.fillStyle=`#0a0a0f`,t.fillRect(0,0,z,B);let re=`${z}x${B}`,ie=k.current?.key===re?k.current.grad:null;if(ie||(ie=t.createRadialGradient(z/2,B/2,0,z/2,B/2,Math.max(z,B)/1.2),ie.addColorStop(0,`rgba(56, 189, 248, 0.06)`),ie.addColorStop(1,`rgba(0, 0, 0, 0)`),k.current={key:re,grad:ie}),t.fillStyle=ie,t.fillRect(0,0,z,B),!a){let e=j.current;(e.frame++%6==0||e.cache===null)&&(e.cache=Ko(L));let n=e.cache;if(bo(t,n,A.current),!N){let e=new Map,r=new Map;for(let t of L)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 L){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;Do(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);jo(t,s.x,s.y+l+12,e,yo(o))}}}}let ae=e=>e.exitingAt==null?1:Math.max(0,1-(F-e.exitingAt)/Fa),oe=ss(o),se=cs(o)&&!N,ce=x.current;if(ce.clear(),n)for(let e of L)ce.add(e.id);else{let e=0;for(let t=L.length-1;t>=0&&e<oe;t--){let n=L[t];!n||n.exitingAt!=null||(ce.add(n.id),e++)}}let le=b.current;le.clear();for(let e of L)le.set(e.id,e);t.lineWidth=2,t.lineCap=`round`,t.lineJoin=`round`;for(let e=0;e<te.length;e++){let n=te[e],r=le.get(n.source),i=le.get(n.target);if(!r||!i||ce.has(r.id)||ce.has(i.id))continue;let a=Math.max(ae(r),ae(i));a<=0||(t.globalAlpha=a,t.strokeStyle=`${Na[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 ue=u.current===`large`,de=ue?`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<te.length;e++){let n=te[e],r=le.get(n.source),i=le.get(n.target);if(!r||!i||!ce.has(r.id)&&!ce.has(i.id))continue;let a=Na[i.burst.decision]??`#6b7280`,o=Math.max(ae(r),ae(i));if(o<=0)continue;let s=es(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,se){let n=Math.min(s,(F/is+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(),No(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=de,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(`${e+1} · ${d}`,f,p-(ue?8:7)),t.restore()}t.globalAlpha=1;let fe=S.current;fe.clear();let pe=C.current;pe.clear();let me=u.current===`large`?10:5;{let e=0;for(let t=L.length-1;t>=0;t--){let r=L[t];!r||r.exitingAt!=null||(!n&&e<3&&fe.add(r.id),e<me&&pe.add(r.id),e++)}}let he=r,ge=m.current;for(let e of L){let r=ae(e);if(r<=0)continue;t.globalAlpha=r;let i=Math.min(1,e.age),o=es(i);e.displayedRadius=a?4:Ra(e.burst);let s=e.displayedRadius,c=a?s*o:(s+2*Math.min(1,e.age))*o,l=Na[e.burst.decision]??`#6b7280`,d=Va(l,za(e.burst));if((e.id===he||e.id===ge)&&(t.beginPath(),t.arc(e.x,e.y,c+6,0,Math.PI*2),t.fillStyle=`${d}33`,t.fill()),se&&(e.burst.decision===`allow`?xo(t,e.x,e.y,i,`#22c55e`,14,.3):e.burst.decision===`ask`&&xo(t,e.x,e.y,i,`#f59e0b`,14,.45)),se&&(e.burst.decision===`block`||e.burst.decision===`force`)){let n=i*$o;if(n<ts){let r=n/ts,i=c+16*ns(r),a=Math.max(0,1-r)*.75;t.beginPath(),t.arc(e.x,e.y,i,0,Math.PI*2),t.strokeStyle=d+Math.floor(a*255).toString(16).padStart(2,`0`),t.lineWidth=1.5,t.stroke()}}if(!N&&fe.has(e.id)&&(t.beginPath(),t.arc(e.x,e.y,c+2,0,Math.PI*2),t.fillStyle=`${d}33`,t.fill()),t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.fillStyle=d,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(),pe.has(e.id)&&(n||ce.has(e.id))){let n=u.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=`${d}cc`,t.fillText(vo(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=Fo(e.burst.tool),s=o===`·`?a:`${o} ${a}`;t.fillStyle=`${d}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*(ce.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(`↓${Ba(l)} ↑${Ba(f)}`,e.x,e.y+c+(n?25:21)),t.globalAlpha=r),t.textAlign=`left`}(e.id===he||e.id===ge)&&(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,se&&L.length>0){let e=null;for(let t=L.length-1;t>=0;t--)if(L[t].exitingAt==null){e=L[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=F%a/a,s=14+rs.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=F%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(!a&&z>220&&Mo(t,z-12,12,Date.now()-ee.current),hs){let t,n=0;for(let e of L)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?I:c*(1-_)+I*_;let _e=l.current;_e&&F-h>250&&(h=F,_e(c))});return E.current=D,O.current=D,T},[n,r,w.w,w.h,a,o]);function M(e,t){let n=d.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 f.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:d,className:`block w-full h-full cursor-crosshair`,onMouseMove:e=>{let t=M(e.clientX,e.clientY);m.current=t;let n=h.current;if(!n)return;if(!t){n.style.display=`none`;return}let r=f.current.find(e=>e.id===t);if(!r){n.style.display=`none`;return}let i=r.burst,a=Na[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(`↓${Ba(i.input_tokens)}`),i.output_tokens!=null&&s.push(`↑${Ba(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:()=>{m.current=null,h.current&&(h.current.style.display=`none`)},onClick:e=>{i(M(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:h,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 vs=3e4,ys=6e4,bs=5e3;function xs(e,t){let n=t?e.filter(e=>Ma(e)===t):e,r=Date.now(),i=n.length>0?n[n.length-1]:null;if(!i||r-i.ts_ms>bs||!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<=vs),o=a.filter(e=>e.decision===`allow`).length,s=a.length>0?Math.round(o/a.length*100):0,c=(a.length/(vs/1e3)).toFixed(1),l=new Set(a.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size,u=n.filter(e=>r-e.ts_ms<=ys&&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 Ss={allow:`ALLOW`,block:`BLOCK`,ask:`ASK`,log:`LOG`,force:`FORCE`,shadow:`SHADOW`},Cs={allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`};function ws({className:e,sessionKey:t}){let n=Aa(),r=ja(),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=xs(n,t);return a.current=e,e},[n,r,t]),s=o.decision?Cs[o.decision]??`#6b7280`:`#6b7280`,c=o.decision?Ss[o.decision]??o.decision:``,l=o.client?vo(o.client):``;return o.idle?(0,D.jsxs)(`div`,{className:mr(`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:mr(`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 Ts=(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?Na[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)(_s,{bursts:f,paused:!1,selectedId:r,onSelect:i,burstSeq:a,compact:!0,activePanelCount:n})})]})});function Es(e){return e<=1?1:e<=4?2:3}function Ds(){let e=Aa(),t=ja(),[n,r]=(0,_.useState)(null),{isBurstActive:i}=Wa(),a=(0,_.useMemo)(()=>Qa(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=Ma(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=Es(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:Na.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:Na.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:Na.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(`
13
- `),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)(_s,{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)(Ts,{sessionKey:e,bursts:t,activePanelCount:s.length,selectedId:n,onSelect:r},e))}),(0,D.jsx)(ws,{className:`absolute bottom-2 left-2 z-10 max-w-[calc(100%-1rem)]`})]})]})}function Os(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 ks(e){return{id:e.id,x:e.x,y:e.y,w:e.w,h:e.h}}function As(e,t){let n=[ks(e)],r=t.map(ks);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(Os(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 js(e){if(e.length===0)return[];let t=[...e].map(ks).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)Os(e,r)&&(e.y=r.y+r.h,t=!0)}n.push(e)}return n}function Ms(e,t,n){let r=e.findIndex(e=>e.id===t);if(r===-1)return{panels:e.map(ks)};let i=As({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:js(e.map(e=>a.get(e.id)).filter(Boolean))}}function Ns({size:e=24,children:t,...n}){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n,children:t})}var Ps=e=>(0,D.jsx)(Ns,{...e,children:(0,D.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),Fs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`path`,{d:`M18 6 6 18`}),(0,D.jsx)(`path`,{d:`m6 6 12 12`})]}),Is=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,D.jsx)(`path`,{d:`M7 10l5 5 5-5`}),(0,D.jsx)(`path`,{d:`M12 15V3`})]}),Ls=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,D.jsx)(`path`,{d:`M17 8l-5-5-5 5`}),(0,D.jsx)(`path`,{d:`M12 3v12`})]}),Rs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`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`}),(0,D.jsx)(`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}),(0,D.jsx)(`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`})]}),zs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`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`}),(0,D.jsx)(`path`,{d:`m15 5 4 4`})]}),Bs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,D.jsx)(`path`,{d:`M3 3v5h5`})]}),Vs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`path`,{d:`M3 6h18`}),(0,D.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,D.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,D.jsx)(`path`,{d:`M10 11v6`}),(0,D.jsx)(`path`,{d:`M14 11v6`})]}),Hs=e=>(0,D.jsxs)(Ns,{...e,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`19`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`5`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`12`,cy:`15`,r:`1`}),(0,D.jsx)(`circle`,{cx:`19`,cy:`15`,r:`1`}),(0,D.jsx)(`circle`,{cx:`5`,cy:`15`,r:`1`})]}),Us=[`hero-metrics`,`graph`,`latency-trace`,`throughput`,`decision-mix`,`tool-decision-breakdown`,`telemetry-feed`,`system-pulse`,`pending-approvals`,`recent-blocks`],Ws={"hero-metrics":`Hero metrics`,graph:`Graph intelligence`,"latency-trace":`Latency trace`,throughput:`Throughput`,"decision-mix":`Decision mix`,"tool-decision-breakdown":`Tool use by decision`,"telemetry-feed":`Telemetry feed`,"system-pulse":`System pulse`,"pending-approvals":`Pending approvals`,"recent-blocks":`Recent blocks`},Gs={"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},"tool-decision-breakdown":{minW:3,minH:2,defaultW:6,defaultH:3},"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 Ks({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?Ws[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 ${Ws[e.id]} (or Arrow keys)`,"aria-label":`Drag ${Ws[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onDragPointerDown(t,e.id,n)},children:(0,D.jsx)(Hs,{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 ${Ws[e.id]} (or Shift+Arrow keys)`,"aria-label":`Resize ${Ws[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 qs=(0,_.memo)(Ks);function Js(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 Ys(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=Gs[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=Gs[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}=Js(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=Gs[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 Xs({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=Ys({gridRef:i,getPanel:(0,_.useCallback)(e=>o.get(e),[o]),onCommit:(0,_.useCallback)(e=>{let t=a.current,{panels:n}=Ms(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)(qs,{panel:e,isEditing:t,drag:s,children:n[e.id]()},e.id))})}function Zs({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),ee=(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),k(!1),h(`Deleted "${e}"`)}function N(){d(),E(!1),h(`Reset to default`)}function P(){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 F(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)(K,{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)(Rs,{size:11,strokeWidth:2.25}),`Save as`]}),!i.builtIn&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>{w(i.name),S(!0)},children:[(0,D.jsx)(zs,{size:11,strokeWidth:2.25}),`Rename`]}),(0,D.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>k(!0),children:[(0,D.jsx)(Vs,{size:11,strokeWidth:2.25}),`Delete`]})]}),(0,D.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),title:`Replace the current layout with the Default preset`,children:[(0,D.jsx)(Bs,{size:11,strokeWidth:2.25}),`Reset`]}),(0,D.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:P,title:`Download current layouts as JSON`,children:[(0,D.jsx)(Is,{size:11,strokeWidth:2.25}),`Export`]}),(0,D.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>ee.current?.click(),title:`Load layouts from a JSON file`,children:[(0,D.jsx)(Ls,{size:11,strokeWidth:2.25}),`Import`]}),(0,D.jsx)(`input`,{ref:ee,type:`file`,accept:`application/json,.json`,onChange:F,className:`hidden`,"aria-hidden":!0}),(0,D.jsxs)(K,{variant:`primary`,size:`sm`,onClick:()=>n(!1),children:[(0,D.jsx)(Ps,{size:11,strokeWidth:2.5}),`Done`]})]}):(0,D.jsxs)(K,{variant:`secondary`,size:`sm`,onClick:()=>n(!0),children:[(0,D.jsx)(zs,{size:11,strokeWidth:2.25}),`Edit layout`]})}),g&&(0,D.jsx)(Qs,{title:`Save layout as`,value:y,placeholder:`My dashboard`,onChange:b,onConfirm:A,onCancel:()=>{v(!1),b(``)},confirmLabel:`Save`}),x&&(0,D.jsx)(Qs,{title:`Rename layout`,value:C,placeholder:i.name,onChange:w,onConfirm:j,onCancel:()=>S(!1),confirmLabel:`Rename`}),T&&(0,D.jsx)($s,{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}),O&&(0,D.jsx)($s,{title:`Delete "${i.name}"?`,body:`This layout will be removed. You can always recreate it via Save as.`,confirmLabel:`Delete`,onConfirm:M,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 Qs({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)(K,{variant:`ghost`,size:`sm`,onClick:a,children:[(0,D.jsx)(Fs,{size:11,strokeWidth:2.25}),`Cancel`]}),(0,D.jsx)(K,{variant:`primary`,size:`sm`,onClick:i,children:o})]})]})})}function $s({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)(K,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,D.jsx)(K,{variant:r?`danger`:`primary`,size:`sm`,onClick:i,children:n})]})]})})}var ec={default:`builtin-default`,focusLatency:`builtin-focus-latency`,focusApprovals:`builtin-focus-approvals`,compact:`builtin-compact`},tc={id:ec.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:`decision-mix`,x:8,y:2,w:4,h:2},{id:`pending-approvals`,x:8,y:4,w:4,h:3},{id:`telemetry-feed`,x:0,y:7,w:12,h:3},{id:`tool-decision-breakdown`,x:0,y:10,w:12,h:3}]},nc={id:ec.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}]},rc={id:ec.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}]},ic={id:ec.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}]},ac=Object.freeze([tc,nc,rc,ic]);function oc(){return ac.map(e=>({...e,panels:e.panels.map(e=>({...e}))}))}function sc(){return{version:1,activeLayoutId:ec.default,layouts:oc()}}function cc(e){return Object.values(ec).includes(e)}var lc=new Set(Us),uc=new Set(ac.map(e=>e.id));function dc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fc(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 pc(e,t){let n=(typeof e==`string`?e:``).replace(/[\u0000-\u001F\u007F]/g,``).trim();return n.length===0?t:n.slice(0,40)}function mc(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 hc(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 gc(e){if(!dc(e))return null;let{id:t}=e;if(typeof t!=`string`||!lc.has(t))return null;let n=t,r=Gs[n],i=fc(e.x,0,11,0),a=fc(e.w,r.minW,12,r.defaultW);return{id:n,x:i+a>12?12-a:i,y:fc(e.y,0,999,0),w:a,h:fc(e.h,r.minH,99,r.defaultH)}}function _c(e,t){if(!dc(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=pc(e.name,t),i=uc.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=gc(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:mc(s)},droppedPanels:c}}function vc(e){if(!dc(e)||e.version!==1)return{config:sc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let t=e.layouts;if(!Array.isArray(t)||t.length===0)return{config:sc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let n=[],r=0,i=0,a=0;for(let e of t){let{layout:t,droppedPanels:o}=_c(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:sc(),droppedPanels:r,prunedLayouts:a,fellBackToDefault:!0};let o=new Set(n.map(e=>e.id));for(let e of ac)o.has(e.id)||n.push({...e,panels:e.panels.map(e=>({...e}))});let s=new Map(ac.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(hc(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:ac[0].id,layouts:n},droppedPanels:r,prunedLayouts:a,fellBackToDefault:!1,backfilledPanels:c,refreshedBuiltins:l}}var yc=`ssg:dashboard-layout:v1`,bc=300;function xc(){if(typeof localStorage>`u`)return null;try{let e=`__ssg_probe__`;return localStorage.setItem(e,`1`),localStorage.removeItem(e),localStorage}catch{return null}}var Sc;function Cc(){return Sc===void 0&&(Sc=xc()),Sc}function wc(){let e=Cc();if(!e)return{config:sc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let t=null;try{t=e.getItem(yc)}catch{t=null}if(t===null)return{config:sc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let n=null;try{n=JSON.parse(t)}catch{return{config:sc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0}}return vc(n)}var Tc=null,Ec=null,Dc=null;function Oc(e){return Dc=e,()=>{Dc===e&&(Dc=null)}}function kc(e){Dc?Dc(e):typeof console<`u`&&console.warn(`[ssg-layout]`,e)}function Ac(){if(Ec=null,!Tc)return;let e=Cc();if(!e){Tc=null;return}let t=Tc;Tc=null;try{e.setItem(yc,JSON.stringify(t))}catch(e){e instanceof Error&&e.name===`QuotaExceededError`?kc(`Layout storage full — save skipped`):kc(`Layout save failed: ${e instanceof Error?e.message:String(e)}`)}}function jc(e){Tc=e,Ec===null&&(Ec=setTimeout(Ac,bc))}function Mc(e){Tc=e,Ec!==null&&(clearTimeout(Ec),Ec=null),Ac()}function Nc(e){let t=0;for(let n of e.layouts)n.builtIn||(t+=1);return t}function Pc(e){return e.map(e=>({...e}))}function Fc(){return`user-${Math.random().toString(16).slice(2,11)}`}function Ic(){let[e,t]=(0,_.useState)(()=>wc().config),[n,r]=(0,_.useState)(null);(0,_.useEffect)(()=>Oc(e=>r(e)),[]),(0,_.useEffect)(()=>{jc(e)},[e]);let i=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0]??oc()[0],a=Nc(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:Pc(e)}:t)}})},[]),c=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>{if(Nc(e)>=12)return e;let t=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0];if(!t)return e;let r={id:Fc(),name:n,builtIn:!1,panels:Pc(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??ac[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=cc(t.id)?ac.find(e=>e.id===t.id):ac[0];return n?{...e,layouts:e.layouts.map(e=>e.id===t.id?{...e,panels:Pc(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=vc(n);if(r.fellBackToDefault)return{ok:!1,message:`Import rejected: schema invalid, no changes applied`};t(r.config),Mc(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(sc())},[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 Lc=[`rules-changed`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`],Rc={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 zc({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 Bc({notification:e,onAction:t}){let[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(null),o=Rc[e.severity];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)(zc,{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: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))}}},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 Vc({showEmptyState:e=!1,hideHeader:t=!1}={}){let n=Ge(Lc),{data:r,refetch:i}=U(`/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`,...W()}});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)(Bc,{notification:e,onAction:a},e.id))})]})}var Hc=e=>Math.max(0,Math.round(e)).toLocaleString(void 0,{useGrouping:!0});function Uc(e,t){if(e===`spring`){let e=Vr();return{ease:e.fn,durationMs:e.duration}}return e===`quart`?{ease:Cr.out,durationMs:t}:{ease:Sr.out,durationMs:t}}var Wc=250;function Gc({value:e,duration:t=320,format:n=Hc,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)(Yr()),f=(0,_.useRef)(null),p=(0,_.useRef)(0);return p.current===0&&(p.current=performance.now()),(0,_.useEffect)(()=>{if(c.current===e)return;if(performance.now()-p.current<Wc){c.current=e,s.current=e,o(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:m}=Uc(i,t),h=e=>{let t=Math.min(1,(e-l.current)/m),n=r(t);o(s.current+(c.current-s.current)*n),t<1?u.current=requestAnimationFrame(h):u.current=null};return u.current=requestAnimationFrame(h),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,i,a]),(0,D.jsx)(`span`,{ref:f,className:mr(`tabular-nums`,r),children:n(a)})}function Kc({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=Yr();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}%`:pi(e,{width:[`${c}%`,`${s}%`],duration:480,ease:`outExpo`}),o.current[t]=s})},[i,r.find]),(0,D.jsxs)(`div`,{className:mr(`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:mr(`uppercase tracking-wide truncate`,e.textClass),children:e.label})]}),(0,D.jsx)(Gc,{value:e.value,className:`shrink-0 tabular-nums text-[var(--color-fg-1)]`})]},e.key))}):null]})}function qc({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 Jc(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Yc({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)(Jc());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]=Qo(e);return t},[r,i,a,n]),(0,D.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 ${r} ${i}`,className:mr(`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 Xc=ir(`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`}}),Zc={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)`},Qc={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)`},$c={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)]`},el=1e3,tl=.35;function nl(e,t,n){let r=Date.now(),i=r-n,a=Math.max(2,Math.floor(n/el)),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)/el);e>=0&&e<a&&o[e]++}let s=Array(a),c=o[0];for(let e=0;e<a;e++)c=tl*o[e]+(1-tl)*c,s[e]={ts:i+(e+1)*el,v:c};return s}function rl({label:e,value:t,series:n,burstRing:r,filter:i,sparkWindowMs:a=6e4,sub:o,tone:s,format:c,href:l,className:u,...d}){let f=s??`neutral`,p=Zc[f]??Zc.neutral,m=Qc[f]??Qc.neutral,h=$c[f]??$c.neutral,g=(0,_.useRef)(null),v=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(v.current===t)return;v.current=t;let e=g.current;e&&pi(e,{"--tick":[0,1],duration:160,ease:`outCubic`,onComplete:()=>{pi(e,{"--tick":[1,0],duration:520,ease:`outCubic`,onComplete:e=>{e.style.removeProperty(`--tick`)}})}})},[t]);let y=(0,_.useMemo)(()=>r?nl(r,i,a):null,[r,i,a]),b=y!==null,x=!b&&n&&n.length>=2,S=(0,D.jsxs)(`div`,{ref:g,className:mr(Xc({tone:s,className:u}),l&&`is-link cursor-pointer`),...d,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)(Gc,{value:t,format:c,className:mr(`text-[2.4rem] leading-none font-semibold tracking-tight`,h)}),b?(0,D.jsx)(Yc,{samples:y,width:108,height:36,windowMs:a,color:p,fillColor:m,className:`shrink-0`}):x?(0,D.jsx)(qc,{data:n,width:96,height:28,color:p}):null]})]});return l?(0,D.jsx)(`a`,{href:l,className:`contents`,"aria-label":`${e} — open Monitor`,children:S}):S}var il={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 al(e,t,n=200){let r=Math.max(0,Math.floor(e)),i=Math.max(0,Math.floor(t)),a=Math.max(0,r-il.containerPaddingX),o=Math.max(0,i-il.containerPaddingY),s=o-(il.trendRowH*3+il.trendRowGap*2+il.trendTopPad+il.topToTrendGap),c=s-il.scatterHeaderH-il.scatterLegendH-il.scatterInnerGap>=il.scatterAcceptableMin,l=c?s:o,u=l-il.scatterHeaderH-il.scatterLegendH-il.scatterInnerGap,d=u>=il.scatterAbsoluteMin,f=u>=il.scatterAbsoluteMin&&l>=140,p=Math.floor(l/il.gaugeFootprintFactor),m=Math.floor(a*.45/il.gaugeFootprintFactor),h=Math.max(il.gaugeAbsoluteMin,Math.min(il.gaugeAbsoluteMax,n,p,m)),g=Math.ceil(h*il.gaugeFootprintFactor+8),_=l-(d?il.scatterHeaderH:0)-(f?il.scatterLegendH:0)-il.scatterInnerGap;return{gaugeSize:h,gaugeColumnMaxWidth:g,scatterMinHeight:Math.max(il.scatterAbsoluteMin,Math.min(160,_)),showTrendRows:c,showScatterHeader:d,showLegend:f,variant:o>=480?`wide`:o>=300?`normal`:`compact`}}var ol=135,sl=405,cl=sl-ol,ll=`#34d399`,ul=`#f59e0b`,dl=`#ef4444`;function fl(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 pl(e,t,n,r,i){let a=fl(e,t,n,r),o=fl(e,t,n,i),s=+(i-r>180);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 ml(e,t){return ol+Math.max(0,Math.min(1,e/Math.max(t,1e-9)))*cl}function hl(e,t,n){return e+(t-e)*n}function gl(e){let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}function _l(e,t,n){let[r,i,a]=gl(e),[o,s,c]=gl(t);return`rgb(${Math.round(hl(r,o,n))},${Math.round(hl(i,s,n))},${Math.round(hl(a,c,n))})`}function vl(e,t,n){let r=.04;return e<t-r?ll:e<t+r?_l(ll,ul,(e-(t-r))/(r*2)):e<n-r?ul:e<n+r?_l(ul,dl,(e-(n-r))/(r*2)):dl}function yl(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var bl=0;function xl(){return bl=bl+1|0,bl.toString(36)}function Sl({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)(()=>pl(x,S,C,ol,sl),[x,S,C]),E=(0,_.useMemo)(()=>pl(x,S,C-8,ol,sl),[x,S,C]),O=ol+n*cl,k=ol+r*cl,ee=(0,_.useMemo)(()=>pl(x,S,C,ol,O),[x,S,C,O]),A=(0,_.useMemo)(()=>pl(x,S,C,O,k),[x,S,C,O,k]),j=(0,_.useMemo)(()=>pl(x,S,C,k,sl),[x,S,C,k]),M=(0,_.useMemo)(()=>pl(x,S,C-14,300,420),[x,S,C]),N=ol+w*cl,P=(0,_.useMemo)(()=>pl(x,S,C,ol,Math.max(ol+.01,N)),[x,S,C,N]),F=vl(w,n,r),I=(0,_.useMemo)(()=>xl(),[]),L=`lgf-${I}`,te=`lgb-${I}`,ne=`lgd-${I}`,R=`lgh-${I}`,z=`lgg-${I}`,B=`lgl-${I}`,re=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=10;t++)e.push(ol+t/10*cl);return e},[u]),ie=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=40;t++)t%4!=0&&e.push(ol+t/40*cl);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=ol+(r+.5)/e*cl;n.push(fl(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),V=`${we},${S} ${Ce},${S-Te} ${Ce},${S+Te}`,Ee=d*.48,De=d*.17,Oe=x-Ee/2,ke=S+d*.16,Ae=ke+De*.68;return(0,_.useEffect)(()=>{let e=yl(),t=performance.now(),n=me.current,r=0,i=me.current,a=0,o=me.current,s=``,l=``,d=``,f=-1,m=``,h=``,[g]=Qo(()=>{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=ol+O*cl,ee=ol+Math.max(0,Math.min(1,i/Math.max(b,1e-9)))*cl,A=vl(O,w,T),j=`rotate(${(k-90).toFixed(3)} ${x} ${S})`;ae.current&&j!==s&&(ae.current.setAttribute(`transform`,j),s=j),A!==d&&(oe.current&&oe.current.setAttribute(`fill`,A),se.current&&se.current.setAttribute(`fill`,A),ce.current&&ce.current.setAttribute(`stroke`,A),ue.current&&ue.current.setAttribute(`fill`,A),d=A);let M=`rotate(${(ee-90).toFixed(3)} ${x} ${S})`;if(le.current&&M!==l&&(le.current.setAttribute(`transform`,M),l=M),de.current&&c){let e=c(o);e!==h&&(de.current.textContent=e,h=e)}if(fe.current&&u===`ring`){let e=pl(x,S,C,ol,Math.max(ol+.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`,vl(a,w,T)),i.setAttribute(`opacity`,s.toFixed(3))}}}}});return g},[x,S,C,u,p,c]),(0,D.jsxs)(`div`,{className:mr(`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:L,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:te,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:ne,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:R,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:z,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:B,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(#${te})`,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(#${ne})`})]}):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:ee,fill:`none`,stroke:ll,strokeWidth:5,strokeLinecap:`round`,opacity:.78}),(0,D.jsx)(`path`,{d:A,fill:`none`,stroke:ul,strokeWidth:5,strokeLinecap:`round`,opacity:.82}),(0,D.jsx)(`path`,{d:j,fill:`none`,stroke:dl,strokeWidth:5,strokeLinecap:`round`,opacity:.9}),ie.map((e,t)=>{let n=fl(x,S,C-4,e),r=fl(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}`)}),re.map((e,t)=>{let n=fl(x,S,C-8,e),r=fl(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?ve.map((e,t)=>(0,D.jsx)(`circle`,{ref:e=>{pe.current[t]=e},cx:e.x,cy:e.y,r:Math.max(1.6,d*.013),fill:ll,opacity:0,filter:`url(#${L})`},t)):null,i===void 0?null:(0,D.jsx)(Cl,{cx:x,cy:S,r:C,angle:ml(i,t),emphasis:!0}),a===void 0?null:(0,D.jsx)(Cl,{cx:x,cy:S,r:C,angle:ml(a,t),emphasis:!0}),l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(wl,{cx:x,cy:S,r:C,angle:O,text:l(n),size:d}),(0,D.jsx)(wl,{cx:x,cy:S,r:C,angle:k,text:l(r),size:d}),(0,D.jsx)(wl,{cx:x,cy:S,r:C,angle:sl,text:l(1),size:d})]}):null,(0,D.jsx)(`path`,{d:M,fill:`none`,stroke:`url(#${z})`,strokeWidth:d*.14,strokeLinecap:`butt`}),c||s!==void 0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{x:Oe,y:ke,width:Ee,height:De,rx:d*.022,ry:d*.022,fill:`url(#${B})`,stroke:`#242a33`,strokeWidth:1}),(0,D.jsx)(`rect`,{x:Oe+1,y:ke+1,width:Ee-2,height:1,fill:`#ffffff`,opacity:.08})]}):null,(0,D.jsx)(`g`,{ref:le,opacity:.28,children:(0,D.jsx)(`polygon`,{ref:ue,points:Se,fill:F})}),(0,D.jsxs)(`g`,{ref:ae,children:[(0,D.jsx)(`polygon`,{ref:oe,points:Se,fill:F,stroke:`#05070a`,strokeWidth:.6}),(0,D.jsx)(`polygon`,{ref:se,points:V,fill:F,opacity:.7})]}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.06,fill:`url(#${R})`,stroke:`#06080c`,strokeWidth:1}),(0,D.jsx)(`circle`,{ref:ce,cx:x,cy:S,r:d*.036,fill:`#0a0c11`,stroke:F,strokeWidth:1.4}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.012,fill:`#f5f7fb`,opacity:.9})]}):(0,D.jsx)(`path`,{ref:fe,d:P,fill:`none`,stroke:F,strokeWidth:12,strokeLinecap:`round`}),u===`needle`&&(c||s!==void 0)?c?(0,D.jsx)(`text`,{ref:de,x,y:Ae,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:Ae,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:s}):c?(0,D.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,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 Cl({cx:e,cy:t,r:n,angle:r,emphasis:i=!1}){let a=fl(e,t,n-(i?10:6),r),o=fl(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 wl({cx:e,cy:t,r:n,angle:r,text:i,size:a}){let o=fl(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 Tl={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`};function El(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}function Dl({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)(()=>al(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(al(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:Tl[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]=Qo(()=>{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,D.jsxs)(`div`,{ref:d,"data-lt-variant":f.variant,className:mr(`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:mr(`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)(Sl,{value:l,max:n,warnAt:Math.min(.85,.5/n),critAt:Math.min(.92,2/n),marker50:c,marker99:u,displayFormat:e=>El(e*1e6),scaleLabels:f.gaugeSize>=130?e=>El(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)(Ol,{})}):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)(kl,{label:`p50 · median`,value:El(e?.p50_ns??0),color:`#34d399`,fill:`rgba(52, 211, 153, 0.14)`,samples:y.p50,windowMs:i*1e3}),(0,D.jsx)(kl,{label:`p95 · 95th`,value:El(e?.p95_ns??0),color:`#38bdf8`,fill:`rgba(56, 189, 248, 0.14)`,samples:y.p95,windowMs:i*1e3}),(0,D.jsx)(kl,{label:`p99 · 99th`,value:El(e?.p99_ns??0),color:`#6366f1`,fill:`rgba(99, 102, 241, 0.14)`,samples:y.p99,windowMs:i*1e3})]}):null]})}function Ol(){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:Tl.allow},{key:`ask`,color:Tl.ask},{key:`block`,color:Tl.block},{key:`force`,color:Tl.force},{key:`log`,color:Tl.log},{key:`shadow`,color:Tl.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 kl({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)(Yc,{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 Al(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 jl(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 Ml(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 Nl(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 Pl({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=jl(e,n),p=jl(r,a),m=`var(--color-decision-log)`,h=(0,_.useMemo)(()=>Nl(t,d),[t]),g=(0,_.useMemo)(()=>Nl(i,d),[i]),v=(0,_.useMemo)(()=>Nl(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=pi(e,{translateY:[28,0],scale:[.94,1],opacity:[0,1],duration:720,delay:Gr(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:mr(`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)(Fl,{registerRef:e=>y.current[0]=e,label:`CPU`,color:f,fill:Ml(f),pulse:b,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Gc,{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)(Fl,{registerRef:e=>y.current[1]=e,label:`Memory`,color:p,fill:Ml(p),pulse:x,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Gc,{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)(Fl,{registerRef:e=>y.current[2]=e,label:`Heap`,color:m,fill:Ml(m),valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Gc,{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)(Fl,{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:Al(l)}),subText:`since daemon start`})]})})}function Fl({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=pi(u.current,{"--breach":[0,1],duration:420,ease:`outCubic`,onComplete:()=>{e||!u.current||(t=pi(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)(Yc,{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 Z=ir(`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`}}),Q={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`},Il={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 Ll(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 Rl(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 zl(e){return e.variant===`raw`?(0,D.jsx)(Vl,{...e}):(0,D.jsx)(Bl,{...e})}function Bl({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&&(Yr()||pi(t,{translateX:[-10,0],opacity:[0,1],duration:220,ease:`outExpo`}))},[d,s]),(0,D.jsxs)(`div`,{className:mr(Z({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 ${Q[e.decision]??`#666`}`},children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:Ll(e.ts_ms)}),(0,D.jsx)(`span`,{className:mr(`uppercase tracking-wide font-medium`,Il[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} — ${ea(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:Rl(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)(Hl,{}):null]})}function Vl({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:mr(Z({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)(Hl,{}):null]})}function Hl(){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`})}var Ul=[`allow`,`ask`,`force`,`block`,`log`,`shadow`];function Wl(e){return e.audit_id??`${e.ts_ms}:${e.tool}`}function Gl(){return{allow:0,block:0,log:0,shadow:0,ask:0,force:0}}function Kl(e,t=0){let n=new Map;for(let t of e){let e=n.get(t.tool);e||(e={tool:t.tool,count:0,totalDurationNs:0,byDecision:Gl(),dominant:t.decision},n.set(t.tool,e)),e.count+=1,e.totalDurationNs+=t.duration_ns,e.byDecision[t.decision]+=1}let r=Array.from(n.values());for(let e of r){let t=`allow`,n=-1;for(let r of Ul)e.byDecision[r]>n&&(n=e.byDecision[r],t=r);e.dominant=t}if(r.sort((e,t)=>t.count-e.count||e.tool.localeCompare(t.tool)),t>0&&r.length>t){let e=r.slice(0,t-1),n=r.slice(t-1),i={tool:`+${n.length} more`,count:0,totalDurationNs:0,byDecision:Gl(),dominant:`shadow`};for(let e of n){i.count+=e.count,i.totalDurationNs+=e.totalDurationNs;for(let t of Ul)i.byDecision[t]+=e.byDecision[t]}return e.push(i),e}return r}function ql(e){if(e.length===0)return{rows:[],t0:0,t1:0,maxDurationNs:0};let t=[...e].sort((e,t)=>e.ts_ms-t.ts_ms),n=t[0].ts_ms,r=t[t.length-1].ts_ms,i=Math.max(1,r-n),a=0;for(let e of t)e.duration_ns>a&&(a=e.duration_ns);let o=Math.log10(Math.max(1,a)+1);return{rows:t.map(e=>{let t=(e.ts_ms-n)/i,r=Math.log10(Math.max(0,e.duration_ns)+1),a=.04+(o>0?r/o:0)*.96;return{id:Wl(e),tool:e.tool,decision:e.decision,rule_id:e.rule_id,ts_ms:e.ts_ms,durationNs:e.duration_ns,startFrac:t,widthFrac:a}}),t0:n,t1:r,maxDurationNs:a}}function Jl(e,t,n=`count`){let r=e=>n===`duration`?Math.max(0,e.duration_ns):1,i={name:t,value:0,depth:0,x0:0,x1:1,children:[]};if(e.length===0)return i;let a=new Map;for(let t of e){let e=r(t);i.value+=e;let n=a.get(t.tool);n||(n={value:0,byDecision:new Map},a.set(t.tool,n)),n.value+=e;let o=n.byDecision.get(t.decision);o||(o={value:0,ids:[]},n.byDecision.set(t.decision,o)),o.value+=e,o.ids.push(Wl(t))}if(i.value<=0)return i;let o=Array.from(a.entries()).sort((e,t)=>t[1].value-e[1].value||e[0].localeCompare(t[0])),s=0;for(let[e,t]of o){let n=t.value/i.value,r=s,a=Math.min(1,s+n);s=a;let o={name:e,value:t.value,depth:1,x0:r,x1:a,children:[]},c=Array.from(t.byDecision.entries()).sort((e,t)=>t[1].value-e[1].value),l=r,u=a-r;for(let[e,n]of c){let r=n.value/t.value*u,i=l,s=Math.min(a,l+r);l=s;let c={name:e,value:n.value,depth:2,x0:i,x1:s,decision:e,children:[]},d=n.ids.length===1?n.ids[0]:void 0;d!==void 0&&(c.id=d),o.children.push(c)}i.children.push(o)}return i}function Yl(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};return n(e),t}var Xl=8;function Zl(e,t){let n={id:`root`,label:t,depth:0,x:.5,y:.12,value:e.length,parent:null};if(e.length===0)return{nodes:[n],maxDepth:0};let r=new Map;for(let t of e){let e=r.get(t.tool);e||(e={value:0,byDecision:new Map},r.set(t.tool,e)),e.value+=1;let n=e.byDecision.get(t.decision);n||(n={value:0,ids:[]},e.byDecision.set(t.decision,n)),n.value+=1,n.ids.push(Wl(t))}let i=Array.from(r.entries()).sort((e,t)=>t[1].value-e[1].value||e[0].localeCompare(t[0])),a=0;if(i.length>Xl){let e=i.slice(Xl-1);for(let[,t]of e)a+=t.value;i=i.slice(0,Xl-1)}let o=i.map(([e,t])=>{let n=Array.from(t.byDecision.entries()).sort((e,t)=>t[1].value-e[1].value).map(([e,t])=>({decision:e,value:t.value,ids:t.ids}));return{name:e,value:t.value,dominant:n[0]?.decision??`allow`,leaves:n}});a>0&&o.push({name:`+${r.size-(Xl-1)} more`,value:a,dominant:`shadow`,leaves:[]});let s=.06;1-2*s;let c=o.reduce((e,t)=>e+Math.max(1,t.leaves.length),0),l=[n],u=0,d=[];return o.forEach((e,t)=>{let n=Math.max(1,e.leaves.length),r=[];for(let e=0;e<n;e++)r.push(s+(u+.5)/c*.88),u+=1;let i=r.reduce((e,t)=>e+t,0)/r.length;d.push(i);let a=`t${t}`;l.push({id:a,label:e.name,depth:1,x:i,y:.5,value:e.value,decision:e.dominant,parent:`root`}),e.leaves.forEach((e,t)=>{let n={id:`${a}d${t}`,label:e.decision,depth:2,x:r[t]??i,y:.88,value:e.value,decision:e.decision,parent:a},o=e.ids.length===1?e.ids[0]:void 0;o!==void 0&&(n.burstId=o),l.push(n)})}),d.length>0&&(n.x=d.reduce((e,t)=>e+t,0)/d.length),{nodes:l,maxDepth:l.reduce((e,t)=>Math.max(e,t.depth),0)}}function Ql(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${Math.round(e)}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(2)}ms`}var $l={allow:`var(--color-decision-allow)`,ask:`var(--color-decision-ask)`,force:`var(--color-decision-force)`,block:`var(--color-decision-block)`,log:`var(--color-decision-log)`,shadow:`var(--color-decision-shadow)`},eu={allow:`text-emerald-300`,ask:`text-amber-300`,force:`text-sky-300`,block:`text-red-300`,log:`text-violet-300`,shadow:`text-[var(--color-fg-3)]`};function tu({bursts:e,limit:t=8,className:n}){let r=(0,_.useMemo)(()=>Kl(e).slice(0,t),[e,t]);if(r.length===0)return(0,D.jsx)(`div`,{className:mr(`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,n),children:`no tool-call data yet`});let i=Ul.filter(e=>r.some(t=>t.byDecision[e]>0));return(0,D.jsxs)(`div`,{className:mr(`flex flex-col gap-2`,n),children:[r.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`w-28 shrink-0 truncate text-[var(--color-fg-2)]`,title:e.tool,children:e.tool}),(0,D.jsx)(`div`,{className:`flex h-3 flex-1 overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-2)]`,children:e.count===0?null:Ul.map(t=>{let n=e.byDecision[t];return n?(0,D.jsx)(`div`,{style:{width:`${n/e.count*100}%`,background:$l[t]},title:`${e.tool} · ${t}: ${n}`},t):null})}),(0,D.jsx)(`span`,{className:`w-10 shrink-0 text-right tabular-nums text-[var(--color-fg-3)]`,children:e.count})]},e.tool)),i.length>0?(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] font-mono`,children:i.map(e=>(0,D.jsxs)(`span`,{className:mr(`flex items-center gap-1 uppercase tracking-wide`,eu[e]),children:[(0,D.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-sm`,style:{background:$l[e]}}),e]},e))}):null]})}function nu(e,t){let n=e?.allow??0,r=e?.block??0,i=e?.ask??0,a=e?.log??0,o=e?.force??0,s=e?.shadow??0,c=n+r+i+a+o+s,l=t?.counters.total??0;return t&&l>0&&l>=c&&t?{...t.counters}:{allow:n,block:r,ask:i,log:a,force:o,shadow:s,total:c}}function ru(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,Yr()){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`}),pi(Array.from(i),{opacity:[0,1],translateY:[c,0],duration:l,ease:`outBack(1.2)`,delay:Gr(s,{from:u}),onComplete:e=>{let t=e;t.style.willChange=``,t.style.transform=``}})},[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(!Yr()){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 iu(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 au(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:W()})}var ou=e=>!0,su=e=>e.decision===`allow`,cu=e=>e.decision===`block`,lu=e=>e.decision===`ask`,uu=e=>e.decision===`force`,du=e=>e.decision===`log`;function fu(){let e=new Date;return e.setHours(0,0,0,0),e.getTime()}function pu(){history.pushState(null,``,`/approvals`),window.dispatchEvent(new PopStateEvent(`popstate`))}function mu({pendingCount:e}){let t=e>0;return(0,D.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-4 rounded-sm border p-4 ${t?`border-[var(--color-brand)] bg-[var(--color-accent-tint)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)]`}`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{background:t?`var(--color-brand)`:`var(--color-decision-allow)`}}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`div`,{className:`font-semibold text-[var(--color-fg-0)]`,children:t?`${e} tool ${e===1?`call`:`calls`} waiting for your decision`:`You're all caught up`}),(0,D.jsx)(`div`,{className:`text-[13px] text-[var(--color-fg-2)]`,children:t?`Approve or block them so your agents can continue.`:`No tool calls are waiting. New requests appear here the moment an agent asks.`})]}),(0,D.jsx)(K,{variant:t?`primary`:`secondary`,onClick:pu,className:`shrink-0`,children:t?`Review pending →`:`View approvals`})]})}function hu(){let e=Ge([`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`]),t=ka();ja();let n=Aa(),[r,i]=(0,_.useState)(()=>fu());(0,_.useEffect)(()=>{let e=()=>{if(document.visibilityState!==`visible`)return;let e=fu();i(t=>e===t?t:e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{activeProject:a}=Ze(),{data:o}=U(Qe(`/api/state/counters?since_ms=${r}`,a),[e[`counters-updated`],r,a]),{data:s}=U(`/api/state/runtime`,[e[`runtime-tick`]]),{data:c}=U(`/api/json/limits`,[e[`runtime-tick`]]),{data:l,refetch:u}=U(`/api/json/pending`,[e[`pending-changed`]]),{data:d}=U(`/api/json/blocked`,[e[`activity-updated`]]),f=Ic(),[p,m]=(0,_.useState)(!1),h=(0,_.useMemo)(()=>nu(o,t),[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)(rl,{label:`Total`,value:h.total,href:`/monitor`,tone:`amber`,sub:t&&t.counters.total>0?iu(t.duration_ns):void 0,burstRing:n,filter:ou}),(0,D.jsx)(rl,{label:`Allow`,value:h.allow,href:`/monitor`,tone:`green`,burstRing:n,filter:su}),(0,D.jsx)(rl,{label:`Block`,value:h.block,href:`/monitor`,tone:`red`,burstRing:n,filter:cu}),(0,D.jsx)(rl,{label:`Ask`,value:h.ask,href:`/monitor`,tone:`amber`,burstRing:n,filter:lu}),(0,D.jsx)(rl,{label:`Force`,value:h.force,href:`/monitor`,tone:`blue`,burstRing:n,filter:uu}),(0,D.jsx)(rl,{label:`Log`,value:h.log,href:`/monitor`,tone:`purple`,burstRing:n,filter:du})]})}),graph:()=>(0,D.jsx)(Ds,{}),"latency-trace":()=>(0,D.jsx)(Dl,{latency:x,bursts:n,gaugeMaxMs:10,windowMs:3e4,trendWindowSec:60,gaugeSize:200}),throughput:()=>(0,D.jsxs)(q,{className:`h-full`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`throughput · evals/s`}),(0,D.jsxs)(G,{variant:`blue`,children:[g.toFixed(1),`/s`]})]}),(0,D.jsxs)(Y,{children:[(0,D.jsx)(Yc,{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)(q,{className:`h-full`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`decision mix`}),(0,D.jsx)(G,{variant:`gray`,children:h.total.toLocaleString()})]}),(0,D.jsx)(Y,{children:(0,D.jsx)(Kc,{counters:{allow:h.allow,block:h.block,ask:h.ask,log:h.log,force:h.force,shadow:h.shadow}})})]}),"tool-decision-breakdown":()=>(0,D.jsxs)(q,{className:`h-full`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`tool use · by decision`}),(0,D.jsx)(G,{variant:`gray`,children:n.length.toLocaleString()})]}),(0,D.jsx)(Y,{children:(0,D.jsx)(tu,{bursts:n,limit:8})})]}),"telemetry-feed":()=>(0,D.jsxs)(q,{variant:`flush`,className:`h-full flex flex-col`,children:[(0,D.jsxs)(J,{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)(Y,{className:`p-0 flex-1 min-h-0`,children:(0,D.jsx)(zl,{variant:`decision`,bursts:n,windowSize:80,height:360,className:`border-0 rounded-none`})})]}),"system-pulse":()=>(0,D.jsx)(Pl,{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)(q,{className:`h-full`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`pending approvals`}),(0,D.jsx)(G,{variant:l&&l.length>0?`amber`:`gray`,children:l?.length??0})]}),(0,D.jsx)(Y,{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:_r(e.toolCall.tool,JSON.stringify(e.toolCall.input??{}))})]}),(0,D.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,D.jsx)(K,{size:`sm`,variant:`primary`,onClick:()=>au(e.id,`allow`).then(u),children:`allow`}),(0,D.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>au(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)(q,{className:`h-full`,children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent blocks & forces`}),(0,D.jsx)(G,{variant:d&&d.length>0?`red`:`gray`,children:d?.length??0})]}),(0,D.jsx)(Y,{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)(G,{variant:e.decision===`force`?`amber`:`red`,children:e.decision}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] truncate flex-1`,children:_r(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=ru({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.jsx)(mu,{pendingCount:l?.length??0}),(0,D.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,D.jsx)(`div`,{className:`flex-1`,"data-tutorial":`cb-layout`,children:(0,D.jsx)(Zs,{manager:f,isEditing:p,onToggleEditing:m})})}),(0,D.jsx)(Vc,{}),(0,D.jsx)(`div`,{"data-tutorial":`cb-grid`,children:(0,D.jsx)(Xs,{panels:f.activeLayout.panels,isEditing:p,renderers:S,onPanelsChange:f.updateActivePanels})})]})}var gu=[{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`}],_u={rca:{title:`Root Cause Analysis`,body:`When an eval errors, an ssqa finding arrives, or a daemon-level error fires, SSG auto-composes a diagnosis with ranked hypotheses, evidence, and suggested next actions — the same pack Claude reads through MCP.`,useWhen:`Something just broke and you want the short version before grepping logs.`},timeline:{title:`Eval Timeline`,body:`Flame-chart of the last 1024 frames across every rule and tool call. Each row is one tool call (trace_id); each bar is one pipeline stage colored by kind; a red outline means that stage errored.`,useWhen:`You want to see which stages a rule went through and how long each took. Click a bar to inspect the frame.`},watch:{title:`Live URI Watch`,body:`Subscribe to any ssg:// resource and watch it update as the daemon emits events. Every CLI, MCP, and dashboard surface ultimately reads through these same URIs.`,useWhen:`You know exactly which internal resource (rules, audit rows, frames, RCA pack, native stats) you want to inspect.`},state:{title:`Daemon Snapshot`,body:`Live vitals for the SSG daemon process — uptime, rules loaded, native FFI availability, frame ring size, eval quotas, audit worker readiness.`,useWhen:`The daemon feels off (slow, dropping events, refusing calls) and you want to confirm it's healthy.`},metrics:{title:`Performance Counters`,body:`Latency distributions and event counters for the eval pipeline (per-stage timings, native call overhead, audit throughput).`,useWhen:`Evals feel slow and you want to find the hot stage before optimizing.`}};function vu(){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:`space-y-2`,children:[(0,D.jsxs)(`div`,{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)(wu,{})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`one surface · cli · mcp · dashboard`})]}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] max-w-3xl leading-snug`,children:`See exactly what happened inside SSG during recent rule evaluations — which stage ran, which rule matched, how long each step took, and what went wrong. The same data Claude reads via MCP.`})]}),(0,D.jsx)(bu,{}),(0,D.jsx)(Su,{}),(0,D.jsx)(`nav`,{"data-tutorial":`debug-tabs`,className:`flex items-center gap-1 border-b border-[var(--color-line-1)]`,children:gu.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.jsx)(Cu,{tab:e}),(0,D.jsxs)(`section`,{"data-tutorial":`debug-pane`,className:`flex-1 min-h-0`,children:[e===`rca`&&(0,D.jsx)(Tu,{}),e===`timeline`&&(0,D.jsx)(Au,{}),e===`watch`&&(0,D.jsx)(Ru,{}),e===`state`&&(0,D.jsx)(zu,{uri:`ssg://daemon/state`}),e===`metrics`&&(0,D.jsx)(zu,{uri:`ssg://daemon/metrics`})]})]})}var yu=`ssg.debug.intro.dismissed`;function bu(){let[e,t]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(yu)===`1`}catch{return!1}});return e?(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsx)(`button`,{type:`button`,onClick:()=>{t(!1);try{window.localStorage.removeItem(yu)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`,children:`what is this?`})}):(0,D.jsx)(`aside`,{className:`rounded-sm 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 justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-3 min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:`who this page is for`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:`SSG sits between your AI coding agent (Claude Code, Cursor, Copilot, …) and your filesystem/shell, deciding which tool calls to allow, block, or warn on. This page is the window into those decisions — useful any time SSG's behavior surprises you.`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] mb-1.5`,children:`what you'd use it for`}),(0,D.jsx)(`table`,{className:`text-[12px] text-[var(--color-fg-3)] w-full border-separate border-spacing-y-1`,children:(0,D.jsxs)(`tbody`,{children:[(0,D.jsx)(xu,{question:`Why did SSG block my agent from running this command?`,tab:`rca`,how:`open RCA — or find the trace in Timeline and read the deciding rule`}),(0,D.jsx)(xu,{question:`I just wrote a rule. Did it actually fire?`,tab:`timeline`,how:`trigger the tool call, find your trace, look for your rule_id in a match-stage bar`}),(0,D.jsx)(xu,{question:`Are my rules even loaded? Did a syntax error skip one?`,tab:`state`,how:`check the rules_loaded count — or open Watch and resolve ssg://rules/list`}),(0,D.jsx)(xu,{question:`My agent feels slow when SSG is on — is SSG the cause?`,tab:`metrics`,how:`look at per-stage latency; the hot stage tells you whether parse, match, native FFI, or audit is the culprit`}),(0,D.jsx)(xu,{question:`Something errored and I want a one-line diagnosis before reading logs`,tab:`rca`,how:`the latest RCA pack ranks hypotheses by confidence and suggests next actions`})]})})]}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-relaxed`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:`heads up ·`}),` `,`The Timeline (every frame of every eval) is opt-in because it adds overhead. Restart the daemon with`,` `,(0,D.jsx)(`code`,{className:`text-amber-300 font-mono`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),` `,`to turn it on. RCA, State, and Metrics work without it.`]})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{t(!0);try{window.localStorage.setItem(yu,`1`)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] shrink-0`,title:`Hide this panel`,children:`hide`})]})})}function xu({question:e,tab:t,how:n}){return(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{className:`align-top pr-3 text-[12px] text-[var(--color-fg-2)] w-[55%]`,children:e}),(0,D.jsx)(`td`,{className:`align-top pr-3 w-[80px]`,children:(0,D.jsx)(`span`,{className:`chip text-[10px] uppercase tracking-wider text-sky-300 border-sky-500/30`,children:t})}),(0,D.jsx)(`td`,{className:`align-top text-[11px] text-[var(--color-fg-4)] leading-snug`,children:n})]})}function Su(){let{data:e}=U(`/api/json/debug?uri=ssg%3A%2F%2Fdaemon%2Fstate`,[]);return e?.data?.debug_enabled===!1?(0,D.jsxs)(`aside`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/5 p-3 text-[12px] text-amber-200 space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-amber-300`,children:`timeline disabled · frame collection is off`}),(0,D.jsx)(`p`,{className:`text-[12px] leading-snug`,children:`The daemon is running but not capturing per-stage eval frames — so the Timeline tab will stay empty no matter how many tool calls fire. RCA, State, and Metrics still work.`}),(0,D.jsxs)(`p`,{className:`text-[12px] leading-snug`,children:[`To turn frame capture on, restart with`,` `,(0,D.jsx)(`code`,{className:`text-amber-100 font-mono bg-amber-900/30 px-1.5 py-0.5 rounded-sm`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),`. It's opt-in because collecting every frame adds overhead on the hot path.`]})]}):null}function Cu({tab:e}){let t=_u[e];return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:t.title}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-snug`,children:t.body}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-snug`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:`use when ·`}),` `,t.useWhen]})]})}function wu(){let e=Ge([`debug-frame`])[`debug-frame`]??0,{data:t}=U(`/api/json/debug?uri=ssg%3A%2F%2Fdaemon%2Fstate`,[e]),n=t?.data?.debug_enabled;return n===!1?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-amber-300`,title:`Frame collection is OFF. Restart the daemon with SSG_DEBUG_ENABLED=1 to capture frames.`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-sm bg-amber-400`}),`debug off`]}):n===void 0?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-sm bg-[var(--color-fg-4)]`}),`connecting…`]}):(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,title:`Debug collection is on. ${e} debug-frame bursts received this session.`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`live · `,e]})}function Tu(){let e=Ge([`debug-frame`,`activity-updated`]),{data:t,loading:n,error:r,refetch:i}=U(`/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)(Du,{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`,`
8
+ `+e.stack}}var ve=Object.prototype.hasOwnProperty,ye=t.unstable_scheduleCallback,be=t.unstable_cancelCallback,xe=t.unstable_shouldYield,Se=t.unstable_requestPaint,Ce=t.unstable_now,we=t.unstable_getCurrentPriorityLevel,Te=t.unstable_ImmediatePriority,V=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,De=t.unstable_LowPriority,Oe=t.unstable_IdlePriority,ke=t.log,Ae=t.unstable_setDisableYieldValue,H=null,je=null;function Me(e){if(typeof ke==`function`&&Ae(e),je&&typeof je.setStrictMode==`function`)try{je.setStrictMode(H,e)}catch{}}var Ne=Math.clz32?Math.clz32:Ie,Pe=Math.log,Fe=Math.LN2;function Ie(e){return e>>>=0,e===0?32:31-(Pe(e)/Fe|0)|0}var Le=256,Re=262144,ze=4194304;function Be(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 Ve(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=Be(n))):i=Be(o):i=Be(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Be(n))):i=Be(o)):i=Be(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 He(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ue(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 We(){var e=ze;return ze<<=1,!(ze&62914560)&&(ze=4194304),e}function U(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ge(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ke(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-Ne(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&&qe(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function qe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ne(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Je(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ne(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ye(e,t){var n=t&-t;return n=n&42?1:Xe(n),(n&(e.suspendedLanes|t))===0?n:0}function Xe(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 Ze(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Qe(){var e=I.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function $e(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var et=Math.random().toString(36).slice(2),tt=`__reactFiber$`+et,nt=`__reactProps$`+et,rt=`__reactContainer$`+et,it=`__reactEvents$`+et,at=`__reactListeners$`+et,ot=`__reactHandles$`+et,st=`__reactResources$`+et,ct=`__reactMarker$`+et;function lt(e){delete e[tt],delete e[nt],delete e[it],delete e[at],delete e[ot]}function ut(e){var t=e[tt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[rt]||n[tt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[tt])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function dt(e){if(e=e[tt]||e[rt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ft(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function pt(e){var t=e[st];return t||=e[st]={hoistableStyles:new Map,hoistableScripts:new Map},t}function mt(e){e[ct]=!0}var ht=new Set,gt={};function _t(e,t){vt(e,t),vt(e+`Capture`,t)}function vt(e,t){for(gt[e]=t,e=0;e<t.length;e++)ht.add(t[e])}var yt=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]*$`),bt={},xt={};function St(e){return ve.call(xt,e)?!0:ve.call(bt,e)?!1:yt.test(e)?xt[e]=!0:(bt[e]=!0,!1)}function Ct(e,t,n){if(St(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 wt(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 Tt(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 Et(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Dt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ot(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 kt(e){if(!e._valueTracker){var t=Dt(e)?`checked`:`value`;e._valueTracker=Ot(e,t,``+e[t])}}function At(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Dt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function jt(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 Mt=/[\n"\\]/g;function Nt(e){return e.replace(Mt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Pt(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=``+Et(t)):e.value!==``+Et(t)&&(e.value=``+Et(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):It(e,o,Et(n)):It(e,o,Et(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=``+Et(s):e.removeAttribute(`name`)}function Ft(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)){kt(e);return}n=n==null?``:``+Et(n),t=t==null?n:``+Et(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),kt(e)}function It(e,t,n){t===`number`&&jt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Lt(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=``+Et(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 Rt(e,t,n){if(t!=null&&(t=``+Et(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Et(n)}function zt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(P(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Et(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),kt(e)}function Bt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Vt=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 Ht(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||Vt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ut(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&&Ht(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ht(e,o,t[o])}function Wt(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 Gt=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`]]),Kt=/^[\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 qt(e){return Kt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Jt(){}var Yt=null;function Xt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zt=null,Qt=null;function $t(e){var t=dt(e);if(t&&(e=t.stateNode)){var n=e[nt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Pt(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="`+Nt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[nt]||null;if(!a)throw Error(i(90));Pt(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&&At(r)}break a;case`textarea`:Rt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Lt(e,!!n.multiple,t,!1)}}}var en=!1;function tn(e,t,n){if(en)return e(t,n);en=!0;try{return e(t)}finally{if(en=!1,(Zt!==null||Qt!==null)&&(_u(),Zt&&(t=Zt,e=Qt,Qt=Zt=null,$t(t),e)))for(t=0;t<e.length;t++)$t(e[t])}}function W(e,t){var n=e.stateNode;if(n===null)return null;var r=n[nt]||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 nn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),rn=!1;if(nn)try{var an={};Object.defineProperty(an,`passive`,{get:function(){rn=!0}}),window.addEventListener(`test`,an,an),window.removeEventListener(`test`,an,an)}catch{rn=!1}var on=null,sn=null,cn=null;function ln(){if(cn)return cn;var e,t=sn,n=t.length,r,i=`value`in on?on.value:on.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 cn=i.slice(e,1<r?1-r:void 0)}function un(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 dn(){return!0}function fn(){return!1}function pn(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)?dn:fn,this.isPropagationStopped=fn,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=dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=dn)},persist:function(){},isPersistent:dn}),t}var mn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hn=pn(mn),gn=h({},mn,{view:0,detail:0}),_n=pn(gn),vn,yn,bn,xn=h({},gn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mn,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!==bn&&(bn&&e.type===`mousemove`?(vn=e.screenX-bn.screenX,yn=e.screenY-bn.screenY):yn=vn=0,bn=e),vn)},movementY:function(e){return`movementY`in e?e.movementY:yn}}),Sn=pn(xn),Cn=pn(h({},xn,{dataTransfer:0})),wn=pn(h({},gn,{relatedTarget:0})),Tn=pn(h({},mn,{animationName:0,elapsedTime:0,pseudoElement:0})),En=pn(h({},mn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Dn=pn(h({},mn,{data:0})),On={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},kn={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`},An={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function jn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=An[e])?!!t[e]:!1}function Mn(){return jn}var Nn=pn(h({},gn,{key:function(e){if(e.key){var t=On[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=un(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?kn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mn,charCode:function(e){return e.type===`keypress`?un(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?un(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Pn=pn(h({},xn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Fn=pn(h({},gn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mn})),In=pn(h({},mn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=pn(h({},xn,{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=pn(h({},mn,{newState:0,oldState:0})),zn=[9,13,27,32],Bn=nn&&`CompositionEvent`in window,Vn=null;nn&&`documentMode`in document&&(Vn=document.documentMode);var Hn=nn&&`TextEvent`in window&&!Vn,Un=nn&&(!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=ln(),cn=sn=on=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){Zt?Qt?Qt.push(r):Qt=[r]:Zt=r,t=Td(t,`onChange`),0<t.length&&(n=new hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var er=null,tr=null;function nr(e){_d(e,0)}function rr(e){if(At(ft(e)))return e}function ir(e,t){if(e===`change`)return t}var ar=!1;if(nn){var or;if(nn){var sr=`oninput`in document;if(!sr){var cr=document.createElement(`div`);cr.setAttribute(`oninput`,`return;`),sr=typeof cr.oninput==`function`}or=sr}else or=!1;ar=or&&(!document.documentMode||9<document.documentMode)}function lr(){er&&(er.detachEvent(`onpropertychange`,ur),tr=er=null)}function ur(e){if(e.propertyName===`value`&&rr(tr)){var t=[];$n(t,tr,e,Xt(e)),tn(nr,t)}}function dr(e,t,n){e===`focusin`?(lr(),er=t,tr=n,er.attachEvent(`onpropertychange`,ur)):e===`focusout`&&lr()}function fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return rr(tr)}function pr(e,t){if(e===`click`)return rr(t)}function mr(e,t){if(e===`input`||e===`change`)return rr(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 G(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(!ve.call(t,i)||!gr(e[i],t[i]))return!1}return!0}function _r(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function vr(e,t){var n=_r(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=_r(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=jt(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=jt(e.document)}return t}function K(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 xr=nn&&`documentMode`in document&&11>=document.documentMode,Sr=null,Cr=null,wr=null,Tr=!1;function Er(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Tr||Sr==null||Sr!==jt(r)||(r=Sr,`selectionStart`in r&&K(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}),wr&&G(wr,r)||(wr=r,r=Td(Cr,`onSelect`),0<r.length&&(t=new hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Sr)))}function Dr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Or={animationend:Dr(`Animation`,`AnimationEnd`),animationiteration:Dr(`Animation`,`AnimationIteration`),animationstart:Dr(`Animation`,`AnimationStart`),transitionrun:Dr(`Transition`,`TransitionRun`),transitionstart:Dr(`Transition`,`TransitionStart`),transitioncancel:Dr(`Transition`,`TransitionCancel`),transitionend:Dr(`Transition`,`TransitionEnd`)},kr={},Ar={};nn&&(Ar=document.createElement(`div`).style,`AnimationEvent`in window||(delete Or.animationend.animation,delete Or.animationiteration.animation,delete Or.animationstart.animation),`TransitionEvent`in window||delete Or.transitionend.transition);function jr(e){if(kr[e])return kr[e];if(!Or[e])return e;var t=Or[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Ar)return kr[e]=t[n];return e}var Mr=jr(`animationend`),Nr=jr(`animationiteration`),Pr=jr(`animationstart`),Fr=jr(`transitionrun`),Ir=jr(`transitionstart`),Lr=jr(`transitioncancel`),Rr=jr(`transitionend`),zr=new Map,Br=`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(` `);Br.push(`scrollEnd`);function Vr(e,t){zr.set(e,t),_t(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-Ne(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<cu)throw cu=0,lu=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,re.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:_e(t)},li.set(e,t),t):n}return{value:e,source:t,stack:_e(t)}}var di=[],fi=0,pi=null,mi=0,hi=[],gi=0,_i=null,q=1,vi=``;function J(e,t){di[fi++]=mi,di[fi++]=pi,pi=e,mi=t}function Y(e,t,n){hi[gi++]=q,hi[gi++]=vi,hi[gi++]=_i,_i=e;var r=q;e=vi;var i=32-Ne(r)-1;r&=~(1<<i),n+=1;var a=32-Ne(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,q=1<<32-Ne(t)+i|n<<i|r,vi=a+e}else q=1<<a|n<<i|r,vi=e}function X(e){e.return!==null&&(J(e,1),Y(e,1,0))}function yi(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,vi=hi[--gi],hi[gi]=null,q=hi[--gi],hi[gi]=null}function bi(e,t){hi[gi++]=q,hi[gi++]=vi,hi[gi++]=_i,q=t.id,vi=t.overflow,_i=e}var xi=null,Si=null,Ci=!1,wi=null,Ti=!1,Ei=Error(i(519));function Di(e){throw Ni(ui(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[tt]=e,t[nt]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),Ft(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),zt(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&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=Jt),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&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),wi=null),e}function Ni(e){wi===null?wi=[e]:wi.push(e)}var Pi=R(null),Fi=null,Ii=null;function Li(e,t,n){B(Pi,t._currentValue),t._currentValue=n}function Ri(e){e._currentValue=Pi.current,z(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;gr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===oe.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){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=ld(),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=F.S;F.S=function(e,t){Zl=Ce(),typeof t==`object`&&t&&typeof t.then==`function`&&ra(e,t),oa!==null&&oa(e,t)};var sa=R(null);function ca(){var e=sa.current;return e===null?Pl.pooledCache:e}function la(e,t){t===null?B(sa,sa.current):B(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(Jt,Jt),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(Jt,Jt);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(P(t)||j(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(P(n)||j(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(P(r)||j(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&&J(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&&J(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&&J(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&&J(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&&J(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&&J(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(P(o))return h(e,r,o,c);if(j(o)){if(l=j(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,Je(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?($&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),Hl|=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=R(null),Ha=R(0);function Ua(e,t){e=Bl,B(Ha,e),B(Va,t),Bl=e|t.baseLanes}function Wa(){B(Ha,Bl),B(Va,Va.current)}function Ga(){Bl=Ha.current,z(Va),z(Ha)}var Ka=R(null),qa=null;function Ja(e){var t=e.alternate;B($a,$a.current&1),B(Ka,e),qa===null&&(t===null||Va.current!==null||t.memoizedState!==null)&&(qa=e)}function Ya(e){B($a,$a.current),B(Ka,e),qa===null&&(qa=e)}function Xa(e){e.tag===22?(B($a,$a.current),B(Ka,e),qa===null&&(qa=e)):Za(e)}function Za(){B($a,$a.current),B(Ka,Ka.current)}function Qa(e){z(Ka),qa===e&&(qa=null),z($a)}var $a=R(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,F.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){F.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)}F.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=F.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,F.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]=ee;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:($&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,Hl|=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,Hl|=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=Ci;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&&fu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){Me(!0);try{n()}finally{Me(!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)}};F.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=F.T,o={};F.T=o;try{var s=n(i,r),c=F.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),F.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){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||to&1073741824&&!($&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),Z.lanes|=e,Hl|=e,n)}function ps(e,t,n,r){return gr(n,t)?n:Va.current===null?!(to&42)||to&1073741824&&!($&261930)?(Ys=!0,e.memoizedState=n):(e=du(),Z.lanes|=e,Hl|=e,t):(e=fs(e,n,r),gr(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,Es(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,aa(c,r),uu(e)):Ts(e,t,r,uu(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.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,L,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:L},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,{},uu())}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=uu();e=Ma(n);var r=Na(t,e,n);r!==null&&(fu(r,t,n),Pa(r,t,n)),t={cache:Zi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=uu();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&&(fu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,uu())}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 fu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:ld(),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&&fu(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,Je(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){Me(!0);try{e()}finally{Me(!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){Me(!0);try{n(t)}finally{Me(!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));$&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=vi,r=q;n=(r&~(1<<32-Ne(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=uu(),i=Ma(r);i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(fu(t,e,r),Pa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=Ma(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Na(e,i,r),t!==null&&(fu(t,e,r),Pa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=Ma(n);r.tag=2,t!=null&&(r.callback=t),t=Na(e,r,n),t!==null&&(fu(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?!G(n,r)||!G(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`&&(eu===null?eu=new Set([this]):eu.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?wu():n.alternate===null&&Vl===0&&(Vl=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),Uu(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)),Uu(e,r,a)),!1}throw Error(i(435,n.tag))}return Uu(e,r,a),wu(),!1}if(Ci)return t=Ka.current,t===null?(r!==Ei&&(t=Error(i(423),{cause:r}),Ni(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),Vl!==4&&(Vl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ei&&(e=Error(i(422),{cause:r}),Ni(ui(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ui(o,n),ql===null?ql=[o]:ql.push(o),Vl!==4&&(Vl=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`&&(eu===null||!eu.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&&X(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?G: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(G(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:_i===null?null:{id:q,overflow:vi},retryLane:536870912,hydrationErrors:null},n=si(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=Ye(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Yr(e,s),fu(r,e,s),Js;wu(),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=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)):(Ci&&r&&X(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&&X(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 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|=Gl),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:_i===null?null:{id:q,overflow:vi},retryLane:536870912,hydrationErrors:null},n=si(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=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,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=Ye(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Yr(e,r),fu(s,e,r),Js;af(c)||wu(),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=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),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,B($a,o),Xs(e,t,r,n),r=Ci?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),Hl|=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:se(t,t.stateNode.containerInfo),Li(t,Xi,e.memoizedState.cache),ji();break;case 27:case 5:le(t);break;case 4:se(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),B($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&&Y(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=N(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(se(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=ui(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(ae.current).createElement(n),r[tt]=t,r[nt]=e,Pd(r,n,e),mt(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return le(t),e===null&&Ci&&(r=t.stateNode=ff(t.type,t.pendingProps,ae.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)),le(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 se(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(xu())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(xu())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:We(),e.lanes|=t,Kl|=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),ce(),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(ue(t),n=ae.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=re.current,Ai(t)?Oi(t,e):(e=ff(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(ue(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=re.current,Ai(t))Oi(t,o);else{var s=Bd(ae.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[tt]=t,o[nt]=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=ae.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[tt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Di(t,!0)}else e=Bd(e).createTextNode(r),e[tt]=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[tt]=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[tt]=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 ce(),e===null&&xd(t.stateNode.containerInfo),Ac(t),null;case 10:return Ri(t.type),Ac(t),null;case 19:if(z($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(Vl!==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 B($a,$a.current&1|2),Ci&&J(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ce()>Ql&&(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*Ce()-r.renderingStartTime>Ql&&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=Ce(),e.sibling=null,n=$a.current,B($a,a?n&1|2:n&1),Ci&&J(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&&z(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),ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ue(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 z($a),null;case 4:return ce(),null;case 10:return Ri(t.type),null;case 22:case 23:return Qa(t),Ga(),e!==null&&z(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),ce();break;case 26:case 27:case 5:ue(t);break;case 4:ce();break;case 31:t.memoizedState!==null&&Qa(t);break;case 13:Qa(t);break;case 19:z($a);break;case 10:Ri(t.type);break;case 22:case 23:Qa(t),Ga(),e!==null&&z(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){Hu(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){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ba(t,n)}catch(t){Hu(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){Hu(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){Hu(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){Hu(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){Hu(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){Hu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[nt]=t}catch(t){Hu(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=Jt));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[tt]=e,t[nt]=n}catch(t){Hu(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),K(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){Hu(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){Hu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(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){Hu(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=Ku.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&&lt(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(je&&typeof je.onCommitFiberUnmount==`function`)try{je.onCommitFiberUnmount(H,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){Hu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Hu(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){Hu(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){Hu(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=qu.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[ct]||o[tt]||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[tt]=e,mt(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[tt]=e,mt(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{Bt(a,``)}catch(t){Hu(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){Hu(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){Hu(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)&&(Xl=Ce()),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){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Hu(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){Hu(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&&(Bt(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){Hu(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){Hu(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){Hu(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){Hu(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,$=0,Fl=0,Il=null,Ll=!1,Rl=!1,zl=!1,Bl=0,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return Nl&2&&$!==0?$&-$:F.T===null?Qe():ld()}function du(){if(Gl===0)if(!($&536870912)||Ci){var e=Re;Re<<=1,!(Re&3932160)&&(Re=262144),Gl=e}else Gl=536870912;return e=Ka.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Pl&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,$,Gl,!1)),Ge(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Ul|=n),Vl===4&&gu(e,$,Gl,!1)),td(e))}function pu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||He(e,t),a=r?Du(e,t):Tu(e,t,!0),o=r;do{if(a===0){Rl&&!r&&gu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!hu(n)){a=Tu(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=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(zl&&!l){c.errorRecoveryDisabledLanes|=o,Ul|=o,a=4;break a}o=Jl,Jl=a,o!==null&&(Jl===null?Jl=o:Jl.push.apply(Jl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){yu(e,0),gu(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:gu(r,t,Gl,!Ll);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Xl+300-Ce(),10<a)){if(gu(r,t,Gl,!Ll),Ve(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,`Throttled`,-0,0),a);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,null,-0,0)}}break}while(1);td(e)}function mu(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:Jt},Tl(t,a,d);var m=(a&62914560)===a?Xl-Ce():(a&4194048)===a?Zl-Ce():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(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 gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ne(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&qe(e,n,t)}function _u(){return Nl&6?!0:(nd(0,!1),!1)}function vu(){if(Q!==null){if(Fl===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 yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Pl=e,Q=n=ni(e.current,null),$=t,Fl=0,Il=null,Ll=!1,Rl=He(e,t),zl=!1,Kl=Gl=Wl=Ul=Hl=Vl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ne(r),a=1<<i;t|=e[i],r&=~a}return Bl=t,Kr(),n}function bu(e,t){Z=null,F.H=As,t===da||t===pa?(t=ya(),Fl=3):t===fa?(t=ya(),Fl=4):Fl=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Il=t,Q===null&&(Vl=1,Hs(e,ui(t,e.current)))}function xu(){var e=Ka.current;return e===null?!0:($&4194048)===$?qa===null:($&62914560)===$||$&536870912?e===qa:!1}function Su(){var e=F.H;return F.H=As,e===null?As:e}function Cu(){var e=F.A;return F.A=jl,e}function wu(){Vl=4,Ll||($&4194048)!==$&&Ka.current!==null||(Rl=!0),!(Hl&134217727)&&!(Ul&134217727)||Pl===null||gu(Pl,$,Gl,!1)}function Tu(e,t,n){var r=Nl;Nl|=2;var i=Su(),a=Cu();(Pl!==e||$!==t)&&($l=null,yu(e,t)),t=!1;var o=Vl;a:do try{if(Fl!==0&&Q!==null){var s=Q,c=Il;switch(Fl){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Ka.current===null&&(t=!0);var l=Fl;if(Fl=0,Il=null,ju(e,s,c,l),n&&Rl){o=0;break a}break;default:l=Fl,Fl=0,Il=null,ju(e,s,c,l)}}Eu(),o=Vl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ii=Fi=null,Nl=r,F.H=i,F.A=a,Q===null&&(Pl=null,$=0,Kr()),o}function Eu(){for(;Q!==null;)ku(Q)}function Du(e,t){var n=Nl;Nl|=2;var r=Su(),a=Cu();Pl!==e||$!==t?($l=null,Ql=Ce()+500,yu(e,t)):Rl=He(e,t);a:do try{if(Fl!==0&&Q!==null){t=Q;var o=Il;b:switch(Fl){case 1:Fl=0,Il=null,ju(e,t,o,1);break;case 2:case 9:if(ha(o)){Fl=0,Il=null,Au(t);break}t=function(){Fl!==2&&Fl!==9||Pl!==e||(Fl=7),td(e)},o.then(t,t);break a;case 3:Fl=7;break a;case 4:Fl=5;break a;case 7:ha(o)?(Fl=0,Il=null,Au(t)):(Fl=0,Il=null,ju(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){Fl=0,Il=null;var l=c.sibling;if(l!==null)Q=l;else{var u=c.return;u===null?Q=null:(Q=u,Mu(u))}break b}}Fl=0,Il=null,ju(e,t,o,5);break;case 6:Fl=0,Il=null,ju(e,t,o,6);break;case 8:vu(),Vl=6;break a;default:throw Error(i(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Ii=Fi=null,F.H=r,F.A=a,Nl=n,Q===null?(Pl=null,$=0,Kr(),Vl):0}function Ou(){for(;Q!==null&&!xe();)ku(Q)}function ku(e){var t=wc(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,t===null?Mu(e):Q=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,$);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,$);break;case 5:bo(t);default:Nc(n,t),t=Q=ri(t,Bl),t=wc(n,t,Bl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):Q=t}function ju(e,t,n,r){Ii=Fi=null,bo(t),xa=null,Sa=0;var i=t.return;try{if(qs(e,i,t,n,$)){Vl=1,Hs(e,ui(n,e.current)),Q=null;return}}catch(t){if(i!==null)throw Q=i,t;Vl=1,Hs(e,ui(n,e.current)),Q=null;return}t.flags&32768?(Ci||r===1?e=!0:Rl||$&536870912?e=!1:(Ll=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ka.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Ll);return}e=t.return;var n=jc(t.alternate,t,Bl);if(n!==null){Q=n;return}if(t=t.sibling,t!==null){Q=t;return}Q=t=e}while(t!==null);Vl===0&&(Vl=5)}function Nu(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);Vl=6,Q=null}function Pu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==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,Ke(e,n,o,s,c,l),e===Pl&&(Q=Pl=null,$=0),ru=t,nu=e,iu=n,au=o,ou=a,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(Ee,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,a=I.p,I.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,I.p=a,F.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.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&&K(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 _=vr(s,h),v=vr(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,I.p=r,F.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,I.p=r,F.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,Se();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),Ze(n),t=t.stateNode,je&&typeof je.onCommitFiberRoot==`function`)try{je.onCommitFiberRoot(H,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.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{F.T=t,I.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Qi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=Ze(iu),r=F.T,a=I.p;try{I.p=32>n?32:n,F.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,nd(0,!1),je&&typeof je.onPostCommitFiberRoot==`function`)try{je.onPostCommitFiberRoot(H,o)}catch{}return!0}finally{I.p=a,F.T=r,Ru(e,t)}}function Vu(e,t,n){t=ui(n,t),t=Ws(e.stateNode,t,2),e=Na(e,t,2),e!==null&&(Ge(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=ui(n,e),n=Gs(2),r=Na(t,n,2),r!==null&&(Ks(n,r,t,e),Ge(r,2),td(r));break}}t=t.return}}function Uu(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)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&($&n)===n&&(Vl===4||Vl===3&&($&62914560)===$&&300>Ce()-Xl?!(Nl&2)&&yu(e,0):Wl|=n,Kl===$&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=We()),e=Yr(e,t),e!==null&&(Ge(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(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),Gu(e,n)}function Ju(e,t){return ye(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;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-Ne(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=$,a=Ve(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||He(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=Ce(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ne(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ue(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=$,n=Ve(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&be(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||He(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&be(r),Ze(n)){case 2:case 8:n=V;break;case 32:n=Ee;break;case 268435456:n=Oe;break;default:n=Ee}return r=od.bind(null,e),n=ye(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&be(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=$;return r=Ve(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,Ce()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){Nl&6?ye(Te,rd):id()})}function ld(){if(ed===0){var e=ta;e===0&&(e=Le,Le<<=1,!(Le&261888)&&(Le=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:qt(``+e)}function dd(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 fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[nt]||null).action),o=r.submitter;o&&(t=(t=o[nt]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(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?dd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Br.length;pd++){var md=Br[pd];Vr(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Vr(Mr,`onAnimationEnd`),Vr(Nr,`onAnimationIteration`),Vr(Pr,`onAnimationStart`),Vr(`dblclick`,`onDoubleClick`),Vr(`focusin`,`onFocus`),Vr(`focusout`,`onBlur`),Vr(Fr,`onTransitionRun`),Vr(Ir,`onTransitionStart`),Vr(Lr,`onTransitionCancel`),Vr(Rr,`onTransitionEnd`),vt(`onMouseEnter`,[`mouseout`,`mouseover`]),vt(`onMouseLeave`,[`mouseout`,`mouseover`]),vt(`onPointerEnter`,[`pointerout`,`pointerover`]),vt(`onPointerLeave`,[`pointerout`,`pointerover`]),_t(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),_t(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),_t(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),_t(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),_t(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),_t(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`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(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(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 vd(e,t){var n=t[it];n===void 0&&(n=t[it]=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,ht.forEach(function(t){t!==`selectionchange`&&(gd.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,!rn||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=ut(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}tn(function(){var r=a,i=Xt(n),s=[];a:{var c=zr.get(e);if(c!==void 0){var l=hn,u=e;switch(e){case`keypress`:if(un(n)===0)break a;case`keydown`:case`keyup`:l=Nn;break;case`focusin`:u=`focus`,l=wn;break;case`focusout`:u=`blur`,l=wn;break;case`beforeblur`:case`afterblur`:l=wn;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=Sn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Cn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Fn;break;case Mr:case Nr:case Pr:l=Tn;break;case Rr:l=In;break;case`scroll`:case`scrollend`:l=_n;break;case`wheel`:l=Ln;break;case`copy`:case`cut`:case`paste`:l=En;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Pn;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=W(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!==Yt&&(u=n.relatedTarget||n.fromElement)&&(ut(u)||u[rt]))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?ut(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=Sn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Pn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ft(l),h=u==null?c:ft(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ut(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?ft(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=ir;else if(Qn(c))if(ar)v=mr;else{v=fr;var y=dr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Wt(r.elementType)&&(v=ir):v=pr;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&&It(c,`number`,c.value)}switch(y=r?ft(r):window,e){case`focusin`:(Qn(y)||y.contentEditable===`true`)&&(Sr=y,Cr=r,wr=null);break;case`focusout`:wr=Cr=Sr=null;break;case`mousedown`:Tr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Tr=!1,Er(s,n,i);break;case`selectionchange`:if(xr)break;case`keydown`:case`keyup`:Er(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=ln()):(on=i,sn=`value`in on?on.value:on.textContent,Jn=!0)),y=Td(r,x),0<y.length&&(x=new Dn(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=Td(r,`onBeforeInput`),0<x.length&&(y=new Dn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),fd(s,e,r,n,i)}_d(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=W(e,n),i!=null&&r.unshift(wd(e,i,a)),i=W(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=W(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=W(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===``||Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Bt(e,``+r);break;case`className`:wt(e,`class`,r);break;case`tabIndex`:wt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:wt(e,n,r);break;case`style`:Ut(e,r,o);break;case`data`:if(t!==`object`){wt(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=qt(``+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=qt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Jt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`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=qt(``+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`:vd(`beforetoggle`,e),vd(`toggle`,e),Ct(e,`popover`,r);break;case`xlinkActuate`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Tt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Tt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ct(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=Gt.get(n)||n,Ct(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Ut(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`?Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Bt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Jt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!gt.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[nt]||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,``):Ct(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`:vd(`error`,e),vd(`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`:vd(`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)}}Ft(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`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&&Lt(e,!!r,n,!0):Lt(e,!!r,t,!1);return;case`textarea`:for(s in vd(`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)}zt(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`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`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(Wt(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)}}Pt(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?Lt(e,!!n,n?[]:``,!1):Lt(e,!!n,t,!0)):Lt(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)}Rt(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(Wt(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[ct]||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),lt(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[ct])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]);lt(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=I.d;I.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=_u();return e||t}function yf(e){var t=dt(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=Nt(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),mt(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="`+Nt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Nt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Nt(n.imageSizes)+`"]`)):i+=`[href="`+Nt(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),mt(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="`+Nt(r)+`"][href="`+Nt(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),mt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=pt(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`);mt(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=pt(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`),mt(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=pt(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`),mt(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=ae.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=pt(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=pt(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=pt(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="`+Nt(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),mt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Nt(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~="`+Nt(n.href)+`"]`);if(r)return t.instance=r,mt(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`),mt(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,mt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),mt(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,mt(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),mt(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[ct]||a[tt]||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,mt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),mt(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:L,_currentValue2:L,_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=U(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=U(0),this.hiddenUpdates=U(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&&(fu(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&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=Xe(t);var n=Yr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,up(e,t,n,r)}finally{I.p=a,F.T=i}}function lp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,up(e,t,n,r)}finally{I.p=a,F.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=dt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Be(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ne(o);s.entanglements[1]|=c,o&=~c}td(a),!(Nl&6)&&(Ql=Ce()+500,nd(0,!1))}}break;case 31:case 13:s=Yr(a,2),s!==null&&fu(s,a,2),_u(),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=Xt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ut(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(we()){case Te:return 2;case V:return 8;case Ee:case De:return 32;case Oe: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=dt(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=ut(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,$e(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,$e(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);Yt=r,n.target.dispatchEvent(r),Yt=null}else return t=dt(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=dt(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[nt]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[nt]||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,uu(),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),_u(),t[rt]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Qe();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`));I.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:F,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{H=zp.inject(Rp),je=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[rt]=t.current,xd(e),new Fp(t)}})),g=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()})),_=c(u(),1),v=c(g(),1);function y(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}var b=[{id:`nav:/`,label:`Home`,hint:`/`,group:`Pages`,keywords:`dashboard overview start`,run:()=>y(`/`)},{id:`nav:/approvals`,label:`Approvals`,hint:`/approvals`,group:`Pages`,keywords:`pending approve deny gate`,run:()=>y(`/approvals`)},{id:`nav:/rules`,label:`Rules`,hint:`/rules`,group:`Pages`,keywords:`guardrails policy dsl`,run:()=>y(`/rules`)},{id:`nav:/hub`,label:`Hub`,hint:`/hub`,group:`Pages`,keywords:`rulesets marketplace community`,run:()=>y(`/hub`)},{id:`nav:/audit`,label:`Audit log`,hint:`/audit`,group:`Pages`,keywords:`history activity log evals`,run:()=>y(`/audit`)},{id:`nav:/agents`,label:`Agents`,hint:`/agents`,group:`Pages`,keywords:`adapters clients claude cursor`,run:()=>y(`/agents`)},{id:`nav:/graph`,label:`Graph`,hint:`/graph`,group:`Pages`,keywords:`sessions timeline chart`,run:()=>y(`/graph`)},{id:`nav:/sessions`,label:`Sessions`,hint:`/sessions`,group:`Pages`,keywords:`history transcripts`,run:()=>y(`/sessions`)},{id:`nav:/observability`,label:`Observability`,hint:`/observability`,group:`Pages`,keywords:`metrics latency telemetry`,run:()=>y(`/observability`)},{id:`nav:/monitor`,label:`Monitor`,hint:`/monitor`,group:`Pages`,keywords:`live tail watch`,run:()=>y(`/monitor`)},{id:`nav:/notifications`,label:`Notifications`,hint:`/notifications`,group:`Pages`,keywords:`alerts inbox`,run:()=>y(`/notifications`)},{id:`nav:/plugins`,label:`Plugins`,hint:`/plugins`,group:`Pages`,keywords:`extensions marketplace`,run:()=>y(`/plugins`)},{id:`nav:/setup`,label:`Setup`,hint:`/setup`,group:`Pages`,keywords:`wizard onboarding install`,run:()=>y(`/setup`)},{id:`nav:/profile`,label:`Profile`,hint:`/profile`,group:`Pages`,keywords:`settings account license`,run:()=>y(`/profile`)},{id:`nav:/debug`,label:`Debug`,hint:`/debug`,group:`Pages`,keywords:`inspector internals`,run:()=>y(`/debug`)},{id:`nav:/support`,label:`Support`,hint:`/support`,group:`Pages`,keywords:`help ticket feedback`,run:()=>y(`/support`)}];function x(){let e=document.cookie.match(/ssg_token=([^;]+)/)?.[1];return e?decodeURIComponent(e):null}async function S(e,t){let n=x(),r={"Content-Type":`application/json`};n&&(r[`X-SigmaShake-Token`]=n),await fetch(e,{method:`POST`,headers:r,body:t?JSON.stringify(t):void 0,credentials:`same-origin`}).catch(()=>{})}var C=[{id:`act:mode:ask`,label:`Set mode → Ask`,hint:`every tool call prompts`,group:`Actions`,keywords:`mode ask gate prompt`,run:()=>S(`/api/json/mode`,{mode:`ask`})},{id:`act:mode:allow`,label:`Set mode → Allow`,hint:`auto-allow everything`,group:`Actions`,keywords:`mode allow auto bypass`,run:()=>S(`/api/json/mode`,{mode:`allow`})},{id:`act:mode:deny`,label:`Set mode → Deny`,hint:`block everything (panic)`,group:`Actions`,keywords:`mode deny panic block`,run:()=>S(`/api/json/mode`,{mode:`deny`})},{id:`act:rules:sync`,label:`Sync rule files → DB`,hint:`POST /api/rules/sync-to-db`,group:`Actions`,keywords:`rules sync drift`,run:()=>S(`/api/rules/sync-to-db`)},{id:`act:rules:reload`,label:`Force-reload rules from disk`,hint:`POST /api/rules/force-reload`,group:`Actions`,keywords:`reload refresh rules`,run:()=>S(`/api/rules/force-reload`)},{id:`act:plugins:reload`,label:`Reload plugin registry`,hint:`POST /api/json/plugins/reload`,group:`Actions`,keywords:`plugins reload`,run:()=>S(`/api/json/plugins/reload`)},{id:`act:hard-reload`,label:`Hard reload dashboard`,hint:`window.location.reload()`,group:`Actions`,keywords:`refresh reload cache bust`,run:()=>window.location.reload()},{id:`act:theme:toggle`,label:`Toggle light / dark theme`,hint:`html[data-theme]`,group:`Actions`,keywords:`theme dark light mode`,run:()=>{let e=document.documentElement,t=(e.getAttribute(`data-theme`)||`light`)===`dark`?`light`:`dark`;e.setAttribute(`data-theme`,t);try{localStorage.setItem(`ssg.theme`,t)}catch{}}},{id:`act:copy-url`,label:`Copy current page URL`,hint:`clipboard`,group:`Actions`,keywords:`copy url link share`,run:()=>{navigator.clipboard?.writeText(location.href).catch(()=>{})}},{id:`act:docs:open`,label:`Open SigmaShake docs`,hint:`docs.sigmashake.com`,group:`External`,keywords:`docs help reference`,run:()=>window.open(`https://docs.sigmashake.com`,`_blank`)},{id:`act:hub:open`,label:`Open SigmaShake Hub`,hint:`hub.sigmashake.com`,group:`External`,keywords:`hub rulesets browse`,run:()=>window.open(`https://hub.sigmashake.com`,`_blank`)}];function w(e,t){if(!e)return 0;let n=e.toLowerCase(),r=t.toLowerCase(),i=r.indexOf(n);if(i===0)return 1e3;if(i>0)return 600-i;let a=0,o=-1,s=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(o>=0&&(s+=e-o-1),o=e,a++);return a<n.length?-1:200-s}function T(e,t){if(!e)return 1;let n=w(e,t.label),r=w(e,t.hint),i=t.keywords?w(e,t.keywords):-1;return Math.max(n,r,i)}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[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(0),[o,s]=(0,_.useState)([]),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null);(0,_.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))}function n(e){r(e.detail?.query??``),t(!0)}function i(e){let t=e.detail?.id;t&&[...b,...C].find(e=>e.id===t)?.run()}return window.addEventListener(`keydown`,e),window.addEventListener(`sigmashake:open-palette`,n),window.addEventListener(`sigmashake:run-command`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`sigmashake:open-palette`,n),window.removeEventListener(`sigmashake:run-command`,i)}},[]),(0,_.useEffect)(()=>{if(!e||o.length>0)return;let t=x();fetch(`/api/json/rules`,{headers:t?{"X-SigmaShake-Token":t}:{},credentials:`same-origin`}).then(e=>e.ok?e.json():[]).then(e=>{Array.isArray(e)&&s(e)}).catch(()=>{})},[e,o.length]);let d=(0,_.useMemo)(()=>o.slice(0,200).map(e=>({id:`rule:${e.id}`,label:e.id,hint:e.message?e.message.slice(0,72):e.decision??`rule`,group:`Rules`,keywords:`${e.decision??``} ${e.enabled?`enabled`:`disabled`}`,run:()=>y(`/rules?focus=${encodeURIComponent(e.id)}`)})),[o]),f=(0,_.useMemo)(()=>[...b,...C,...d],[d]),p=(0,_.useMemo)(()=>{let e=n.trim();return f.map(t=>({it:t,s:T(e,t)})).filter(e=>e.s>=0).sort((e,t)=>t.s-e.s).slice(0,80).map(e=>e.it)},[f,n]),m=(0,_.useMemo)(()=>{if(n.trim())return[{group:`Matches`,items:p}];let e=[`Pages`,`Actions`,`External`,`Rules`],t=new Map;for(let e of p){let n=t.get(e.group)??[];n.push(e),t.set(e.group,n)}return e.filter(e=>t.has(e)).map(e=>({group:e,items:t.get(e)??[]}))},[p,n]),h=(0,_.useMemo)(()=>m.flatMap(e=>e.items),[m]);if((0,_.useEffect)(()=>{if(!e)return;a(0);let t=requestAnimationFrame(()=>c.current?.focus());return()=>cancelAnimationFrame(t)},[e]),(0,_.useEffect)(()=>a(0),[n]),(0,_.useEffect)(()=>{if(!e)return;let t=u.current;t&&t.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,e]),!e)return null;let g=e=>{e&&(t(!1),e.run())},v=-1;return(0,D.jsx)(`div`,{className:`cmdk-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,D.jsxs)(`div`,{className:`cmdk-panel`,children:[(0,D.jsx)(`input`,{ref:c,className:`cmdk-input`,placeholder:`Search pages, actions, rules…`,value:n,"aria-label":`Search`,"aria-controls":`cmdk-listbox`,"aria-activedescendant":h[i]?`cmdk-opt-${h[i].id}`:void 0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Escape`?t(!1):e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,h.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Home`?(e.preventDefault(),a(0)):e.key===`End`?(e.preventDefault(),a(Math.max(h.length-1,0))):e.key===`PageDown`?(e.preventDefault(),a(e=>Math.min(e+8,h.length-1))):e.key===`PageUp`?(e.preventDefault(),a(e=>Math.max(e-8,0))):e.key===`Enter`&&(e.preventDefault(),g(h[i]))}}),(0,D.jsx)(`div`,{ref:l,id:`cmdk-listbox`,className:`cmdk-list`,role:`listbox`,"aria-label":`Results`,children:h.length===0?(0,D.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`}):m.map(e=>(0,D.jsxs)(`div`,{className:`cmdk-group`,children:[(0,D.jsx)(`div`,{className:`cmdk-group-label`,children:e.group}),(0,D.jsx)(`div`,{className:`cmdk-group-list`,children:e.items.map(e=>{v+=1;let t=v===i,n=v;return(0,D.jsxs)(`div`,{id:`cmdk-opt-${e.id}`,ref:t?u:null,role:`option`,"aria-selected":t,tabIndex:-1,className:`cmdk-item${t?` cmdk-item--active`:``}`,onMouseEnter:()=>a(n),onMouseDown:t=>{t.preventDefault(),g(e)},children:[(0,D.jsx)(`span`,{className:`cmdk-item-label`,children:e.label}),(0,D.jsx)(`span`,{className:`cmdk-hint`,children:e.hint})]},e.id)})})]},e.group))}),(0,D.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,D.jsx)(`span`,{children:`↑↓ navigate`}),(0,D.jsx)(`span`,{children:`↵ open`}),(0,D.jsx)(`span`,{children:`PgUp/PgDn jump`}),(0,D.jsx)(`span`,{children:`esc close`})]})]})})}var k=2e3,ee=200,A=3e3,j=1e3,M=3e4,N=Object.freeze({counters:Object.freeze({}),latestBurst:null,burstRing:Object.freeze([]),burstSeq:0,lifecycleRing:Object.freeze([]),connectionSeq:0,connected:!1,reconnectAttempts:0,lastErrorAt:null,reconnectDelayMs:j,desktopUpdate:null}),P=new Set,F={},I=[],L=[],te=[],ne=!1,R=!1,z=null,B=null,re=null,ie=null,ae=!1,oe=typeof localStorage<`u`&&localStorage.getItem(`DEBUG_SSE`)===`1`;function se(e,t){oe&&(t?console.debug(`[ssg-sse] ${e}`,t):console.debug(`[ssg-sse] ${e}`))}function ce(){ae||(ae=!0,queueMicrotask(le))}function le(){ae=!1;let e=Object.keys(F),t=I,n=L,r=te,i=ne,a=z!==null||B!==null||re!==null,o=ie!==null;if(e.length===0&&t.length===0&&n.length===0&&r.length===0&&!i&&!a&&!o)return;let s=N.counters;if(e.length>0){let t={...N.counters};for(let n of e)t[n]=(t[n]??0)+(F[n]??0);s=Object.freeze(t),F={}}let c=N.burstRing,l=N.latestBurst,u=N.burstSeq;if(t.length>0){let e=N.burstRing.length+t.length>k?[...N.burstRing,...t].slice(-k):[...N.burstRing,...t];c=Object.freeze(e),l=t[t.length-1]??l,u=N.burstSeq+t.length,I=[]}if(n.length>0){let e=new Map;for(let t of n)e.set(t.tool_use_id,t);let t=!1,r=c.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&&(c=Object.freeze(r),u=N.burstSeq+1),L=[]}let d=N.lifecycleRing;if(r.length>0){let e=N.lifecycleRing.length+r.length>ee?[...N.lifecycleRing,...r].slice(-ee):[...N.lifecycleRing,...r];d=Object.freeze(e),te=[]}let f=N.connected,p=N.connectionSeq;i&&(f=R,p=N.connectionSeq+1,ne=!1);let m=N.reconnectAttempts,h=N.lastErrorAt,g=N.reconnectDelayMs;z!==null&&(m=z,z=null),B!==null&&(h=B,B=null),re!==null&&(g=re,re=null);let _=N.desktopUpdate;o&&ie&&(_=ie,ie=null),N=Object.freeze({counters:s,latestBurst:l,burstRing:c,burstSeq:u,lifecycleRing:d,connectionSeq:p,connected:f,reconnectAttempts:m,lastErrorAt:h,reconnectDelayMs:g,desktopUpdate:_});for(let e of P)e()}var ue=null,de=0,fe=new Set,pe=new Map,me=null,he=j,ge=null;function _e(e,t){if(e===`eval-burst`){try{let e=JSON.parse(t.data);Array.isArray(e?.bursts)&&(I.push(...e.bursts),ce())}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}:{}};L.push(t),ce()}}catch{}return}if(e===`desktop-update-ready`){try{let e=JSON.parse(t.data);if(e&&typeof e.hash==`string`&&e.hash.length>0&&typeof e.version==`string`&&e.version.length>0){let t=typeof e.ts_ms==`number`&&Number.isFinite(e.ts_ms)&&e.ts_ms>0?e.ts_ms:Date.now();ie={hash:e.hash,version:e.version,tsMs:t},ce()}}catch{}return}if(e===`session-lifecycle`){try{let e=JSON.parse(t.data);Array.isArray(e?.events)&&e.events.length>0&&(te.push(...e.events),ce())}catch{}return}F[e]=(F[e]??0)+1,ce()}function ve(e){if(!ue||pe.has(e))return;let t=t=>_e(e,t);ue.addEventListener(e,t),pe.set(e,t)}var ye=0,be=0,xe=2e3;function Se(){if(ue)return;se(`opening EventSource`,{url:`/api/events`}),be=Date.now();let e=new EventSource(`/api/events`);ue=e,pe.clear();for(let e of fe)ve(e);e.onopen=()=>{let e=N.lastErrorAt!==null;he=j,ye=0,z=0,re=j,ne=!0,R=!0,ce(),e&&je(`reconnect`),se(`connected`)},e.onerror=()=>{e.close(),ue=null,pe.clear(),ne=!0,R=!1,B=Date.now(),ce(),ye===0&&Date.now()-be<xe?se(`first-open interrupted (page-load race) — reconnect in ${he}ms`):console.warn(`[ssg-sse] EventSource error — reconnect in ${he}ms (attempt ${ye+1})`),de>0&&(me=setTimeout(()=>{me=null,de>0&&Se()},he),ye++,z=ye,he=Math.min(he*2,M),re=he,ce())}}function Ce(){me&&=(clearTimeout(me),null),ue?.close(),ue=null,pe.clear(),he=j,ye=0,z=0,re=j,ne=!0,R=!1,ce()}typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&de!==0&&(ue||(me&&=(clearTimeout(me),null),se(`visibilitychange → reconnecting`),Se()))});function we(){for(let e of fe)e!==`eval-burst`&&(F[e]=(F[e]??0)+1);ce()}function Te(e){return P.add(e),()=>{P.delete(e)}}function V(){return N}var Ee=2e3,De=1e4,Oe=1440*60*1e3,ke=500,Ae=0,H=null;function je(e){let t=Date.now();if(t-Ae<De){se(`hydrate skipped (cooldown)`,{reason:e});return}if(H)return;let n=t-Oe,r=N.burstRing[N.burstRing.length-1],i=N.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;Ae=t;let s=new AbortController;H=s,se(`hydrate start`,{reason:e,since:a,until:o,ringLen:N.burstRing.length}),(async()=>{let t=a,n=0;try{for(;n<Ee&&t<o&&!s.signal.aborted;){let r=Math.min(ke,Ee-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||(I.push(...a.bursts),ce(),n+=a.bursts.length,se(`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}se(`hydrate done`,{reason:e,fetched:n})}catch(t){t.name!==`AbortError`&&console.warn(`[ssg-sse] ring hydration failed (${e})`,t)}finally{H=null}})()}function Me(e){for(let t of e)fe.add(t),ve(t);return de++,de===1&&(je(`initial`),Se(),ge=setInterval(we,A)),()=>{de--,de===0&&(Ce(),ge&&=(clearInterval(ge),null))}}function Ne(){let e=(0,_.useSyncExternalStore)(Te,V);return(0,_.useEffect)(()=>Me([`desktop-update-ready`]),[]),e.desktopUpdate}var Pe=`ssg:desktop-update:dismissed-hash`;function Fe(){let e=Ne(),[t,n]=(0,_.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage?.getItem(Pe)??``}catch{return``}});return(0,_.useEffect)(()=>{if(e&&e.hash!==t)try{window.localStorage?.removeItem(Pe)}catch{}},[e,t]),!e||e.hash===t?null:(0,D.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`hig-banner hig-banner-info`,title:`Update hash ${e.hash.slice(0,12)}`,children:[(0,D.jsx)(`span`,{children:`↑`}),(0,D.jsxs)(`span`,{children:[`SigmaShake Desktop v`,e.version,` is downloaded — open the tray and choose `,(0,D.jsx)(`strong`,{children:`Restart to apply`}),`.`]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":`Dismiss update banner`,className:`hig-banner-dismiss`,onClick:()=>{n(e.hash);try{window.localStorage?.setItem(Pe,e.hash)}catch{}},style:{marginLeft:`auto`,background:`transparent`,color:`inherit`,border:`none`,padding:`0 0.25rem`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1},children:`×`})]})}var Ie=`ssg:ui:font-scale:v1`,Le=[{label:`S`,value:.9},{label:`M`,value:1},{label:`L`,value:1.15},{label:`XL`,value:1.3}],Re=1;function ze(e){if(typeof e!=`number`||!Number.isFinite(e))return Re;let t=Le.find(t=>Math.abs(t.value-e)<.001);return t?t.value:Re}function Be(){if(typeof localStorage>`u`)return Re;try{let e=localStorage.getItem(Ie);return e===null?Re:ze(parseFloat(e))}catch{return Re}}function Ve(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Ie,String(e))}catch{}}function He(e){typeof document>`u`||(document.documentElement.style.setProperty(`--ssg-font-scale`,String(e)),document.documentElement.style.fontSize=`${16*e}px`)}function Ue(){let[e,t]=(0,_.useState)(()=>{let e=Be();return He(e),e});return(0,_.useEffect)(()=>{He(e)},[e]),{scale:e,setScale:(0,_.useCallback)(e=>{t(e),Ve(e),He(e)},[])}}function We(){let{scale:e,setScale:t}=Ue();return(0,D.jsx)(`div`,{role:`radiogroup`,"aria-label":`Font size`,className:`hig-segmented`,style:{height:`24px`},children:Le.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)})})}function U(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}}function Ge(e){let t=(0,_.useSyncExternalStore)(Te,V);(0,_.useEffect)(()=>Me(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 Ke=`ssg:active-project:v1`,qe=`ssg:active-project-change`;function Je(){try{let e=localStorage.getItem(Ke);return e&&e.length>0?e:`all`}catch{return`all`}}function Ye(e){try{localStorage.setItem(Ke,e)}catch{}}function Xe(e){window.dispatchEvent(new CustomEvent(qe,{detail:e}))}function Ze(){let[e,t]=(0,_.useState)(()=>Je());return(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;typeof n==`string`&&t(n)};return window.addEventListener(qe,e),()=>window.removeEventListener(qe,e)},[]),{activeProject:e,setActiveProject:(0,_.useCallback)(e=>{t(e),Ye(e),Xe(e)},[])}}function Qe(e,t){return!t||t===`all`?e:`${e}${e.includes(`?`)?`&`:`?`}project=${encodeURIComponent(t)}`}var $e=`ssg:hidden-projects:v1`,et=`ssg:hidden-projects-change`;function tt(){try{let e=localStorage.getItem($e);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?[...new Set(t.filter(e=>typeof e==`string`&&e.length>0))]:[]}catch{return[]}}function nt(e){try{localStorage.setItem($e,JSON.stringify(e))}catch{}}function rt(e){window.dispatchEvent(new CustomEvent(et,{detail:e}))}function it(){let[e,t]=(0,_.useState)(()=>tt());(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;Array.isArray(n)&&t(n)};return window.addEventListener(et,e),()=>window.removeEventListener(et,e)},[]);let n=(0,_.useCallback)(e=>{t(e),nt(e),rt(e)},[]),r=(0,_.useCallback)(t=>{!t||e.includes(t)||n([...e,t])},[e,n]),i=(0,_.useCallback)(t=>{e.includes(t)&&n(e.filter(e=>e!==t))},[e,n]),a=(0,_.useCallback)(()=>{e.length!==0&&n([])},[e,n]);return{hidden:(0,_.useMemo)(()=>new Set(e),[e]),hideProject:r,restoreProject:i,restoreAll:a}}function at({label:e,count:t,activeCount:n=0,selected:r,title:i,onClick:a}){return(0,D.jsxs)(`button`,{type:`button`,onClick:a,title:i,"data-active":r?`true`:`false`,className:`group flex shrink-0 items-center gap-1.5 rounded-sm border px-2.5 py-1 text-[11px] font-mono transition-colors ${r?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`,children:[n>0&&(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,D.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e}),(0,D.jsx)(`span`,{className:`tabular-nums ${r?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:t})]})}function ot({project:e,selected:t,onSelect:n,onRemove:r}){return(0,D.jsxs)(`div`,{"data-active":t?`true`:`false`,title:e.cwd??e.label,className:`group/tab relative flex shrink-0 items-center rounded-sm border py-1 pl-2.5 pr-6 text-[11px] font-mono transition-colors ${t?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1.5 outline-none`,children:[e.active_count>0&&(0,D.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400 animate-pulse`}),(0,D.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.label}),(0,D.jsx)(`span`,{className:`tabular-nums ${t?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:e.session_count})]}),(0,D.jsx)(`button`,{type:`button`,onClick:r,title:`Remove “${e.label}” from the switcher`,"aria-label":`Remove ${e.label} from the switcher`,className:`absolute right-1 top-1/2 flex size-3.5 -translate-y-1/2 items-center justify-center rounded-full text-[12px] leading-none text-[var(--color-fg-4)] opacity-0 transition hover:bg-rose-500/20 hover:text-rose-300 focus:opacity-100 group-hover/tab:opacity-100`,children:`×`})]})}function st(){let{activeProject:e,setActiveProject:t}=Ze(),{hidden:n,hideProject:r,restoreProject:i,restoreAll:a}=it(),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),{data:u}=U(`/api/json/projects`,[o]),d=Ge([`activity-updated`,`session-lifecycle`]),f=(d[`activity-updated`]??0)+(d[`session-lifecycle`]??0);(0,_.useEffect)(()=>{f>0&&s(e=>e+1)},[f]);let p=u?.projects??[],m=u?.total_sessions??0,h=p.filter(e=>!n.has(e.id)),g=p.filter(e=>n.has(e.id));return(0,_.useEffect)(()=>{e!==`all`&&n.has(e)&&t(`all`)},[e,n,t]),(0,_.useEffect)(()=>{e!==`all`&&p.length>0&&!p.some(t=>t.id===e)&&t(`all`)},[e,p,t]),h.length<=1&&g.length===0?null:(0,D.jsxs)(`div`,{"data-tutorial":`project-tabs`,className:`flex items-center gap-1.5 overflow-x-auto border-b border-[var(--color-line-1)] bg-[var(--color-surface-1)]/40 px-4 py-1.5`,children:[(0,D.jsx)(`span`,{className:`shrink-0 pr-1 text-[10px] uppercase tracking-wide text-[var(--color-fg-4)]`,children:`Project`}),(0,D.jsx)(at,{label:`All projects`,count:m,selected:e===`all`,onClick:()=>t(`all`)}),h.map(n=>(0,D.jsx)(ot,{project:n,selected:e===n.id,onSelect:()=>t(n.id),onRemove:()=>r(n.id)},n.id)),g.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,title:`Projects you've removed from the switcher — add them back`,className:`shrink-0 rounded-sm border border-dashed border-[var(--color-line-1)] px-2 py-1 text-[11px] font-mono text-[var(--color-fg-4)] transition hover:border-[var(--color-hig-blue)]/50 hover:text-[var(--color-fg-2)]`,children:c?`− hide list`:`+ ${g.length} hidden`}),c&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[var(--color-line-1)]`}),g.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:`Add “${e.label}” back to the switcher`,className:`flex shrink-0 items-center gap-1 rounded-sm border border-dashed border-[var(--color-line-1)] px-2 py-1 text-[11px] font-mono text-[var(--color-fg-4)] transition hover:border-emerald-400/50 hover:text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:`+`}),(0,D.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.label})]},e.id)),g.length>1&&(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 px-1.5 py-1 text-[11px] font-mono text-[var(--color-fg-4)] underline-offset-2 transition hover:text-[var(--color-fg-2)] hover:underline`,children:`Restore all`})]})]})]})}var ct=`ssg:ui:theme:v1`,lt=[{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`}],ut=new Set([`light`,`gruvbox-light`,`apple-light`]),dt=new Set([`apple-dark`,`dracula`,`gruvbox-dark`,`tokyo-night`,`catppuccin-mocha`,`nord`,`one-dark-pro`]),ft=`default`;function pt(e){return typeof e==`string`&&lt.some(t=>t.value===e)}function mt(){if(typeof localStorage>`u`)return ft;try{let e=localStorage.getItem(ct);return pt(e)?e:ft}catch{return ft}}function ht(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ct,e)}catch{}}function gt(e){typeof document>`u`||(e===ft?(document.documentElement.removeAttribute(`data-theme`),document.documentElement.style.colorScheme=`light dark`):(document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=ut.has(e)?`light`:dt.has(e)?`dark`:`light dark`))}function _t(){let[e,t]=(0,_.useState)(()=>{let e=mt();return gt(e),e});return(0,_.useEffect)(()=>{gt(e)},[e]),{theme:e,setTheme:(0,_.useCallback)(e=>{t(e),ht(e),gt(e)},[])}}function vt(){let{theme:e,setTheme:t}=_t();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:lt.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function yt(){return{target:`[data-tutorial="app-tutorial-btn"]`,title:`Replay anytime`,body:`That's the tour. Reopen this walkthrough whenever you need it from the Tutorial button — every page has its own.`,placement:`bottom`}}function bt(){return{target:`[data-tutorial="app-sidebar"]`,title:`Move around`,body:`The sidebar groups every dashboard area — Overview, Rules, Activity and Tools. Your current page stays highlighted. Tip: press ⌘K (Ctrl+K) to jump to any page instantly.`,placement:`right`}}var xt={"home-pro":{id:`home-pro`,title:`Dashboard`,steps:[{title:`Welcome to SigmaShake`,body:`SigmaShake governs what your AI coding agents are allowed to do. Anything waiting on your decision surfaces at the top of this Dashboard — review those first; the live panels below show the full picture.`},{target:`[data-tutorial="cb-grid"]`,title:`Live panels`,body:`These panels stream straight from the governance engine: eval counters, the allow/block/ask decision mix, a telemetry feed and system vitals. They refresh on their own — no reload needed.`},{target:`[data-tutorial="cb-layout"]`,title:`Make it yours`,body:`Use the layout controls to enter edit mode, then drag and resize panels or swap layout presets. SigmaShake remembers the arrangement on this device.`,placement:`bottom`},{target:`[data-tutorial="app-mode"]`,title:`Enforcement mode`,body:`This pill controls how hard SigmaShake enforces. Cycle On → Soft → Audit → Off when you need to temporarily loosen the guardrails.`,placement:`bottom`},bt(),yt()]},"home-newcomer":{id:`home-newcomer`,title:`Home`,steps:[{title:`Welcome to SigmaShake`,body:`SigmaShake is a seatbelt for AI coding agents — it checks every action your agent takes and stops the risky ones. Here's the quick tour.`},{target:`[data-tutorial="wh-hero"]`,title:`Today at a glance`,body:`These counters show how many actions your AI agent took today and how SigmaShake responded to each one.`,placement:`bottom`},{target:`[data-tutorial="wh-actions"]`,title:`Start here`,body:`These cards are your shortcuts — connect an AI agent, choose guardrails, and review activity. Work through them top to bottom.`},{target:`[data-tutorial="wh-try"]`,title:`Try it risk-free`,body:`The sandbox lets you watch SigmaShake judge realistic scenarios without touching your real machine. Great for building intuition.`},bt(),yt()]},graph:{id:`graph`,title:`Graph`,steps:[{title:`The live Graph`,body:`Watch tool calls flow through the governance engine in real time. Each node is a decision; the graph redraws as your agent works.`},{target:`[data-tutorial="graph-panels"]`,title:`Session panels`,body:`Every active agent session gets its own panel. The busiest session takes the larger hero slot up top.`},{target:`[data-tutorial="graph-views"]`,title:`View modes`,body:`Switch between full, feed, stream and broadcast layouts depending on whether you're inspecting, demoing or streaming.`,placement:`bottom`},{target:`[data-tutorial="graph-timeline"]`,title:`Scrub time`,body:`The timeline lets you rewind and replay what happened — pause the live feed and drag to any moment.`,placement:`top`},{target:`[data-tutorial="graph-inspector"]`,title:`Inspect a node`,body:`Click any node and its details — tool, rule, latency, decision — appear in this side panel.`,placement:`left`},{target:`[data-tutorial="graph-clear"]`,title:`Clear the canvas`,body:`Reset the view when it gets crowded. This only clears the display — your audit log keeps everything.`,placement:`bottom`},yt()]},sessions:{id:`sessions`,title:`Sessions`,steps:[{title:`Agent sessions`,body:`Every run of an AI agent is grouped into a session. This page lists them all with per-session counts and outcomes.`},{target:`[data-tutorial="sessions-table"]`,title:`The session list`,body:`Each row is one session — client, action counts and decision mix. Click a row to open its full inspector.`},{target:`[data-tutorial="sessions-filter"]`,title:`Find a session`,body:`Filter by client, agent id or session key when the list gets long.`,placement:`bottom`},{target:`[data-tutorial="sessions-refresh"]`,title:`Refresh`,body:`Sessions update as agents run — tap refresh to pull the very latest.`,placement:`bottom`},yt()]},"session-detail":{id:`session-detail`,title:`Session Inspector`,steps:[{title:`Session inspector`,body:`A deep dive into one agent session — its decision breakdown, busiest tools and rules, latency profile and full audit trail.`},{target:`[data-tutorial="sd-back"]`,title:`Back to the list`,body:`This breadcrumb returns you to every session. Each row over there links to its own inspector.`,placement:`bottom`},{target:`[data-tutorial="sd-audit"]`,title:`Every action`,body:`The audit panel lists each tool call in this session in order, with the rule that decided it and why.`,placement:`top`},yt()]},debug:{id:`debug`,title:`Debug`,steps:[{title:`AI-native debugger`,body:`When a rule misfires, start here. The debugger surfaces root-cause analysis, eval timelines and live daemon state.`},{target:`[data-tutorial="debug-tabs"]`,title:`Pick a lens`,body:`Each tab is a different debugging view — RCA pack, eval flame chart, ssg:// watch, raw state and metrics.`,placement:`bottom`},{target:`[data-tutorial="debug-pane"]`,title:`The active view`,body:`The selected lens renders here. The RCA pack is the fastest way to understand a misbehaving evaluation.`,placement:`top`},yt()]},rules:{id:`rules`,title:`Rules`,steps:[{title:`Your rules`,body:`Rules are the policy SigmaShake enforces. This page is where you see, tune and monitor every one of them.`},{target:`[data-tutorial="rules-firewall"]`,title:`Firewall controls`,body:`The firewall card is the master switch — see how many rules are active and toggle enforcement in bulk.`},{target:`[data-tutorial="rules-stats"]`,title:`Performance at a glance`,body:`This bar shows how often rules fired and how fast the engine ran over your chosen time window.`},{target:`[data-tutorial="rules-top"]`,title:`Busiest rules`,body:`The chart ranks rules by how often they triggered. Click a bar to jump straight to that rule.`},{target:`[data-tutorial="rules-activity"]`,title:`Blocks & holds`,body:`See which rules are actually stopping or pausing your agent — the ones doing the real work.`},{target:`[data-tutorial="rules-recent"]`,title:`Latest decisions`,body:`A live strip of the most recent rule hits, so you can spot a noisy or misfiring rule fast.`},yt()]},audit:{id:`audit`,title:`Audit`,steps:[{title:`The audit log`,body:`Every action your AI agent attempted — and exactly what SigmaShake decided — is recorded here, in full.`},{target:`[data-tutorial="audit-filters"]`,title:`Narrow it down`,body:`Filter by decision, AI agent or tool to focus on just the activity you care about.`,placement:`bottom`},{target:`#audit-search`,title:`Search this page`,body:`Full-text search across the current page of results — tool names, rule ids, commands and file paths.`,placement:`bottom`},{target:`[data-tutorial="audit-config"]`,title:`Storage budget`,body:`Tune how many rows the audit log keeps before it rotates — right where you read the data.`},{target:`[data-tutorial="audit-sinks"]`,title:`Forward your logs`,body:`Stream audit events to a central logging destination for long-term retention or SIEM analysis.`},yt()]},approvals:{id:`approvals`,title:`Approvals`,steps:[{title:`Approvals`,body:`When a rule decides ASK, the action pauses here for your call. This page is your review queue.`},{target:`[data-tutorial="appr-stats"]`,title:`Queue health`,body:`A quick read on how many actions are waiting and how you've been responding to them.`,placement:`bottom`},{target:`.ss-noisy-card`,title:`Tame noisy rules`,body:`If a rule asks too often, silence it from here instead of letting it interrupt every run.`},{target:`[data-tutorial="appr-pending"]`,title:`Decide`,body:`Each pending card shows the tool call and the rule that held it. Approve to let it through, deny to block it.`},{target:`[data-tutorial="appr-history"]`,title:`Past decisions`,body:`Everything you've already approved or denied, searchable, so you can revisit any call.`},yt()]},profile:{id:`profile`,title:`Profile`,steps:[{title:`Performance profile`,body:`Two tools in one: an eval profiler that finds governance bottlenecks, and a runtime inspector for the dashboard process itself.`},{target:`[data-tutorial="profile-tabs"]`,title:`Switch tools`,body:`Toggle between the eval profile and the runtime inspector here.`,placement:`bottom`},{target:`[data-tutorial="profile-metrics"]`,title:`The numbers`,body:`Headline latency and throughput metrics for rule evaluation — your baseline for spotting regressions.`},yt()]},agents:{id:`agents`,title:`Agents`,steps:[{title:`AI agents`,body:`SigmaShake works with many AI coding tools. This page connects them and shows which are wired up.`},{target:`[data-tutorial="agents-active"]`,title:`Connected agent`,body:`The agent SigmaShake currently detects sits up top, with its live connection status.`},{target:`[data-tutorial="agents-filter"]`,title:`Browse adapters`,body:`Filter the list to see every supported agent, just the detected ones, or what's available to add.`,placement:`bottom`},{target:`[data-tutorial="agents-list"]`,title:`Wire one up`,body:`Pick an agent to install the SigmaShake hook into it. Each row opens its setup details.`},{target:`[data-tutorial="agents-connections"]`,title:`Where it's installed`,body:`An overview of which projects each agent is governing.`},yt()]},notifications:{id:`notifications`,title:`Notifications`,steps:[{title:`Notifications`,body:`One place to answer "is anything wrong?" — rule drift, audit capacity, daemon health and noisy rules.`},{target:`[data-tutorial="notif-list"]`,title:`What needs attention`,body:`Each item is something SigmaShake noticed. An empty list means everything is healthy.`},bt(),yt()]},setup:{id:`setup`,title:`Setup Status`,steps:[{title:`Setup status`,body:`A full health check of your SigmaShake install — license, daemon, native engine, rules directories and per-agent wiring.`},{target:`[data-tutorial="setup-summary"]`,title:`Overall status`,body:`The top card is the verdict. Green means you're fully set up; warnings point you at what's left.`},{target:`[data-tutorial="setup-checks"]`,title:`The checklist`,body:`Each probe verifies one piece of the install. Expand any that aren't passing to see the fix.`},yt()]},simulator:{id:`simulator`,title:`Try It`,steps:[{title:`Try it`,body:`A safe sandbox: run realistic scenarios past your rules and see what SigmaShake would allow, block, ask or log — nothing actually executes.`},{target:`[data-tutorial="try-scenarios"]`,title:`Pick a scenario`,body:`Scenarios are grouped by category. Choose one to load a realistic command.`},{target:`[data-tutorial="try-detail"]`,title:`Review & run`,body:`The selected scenario shows the exact command. Hit Run simulation to get a verdict.`},{target:`#tryit-result`,title:`The verdict`,body:`SigmaShake explains its decision here — what it decided, why, and what would have happened.`,placement:`top`},{target:`[data-tutorial="try-advanced"]`,title:`Custom input`,body:`Drop in your own tool call to test an edge case the preset scenarios don't cover.`},yt()]},guardrails:{id:`guardrails`,title:`Guardrails`,steps:[{title:`Guardrails`,body:`Starter packs are bundles of rules curated for a job. Install one and you're protected in a tap — no rule writing.`},{target:`[data-tutorial="guard-hero"]`,title:`One-tap protection`,body:`Pick the pack that matches what you're worried about — SigmaShake handles the rest.`},{target:`[data-tutorial="guard-packs"]`,title:`Browse the packs`,body:`Each row is a pack. Expand it to see exactly which rules it adds before you install.`},{target:`[data-tutorial="guard-advanced"]`,title:`Go further`,body:`Ready for more control? Flip to Advanced mode for the full rule library, audit log, graph, and per-rule controls.`},yt()]},hub:{id:`hub`,title:`Hub`,steps:[{title:`Rules hub`,body:`A marketplace of community governance rulesets. Find one that fits, install it, and it joins your rules.`},{target:`[data-tutorial="hub-search"]`,title:`Search`,body:`Search rulesets by name or keyword.`,placement:`bottom`},{target:`[data-tutorial="hub-filters"]`,title:`Filter & sort`,body:`Narrow by decision type or severity, and sort to surface the most relevant or popular packs.`,placement:`bottom`},{target:`[data-tutorial="hub-grid"]`,title:`Browse rulesets`,body:`Each card is an installable ruleset. Open one to read its rules before committing.`},{target:`[data-tutorial="hub-tabs"]`,title:`All vs installed`,body:`Flip between the whole catalog and just what you've already installed.`,placement:`bottom`},{target:`[data-tutorial="hub-connect"]`,title:`Publish your own`,body:`Connect a GitHub account to publish your own rulesets back to the hub.`,placement:`bottom`},yt()]},"hub-connect":{id:`hub-connect`,title:`Connect Hub`,steps:[{title:`Connect GitHub`,body:`Publishing rulesets to the hub needs a GitHub account. This page runs the secure device-code sign-in.`},{title:`The device-code flow`,body:`Start the flow, then enter the short code shown on this page at GitHub's verification page. The dashboard polls until you approve it — no password ever touches SigmaShake.`},yt()]},"hub-publish":{id:`hub-publish`,title:`Publish to Hub`,steps:[{title:`Publish a ruleset`,body:`Share a governance ruleset you keep in a GitHub repo with the whole SigmaShake community.`},{target:`[data-tutorial="hubpub-input"]`,title:`Point at your repo`,body:`Paste the GitHub URL of the repo holding your .rules files.`},{title:`Submit for review`,body:`Publish sends the ruleset to the hub. Once accepted it appears in the marketplace for everyone to install.`},yt()]},"hub-detail":{id:`hub-detail`,title:`Hub Ruleset`,steps:[{title:`Ruleset details`,body:`Everything about one hub ruleset — what it does, which technologies it covers, and every rule inside.`},{title:`Install it`,body:`The install button adds this ruleset to your local rules. You can disable individual rules afterwards on the Rules page.`},{title:`Read before you install`,body:`Scroll the rule list to see the actual policy — each rule's decision and trigger — so there are no surprises.`},yt()]},monitor:{id:`monitor`,title:`Monitor`,steps:[{title:`Daemon monitor`,body:`Live vitals for the evaluation daemon — the background process that judges every tool call.`},{target:`[data-tutorial="monitor-counters"]`,title:`Eval counters`,body:`Running totals of evaluations by outcome, straight from the daemon.`},{target:`[data-tutorial="monitor-resources"]`,title:`Resource limits`,body:`Watch CPU and memory, and set the limits that keep the daemon from running away.`},{target:`[data-tutorial="monitor-tail"]`,title:`Live event tail`,body:`The most recent daemon events scroll here — the fastest way to confirm it's healthy.`,placement:`top`},yt()]},observability:{id:`observability`,title:`Observability`,steps:[{title:`Observability`,body:`Deep system health — database integrity, rule drift, the flight recorder and the daemon log, all in one place.`},{target:`[data-tutorial="observ-drift"]`,title:`Rule drift`,body:`The most important card: it flags when a rule in the database has diverged from its .rules file source. Sync it back from here.`},{target:`[data-tutorial="observ-capacity"]`,title:`Audit capacity`,body:`Track how full the audit log is and when it will next rotate.`},{title:`Dig deeper`,body:`Further down: SQLite health, the flight recorder, the runtime profiler and a live daemon log tail — scroll for the full picture.`},yt()]},plugins:{id:`plugins`,title:`Plugins`,steps:[{title:`Plugin marketplace`,body:`Plugins extend the dashboard with new pages and features. Browse, install and manage them here.`},{target:`[data-tutorial="plugins-tabs"]`,title:`Three views`,body:`Browse the marketplace, manage what you've Installed, or see the Built-in features that ship with SigmaShake.`,placement:`bottom`},{target:`[data-tutorial="plugins-search"]`,title:`Find a plugin`,body:`Search the marketplace by name or keyword.`,placement:`bottom`},{target:`[data-tutorial="plugins-categories"]`,title:`Filter by category`,body:`Category chips narrow the marketplace to one kind of plugin.`,placement:`bottom`},{target:`[data-tutorial="plugins-featured"]`,title:`Editor's picks`,body:`Hand-picked plugins worth a look if you're not sure where to start.`},yt()]},"plugin-publish":{id:`plugin-publish`,title:`Publish a Plugin`,steps:[{title:`Publish a plugin`,body:`Built something useful? This page walks you through getting it onto the marketplace.`},{title:`Three commands`,body:`It's a CLI flow: ssg plugins init scaffolds the plugin, build bundles and signs it, and publish cuts the release.`},{target:`[data-tutorial="pubplug-submit"]`,title:`Submit to the hub`,body:`After building, this link opens the hub submission form to finish your listing.`},yt()]},support:{id:`support`,title:`Support`,steps:[{title:`Support & feedback`,body:`Hit a bug, want a feature, or have a question? Send it straight to the SigmaShake team from here.`},{target:`[data-tutorial="support-subject"]`,title:`Subject`,body:`A short summary. Pick the category above first so it routes to the right place.`},{target:`[data-tutorial="support-desc"]`,title:`Describe it`,body:`The detail. For bugs, what you did and what you expected helps most — diagnostics are attached automatically.`},{target:`[data-tutorial="support-attach"]`,title:`Add a screenshot`,body:`Drag in an image — a screenshot of the problem is worth a thousand words.`},yt()]}};function St(e,t){return e===`/`?t===`newcomer`?xt[`home-newcomer`]:xt[`home-pro`]:e===`/graph`?xt.graph:e===`/sessions`?xt.sessions:e.startsWith(`/sessions/`)?xt[`session-detail`]:e===`/debug`?xt.debug:e===`/rules`?xt.rules:e===`/audit`?xt.audit:e===`/approvals`?xt.approvals:e===`/profile`?xt.profile:e===`/agents`?xt.agents:e===`/notifications`?xt.notifications:e===`/setup`?xt.setup:e===`/try`?xt.simulator:e===`/guardrails`?xt.guardrails:e===`/hub/connect`?xt[`hub-connect`]:e===`/hub/publish`?xt[`hub-publish`]:e.startsWith(`/hub/`)?xt[`hub-detail`]:e===`/hub`?xt.hub:e===`/monitor`?xt.monitor:e===`/observability`?xt.observability:e===`/plugins`?xt.plugins:e===`/publish-plugin`?xt[`plugin-publish`]:e===`/support`?xt.support:null}var Ct=m(),wt=344,Tt=8,Et=16,Dt=14;function Ot(e){if(!e)return null;let t=null;try{t=document.querySelector(e)}catch{return null}if(!t)return null;let n=t.getBoundingClientRect();return n.width<1||n.height<1?null:{top:n.top,left:n.left,width:n.width,height:n.height}}function kt(e,t,n,r){let i=window.innerWidth,a=window.innerHeight;if(!e||t===`center`)return{top:Math.max(Dt,(a-r)/2),left:Math.max(Dt,(i-n)/2),side:`center`};let o={top:e.top-Tt,left:e.left-Tt,right:e.left+e.width+Tt,bottom:e.top+e.height+Tt,cx:e.left+e.width/2,cy:e.top+e.height/2},s={bottom:a-o.bottom>=r+Et+Dt,top:o.top>=r+Et+Dt,right:i-o.right>=n+Et+Dt,left:o.left>=n+Et+Dt},c=(t===`auto`?[`bottom`,`top`,`right`,`left`]:[t,`bottom`,`top`,`right`,`left`]).find(e=>s[e])??`bottom`,l=0,u=0;return c===`bottom`?(l=o.bottom+Et,u=o.cx-n/2):c===`top`?(l=o.top-Et-r,u=o.cx-n/2):c===`right`?(u=o.right+Et,l=o.cy-r/2):(u=o.left-Et-n,l=o.cy-r/2),u=Math.min(Math.max(Dt,u),i-n-Dt),l=Math.min(Math.max(Dt,l),a-r-Dt),{top:l,left:u,side:c}}function At({tutorial:e,onClose:t}){let[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)({top:-9999,left:-9999,side:`center`}),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=e.steps.length,d=e.steps[n],f=n>=u-1,p=n===0,m=(0,_.useCallback)(()=>{n>=e.steps.length-1?t():r(e=>e+1)},[n,e.steps.length,t]),h=(0,_.useCallback)(()=>{r(e=>Math.max(0,e-1))},[]);if((0,_.useEffect)(()=>{let e=d?.target;if(a(Ot(e)),!e)return;let t=null;try{t=document.querySelector(e)}catch{t=null}if(!t)return;t.scrollIntoView({block:`center`,inline:`nearest`,behavior:`smooth`});let n=window.setTimeout(()=>a(Ot(e)),380);return()=>window.clearTimeout(n)},[d]),(0,_.useEffect)(()=>{let e=d?.target;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a(Ot(e)))};return window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[d]),(0,_.useLayoutEffect)(()=>{let e=c.current,t=e?.offsetWidth??wt,n=e?.offsetHeight??220;s(kt(i,d?.placement??`auto`,t,n))},[i,d]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.preventDefault(),t()):e.key===`ArrowRight`?(e.preventDefault(),m()):e.key===`ArrowLeft`&&(e.preventDefault(),h())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,h,t]),(0,_.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[n]),!d)return null;let g=i!==null;return(0,Ct.createPortal)((0,D.jsxs)(`div`,{className:`ssg-tut-root`,role:`presentation`,children:[(0,D.jsx)(`div`,{className:`ssg-tut-catcher${g?``:` ssg-tut-catcher--dim`}`}),g&&i&&(0,D.jsx)(`div`,{className:`ssg-tut-spot`,"aria-hidden":`true`,style:{top:i.top-Tt,left:i.left-Tt,width:i.width+Tt*2,height:i.height+Tt*2}}),(0,D.jsxs)(`div`,{ref:c,className:`ssg-tut-card ssg-tut-card--${o.side}`,style:{top:o.top,left:o.left},role:`dialog`,"aria-modal":`true`,"aria-label":`${e.title} tutorial`,children:[(0,D.jsx)(`button`,{type:`button`,className:`ssg-tut-close`,onClick:t,"aria-label":`Close tutorial`,children:(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`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.jsxs)(`div`,{className:`ssg-tut-eyebrow`,children:[(0,D.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`M12 3l2.5 5.5L20 11l-5.5 2.5L12 19l-2.5-5.5L4 11l5.5-2.5z`})}),(0,D.jsxs)(`span`,{children:[`Tutorial · `,e.title]})]}),(0,D.jsxs)(`div`,{className:`ssg-tut-counter`,children:[`Step `,n+1,` of `,u]}),(0,D.jsx)(`h2`,{className:`ssg-tut-title`,children:d.title}),(0,D.jsx)(`p`,{className:`ssg-tut-body`,children:d.body}),(0,D.jsx)(`div`,{className:`ssg-tut-dots`,role:`tablist`,"aria-label":`Tutorial steps`,children:e.steps.map((e,t)=>(0,D.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,"aria-label":`Step ${t+1}: ${e.title}`,className:`ssg-tut-dot${t===n?` ssg-tut-dot--on`:``}${t<n?` ssg-tut-dot--done`:``}`,onClick:()=>r(t)},e.title))}),(0,D.jsxs)(`div`,{className:`ssg-tut-actions`,children:[!f&&(0,D.jsx)(`button`,{type:`button`,className:`hig-button hig-button-plain hig-button-small`,onClick:t,children:`Skip tour`}),(0,D.jsx)(`span`,{className:`ssg-tut-actions-spacer`}),(0,D.jsx)(`button`,{type:`button`,className:`hig-button hig-button-small`,onClick:h,disabled:p,children:`Back`}),(0,D.jsx)(`button`,{ref:l,type:`button`,className:`hig-button hig-button-primary hig-button-small`,onClick:m,children:f?`Finish`:`Next`})]})]},n)]}),document.body)}var jt=`ssg.tutorial.seen.`;function Mt(e){try{return localStorage.getItem(jt+e)===`1`}catch{return!0}}function Nt(e){try{localStorage.setItem(jt+e,`1`)}catch{}}function Pt({pathname:e,mode:t}){let n=St(e,t),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!0);(0,_.useEffect)(()=>{i(!1),o(n?Mt(n.id):!0)},[n]);let s=(0,_.useCallback)(()=>{n&&(Nt(n.id),o(!0),i(!0))},[n]);return n?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`button`,{type:`button`,"data-tutorial":`app-tutorial-btn`,className:`hig-button hig-button-small ssg-tut-launch`,onClick:s,title:`Take the ${n.title} tutorial`,"aria-label":`Take the ${n.title} tutorial`,children:[(0,D.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,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`})]}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:`Tutorial`}),!a&&(0,D.jsx)(`span`,{className:`ssg-tut-launch-hint`,"aria-hidden":`true`})]}),r&&(0,D.jsx)(At,{tutorial:n,onClose:()=>i(!1)})]}):null}var Ft=`ssg:ui:mode:v1`,It=`ssg:ui:mode:seeded`,Lt=`ssg:ui-mode-change`,Rt=new Set([`professional`,`enterprise`,`agent-dev`]);function zt(){try{let e=localStorage.getItem(Ft);if(e===`newcomer`||e===`pro`)return e}catch{}return null}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}async function Vt(){if(zt()===null){try{if(localStorage.getItem(It))return;localStorage.setItem(It,`1`)}catch{return}try{let e=await fetch(`/api/json/wizard-state`);if(!e.ok){Bt(`newcomer`);return}let t=await e.json(),n=Rt.has(t.profile??``)?`pro`:`newcomer`;Bt(n),window.dispatchEvent(new CustomEvent(Lt,{detail:n}))}catch{Bt(`newcomer`)}}}function Ht(){let[e,t]=(0,_.useState)(()=>zt()??`newcomer`);return(0,_.useEffect)(()=>{Vt().then(()=>{let n=zt();n&&n!==e&&t(n)});let n=e=>{let n=e.detail;(n===`newcomer`||n===`pro`)&&t(n)};return window.addEventListener(Lt,n),()=>window.removeEventListener(Lt,n)},[e]),{mode:e,setMode:(0,_.useCallback)(e=>{t(e),Bt(e),window.dispatchEvent(new CustomEvent(Lt,{detail:e}))},[])}}function Ut(){let{mode:e,setMode:t}=Ht(),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 Wt=A;function Gt(){(0,_.useEffect)(()=>Me([]),[]);let e=(0,_.useSyncExternalStore)(Te,V),[,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=Kt(e),r=n===`reconnecting`&&e.lastErrorAt!==null?Math.max(0,Math.ceil((e.lastErrorAt+e.reconnectDelayMs-Date.now())/1e3)):null,i=Math.round(Wt/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 Kt(e){return e.connected?`connected`:e.reconnectAttempts>0||e.lastErrorAt!==null?`reconnecting`:`disconnected`}var qt=[{id:`voice-navigator`,name:`Voice Navigator`,description:`Hands-free dashboard control. Tap the orb or press Ctrl/Cmd+Shift+V, then speak to navigate pages (“go to rules”), run actions (“set mode to ask”), or dictate a .rules file (“block any command containing curl”). Replies are spoken back. Uses your browser's built-in speech engine — nothing to download.`,icon:`🎙`}],Jt=`ssg:builtin-features:v1`,Yt=`ssg:builtin-features-change`,Xt={"voice-navigator":!0};function Zt(){try{let e=localStorage.getItem(Jt);if(!e)return{...Xt};let t=JSON.parse(e);if(typeof t!=`object`||!t)return{...Xt};let n={...Xt};for(let e of Object.keys(Xt)){let r=t[e];typeof r==`boolean`&&(n[e]=r)}return n}catch{return{...Xt}}}function Qt(e){try{localStorage.setItem(Jt,JSON.stringify(e))}catch{}}function $t(e){window.dispatchEvent(new CustomEvent(Yt,{detail:e}))}function en(){let[e,t]=(0,_.useState)(()=>Zt());return(0,_.useEffect)(()=>{let e=e=>{let n=e.detail;n&&t(n)};return window.addEventListener(Yt,e),()=>window.removeEventListener(Yt,e)},[]),{features:e,setFeature:(0,_.useCallback)((n,r)=>{let i={...e,[n]:r};t(i),Qt(i),$t(i)},[e])}}function tn(e){let{features:t}=en();return t[e]}function W(){let e=document.querySelector(`meta[name="ssg-csrf"]`)?.content??``;return e?{"X-SigmaShake-Token":e}:{}}function nn(){return window.SpeechRecognition??window.webkitSpeechRecognition??null}function rn(){return nn()!==null}function an(){return typeof window<`u`&&`speechSynthesis`in window}function on(){try{return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var sn=null;function cn(){if(!an())return null;if(sn)return sn;let e=window.speechSynthesis.getVoices();if(e.length===0)return null;let t=e.filter(e=>e.lang.toLowerCase().startsWith(`en`)),n=t.length>0?t:e;return sn=n.find(e=>/google|samantha|daniel|aria|natural|neural/i.test(e.name))??n[0]??null,sn}function ln(e,t={}){let n=t.onEnd;if(t.muted||!an()||!e){n?.();return}try{let t=window.speechSynthesis;t.cancel();let r=new SpeechSynthesisUtterance(e),i=cn();i&&(r.voice=i),r.rate=1.05,r.pitch=1,r.volume=1,n&&(r.onend=()=>n(),r.onerror=()=>n()),t.speak(r)}catch{n?.()}}function un(){if(an())try{window.speechSynthesis.cancel()}catch{}}function dn(){if(an())try{cn(),window.speechSynthesis.addEventListener?.(`voiceschanged`,()=>{sn=null,cn()})}catch{}}var fn=new Set(`the.a.an.to.go.goto.open.show.me.my.please.take.navigate.jump.switch.bring.up.page.screen.view.let.lets.hey.sigma.sigmashake.shake.assistant.navi.can.you.i.want.would.like.of.for.from.and.on.into.tab.section.over.there.now.then.just.gimme.give.get.head`.split(`.`)),pn={"nav:/":[`home`,`dashboard`,`overview`,`main`],"nav:/approvals":[`approvals`,`approval`,`pending`,`queue`,`decisions`],"nav:/rules":[`rules`,`rule`,`guardrails`,`guardrail`,`policy`,`policies`],"nav:/hub":[`hub`,`marketplace`,`rulesets`],"nav:/audit":[`audit`,`activity`,`log`,`logs`,`history`],"nav:/agents":[`agents`,`agent`,`adapters`,`clients`],"nav:/graph":[`graph`,`chart`,`timeline`],"nav:/sessions":[`sessions`,`session`,`transcripts`],"nav:/observability":[`observability`,`metrics`,`telemetry`,`latency`],"nav:/monitor":[`monitor`,`watch`,`tail`,`live`],"nav:/notifications":[`notifications`,`notification`,`alerts`,`inbox`],"nav:/plugins":[`plugins`,`plugin`,`extensions`,`marketplace`],"nav:/setup":[`setup`,`wizard`,`onboarding`,`install`],"nav:/profile":[`profile`,`settings`,`account`,`license`],"nav:/debug":[`debug`,`inspector`,`internals`],"nav:/support":[`support`,`help`,`ticket`,`feedback`],"act:mode:ask":[`ask`],"act:mode:allow":[`allow`,`allowing`],"act:mode:deny":[`deny`,`panic`,`lockdown`],"act:rules:sync":[`sync`],"act:rules:reload":[`reload`,`refresh`],"act:plugins:reload":[`plugins`],"act:hard-reload":[`reload`,`dashboard`],"act:theme:toggle":[`theme`,`dark`,`light`],"act:copy-url":[`copy`,`url`,`link`],"act:docs:open":[`docs`,`documentation`],"act:hub:open":[`hub`]};function mn(e){return e.length>3&&e.endsWith(`s`)?e.slice(0,-1):e}function hn(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,` `).split(/\s+/).filter(Boolean).map(mn)}function gn(e){let t=new Set,n=new Set;for(let n of hn(e.label))n.length>=2&&!fn.has(n)&&n!==`set`&&t.add(n);let r=e.hint.startsWith(`/`)?e.hint.slice(1):``;r&&/^[a-z]+$/.test(r)&&t.add(mn(r));for(let t of hn(e.keywords??``))t.length>=2&&n.add(t);for(let n of pn[e.id]??[])t.add(mn(n));for(let e of t)n.delete(e);return{strong:t,weak:n}}var _n=/\b(block|blocks|deny|denies|denied|forbid|forbids|prevent|prevents|disallow|warn|allow only|ask before|require)\b/,vn=/^(create|add|make|write|new|draft|set up|setup)\s+(a\s+|an\s+)?(rule|guardrail|policy)\b/;function yn(e){return e.replace(vn,``).replace(/^\s*(that|which|to|saying)\s+/i,``).trim()}function bn(e){let t=e.trim();if(!t)return{kind:`unknown`,transcript:t};let n=t.toLowerCase(),r=hn(t),i=new Set(r);if(r.length<=3){if(/^(stop|stop listening|cancel listening|that's all|thats all|nevermind|never mind)$/.test(n))return{kind:`control`,control:`stop`};if(/^(cancel|discard|forget it|scratch that)$/.test(n))return{kind:`control`,control:`cancel`};if(/^(save|save it|yes|confirm|do it|apply)$/.test(n))return{kind:`control`,control:`confirm`};if(/^(overwrite|replace|replace it)$/.test(n))return{kind:`control`,control:`overwrite`};if(/^(no|don't|dont|stop that)$/.test(n))return{kind:`control`,control:`discard`};if(/^(help|what can you do|commands|options)$/.test(n))return{kind:`control`,control:`help`}}if((vn.test(n)||_n.test(n))&&!/\bmode\b/.test(n)){let e=yn(t);if(e.length>=4)return{kind:`rule`,ruleText:e}}let a=[...b.map(e=>({kind:`nav`,item:e})),...C.map(e=>({kind:`action`,item:e}))],o=null,s=0;for(let e of a){let{strong:t,weak:n}=gn(e.item),r=0;for(let e of t)i.has(e)&&(r+=3);for(let e of n)i.has(e)&&(r+=1);r>s&&(s=r,o=e)}return o&&s>=3?{kind:o.kind,item:o.item}:{kind:`unknown`,transcript:t}}var xn=`voice-navigator`,Sn=`ssg:voice:muted`,Cn=[`go to rules`,`open the audit log`,`set mode to ask`,`block any command containing curl`];function wn(e){let t=e;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}function Tn(){let e=tn(xn),t=rn(),[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(()=>{try{return localStorage.getItem(Sn)===`1`}catch{return!1}}),m=(0,_.useRef)(null),h=(0,_.useRef)(`idle`),g=(0,_.useRef)(f),v=(0,_.useRef)(!1),b=(0,_.useRef)(!1),x=on();(0,_.useEffect)(()=>{h.current=n},[n]),(0,_.useEffect)(()=>{g.current=f;try{localStorage.setItem(Sn,f?`1`:`0`)}catch{}},[f]),(0,_.useEffect)(()=>{e&&an()&&dn()},[e]);let S=(0,_.useCallback)((e,t)=>{ln(e,{muted:g.current,onEnd:t})},[]),C=(0,_.useCallback)(()=>{let e=m.current;if(e){try{e.onresult=null,e.onend=null,e.onerror=null,e.abort()}catch{}m.current=null}},[]),w=(0,_.useCallback)(async(e,t)=>{r(`thinking`);try{let n=await(await fetch(`/api/rules/dictate/save`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({args:e,overwrite:t})})).json();n.ok?(d(null),b.current=!1,l(`Saved rule “${e.name}”.`),r(`speaking`),S(`Saved the rule ${e.name}.`,()=>r(`idle`)),y(`/rules?focus=${encodeURIComponent(e.name)}`)):n.error===`exists`&&!t?(b.current=!0,l(`A rule named “${e.name}” already exists. Say “overwrite”, or use the buttons.`),r(`confirm`),S(`A rule named ${e.name} already exists. Say overwrite to replace it, or cancel.`)):(l(`Could not save: ${n.error??`unknown error`}`),r(`error`),S(`I couldn't save that rule.`,()=>r(`idle`)))}catch(e){l(`Save failed: ${e instanceof Error?e.message:String(e)}`),r(`error`),S(`Saving the rule failed.`,()=>r(`idle`))}},[S]),T=(0,_.useCallback)(async e=>{r(`thinking`),l(`Drafting a rule from “${e}”…`);try{let t=await(await fetch(`/api/rules/dictate`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({transcript:e})})).json(),n=t.missingSlots??[];if(!t.matched||!t.args){l(`I couldn't turn that into a rule. Try: “block any command containing curl”.`),r(`error`),S(`I couldn't turn that into a rule. Try saying, block any command containing, and then the text.`,()=>r(`idle`));return}if(n.length>0){l(`I need a bit more: ${n.join(`, `)}.`),r(`error`),S(`I need more detail for: ${n.join(`, `)}.`,()=>r(`idle`));return}b.current=!1,d(t),a(!0),l(`Drafted “${t.args.name}”. Say “save” to apply, or “cancel”.`),r(`confirm`),S(`I drafted a rule that ${t.args.decision}s ${t.args.target||`the target`}. Say save to apply, or cancel.`)}catch(e){l(`Dictation failed: ${e instanceof Error?e.message:String(e)}`),r(`error`),S(`Rule dictation failed.`,()=>r(`idle`))}},[S]),E=(0,_.useCallback)(e=>{let t=bn(e);switch(t.kind){case`nav`:case`action`:t.item.run(),l(`→ ${t.item.label}`),r(`speaking`),S(`${t.kind===`nav`?`Opening`:`Running`} ${t.item.label}.`,()=>r(`idle`));return;case`rule`:T(t.ruleText);return;case`control`:if(t.control===`help`){a(!0),l(`Try one of the examples below.`),r(`speaking`),S(`You can say things like, go to rules, set mode to ask, or create a rule that blocks a command.`,()=>r(`idle`));return}if(t.control===`stop`){l(`Stopped listening.`),r(`idle`);return}if(u?.args){t.control===`confirm`||t.control===`overwrite`?w(u.args,b.current):(d(null),b.current=!1,l(`Discarded the draft rule.`),r(`speaking`),S(`Discarded.`,()=>r(`idle`)));return}l(`Nothing to confirm.`),r(`idle`);return;default:l(`I didn't catch a command in “${e}”.`),a(!0),r(`error`),S(`I didn't catch a command. Say help to hear what I can do.`,()=>r(`idle`))}},[T,w,S,u]),O=(0,_.useCallback)(()=>{if(!t){a(!0),l(`Speech recognition isn't available in this browser. Use Chrome, or the Voice Dictation plugin.`),r(`error`);return}if(h.current===`listening`)return;let e=nn();if(!e)return;un(),C();let n=new e;n.lang=`en-US`,n.continuous=!1,n.interimResults=!0,n.maxAlternatives=1,v.current=!1,m.current=n,n.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r],a=i[0];a&&(i.isFinal?n+=a.transcript:t+=a.transcript)}n?(s(n.trim()),v.current||(v.current=!0,E(n.trim()))):s(t)},n.onerror=e=>{e.error===`no-speech`?l(`I didn't hear anything — try again.`):e.error===`not-allowed`||e.error===`service-not-allowed`?l(`Microphone access was blocked. Allow the mic for this site, then try again.`):e.error!==`aborted`&&l(`Voice error: ${e.error}`),e.error!==`aborted`&&r(`error`)},n.onend=()=>{m.current=null,!v.current&&h.current===`listening`&&r(`idle`)};try{n.start(),s(``),l(`Listening…`),a(!0),r(`listening`)}catch{m.current=null,r(`idle`)}},[t,C,E]),k=(0,_.useCallback)(()=>{C(),h.current===`listening`&&(r(`idle`),l(`Stopped.`))},[C]),ee=(0,_.useCallback)(()=>{h.current===`listening`?k():O()},[O,k]);if((0,_.useEffect)(()=>{if(!e)return;function t(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`v`&&!wn(e.target)){e.preventDefault(),ee();return}e.key===`Escape`&&h.current===`listening`&&k()}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,ee,k]),(0,_.useEffect)(()=>{if(!e)return;let t=()=>O();return window.addEventListener(`sigmashake:voice-activate`,t),()=>window.removeEventListener(`sigmashake:voice-activate`,t)},[e,O]),(0,_.useEffect)(()=>(e||(C(),un(),r(`idle`),a(!1)),()=>{C(),un()}),[e,C]),!e)return null;let A=n===`listening`,j=A||n===`thinking`||n===`speaking`;return(0,D.jsxs)(`div`,{className:`voicenav`,"data-phase":n,"data-reduce-motion":x?`true`:`false`,children:[i&&(0,D.jsxs)(`div`,{className:`voicenav-panel`,role:`dialog`,"aria-label":`Voice Navigator`,children:[(0,D.jsxs)(`div`,{className:`voicenav-panel-head`,children:[(0,D.jsxs)(`span`,{className:`voicenav-title`,children:[(0,D.jsx)(`span`,{className:`voicenav-dot`,"aria-hidden":`true`}),`Voice Navigator`]}),(0,D.jsxs)(`div`,{className:`voicenav-panel-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voicenav-iconbtn`,"aria-pressed":f,title:f?`Unmute spoken replies`:`Mute spoken replies`,onClick:()=>p(e=>!e),children:f?`🔇`:`🔊`}),(0,D.jsx)(`button`,{type:`button`,className:`voicenav-iconbtn`,title:`Close`,"aria-label":`Close voice navigator panel`,onClick:()=>{k(),a(!1)},children:`×`})]})]}),(0,D.jsx)(`div`,{className:`voicenav-status`,"aria-live":`polite`,children:c||(t?`Tap the orb or press Ctrl+Shift+V, then speak.`:`Voice input isn't supported here.`)}),(o||A)&&(0,D.jsx)(`div`,{className:`voicenav-transcript`,"data-empty":!o,children:o||`…`}),u?.preview&&(0,D.jsxs)(`div`,{className:`voicenav-rule`,children:[(0,D.jsx)(`pre`,{className:`voicenav-rule-preview`,children:u.preview}),(0,D.jsxs)(`div`,{className:`voicenav-rule-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voicenav-btn voicenav-btn--primary`,onClick:()=>u.args&&void w(u.args,b.current),children:b.current?`Overwrite`:`Save rule`}),(0,D.jsx)(`button`,{type:`button`,className:`voicenav-btn`,onClick:()=>{d(null),b.current=!1,l(`Discarded the draft rule.`),r(`idle`)},children:`Discard`})]})]}),(0,D.jsx)(`div`,{className:`voicenav-examples`,children:Cn.map(e=>(0,D.jsx)(`button`,{type:`button`,className:`voicenav-chip`,title:`Run as if spoken`,onClick:()=>E(e),children:e},e))})]}),(0,D.jsxs)(`button`,{type:`button`,className:`voicenav-orb`,"data-active":j,"data-listening":A,"aria-label":A?`Stop voice navigator`:`Start voice navigator`,title:t?`Voice Navigator (Ctrl/Cmd+Shift+V)`:`Voice Navigator — open panel`,onClick:()=>{i||a(!0),ee()},children:[(0,D.jsx)(`span`,{className:`voicenav-orb-ring`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`voicenav-orb-ring voicenav-orb-ring--2`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`voicenav-orb-core`,"aria-hidden":`true`,children:(0,D.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z`}),(0,D.jsx)(`path`,{d:`M5 11a7 7 0 0 0 14 0`}),(0,D.jsx)(`path`,{d:`M12 18v3`})]})}),A&&(0,D.jsxs)(`span`,{className:`voicenav-wave`,"aria-hidden":`true`,children:[(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{}),(0,D.jsx)(`i`,{})]})]})]})}var En=`ssg:autostart-changed`;async function Dn(e){return await(await fetch(`/api/json/autostart`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify(e)})).json()}function On(){let{data:e,loading:t,error:n,refetch:r}=U(`/api/json/autostart`),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)({kind:`idle`});(0,_.useEffect)(()=>{let e=()=>r();return window.addEventListener(En,e),()=>window.removeEventListener(En,e)},[r]);let c=(0,_.useCallback)(()=>s({kind:`idle`}),[]),l=(0,_.useCallback)(async e=>{a(!0);try{await Dn({action:e,confirm:!0})}finally{a(!1),s({kind:`idle`}),window.dispatchEvent(new Event(En))}},[]),u=(0,_.useCallback)(async e=>{a(!0);try{let t=await Dn({action:e});if(!t||t.status!==`ask`){window.dispatchEvent(new Event(En));return}let n=t;if(n.askMode===`dashboard`){let t=await(await fetch(`/api/pending`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({toolCall:{tool:`ssg.autostart`,input:{action:e}},ruleId:n.ruleId,ruleMessage:n.prompt,prompt:n.prompt})})).json();t.id?s({kind:`dashboard-pending`,env:n,id:t.id}):s({kind:`native-confirm`,env:n})}else s({kind:`native-confirm`,env:n})}finally{a(!1)}},[]),d=(0,_.useCallback)(()=>{o.kind===`native-confirm`&&l(o.env.action)},[o,l]),f=(0,_.useCallback)(async e=>{if(o.kind===`dashboard-pending`){try{await fetch(`/api/decide/${encodeURIComponent(o.id)}?decision=${e}`,{method:`POST`,headers:{...W()}})}catch{}e===`allow`?await l(o.env.action):c()}},[o,l,c]);return(0,_.useEffect)(()=>{if(o.kind!==`dashboard-pending`)return;let e=!1,t,n=async()=>{try{let t=await(await fetch(`/api/pending/${encodeURIComponent(o.id)}/status`)).json();if(e)return;if(t.status===`decided`){t.decision===`allow`?l(o.env.action):c();return}}catch{}e||(t=setTimeout(n,1500))};return t=setTimeout(n,1500),()=>{e=!0,clearTimeout(t)}},[o,l,c]),{status:e,loading:t,error:n,saving:i,flow:o,begin:u,confirmNative:d,approveDashboard:()=>f(`allow`),denyDashboard:()=>f(`block`),cancel:c,refetch:r}}var kn=`ssg:self-protection-changed`;function An(){let{data:e,loading:t,refetch:n}=U(`/api/json/self-protection`),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=()=>n();return window.addEventListener(kn,e),()=>window.removeEventListener(kn,e)},[n]);let a=(0,_.useCallback)(async e=>{i(!0);try{await fetch(`/api/json/self-protection`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({enabled:e})}),window.dispatchEvent(new Event(kn))}finally{i(!1)}},[]);return{enabled:e?.enabled??!1,present:e?.present??!1,ruleCount:e?.ruleCount??0,loading:t,saving:r,setEnabled:a,refetch:n}}var jn=`ssg-dashboard-tabs`,Mn=2e3,Nn=6e3;function Pn(){return`tab-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Fn(){let[e,t]=(0,_.useState)(0),[n,r]=(0,_.useState)(!0),i=(0,_.useRef)(Pn()),a=(0,_.useRef)(new Map);return(0,_.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(jn);function n(){let e=Date.now();for(let[t,n]of a.current.entries())e-n>Nn&&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()},Mn),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 In(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 Ln(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 Rn(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&&(!In(f,i.hooks)||!Ln(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`,...W()},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`,...W()},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`,...W()},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 zn({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 Bn({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 Vn(){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 Hn({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:_}=Rn(e,t);if(i)return(0,D.jsx)(Vn,{});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)(zn,{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)(zn,{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)(Bn,{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 Un({open:e,onClose:t,title:n,subtitle:r,children:i,footer:a,size:o=`md`}){let s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(t);return l.current=t,(0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement;let t=document.body.style.overflow;document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&(e.preventDefault(),l.current())};return document.addEventListener(`keydown`,n),s.current?.focus(),()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=t,c.current?.focus?.()}},[e]),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 Wn=`http://www.w3.org/2000/svg`;function Gn({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="${Wn}">${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 Kn({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)(Gn,{markup:e.glyph,size:Math.round(t*.55)})})}function qn({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 Jn(){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 Yn({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 Xn(e,t){return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}function Zn({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)(Hn,{agentId:e,projectDir:t})})})]})}function Qn({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`,...W()}})).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`,...W()},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`,...W()},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`,ee=u?`Saving…`:e.pinned?`Pinned ✓`:`Set as my agent`,A=u||e.pinned;return(0,D.jsxs)(Un,{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: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:ee})]}),children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-4 mb-4`,children:[(0,D.jsx)(Kn,{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)(qn,{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()?Xn(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:Xn(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)(Yn,{text:C})]}),(0,D.jsx)(Zn,{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)($n,{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 $n({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 er({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)(Kn,{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)(qn,{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)(Jn,{})]})}function tr(){let{data:e,refetch:t}=U(`/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-6xl mx-auto`,children:[(0,D.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3 lg:items-start`,children:[(0,D.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,D.jsxs)(`section`,{"data-tutorial":`agents-active`,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)(Kn,{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)(qn,{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`,...W()},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`,{"data-tutorial":`agents-filter`,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`,{"data-tutorial":`agents-list`,className:`ss-list`,children:o.map(e=>(0,D.jsx)(er,{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.jsxs)(`div`,{className:`space-y-6`,children:[(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)(nr,{ctx:e.context,adapters:e.adapters}),(0,D.jsx)(ir,{})]})]}),l&&(0,D.jsx)(Qn,{agent:l,ctx:e.context,onClose:()=>a(null),onInstalled:()=>t()})]})}function nr({ctx:e,adapters:t}){let{data:n}=U(`/api/json/adapters/recent`),r=t.find(e=>e.active)??null,i=t.filter(e=>e.detected);return(0,D.jsxs)(`section`,{"data-tutorial":`agents-connections`,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)(rr,{label:`Daemon`,status:`on`,detail:`Running — watching tool calls in real time.`}),(0,D.jsx)(rr,{label:`Active AI agent`,status:r?`on`:`off`,detail:r?`${r.displayName} (${r.vendor})`:`Nothing detected yet — install an adapter below.`}),(0,D.jsx)(rr,{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:Xn(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 rr({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 ir(){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`,...W()},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 ar(e,t){if(!e)return;let n=typeof e;if(n===`string`||n===`number`||n===`bigint`){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)ar(n,t);return}if(n===`object`)for(let[n,r]of Object.entries(e))r&&t.push(n)}function or(...e){let t=[];for(let n of e)ar(n,t);return t.join(` `)}function sr(e,t){return n=>{let r=[e],i=t?.variants;if(i){let e=i,a=t?.defaultVariants??{},o=n??{};for(let[t,n]of Object.entries(e)){let e=o[t]??a[t];typeof e==`string`&&r.push(n[e])}}return r.push(n?.class,n?.className),or(...r)}}var cr={block:`display`,"inline-block":`display`,inline:`display`,flex:`display`,"inline-flex":`display`,table:`display`,"inline-table":`display`,grid:`display`,"inline-grid":`display`,contents:`display`,hidden:`display`,"flow-root":`display`,"list-item":`display`,"sr-only":`display`,"not-sr-only":`display`,static:`position`,fixed:`position`,absolute:`position`,relative:`position`,sticky:`position`,"flex-row":`flex-direction`,"flex-row-reverse":`flex-direction`,"flex-col":`flex-direction`,"flex-col-reverse":`flex-direction`,"flex-wrap":`flex-wrap`,"flex-wrap-reverse":`flex-wrap`,"flex-nowrap":`flex-wrap`,"flex-1":`flex`,"flex-auto":`flex`,"flex-initial":`flex`,"flex-none":`flex`,grow:`flex-grow`,"grow-0":`flex-grow`,shrink:`flex-shrink`,"shrink-0":`flex-shrink`,"box-border":`box-sizing`,"box-content":`box-sizing`,visible:`visibility`,invisible:`visibility`,collapse:`visibility`,isolate:`isolation`,"isolation-auto":`isolation`,"text-left":`text-align`,"text-center":`text-align`,"text-right":`text-align`,"text-justify":`text-align`,"text-start":`text-align`,"text-end":`text-align`,uppercase:`text-transform`,lowercase:`text-transform`,capitalize:`text-transform`,"normal-case":`text-transform`,italic:`font-style`,"not-italic":`font-style`,underline:`text-decoration`,overline:`text-decoration`,"line-through":`text-decoration`,"no-underline":`text-decoration`,truncate:`text-overflow`,"text-ellipsis":`text-overflow`,"text-clip":`text-overflow`,antialiased:`font-smoothing`,"subpixel-antialiased":`font-smoothing`,"font-sans":`font-family`,"font-serif":`font-family`,"font-mono":`font-family`,"whitespace-normal":`whitespace`,"whitespace-nowrap":`whitespace`,"whitespace-pre":`whitespace`,"whitespace-pre-line":`whitespace`,"whitespace-pre-wrap":`whitespace`,"whitespace-break-spaces":`whitespace`,"pointer-events-none":`pointer-events`,"pointer-events-auto":`pointer-events`,border:`border-w`,"border-solid":`border-style`,"border-dashed":`border-style`,"border-dotted":`border-style`,"border-double":`border-style`,"border-hidden":`border-style`,"border-none":`border-style`,"border-collapse":`border-collapse`,"border-separate":`border-collapse`,"object-contain":`object-fit`,"object-cover":`object-fit`,"object-fill":`object-fit`,"object-none":`object-fit`,"object-scale-down":`object-fit`,rounded:`rounded`,shadow:`shadow`,transition:`transition`},lr=new Set([`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`7xl`,`8xl`,`9xl`]),ur=new Set([`t`,`r`,`b`,`l`,`tl`,`tr`,`br`,`bl`,`s`,`e`,`ss`,`se`,`ee`,`es`]),dr=new Set([`x`,`y`,`t`,`r`,`b`,`l`,`s`,`e`]);function fr(e){let t=e;if(t.startsWith(`!`)&&(t=t.slice(1)),t.endsWith(`!`)&&(t=t.slice(0,-1)),t.startsWith(`-`)&&(t=t.slice(1)),t===``)return null;let n=cr[t];if(n)return n;let r=t.indexOf(`-`);if(r===-1)return null;let i=t.slice(0,r),a=t.slice(r+1),o=a.split(`-`)[0]??``;switch(i){case`p`:case`px`:case`py`:case`pt`:case`pr`:case`pb`:case`pl`:case`ps`:case`pe`:return`pad-${i}`;case`m`:case`mx`:case`my`:case`mt`:case`mr`:case`mb`:case`ml`:case`ms`:case`me`:return`mar-${i}`;case`w`:return`width`;case`h`:return`height`;case`size`:return`size`;case`min`:return o===`w`?`min-width`:o===`h`?`min-height`:null;case`max`:return o===`w`?`max-width`:o===`h`?`max-height`:null;case`gap`:return o===`x`?`gap-x`:o===`y`?`gap-y`:`gap`;case`z`:return`z-index`;case`opacity`:return`opacity`;case`order`:return`order`;case`basis`:return`flex-basis`;case`aspect`:return`aspect`;case`cursor`:return`cursor`;case`leading`:return`line-height`;case`tracking`:return`letter-spacing`;case`rounded`:return ur.has(o)?`rounded-${o}`:`rounded`;case`shadow`:return`shadow`;case`items`:return`align-items`;case`justify`:return o===`items`?`justify-items`:o===`self`?`justify-self`:`justify-content`;case`self`:return`align-self`;case`content`:return`align-content`;case`transition`:return`transition`;case`duration`:return`duration`;case`delay`:return`delay`;case`ease`:return`ease`;case`top`:return`top`;case`right`:return`right`;case`bottom`:return`bottom`;case`left`:return`left`;case`inset`:return o===`x`?`inset-x`:o===`y`?`inset-y`:`inset`;case`overflow`:return o===`x`?`overflow-x`:o===`y`?`overflow-y`:`overflow`;case`font`:return`font-weight`;case`text`:return pr(a);case`bg`:return`bg-color`;case`border`:return mr(a);case`col`:return o===`span`?`col-span`:`col-start-end`;case`row`:return o===`span`?`row-span`:`row-start-end`;case`grid`:return`grid-${o}`;default:return null}}function pr(e){return lr.has(e)||e.startsWith(`[`)&&/^\[(length:|[\d.]+(px|rem|em|vh|vw|ch|ex|%))/.test(e)?`font-size`:`text-color`}function mr(e){let t=e.split(`-`)[0]??``;return dr.has(t)?`border-w-${t}`:/^\d+$/.test(t)?`border-w`:t===`spacing`?`border-spacing`:`border-color`}function hr(e){let t=0,n=-1;for(let r=0;r<e.length;r++){let i=e[r];i===`[`||i===`(`?t++:i===`]`||i===`)`?t--:i===`:`&&t===0&&(n=r)}return n===-1?{variants:``,base:e}:{variants:e.slice(0,n),base:e.slice(n+1)}}function gr(e){let t=e.split(/\s+/).filter(Boolean),n=new Set,r=[];for(let e=t.length-1;e>=0;e--){let i=t[e],{variants:a,base:o}=hr(i),s=fr(o),c=s===null?`raw:${i}`:`${a}|${s}`;n.has(c)||(n.add(c),r.push(i))}return r.reverse(),r.join(` `)}function G(...e){return gr(or(e))}function _r(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 vr(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 yr(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 br=sr(`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:G(br({variant:t,className:e})),...n})}var xr=e=>e,Sr=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}),Cr=Sr(2),wr=Sr(3),Tr=Sr(4),Er=Sr(5),Dr={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},Or={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},kr={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 Ar(e=1.70158){let t=e;return e=>e*e*((t+1)*e-t)}function jr(e=1.70158){let t=e;return e=>{let n=e-1;return n*n*((t+1)*n+t)+1}}function Mr(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 Nr(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 Pr(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 Fr(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 Ir=7.5625,Lr=2.75,Rr=e=>{if(e<1/Lr)return Ir*e*e;if(e<2/Lr){let t=e-1.5/Lr;return Ir*t*t+.75}if(e<2.5/Lr){let t=e-2.25/Lr;return Ir*t*t+.9375}let t=e-2.625/Lr;return Ir*t*t+.984375},zr=e=>1-Rr(1-e),Br=e=>e<.5?(1-Rr(1-2*e))/2:(1+Rr(2*e-1))/2;function Vr(e){let t=Math.max(1,Math.floor(e));return e=>e>=1?1:e<=0?0:Math.floor(e*t)/t}function Hr(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 Ur(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 Wr={linear:xr,inQuad:Cr.in,outQuad:Cr.out,inOutQuad:Cr.inOut,inCubic:wr.in,outCubic:wr.out,inOutCubic:wr.inOut,inQuart:Tr.in,outQuart:Tr.out,inOutQuart:Tr.inOut,inQuint:Er.in,outQuint:Er.out,inOutQuint:Er.inOut,inSine:Dr.in,outSine:Dr.out,inOutSine:Dr.inOut,inExpo:Or.in,outExpo:Or.out,inOutExpo:Or.inOut,inCirc:kr.in,outCirc:kr.out,inOutCirc:kr.inOut,inBack:Ar(),outBack:jr(),inOutBack:Mr(),inElastic:Pr(),outElastic:Nr(),inOutElastic:Fr(),inBounce:zr,outBounce:Rr,inOutBounce:Br};function Gr(e){if(typeof e==`function`)return e;if(e===void 0)return Wr.outCubic;let t=Wr[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 Nr(t[0],t[1]);case`inElastic`:return Pr(t[0],t[1]);case`inOutElastic`:return Fr(t[0],t[1]);case`outBack`:return jr(t[0]);case`inBack`:return Ar(t[0]);case`inOutBack`:return Mr(t[0]);case`steps`:return Vr(t[0]??4);case`cubicBezier`:return t.length>=4?Hr(t[0],t[1],t[2],t[3]):Wr.outCubic;default:return Wr.outCubic}}return Wr.outCubic}function Kr(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 qr(e,t={}){let n=t.start??0,r=t.direction===`reverse`;return(i,a)=>{if(a<=0)return n;let o=Kr(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 Jr=new Set([`duration`,`delay`,`ease`,`loop`,`alternate`,`onBegin`,`onUpdate`,`onComplete`]);function Yr(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 Xr(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 Zr(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Qr=/^(-?\d*\.?\d+)([a-z%]*)$/i;function $r(e){if(typeof e==`number`)return{value:e,unit:``};let t=e.trim().match(Qr);return t?{value:parseFloat(t[1]),unit:t[2]??``}:{value:0,unit:``}}function ei(e){return e.unit===``?`${e.value}`:`${e.value}${e.unit}`}var ti=new Set([`translate`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`]),ni=new WeakMap;function ri(e){let t=ni.get(e);return t||(t={values:{}},ni.set(e,t)),t}function ii(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 ai(e,t,n){if(ti.has(t)){let r=ri(e);r.values[t]=n,e.style.transform=ii(r);return}if(t===`opacity`){e.style.opacity=`${n.value}`;return}e.style.setProperty(t,ei(n))}function oi(e,t){return ti.has(t)?ri(e).values[t]||{value:+!!t.startsWith(`scale`),unit:``}:$r(e.style.getPropertyValue(t)||(typeof window<`u`?window.getComputedStyle(e).getPropertyValue(t):``)||(t===`opacity`?`1`:`0`))}function si(e,t,n){return e+(t-e)*n}function ci(e,t,n){return e===void 0?0:typeof e==`number`?e:e(t,n)}function li(e){if(e&&typeof e==`object`&&`spring`in e){let t=Ur(e.spring);return{ease:t.fn,duration:t.duration}}return{ease:Gr(e),duration:null}}var ui=0,di=new Set;function fi(e){for(let t of di){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)ai(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&&ai(n.el,e.name,pi(e.from,e.to,t))}n.el!==null&&r.onUpdate?.(d,n.el,n.index)}for(let e of[...di])e.done&&di.delete(e);if(di.size===0){ui=0;return}ui=requestAnimationFrame(fi)}function pi(e,t,n){let r=e.unit||t.unit;return{value:si(e.value,t.value,n),unit:r}}function mi(){ui===0&&(typeof requestAnimationFrame>`u`||(ui=requestAnimationFrame(fi)))}function hi(e,t){let n=Xr(e),r=n.length,i=Object.keys(t).filter(e=>!Jr.has(e)),a=Zr(),{ease:o,duration:s}=li(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=Yr(r);if(i===null)continue;let s,c;Array.isArray(i)?(s=$r(i[0]),c=$r(i[1])):(s=oi(e,n),c=$r(i)),a.push({name:n,from:s,to:c,ease:o})}return{el:e,index:n,props:a,duration:c,delay:ci(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)ai(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)ai(r,e.name,e.from);let s={target:i,start:o,options:t,done:!1};l.push(s),di.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 mi(),{cancel(){if(!p){p=!0;for(let e of l)e.done=!0,di.delete(e)}},finished:Promise.all(u).then(()=>void 0),get done(){return p||l.every(e=>e.done)}}}var gi=sr(`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 _i(e,t){if(Zr())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),hi(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:G(gi({variant:t,size:n,className:e})),onMouseDown:e=>{_i(e.currentTarget,e),r?.(e)},onClick:i,...a}));q.displayName=`Button`;var vi=sr(`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:G(vi({variant:t,className:e})),...n})}function Y({className:e,...t}){return(0,D.jsx)(`div`,{className:G(`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:G(`px-4 py-3 flex-1 min-h-0 overflow-auto`,e),...t})}function yi({className:e,children:t,...n}){return(0,D.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 bi=new Map;async function xi(e){let t=bi.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 bi.set(e,{status:`error`,error:`HTTP ${t.status}`}),null;let n=await t.json();return bi.set(e,{status:`ok`,data:n}),n}catch(t){return bi.set(e,{status:`error`,error:String(t)}),null}})();return bi.set(e,{status:`loading`,promise:n}),n}var Si=220,Ci=90;function wi({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),xi(e).then(e=>{e&&o(e)});let t=bi.get(e);t&&t.status===`ok`&&o(t.data)},Si)},[e,p,f]),h=(0,_.useCallback)(()=>{f(),d.current=setTimeout(()=>{i(!1)},Ci)},[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)(Ti,{data:a}):(0,D.jsx)(`span`,{className:`ss-rule-popover__loading`,children:`loading rule…`})})]})}function Ti({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 Ei={dashboard:`dashboard`,native:`native`,tty:`tty`,cli:`cli`},Di={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},Oi=[`all`,`allow`,`block`,`ask`,`force`,`log`],ki={allow:`text-emerald-300`,block:`text-red-300`,ask:`text-sky-300`,force:`text-amber-300`,log:`text-[var(--color-fg-3)]`},Ai=[`allow`,`ask`,`block`,`disable`],ji={allow:{label:`Always allow`,blurb:`Auto-approve matching tool calls — no prompt.`,toast:`Now always allowing`,tone:`#3fb950`},ask:{label:`Ask every time`,blurb:`Pause and wait for a manual approval each time.`,toast:`Now asking before`,tone:`#58a6ff`},block:{label:`Always block`,blurb:`Auto-deny matching tool calls — no prompt.`,toast:`Now always blocking`,tone:`#ff6f6f`},disable:{label:`Disable rule`,blurb:`Turn the rule off — it stops evaluating entirely.`,toast:`Disabled`,tone:`#8b949e`}};function Mi(e){return new Date(e*1e3).toLocaleString()}function Ni(e,t){if(!t)return``;let n=t-e;return n<60?`${n}s`:`${Math.round(n/60)}m`}async function Pi(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:W()})}async function Fi(e,t){try{return await(await fetch(`/api/rules/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,enabled:t})})).json()}catch(e){return{error:String(e)}}}async function Ii(e,t,n){try{let r=await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t,decision:n})}),i=await r.json().catch(()=>({}));return r.ok?{ok:i.ok!==!1,error:i.error}:{ok:!1,error:i.error??`HTTP ${r.status}`}}catch(e){return{ok:!1,error:String(e)}}}function Li(e,t){return e===`disable`?{decision:t.decision,enabled:!1}:{decision:e,enabled:!0}}function Ri(e){return e.enabled?e.decision===`allow`?`allow`:e.decision===`ask`?`ask`:e.decision===`block`?`block`:null:`disable`}function zi(e,t){if(e===`disable`)return`This rule will stop evaluating tool calls.`;let n=[];return t.decision!==e&&n.push(`decision ${t.decision} → ${e}`),t.enabled||n.push(`rule switched back on`),n.length?n.join(` · `):`No change.`}function Bi(e){try{let t=JSON.parse(e).input;return t&&typeof t==`object`?yr(``,JSON.stringify(t)):yr(``,e)}catch{return e.slice(0,80)}}function Vi(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 Hi({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 Ui(){return(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)(`line`,{x1:`4`,y1:`21`,x2:`4`,y2:`14`}),(0,D.jsx)(`line`,{x1:`4`,y1:`10`,x2:`4`,y2:`3`}),(0,D.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`3`}),(0,D.jsx)(`line`,{x1:`20`,y1:`21`,x2:`20`,y2:`16`}),(0,D.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`3`}),(0,D.jsx)(`line`,{x1:`1`,y1:`14`,x2:`7`,y2:`14`}),(0,D.jsx)(`line`,{x1:`9`,y1:`8`,x2:`15`,y2:`8`}),(0,D.jsx)(`line`,{x1:`17`,y1:`16`,x2:`23`,y2:`16`})]})}function Wi(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 Gi(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 Ki({toast:e,ruleMessage:t,ruleId:n,onDismiss:r,onUndo:i}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>(s.current=setTimeout(r,6e3),()=>{s.current&&clearTimeout(s.current)}),[r]),(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:[e,` `,(0,D.jsx)(`span`,{className:`font-mono text-[var(--color-fg-0)]`,children:t})]}),(0,D.jsx)(`button`,{type:`button`,disabled:a,onClick:async()=>{o(!0),await i(),r()},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 change to ${n}`,children:a?`undoing…`:`undo`}),(0,D.jsx)(`button`,{type:`button`,onClick:r,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 qi({target:e,current:t,rulesLoaded:n,onClose:r,onConfirm:i}){let[a,o]=(0,_.useState)(e?.suggest??null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);if(!e)return null;let d=t?Ri(t):null,f=a!==null&&a===d,p=a!==null&&t!==null&&!f&&!s,m=null;return e.pendingId&&a&&!f&&(m=a===`allow`?`The tool call waiting on this rule will be approved.`:a===`ask`?`The waiting tool call stays pending for you to decide.`:`The tool call waiting on this rule will be denied.`),(0,D.jsxs)(Un,{open:!!e,onClose:r,size:`sm`,title:`Adjust this rule`,subtitle:`Change what this rule does when it matches — or switch it off. Every change here is reversible.`,footer:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--secondary`,disabled:s,onClick:r,children:`Cancel`}),(0,D.jsx)(`button`,{type:`button`,className:`ss-btn ss-btn--primary`,style:{"--tone":a&&!f?ji[a].tone:`var(--color-brand)`},disabled:!p,onClick:async()=>{if(!a||!t)return;c(!0),u(null);let n=await i(e,t,a);if(c(!1),!n.ok){u(n.message??`Could not apply the change.`);return}r()},children:s?`Applying…`:a&&!f?ji[a].label:`Confirm`})]}),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.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 flex-wrap`,children:[(0,D.jsx)(wi,{ruleId:e.ruleId,children:(0,D.jsx)(`code`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] break-all`,children:e.ruleId})}),t&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(K,{variant:Di[t.decision]??`gray`,children:t.decision}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:t.enabled?`enabled`:`disabled`})]})]})]})}),(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.`]})]})})]}),n?t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] mt-4 mb-2`,children:`what should it do?`}),(0,D.jsx)(`div`,{role:`radiogroup`,"aria-label":`Choose what this rule does`,className:`space-y-1.5`,children:Ai.map(e=>{let t=ji[e],n=e===d,r=e===a;return(0,D.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:n||s,onClick:()=>o(e),className:`w-full flex items-start gap-3 px-3 py-2.5 rounded-md border text-left transition-colors ${r?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/8`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)]`} ${n?`opacity-55 cursor-not-allowed`:`cursor-pointer hover:border-[var(--color-line-2)]`}`,children:[(0,D.jsx)(`span`,{className:`mt-0.5 shrink-0 flex items-center justify-center w-3.5 h-3.5 rounded-full border ${r?`border-[var(--color-brand)]`:`border-[var(--color-fg-4)]`}`,children:r&&(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-[var(--color-brand)]`})}),(0,D.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium`,style:{color:t.tone},children:t.label}),n&&(0,D.jsx)(K,{variant:`gray`,children:`current`})]}),(0,D.jsx)(`span`,{className:`block text-xs text-[var(--color-fg-3)] mt-0.5`,children:t.blurb})]})]},e)})}),a&&!f&&(0,D.jsx)(`p`,{className:`mt-3 text-xs font-mono text-[var(--color-fg-2)]`,children:zi(a,t)}),f&&(0,D.jsx)(`p`,{className:`mt-3 text-xs text-[var(--color-fg-3)]`,children:`The rule is already set this way — pick a different option.`}),m&&(0,D.jsx)(`p`,{className:`mt-1.5 text-xs text-[var(--color-fg-3)]`,children:m})]}):(0,D.jsx)(`p`,{className:`mt-3 text-xs text-amber-300`,role:`alert`,children:`This rule is no longer present in your ruleset, so it can't be adjusted. It may have been deleted.`}):(0,D.jsx)(`p`,{className:`mt-3 text-xs text-[var(--color-fg-3)]`,children:`Loading this rule's current state…`}),(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-3 leading-relaxed`,children:[`Reversible — undo straight after, or open`,` `,(0,D.jsx)(`a`,{href:`/rules`,className:`text-[var(--color-brand)] hover:underline`,children:`Rules`}),` `,`anytime.`]}),l&&(0,D.jsx)(`p`,{className:`mt-3 text-xs text-red-300`,role:`alert`,children:l})]})}function Ji(){let e=Ge([`pending-changed`,`rules-changed`]),{data:t,refetch:n}=U(`/api/json/pending`,[e[`pending-changed`]]),{data:r}=U(`/api/json/approvals`,[e[`pending-changed`]]),{data:i,refetch:a}=U(`/api/json/rules`,[e[`rules-changed`]]),[o,s]=(0,_.useState)(`all`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(new Set),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),g=(0,_.useMemo)(()=>{let e=new Map;for(let t of i?.rulesets??[])for(let n of t.rules??[])e.has(n.id)||e.set(n.id,{decision:n.decision,enabled:n.enabled,file:t.file});return e},[i]),v=i!=null,y=(0,_.useMemo)(()=>Wi(r??[],t??[]),[r,t]),b=(0,_.useMemo)(()=>{let e=new Map;for(let t of y)e.set(t.ruleId,t.count);return e},[y]),x=Math.floor(Date.now()/1e3),S=(r??[]).filter(e=>e.created_at>=x-86400).length,C=(r??[]).reduce((e,t)=>(e[t.decision]=(e[t.decision]??0)+1,e),{}),w=(r??[]).filter(e=>{if(o!==`all`&&e.decision!==o)return!1;if(c){let t=c.toLowerCase(),n=Bi(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 T(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function E(e,t,r){let i=Li(r,t),o={decision:t.decision,enabled:t.enabled};if(i.decision!==t.decision){let n=await Ii(e.ruleId,t.file,i.decision);if(!n.ok)return{ok:!1,message:n.error??`Could not change the rule decision.`}}if(i.enabled!==t.enabled){let t=await Fi(e.ruleId,i.enabled);if(t.error||t.ok===!1)return{ok:!1,message:t.error??`Could not change the rule state.`}}if(e.pendingId)try{r===`allow`?await Pi(e.pendingId,`allow`):r!==`ask`&&await Pi(e.pendingId,`block`)}catch{}return h({ruleId:e.ruleId,ruleMessage:e.ruleMessage,file:t.file,action:r,prior:o,end:i}),n(),a(),{ok:!0}}async function O(e){e.end.decision!==e.prior.decision&&await Ii(e.ruleId,e.file,e.prior.decision),e.end.enabled!==e.prior.enabled&&await Fi(e.ruleId,e.prior.enabled),n(),a()}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 · adjust or disable noisy rules`})]}),(0,D.jsxs)(`div`,{"data-tutorial":`appr-stats`,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)(Hi,{label:`pending`,value:t?.length??0,tone:`text-amber-300`}),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),[`allow`,`block`,`ask`,`force`,`log`].map(e=>(0,D.jsx)(Hi,{label:e,value:C[e]??0,tone:ki[e]},e)),(0,D.jsx)(`span`,{className:`text-[var(--color-line-2)]`,children:`|`}),(0,D.jsx)(Hi,{label:`last 24h`,value:S})]}),y.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`]}),y.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)(wi,{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 `,Gi(e.lastSeen)]})]}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill`,onClick:()=>p({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:e.count,suggest:`disable`}),"aria-label":`Adjust rule ${e.ruleId}`,children:[(0,D.jsx)(Ui,{}),`Adjust`]})]},e.ruleId))]}),t&&t.length>0&&(0,D.jsxs)(`section`,{"data-tutorial":`appr-pending`,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=b.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 Pi(e.id,`allow`),n()},children:`approve`}),(0,D.jsx)(q,{size:`sm`,variant:`danger`,onClick:async()=>{await Pi(e.id,`block`),n()},children:`deny`}),(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill`,onClick:()=>p({ruleId:e.ruleId,ruleMessage:e.ruleMessage,fireCount:t||1,pendingId:e.id}),"aria-label":`Adjust rule ${e.ruleId}`,children:[(0,D.jsx)(Ui,{}),`Adjust 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)(wi,{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)(yi,{children:JSON.stringify(e.toolCall.input,null,2)})]})]},e.id)})})]}),(0,D.jsxs)(`section`,{"data-tutorial":`appr-history`,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:Oi.map(e=>(0,D.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-sm text-[11px] font-mono uppercase tracking-wider transition-colors cursor-pointer ${o===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:c,onChange:e=>l(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`}):w.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:w.map(e=>{let t=u.has(e.id),n=Bi(e.input),r=Ni(e.created_at,e.resolved_at);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`button`,{onClick:()=>T(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:Mi(e.resolved_at??e.created_at)}),(0,D.jsx)(K,{variant:Di[e.decision]??`gray`,children:e.decision}),e.source&&(0,D.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)]`,title:`Approval source: ${e.source}`,children:Ei[e.source]??e.source}),(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)(wi,{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:Mi(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:Mi(e.resolved_at)})]}),e.rule_id&&(0,D.jsxs)(`button`,{type:`button`,className:`ss-pill ml-auto`,onClick:()=>p({ruleId:e.rule_id,ruleMessage:e.rule_message||e.rule_id,fireCount:b.get(e.rule_id)??1}),"aria-label":`Adjust rule ${e.rule_id}`,children:[(0,D.jsx)(Ui,{}),`Adjust 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)(yi,{children:Vi(e.input)})]})]},e.id)})})})]}),(0,D.jsx)(qi,{target:f,current:f?g.get(f.ruleId)??null:null,rulesLoaded:v,onClose:()=>p(null),onConfirm:E},f?.ruleId??`closed`),m&&(0,D.jsx)(Ki,{toast:ji[m.action].toast,ruleMessage:m.ruleMessage,ruleId:m.ruleId,onDismiss:()=>h(null),onUndo:()=>O(m)})]})}function Yi(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 Xi(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 Zi(){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=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/audit-config`);if(!e.ok)return;let n=await e.json();t(n),a(String(n.config.maxRows)),s(String(n.config.absoluteMaxRows)),l(String(n.config.minRetentionHours)),d(n.config.maxBytes==null?``:String(Math.round(n.config.maxBytes/(1024*1024))))}catch{}},[]);(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&&` · ${Yi(e.usage.bytes)}`,v!=null&&` · spans ${Xi(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 Qi={"http-json":`HTTP webhook (generic JSON)`,"splunk-hec":`Splunk HEC`,datadog:`Datadog logs`,"file-jsonl":`Local JSONL file`};function $i(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 ea(){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:Qi[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 ee=`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,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:ee,children:e.sinks.length===0?`no destinations`:`${e.sinks.filter(e=>e.enabled).length} of ${e.sinks.length} active`})]}),(0,D.jsx)(`span`,{className:ee,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:Qi[e.type]})]}),(0,D.jsxs)(`div`,{className:`${ee} truncate`,children:[e.endpoint??e.path??``,t&&(0,D.jsxs)(D.Fragment,{children:[` · `,`sent: `,t.last_status??`—`,` · last:`,` `,$i(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:M,children:e.enabled?`disable`:`enable`}),(0,D.jsx)(`button`,{onClick:()=>S(e),disabled:f,className:M,children:`edit`}),(0,D.jsx)(`button`,{onClick:()=>E(e.id),disabled:f,className:`${M} 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:ee,children:`add destination:`}),(e.sinkTypes??[]).map(e=>(0,D.jsxs)(`button`,{onClick:()=>x(e),className:M,children:[`+ `,Qi[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,` · `,Qi[o.type]]}),(0,D.jsx)(`button`,{onClick:()=>l(e=>!e),className:M,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:j,children:`Display name`}),(0,D.jsx)(`input`,{type:`text`,value:o.name,onChange:e=>s({...o,name:e.target.value}),className:`${A} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,children:`Endpoint URL`}),(0,D.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,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,children:`File path`}),(0,D.jsx)(`input`,{type:`text`,value:o.path??``,onChange:e=>s({...o,path:e.target.value}),className:`${A} w-full`})]}),o.type!==`file-jsonl`&&(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} 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:j,children:`Token`}),(0,D.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,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} 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:j,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:`${A} w-full`})]}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`label`,{className:j,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:`${A} w-full`})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1 md:col-span-2`,children:[(0,D.jsxs)(`label`,{className:j,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:`${A} w-full leading-snug`})]})]}),c&&(0,D.jsx)(`textarea`,{value:u,rows:20,onChange:e=>d(e.target.value),className:`${A} 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:M,children:`send test event`}),(0,D.jsx)(`button`,{onClick:C,disabled:f,className:M,children:`cancel`})]})]})]})]})}var ta={__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 na(e){return e?ta[e.toLowerCase()]||`Use the ${e.replace(/^_+/,``)} tool`:`Take an action`}function ra(e){return e?{"claude-code":`Claude Code`,claudecode:`Claude Code`,cursor:`Cursor`,copilot:`GitHub Copilot`,codex:`OpenAI Codex`,"codex-desktop":`Codex Desktop`,gemini:`Gemini`,antigravity:`Antigravity`,pi:`Pi`,generic:`AI agent`,daemon:`SigmaShake`}[e.toLowerCase()]??e:`AI agent`}function ia(e){return e?e.startsWith(`__`):!1}function aa(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 oa(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 sa(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 ca(e){for(let t of[`url`,`URL`,`Url`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function la(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 ua(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 da(e,t){let n=e??``,r=n.toLowerCase(),i=na(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=oa(a);return e?ua(e):{headline:i,detail:`Running a terminal command.`}}if(r===`read`||r===`read_file`||r===`view_file`||r===`cat`||r===`view`){let e=aa(a);return e?{headline:i,detail:`Reading the file \`${la(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=aa(a);return e?{headline:`Save changes to a file`,detail:`Creating or overwriting the file \`${la(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=aa(a);return e?{headline:i,detail:`Editing the file \`${la(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=sa(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=sa(a)??aa(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=ca(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=sa(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 fa({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 pa({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)(fa,{val:t})})]},e))})}var ma={allow:`green`,block:`red`,force:`amber`,ask:`blue`,log:`gray`},ha={allow:`Allowed`,block:`Blocked`,force:`Forced`,ask:`Held`,log:`Logged`},ga={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 _a(e){return e==null?null:e<1e6?`${(e/1e3).toFixed(0)}µs`:`${(e/1e6).toFixed(1)}ms`}function va({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 ya({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 ba({row:e}){let[t,n]=(0,_.useState)(`idle`);return(0,D.jsx)(`button`,{type:`button`,disabled:t===`saving`||t===`done`,title:`Allow this blocked action through from now on — writes a high-priority allow rule that overrides the block. Reversible from Rules.`,onClick:async r=>{if(r.stopPropagation(),!(t===`saving`||t===`done`)){n(`saving`);try{n((await fetch(`/api/autopilot/allow-through`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({tool:e.tool,input:e.input,rule_id:e.rule_id})})).ok?`done`:`error`)}catch{n(`error`)}}},className:`inline-flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider rounded-sm px-2 py-1 transition-colors cursor-pointer disabled:cursor-default ${t===`done`?`border border-emerald-500/40 text-emerald-300 bg-emerald-500/10`:t===`error`?`border border-red-500/40 text-red-300 hover:bg-red-500/10`:`border border-emerald-500/30 text-emerald-300/90 bg-emerald-500/5 hover:text-emerald-200 hover:border-emerald-500/50 hover:bg-emerald-500/10`}`,children:t===`done`?`✓ allowed through`:t===`saving`?`allowing…`:t===`error`?`failed — retry`:`Allow through`})}function xa({row:e,defaultExpanded:t=!1}){let[n,r]=(0,_.useState)(t),i=(0,_.useRef)(null),a=(0,_.useRef)(!0),o=yr(e.tool,e.input),s=o&&o.length>0?o:e.input&&e.input!==`{}`&&e.input!==``?e.input:`—`,c=ma[e.decision]??`gray`,l=ga[e.decision]??`border-l-[var(--color-line-2)]`,u=vr(e.timestamp),d=_a(e.duration_ns),f=da(e.tool,e.input),p=e.decision===`block`||e.decision===`deny`;(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(Zr()){e.style.maxHeight=n?`none`:`0`,e.style.opacity=n?`1`:`0`;return}if(n){let t=e.scrollHeight;hi(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;hi(e,{"max-height":[`${t}px`,`0px`],opacity:[1,0],duration:180,ease:`outCubic`})}}},[n]);let m=(()=>{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:_r(e.timestamp)}),(0,D.jsx)(K,{variant:c,className:`shrink-0 w-20 justify-center`,children:ha[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}),!ia(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:ra(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},"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)(va,{label:`When`,value:u}),(0,D.jsx)(va,{label:`Decision`,children:(0,D.jsx)(K,{variant:c,children:ha[e.decision]??e.decision})}),(0,D.jsx)(va,{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)(va,{label:`AI agent`,value:ra(e.client)}),e.rule_id&&(0,D.jsx)(va,{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)(va,{label:`Source File`,value:e.source_file,mono:!0}),d&&(0,D.jsx)(va,{label:`Latency`,value:d,mono:!0}),e.rules_evaluated!=null&&(0,D.jsx)(va,{label:`Rules Evaluated`,value:`${e.rules_evaluated}`,mono:!0})]}),e.rule_message&&(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:`Rule reason`}),(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-1)] leading-relaxed break-words`,children:e.rule_message})]}),(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)(pa,{inputJson:e.input})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p&&(0,D.jsx)(ba,{row:e}),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)(ya,{text:m})]})]})})]})}var Sa=[``,`allow`,`block`,`force`,`ask`,`log`],Ca=[``,`claude-code`,`gemini`,`antigravity`,`cursor`,`copilot`,`codex`,`pi`,`generic`],wa=[50,100,250,500],Ta=100;function Ea(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(Ta),[u,d]=(0,_.useState)(0),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),{activeProject:y}=Ze();Ge([`activity-updated`]),(0,_.useEffect)(()=>{d(0)},[y]),(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`),y&&y!==`all`&&r.set(`project`,y),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,y]);let b=e=>t=>{e(t.target.value),d(0)},x=(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]),S=f?.total??0,C=Math.floor(u/c)+1,w=Math.max(1,Math.ceil(S/c)),T=S===0?0:u+1,E=Math.min(u+(f?.rows.length??0),S),O=`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`,k=`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:[`· `,S.toLocaleString(),` action`,S===1?``:`s`,` on record`]})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`audit-filters`,className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`select`,{id:`audit-filter-decision`,value:e,onChange:b(t),className:O,children:Sa.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:b(a),className:O,children:Ca.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:b(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:O,title:`Rows per page`,children:wa.map(e=>(0,D.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]})]}),(0,D.jsx)(`div`,{"data-tutorial":`audit-config`,children:(0,D.jsx)(Zi,{})}),(0,D.jsx)(`div`,{"data-tutorial":`audit-sinks`,children:(0,D.jsx)(ea,{})}),(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&&x.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.`:S===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`})]}),x.length>0&&(0,D.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,D.jsx)(xa,{row:e},e.id))}),f&&S>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 `,T.toLocaleString(),`–`,E.toLocaleString(),` `,`of `,S.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{onClick:()=>d(0),disabled:u===0,className:k,children:`⟪ first`}),(0,D.jsx)(`button`,{onClick:()=>d(Math.max(0,u-c)),disabled:u===0,className:k,children:`‹ prev`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`page `,C,` / `,w]}),(0,D.jsx)(`button`,{onClick:()=>d(f.nextOffset==null?u:f.nextOffset),disabled:f.nextOffset==null,className:k,children:`next ›`}),(0,D.jsx)(`button`,{onClick:()=>d((w-1)*c),disabled:f.nextOffset==null,className:k,children:`last ⟫`})]})]})]})}function Da(e){return e?e.added+e.updated+e.removed:0}function Oa(){let[e,t]=(0,_.useState)(!0),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`merge`),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1);async function O(){l(!0),d(null);try{let t=new URLSearchParams;e||t.set(`config`,`0`),n||t.set(`presets`,`0`),i||t.set(`hub`,`0`),o.trim()&&t.set(`label`,o.trim());let r=await fetch(`/api/json/config/export?${t.toString()}`,{headers:W()});if(!r.ok)throw Error(`HTTP ${r.status}`);let a=await r.text(),s=JSON.parse(a),c=new Blob([a],{type:`application/json`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=`ssg-config-bundle.json`,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(l),d({kind:`ok`,text:`Downloaded ${s.rules.length} rule(s), ${s.presets.length} preset(s)${s.config?`, config.toml`:``}.`})}catch(e){d({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}}async function k(e){let t=e.target.files?.[0];t&&(h(t.name),b(null),S(null),p(await t.text()))}async function ee(){E(!0),S(null);try{let e=await(await fetch(`/api/json/pick-file`,{method:`POST`,headers:W()})).json();if(e.ok&&typeof e.content==`string`){b(null),h(e.name??`bundle.json`),p(e.content);return}if(e.reason===`user_cancelled`)return;if(e.reason===`no_picker_found`||e.reason===`no_display`){S({kind:`err`,text:`No native file picker available — drop the bundle below or paste its JSON.`});return}S({kind:`err`,text:e.error??`Could not open the file picker.`})}catch(e){S({kind:`err`,text:e instanceof Error?e.message:String(e)})}finally{E(!1)}}async function A(e){if(!f.trim())return S({kind:`err`,text:`Choose a bundle file first.`}),null;w(!0),S(null);try{let t=await fetch(`/api/json/config/import`,{method:`POST`,headers:{"content-type":`application/json`,...W()},body:JSON.stringify({text:f,mode:g,dryRun:e})}),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);return n}catch(e){return S({kind:`err`,text:e instanceof Error?e.message:String(e)}),null}finally{w(!1)}}async function j(){let e=await A(!0);e&&(b(e),Da(e.counts)===0&&S({kind:`ok`,text:`Already up to date — nothing to apply.`}))}async function M(){let e=await A(!1);if(!e)return;b(null),p(``),h(``);let t=e.counts;S({kind:`ok`,text:`Imported: ${t?.added??0} added, ${t?.updated??0} updated, ${t?.removed??0} removed.${e.backupDir?` Backup → ${e.backupDir}`:``}`})}let N=y?.plan?.filter(e=>e.action!==`skip`)??[];return(0,D.jsxs)(`div`,{className:`p-4 space-y-4 max-w-3xl`,children:[(0,D.jsxs)(`header`,{children:[(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Export & Import`}),(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Share your configuration and rules with teammates, or restore them on another machine. Secrets (tokens, license, audit log) are never included.`})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`h2`,{className:`font-medium`,children:`Export your settings`})}),(0,D.jsxs)(X,{className:`space-y-3`,children:[(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Bundles config.toml, every rule file, presets, and your installed hub rulesets into one JSON file.`}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),` `,`Include config.toml`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` `,`Include presets`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),` `,`Include hub-ruleset list`]})]}),(0,D.jsx)(`input`,{className:`hig-input w-full`,placeholder:`Optional label (e.g. Acme team baseline)`,value:o,onChange:e=>s(e.target.value)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(q,{onClick:O,disabled:c,children:c?`Exporting…`:`Download bundle`}),u&&(0,D.jsx)(`span`,{className:u.kind===`ok`?`text-sm text-emerald-500`:`text-sm text-red-500`,children:u.text})]})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`h2`,{className:`font-medium`,children:`Import a shared bundle`})}),(0,D.jsxs)(X,{className:`space-y-3`,children:[(0,D.jsx)(`p`,{className:`text-sm opacity-70`,children:`Apply a bundle from a teammate. Overwritten files are backed up first. Preview the changes before applying.`}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(q,{onClick:ee,disabled:T,children:T?`Opening…`:`Choose bundle file…`}),(0,D.jsxs)(`label`,{className:`text-sm opacity-70 cursor-pointer underline decoration-dotted`,children:[`or browse`,(0,D.jsx)(`input`,{type:`file`,accept:`application/json,.json`,onChange:k,className:`hidden`})]}),m&&(0,D.jsxs)(`span`,{className:`text-sm opacity-70`,children:[`Loaded: `,m]})]}),(0,D.jsxs)(`details`,{className:`text-sm`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer opacity-70 select-none`,children:`Or paste the bundle JSON`}),(0,D.jsx)(`textarea`,{className:`hig-input w-full mt-2 font-mono text-xs`,rows:5,placeholder:`{"rules":[…],"presets":[…],"config":"…"}`,value:f,onChange:e=>{p(e.target.value),h(e.target.value.trim()?`(pasted)`:``),b(null),S(null)}})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`radio`,name:`import-mode`,checked:g===`merge`,onChange:()=>v(`merge`)}),` `,`Merge (keep my local-only rules)`]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`radio`,name:`import-mode`,checked:g===`replace`,onChange:()=>v(`replace`)}),` `,`Replace (mirror the bundle)`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(q,{variant:`secondary`,onClick:j,disabled:C||!f,children:`Preview changes`}),(0,D.jsx)(q,{variant:g===`replace`?`danger`:`primary`,onClick:M,disabled:C||!y,children:`Apply`}),x&&(0,D.jsx)(`span`,{className:x.kind===`ok`?`text-sm text-emerald-500`:`text-sm text-red-500`,children:x.text})]}),N.length>0&&(0,D.jsx)(`pre`,{className:`text-xs bg-black/20 rounded p-2 overflow-auto max-h-64`,children:N.map(e=>`${e.action.padEnd(7)} ${e.kind===`config`?``:`${e.kind}/`}${e.name}`).join(`
12
+ `)})]})]})]})}var ka=Object.freeze([`eval-burst`,`eval-burst-complete`,`counters-updated`]);function Aa(){(0,_.useEffect)(()=>Me(ka),[])}function ja(){return Aa(),(0,_.useSyncExternalStore)(Te,V).latestBurst}function Ma(){return Aa(),(0,_.useSyncExternalStore)(Te,V).burstRing}function Na(){return Aa(),(0,_.useSyncExternalStore)(Te,V).burstSeq}function Pa(e){return`${e.client}:${e.agent_id??`solo`}`}var Fa=Object.freeze({allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`}),Ia=5*6e4,La=1200,Ra=30*6e4,za=1.4;function Ba(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 6;let n=6+Math.log2(1+t/50)*za;return n<4?4:n>16?16:n}function Va(e){let t=(e.input_tokens??0)+(e.output_tokens??0);if(t<=0)return 0;let n=Math.log2(1+t/50)*za/10;return n<=0?0:n>=1?1:n}function Ha(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function Ua(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 Wa=new Set([`compact`,`end`,`stop`,`subagent-stop`,`close`]),Ga=Object.freeze([`session-lifecycle`]);function Ka(e){(0,_.useEffect)(()=>Me(Ga),[]);let t=(0,_.useSyncExternalStore)(Te,V),[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})}var Ja=1440*60*1e3,Ya=1800*1e3,Xa=3e3;function Za(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=Qa(o);n.has(s)||(n.add(s),r.push(o))}for(;i<e.length;i++){let t=e[i],a=Qa(t);n.has(a)||(n.add(a),r.push(t))}for(;a<t.length;a++){let e=t[a],i=Qa(e);n.has(i)||(n.add(i),r.push(e))}return r}function Qa(e){return e.audit_id??`${e.ts_ms}:${e.tool}:${e.client}`}function $a(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 eo(e,t,n,r=200,i=Ra,a=12){let o=new Map,s=new Map;for(let r of e){if(r.ts_ms>n)break;if(ia(r.tool))continue;let e=Pa(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 to(e={}){let t=e.windowMs??12e4,n=Ma(),[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)(()=>Za(a,n),[a,n]),h=(0,_.useMemo)(()=>m.filter(e=>!ia(e.tool)),[m]),{isBurstActive:g}=Ka(s),v=(0,_.useMemo)(()=>eo(m,g,r.playhead_ms),[m,g,r.playhead_ms]),y=m.length>0?m[0].ts_ms:r.playhead_ms,b=m.length>0?m[m.length-1].ts_ms:r.playhead_ms,x=(0,_.useCallback)(async e=>{if(f.current)return;let t=y,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=Za(e,i.bursts);return t.length>Xa?t.slice(-Xa):t}),Array.isArray(i.lifecycle)&&i.lifecycle.length>0&&c(e=>$a(e,i.lifecycle)),d.current=n}catch(e){e.name!==`AbortError`&&console.warn(`[graph] backfill failed`,e)}finally{f.current=null,u(!1)}},[y]);(0,_.useEffect)(()=>{r.playhead_ms-y<r.window_ms*.5&&x(Ia)},[r.playhead_ms,r.window_ms,y,x]);let S=(0,_.useRef)(!1);(0,_.useEffect)(()=>{S.current||(S.current=!0,x(Ya))},[x]),(0,_.useEffect)(()=>()=>{f.current?.abort(),f.current=null},[]);let C=(0,_.useCallback)(e=>{i(t=>e===`live`?{...t,mode:`live`}:{...t,mode:e})},[]),w=(0,_.useCallback)(e=>{i(t=>({...t,mode:t.mode===`live`?`scrubbing`:t.mode,playhead_ms:e}))},[]),T=(0,_.useCallback)(e=>{i(t=>({...t,window_ms:Math.max(1e3,e)}))},[]),E=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now()}))},[]),D=(0,_.useCallback)(()=>{i(e=>({...e,mode:`live`,playhead_ms:Date.now(),window_ms:Ja})),x(Ja)},[x]);return{snapshot:(0,_.useMemo)(()=>({bursts:v,playback:r,oldest_known_ms:y,newest_known_ms:b,loading_backfill:l}),[v,r,y,b,l]),allBursts:h,setMode:C,setPlayhead:w,setWindow:T,jumpToLive:E,requestBackfill:x,jumpTo24h:D}}var Z=`SSG_AUDIO`,no=`SSG_AUDIO_VOLUME`,ro=12,io=null,ao=null,oo=!1,so=.18,co=[],lo=!1;function uo(){if(typeof localStorage>`u`)return{enabled:!1,volume:.18};let e=localStorage.getItem(Z)===`1`,t=localStorage.getItem(no);return{enabled:e,volume:t?Math.max(0,Math.min(1,parseFloat(t))):.18}}function fo(){if(typeof window>`u`)return null;if(io)return io;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;try{io=new e,ao=io.createGain(),ao.gain.value=so,ao.connect(io.destination),typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{io&&(document.visibilityState===`hidden`?io.suspend():io.resume())})}catch{io=null,ao=null}return io}function po(){if(lo)return;lo=!0;let{enabled:e,volume:t}=uo();oo=e,so=t}function mo(){return po(),oo}function ho(e){for(;co.length>0&&e-co[0]>1e3;)co.shift();return co.length>=ro?!1:(co.push(e),!0)}var go={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 _o(e){if(po(),!oo||typeof document<`u`&&document.visibilityState===`hidden`)return;let t=fo();if(!t||!ao)return;t.state===`suspended`&&t.resume().catch(()=>{});let n=t.currentTime;if(!ho(performance.now()))return;let r=go[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(ao),i.start(n),i.stop(n+r.durationMs/1e3+.05),i.onended=()=>{try{i.disconnect(),a.disconnect()}catch{}}}function vo(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 yo={"claude-code":`C`,"claude-code-ide":`C`,cursor:`>`,copilot:`H`,codex:`X`,pi:`P`,gemini:`G`,antigravity:`A`};function bo(e){return yo[e.toLowerCase()]??`.`}function xo(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 So(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=xo(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 Co(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 wo=`9px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,To=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,Eo=new Map,Do=256;function Oo(e,t){let n=Eo.get(t);if(n!==void 0)return n;let r=e.measureText(t).width;if(Eo.size>=Do){let e=Eo.keys().next().value;e!==void 0&&Eo.delete(e)}return Eo.set(t,r),r}function ko(e,t,n,r,i,a,o){let s=(r.split(`:`)[0]??r).slice(0,18),c=bo(s),l=xo(r),u=Fa[o]??`#6b7280`;e.save(),e.textAlign=`center`;let d=`[${c}] ${s}`,f=`${i.length>14?i.slice(0,14):i} · ${a}`;e.font=To;let p=Oo(e,d);e.font=wo;let m=Oo(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=To,e.fillText(d,t,n+10),e.globalAlpha=.72,e.fillStyle=u,e.font=wo,e.fillText(f,t,n+21),e.restore()}var Ao=`bold 13px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,jo=`bold 10px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`;function Mo(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 No(e,t,n,r,i){e.save(),e.textAlign=`center`,e.font=jo,e.globalAlpha=.7,e.fillStyle=`hsla(${i},78%,72%,0.55)`,e.fillText(`uptime`,t,n),e.font=Ao,e.globalAlpha=.96,e.fillStyle=`hsla(${i},78%,82%,1)`,e.fillText(Mo(r),t,n+13),e.restore()}function Po(e,t,n,r){e.save(),e.textAlign=`right`,e.font=jo,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(Mo(r),t,n+16),e.restore()}function Fo(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 Io={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 Lo(e){if(!e)return`·`;let t=e.lastIndexOf(`__`);return Io[t>=0?e.slice(t+2):e]??Io[e]??`·`}var Ro=2*Math.PI/6e4,zo=2.3999632297286535,Bo=16,Vo=22,Ho=.4,Uo=14,Wo=8,Go=24;function Ko(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)-Go,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(Vo,(i-Bo)/Math.max(1,s-1))),l=Bo,u=Bo+c,d=(l*l+u*u-Uo*Uo)/(2*l*u),f=Math.max(Ho,Math.acos(Math.min(1,Math.max(-1,d))));if(o<=Wo)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=Bo+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(Vo,(i-Bo)/Math.max(1,e.length-1)));for(let n=0;n<e.length;n++){let r=e[n];r&&(r.slotPhi=n*zo,r.slotR=Bo+n*t)}}}function qo(e,t,n,r){for(let i of e)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 Jo(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 Yo(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 Xo=new Set,Zo=0,Qo=0;function $o(){for(let e of Xo)e();Xo.size>0&&(Zo=requestAnimationFrame($o))}function es(e){let t=Qo++;return Xo.add(e),Xo.size===1&&(Zo=requestAnimationFrame($o)),[()=>{Xo.delete(e),Xo.size===0&&(cancelAnimationFrame(Zo),Zo=0)},t]}var ts=820,ns=e=>Math.min(1,e),rs=620,is=e=>1-(1-e)**3,as=Ur({stiffness:120,damping:22,mass:1}),os=1800;function ss(e){return e<=2?Math.min(window.devicePixelRatio,2):e<=4?Math.min(window.devicePixelRatio,1.5):Math.min(window.devicePixelRatio,1)}function cs(e){return e<=2?1:e<=4?2:3}function ls(e){return e<=2?24:e<=4?12:6}function us(e){return e<=4}var ds=!1,fs=!1;function ps(){if(fs||typeof window>`u`)return;fs=!0;let e=navigator;typeof e.getBattery==`function`&&e.getBattery().then(e=>{let t=()=>{ds=!e.charging&&e.level<.2};t(),e.addEventListener(`chargingchange`,t),e.addEventListener(`levelchange`,t)}).catch(()=>{})}function ms(){return typeof window>`u`?!1:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||navigator.connection?.saveData?!0:ds}var hs=typeof window<`u`&&new URLSearchParams(window.location.search).get(`fullrate`)===`1`,gs=typeof window<`u`&&new URLSearchParams(window.location.search).get(`rotate`)!==`0`,_s=typeof window<`u`&&new URLSearchParams(window.location.search).get(`probe`)===`1`;function vs(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=vo(s.ts_ms^e),i=n*.6+(t()-.5)*60,a=r/2+(t()-.5)*40,l=Pa(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 ys(e){let{bursts:t,paused:n,selectedId:r,onSelect:i,compact:a=!1,activePanelCount:o=1,labelDensity:s=`normal`,onFrameTime:c}=e,l=(0,_.useRef)(c);l.current=c;let u=(0,_.useRef)(s);u.current=s;let d=(0,_.useRef)(null),f=(0,_.useRef)([]),p=(0,_.useRef)([]),m=(0,_.useRef)(null),h=(0,_.useRef)(null),g=(0,_.useRef)(0),v=(0,_.useRef)(0),y=(0,_.useRef)(0),b=(0,_.useRef)(new Map),x=(0,_.useRef)(new Set),S=(0,_.useRef)(new Set),C=(0,_.useRef)(new Set),[w,T]=(0,_.useState)({w:0,h:0}),E=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(null),ee=(0,_.useRef)(Date.now()),A=(0,_.useRef)(new Map),j=(0,_.useRef)({frame:0,cache:null});(0,_.useLayoutEffect)(()=>{let e=d.current?.parentElement;if(!e)return;let t=e.getBoundingClientRect();t.width>0&&t.height>0&&T({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||T({w:Math.max(40,e),h:Math.max(40,n)})}});return n.observe(e),()=>n.disconnect()},[]),(0,_.useEffect)(()=>{if(w.w<=0||w.h<=0)return;j.current.frame=0;let e=new Map;for(let t of f.current)e.set(t.id,t);f.current=vs(f.current,t,w.w,w.h),Ko(f.current,w.w/2,w.h/2);let n=gs&&!Zr()?performance.now()*Ro:0;for(let t of f.current){if(t.slotR==null||t.slotPhi==null)continue;let r=w.w/2+t.slotR*Math.cos(t.slotPhi+n),i=w.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(p.current=Yo(f.current,1/0),!Zr())for(let t=0;t<f.current.length;t++){let n=f.current[t];!n||e.has(n.id)||_o(n.burst.decision)}let r=f.current.reduce((e,t)=>t.ts_ms>e?t.ts_ms:e,0);v.current=Math.max(performance.now()+ts,performance.now()+La,r+1500),g.current=performance.now()},[t,w.w,w.h]),(0,_.useEffect)(()=>{let e=d.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;ps();let i=performance.now(),s=0,c=0,h=0,_=.1,[T,D]=es(()=>{let d=performance.now();if(!hs&&ms()){if(s^=1,s===1)return}else s!==0&&(s=0);if(!hs){let e=cs(o);if(e>1&&(O.current=(O.current+1)%e,O.current!==0))return}let T=performance.now(),E=T<v.current,D=T-g.current<200,M=T-y.current>500,N=Zr(),P=gs&&!N;if(!P&&!E&&!D&&!M)return;y.current=T;let F=d,I=Math.min(50,F-i);i=F;let L=f.current,te=p.current,ne=P?performance.now()*Ro:0;qo(L,w.w/2,w.h/2,ne);for(let e of L)e.age<1&&(e.age=Math.min(1,e.age+I/ts));let R=typeof window<`u`?ss(o):1,z=w.w,B=w.h;(e.width!==z*R||e.height!==B*R)&&(e.width=z*R,e.height=B*R,e.style.width=`${z}px`,e.style.height=`${B}px`,t.scale(R,R)),t.fillStyle=`#0a0a0f`,t.fillRect(0,0,z,B);let re=`${z}x${B}`,ie=k.current?.key===re?k.current.grad:null;if(ie||(ie=t.createRadialGradient(z/2,B/2,0,z/2,B/2,Math.max(z,B)/1.2),ie.addColorStop(0,`rgba(56, 189, 248, 0.06)`),ie.addColorStop(1,`rgba(0, 0, 0, 0)`),k.current={key:re,grad:ie}),t.fillStyle=ie,t.fillRect(0,0,z,B),!a){let e=j.current;(e.frame++%6==0||e.cache===null)&&(e.cache=Jo(L));let n=e.cache;if(So(t,n,A.current),!N){let e=new Map,r=new Map;for(let t of L)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 L){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;ko(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);No(t,s.x,s.y+l+12,e,xo(o))}}}}let ae=e=>e.exitingAt==null?1:Math.max(0,1-(F-e.exitingAt)/La),oe=ls(o),se=us(o)&&!N,ce=x.current;if(ce.clear(),n)for(let e of L)ce.add(e.id);else{let e=0;for(let t=L.length-1;t>=0&&e<oe;t--){let n=L[t];!n||n.exitingAt!=null||(ce.add(n.id),e++)}}let le=b.current;le.clear();for(let e of L)le.set(e.id,e);t.lineWidth=2,t.lineCap=`round`,t.lineJoin=`round`;for(let e=0;e<te.length;e++){let n=te[e],r=le.get(n.source),i=le.get(n.target);if(!r||!i||ce.has(r.id)||ce.has(i.id))continue;let a=Math.max(ae(r),ae(i));a<=0||(t.globalAlpha=a,t.strokeStyle=`${Fa[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 ue=u.current===`large`,de=ue?`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<te.length;e++){let n=te[e],r=le.get(n.source),i=le.get(n.target);if(!r||!i||!ce.has(r.id)&&!ce.has(i.id))continue;let a=Fa[i.burst.decision]??`#6b7280`,o=Math.max(ae(r),ae(i));if(o<=0)continue;let s=ns(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,se){let n=Math.min(s,(F/os+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(),Fo(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=de,t.fillStyle=`#94a3b8`,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(`${e+1} · ${d}`,f,p-(ue?8:7)),t.restore()}t.globalAlpha=1;let fe=S.current;fe.clear();let pe=C.current;pe.clear();let me=u.current===`large`?10:5;{let e=0;for(let t=L.length-1;t>=0;t--){let r=L[t];!r||r.exitingAt!=null||(!n&&e<3&&fe.add(r.id),e<me&&pe.add(r.id),e++)}}let he=r,ge=m.current;for(let e of L){let r=ae(e);if(r<=0)continue;t.globalAlpha=r;let i=Math.min(1,e.age),o=ns(i);e.displayedRadius=a?4:Ba(e.burst);let s=e.displayedRadius,c=a?s*o:(s+2*Math.min(1,e.age))*o,l=Fa[e.burst.decision]??`#6b7280`,d=Ua(l,Va(e.burst));if((e.id===he||e.id===ge)&&(t.beginPath(),t.arc(e.x,e.y,c+6,0,Math.PI*2),t.fillStyle=`${d}33`,t.fill()),se&&(e.burst.decision===`allow`?Co(t,e.x,e.y,i,`#22c55e`,14,.3):e.burst.decision===`ask`&&Co(t,e.x,e.y,i,`#f59e0b`,14,.45)),se&&(e.burst.decision===`block`||e.burst.decision===`force`)){let n=i*ts;if(n<rs){let r=n/rs,i=c+16*is(r),a=Math.max(0,1-r)*.75;t.beginPath(),t.arc(e.x,e.y,i,0,Math.PI*2),t.strokeStyle=d+Math.floor(a*255).toString(16).padStart(2,`0`),t.lineWidth=1.5,t.stroke()}}if(!N&&fe.has(e.id)&&(t.beginPath(),t.arc(e.x,e.y,c+2,0,Math.PI*2),t.fillStyle=`${d}33`,t.fill()),t.beginPath(),t.arc(e.x,e.y,Math.max(.1,c),0,Math.PI*2),t.fillStyle=d,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(),pe.has(e.id)&&(n||ce.has(e.id))){let n=u.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=`${d}cc`,t.fillText(bo(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=Lo(e.burst.tool),s=o===`·`?a:`${o} ${a}`;t.fillStyle=`${d}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*(ce.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(`↓${Ha(l)} ↑${Ha(f)}`,e.x,e.y+c+(n?25:21)),t.globalAlpha=r),t.textAlign=`left`}(e.id===he||e.id===ge)&&(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,se&&L.length>0){let e=null;for(let t=L.length-1;t>=0;t--)if(L[t].exitingAt==null){e=L[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=F%a/a,s=14+as.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=F%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(!a&&z>220&&Po(t,z-12,12,Date.now()-ee.current),_s){let t,n=0;for(let e of L)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?I:c*(1-_)+I*_;let _e=l.current;_e&&F-h>250&&(h=F,_e(c))});return E.current=D,O.current=D,T},[n,r,w.w,w.h,a,o]);function M(e,t){let n=d.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 f.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:d,className:`block w-full h-full cursor-crosshair`,onMouseMove:e=>{let t=M(e.clientX,e.clientY);m.current=t;let n=h.current;if(!n)return;if(!t){n.style.display=`none`;return}let r=f.current.find(e=>e.id===t);if(!r){n.style.display=`none`;return}let i=r.burst,a=Fa[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(`↓${Ha(i.input_tokens)}`),i.output_tokens!=null&&s.push(`↑${Ha(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:()=>{m.current=null,h.current&&(h.current.style.display=`none`)},onClick:e=>{i(M(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,Ct.createPortal)((0,D.jsx)(`div`,{ref:h,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`}}),document.body)]})}var bs=3e4,xs=6e4,Ss=5e3;function Cs(e,t){let n=t?e.filter(e=>Pa(e)===t):e,r=Date.now(),i=n.length>0?n[n.length-1]:null;if(!i||r-i.ts_ms>Ss||!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<=bs),o=a.filter(e=>e.decision===`allow`).length,s=a.length>0?Math.round(o/a.length*100):0,c=(a.length/(bs/1e3)).toFixed(1),l=new Set(a.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size,u=n.filter(e=>r-e.ts_ms<=xs&&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 ws={allow:`ALLOW`,block:`BLOCK`,ask:`ASK`,log:`LOG`,force:`FORCE`,shadow:`SHADOW`},Ts={allow:`#22c55e`,block:`#ef4444`,ask:`#f59e0b`,log:`#60a5fa`,force:`#a855f7`,shadow:`#6b7280`};function Es({className:e,sessionKey:t}){let n=Ma(),r=Na(),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=Cs(n,t);return a.current=e,e},[n,r,t]),s=o.decision?Ts[o.decision]??`#6b7280`:`#6b7280`,c=o.decision?ws[o.decision]??o.decision:``,l=o.client?bo(o.client):``;return o.idle?(0,D.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,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: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,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 Ds=(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?Fa[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)(ys,{bursts:f,paused:!1,selectedId:r,onSelect:i,burstSeq:a,compact:!0,activePanelCount:n})})]})});function Os(e){return e<=1?1:e<=4?2:3}function ks(){let e=Ma(),t=Na(),[n,r]=(0,_.useState)(null),{isBurstActive:i}=Ka(),a=(0,_.useMemo)(()=>eo(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=Pa(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=Os(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:Fa.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:Fa.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:Fa.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(`
13
+ `),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)(ys,{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)(Ds,{sessionKey:e,bursts:t,activePanelCount:s.length,selectedId:n,onSelect:r},e))}),(0,D.jsx)(Es,{className:`absolute bottom-2 left-2 z-10 max-w-[calc(100%-1rem)]`})]})]})}function As(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 js(e){return{id:e.id,x:e.x,y:e.y,w:e.w,h:e.h}}function Ms(e,t){let n=[js(e)],r=t.map(js);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(As(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 Ns(e){if(e.length===0)return[];let t=[...e].map(js).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)As(e,r)&&(e.y=r.y+r.h,t=!0)}n.push(e)}return n}function Ps(e,t,n){let r=e.findIndex(e=>e.id===t);if(r===-1)return{panels:e.map(js)};let i=Ms({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:Ns(e.map(e=>a.get(e.id)).filter(Boolean))}}function Fs({size:e=24,children:t,...n}){return(0,D.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n,children:t})}var Is=e=>(0,D.jsx)(Fs,{...e,children:(0,D.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),Ls=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`path`,{d:`M18 6 6 18`}),(0,D.jsx)(`path`,{d:`m6 6 12 12`})]}),Rs=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,D.jsx)(`path`,{d:`M7 10l5 5 5-5`}),(0,D.jsx)(`path`,{d:`M12 15V3`})]}),zs=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,D.jsx)(`path`,{d:`M17 8l-5-5-5 5`}),(0,D.jsx)(`path`,{d:`M12 3v12`})]}),Bs=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`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`}),(0,D.jsx)(`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}),(0,D.jsx)(`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`})]}),Vs=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`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`}),(0,D.jsx)(`path`,{d:`m15 5 4 4`})]}),Hs=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,D.jsx)(`path`,{d:`M3 3v5h5`})]}),Us=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`path`,{d:`M3 6h18`}),(0,D.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,D.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,D.jsx)(`path`,{d:`M10 11v6`}),(0,D.jsx)(`path`,{d:`M14 11v6`})]}),Ws=e=>(0,D.jsxs)(Fs,{...e,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`19`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`5`,cy:`9`,r:`1`}),(0,D.jsx)(`circle`,{cx:`12`,cy:`15`,r:`1`}),(0,D.jsx)(`circle`,{cx:`19`,cy:`15`,r:`1`}),(0,D.jsx)(`circle`,{cx:`5`,cy:`15`,r:`1`})]}),Gs=[`hero-metrics`,`graph`,`latency-trace`,`throughput`,`decision-mix`,`tool-decision-breakdown`,`telemetry-feed`,`system-pulse`,`pending-approvals`,`recent-blocks`],Ks={"hero-metrics":`Hero metrics`,graph:`Graph intelligence`,"latency-trace":`Latency trace`,throughput:`Throughput`,"decision-mix":`Decision mix`,"tool-decision-breakdown":`Tool use by decision`,"telemetry-feed":`Telemetry feed`,"system-pulse":`System pulse`,"pending-approvals":`Pending approvals`,"recent-blocks":`Recent blocks`},qs={"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},"tool-decision-breakdown":{minW:3,minH:2,defaultW:6,defaultH:3},"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 Js({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?Ks[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 ${Ks[e.id]} (or Arrow keys)`,"aria-label":`Drag ${Ks[e.id]}`,onPointerDown:t=>{let n=i.current;n&&r.onDragPointerDown(t,e.id,n)},children:(0,D.jsx)(Ws,{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 ${Ks[e.id]} (or Shift+Arrow keys)`,"aria-label":`Resize ${Ks[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 Ys=(0,_.memo)(Js);function Xs(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 Zs(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=qs[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=qs[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}=Xs(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=qs[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 Qs({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=Zs({gridRef:i,getPanel:(0,_.useCallback)(e=>o.get(e),[o]),onCommit:(0,_.useCallback)(e=>{let t=a.current,{panels:n}=Ps(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)(Ys,{panel:e,isEditing:t,drag:s,children:n[e.id]()},e.id))})}function $s({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),ee=(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),k(!1),h(`Deleted "${e}"`)}function N(){d(),E(!1),h(`Reset to default`)}function P(){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 F(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)(Bs,{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)(Vs,{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)(Hs,{size:11,strokeWidth:2.25}),`Reset`]}),(0,D.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:P,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:()=>ee.current?.click(),title:`Load layouts from a JSON file`,children:[(0,D.jsx)(zs,{size:11,strokeWidth:2.25}),`Import`]}),(0,D.jsx)(`input`,{ref:ee,type:`file`,accept:`application/json,.json`,onChange:F,className:`hidden`,"aria-hidden":!0}),(0,D.jsxs)(q,{variant:`primary`,size:`sm`,onClick:()=>n(!1),children:[(0,D.jsx)(Is,{size:11,strokeWidth:2.5}),`Done`]})]}):(0,D.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>n(!0),children:[(0,D.jsx)(Vs,{size:11,strokeWidth:2.25}),`Edit layout`]})}),g&&(0,D.jsx)(ec,{title:`Save layout as`,value:y,placeholder:`My dashboard`,onChange:b,onConfirm:A,onCancel:()=>{v(!1),b(``)},confirmLabel:`Save`}),x&&(0,D.jsx)(ec,{title:`Rename layout`,value:C,placeholder:i.name,onChange:w,onConfirm:j,onCancel:()=>S(!1),confirmLabel:`Rename`}),T&&(0,D.jsx)(tc,{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}),O&&(0,D.jsx)(tc,{title:`Delete "${i.name}"?`,body:`This layout will be removed. You can always recreate it via Save as.`,confirmLabel:`Delete`,onConfirm:M,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 ec({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)(Ls,{size:11,strokeWidth:2.25}),`Cancel`]}),(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:i,children:o})]})]})})}function tc({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 nc={default:`builtin-default`,focusLatency:`builtin-focus-latency`,focusApprovals:`builtin-focus-approvals`,compact:`builtin-compact`},rc={id:nc.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:`decision-mix`,x:8,y:2,w:4,h:2},{id:`pending-approvals`,x:8,y:4,w:4,h:3},{id:`telemetry-feed`,x:0,y:7,w:12,h:3},{id:`tool-decision-breakdown`,x:0,y:10,w:12,h:3}]},ic={id:nc.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}]},ac={id:nc.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}]},oc={id:nc.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}]},sc=Object.freeze([rc,ic,ac,oc]);function cc(){return sc.map(e=>({...e,panels:e.panels.map(e=>({...e}))}))}function lc(){return{version:1,activeLayoutId:nc.default,layouts:cc()}}function uc(e){return Object.values(nc).includes(e)}var dc=new Set(Gs),fc=new Set(sc.map(e=>e.id));function pc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mc(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 hc(e,t){let n=(typeof e==`string`?e:``).replace(/[\u0000-\u001F\u007F]/g,``).trim();return n.length===0?t:n.slice(0,40)}function gc(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 _c(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 vc(e){if(!pc(e))return null;let{id:t}=e;if(typeof t!=`string`||!dc.has(t))return null;let n=t,r=qs[n],i=mc(e.x,0,11,0),a=mc(e.w,r.minW,12,r.defaultW);return{id:n,x:i+a>12?12-a:i,y:mc(e.y,0,999,0),w:a,h:mc(e.h,r.minH,99,r.defaultH)}}function yc(e,t){if(!pc(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=hc(e.name,t),i=fc.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=vc(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:gc(s)},droppedPanels:c}}function bc(e){if(!pc(e)||e.version!==1)return{config:lc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let t=e.layouts;if(!Array.isArray(t)||t.length===0)return{config:lc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0};let n=[],r=0,i=0,a=0;for(let e of t){let{layout:t,droppedPanels:o}=yc(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:lc(),droppedPanels:r,prunedLayouts:a,fellBackToDefault:!0};let o=new Set(n.map(e=>e.id));for(let e of sc)o.has(e.id)||n.push({...e,panels:e.panels.map(e=>({...e}))});let s=new Map(sc.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(_c(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:sc[0].id,layouts:n},droppedPanels:r,prunedLayouts:a,fellBackToDefault:!1,backfilledPanels:c,refreshedBuiltins:l}}var xc=`ssg:dashboard-layout:v1`,Sc=300;function Cc(){if(typeof localStorage>`u`)return null;try{let e=`__ssg_probe__`;return localStorage.setItem(e,`1`),localStorage.removeItem(e),localStorage}catch{return null}}var wc;function Tc(){return wc===void 0&&(wc=Cc()),wc}function Ec(){let e=Tc();if(!e)return{config:lc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let t=null;try{t=e.getItem(xc)}catch{t=null}if(t===null)return{config:lc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!1};let n=null;try{n=JSON.parse(t)}catch{return{config:lc(),droppedPanels:0,prunedLayouts:0,fellBackToDefault:!0}}return bc(n)}var Dc=null,Oc=null,kc=null;function Ac(e){return kc=e,()=>{kc===e&&(kc=null)}}function jc(e){kc?kc(e):typeof console<`u`&&console.warn(`[ssg-layout]`,e)}function Mc(){if(Oc=null,!Dc)return;let e=Tc();if(!e){Dc=null;return}let t=Dc;Dc=null;try{e.setItem(xc,JSON.stringify(t))}catch(e){e instanceof Error&&e.name===`QuotaExceededError`?jc(`Layout storage full — save skipped`):jc(`Layout save failed: ${e instanceof Error?e.message:String(e)}`)}}function Nc(e){Dc=e,Oc===null&&(Oc=setTimeout(Mc,Sc))}function Pc(e){Dc=e,Oc!==null&&(clearTimeout(Oc),Oc=null),Mc()}function Fc(e){let t=0;for(let n of e.layouts)n.builtIn||(t+=1);return t}function Ic(e){return e.map(e=>({...e}))}function Lc(){return`user-${Math.random().toString(16).slice(2,11)}`}function Rc(){let[e,t]=(0,_.useState)(()=>Ec().config),[n,r]=(0,_.useState)(null);(0,_.useEffect)(()=>Ac(e=>r(e)),[]),(0,_.useEffect)(()=>{Nc(e)},[e]);let i=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0]??cc()[0],a=Fc(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:Ic(e)}:t)}})},[]),c=(0,_.useCallback)(e=>{let n=e.trim();n&&t(e=>{if(Fc(e)>=12)return e;let t=e.layouts.find(t=>t.id===e.activeLayoutId)??e.layouts[0];if(!t)return e;let r={id:Lc(),name:n,builtIn:!1,panels:Ic(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??sc[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=uc(t.id)?sc.find(e=>e.id===t.id):sc[0];return n?{...e,layouts:e.layouts.map(e=>e.id===t.id?{...e,panels:Ic(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=bc(n);if(r.fellBackToDefault)return{ok:!1,message:`Import rejected: schema invalid, no changes applied`};t(r.config),Pc(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(lc())},[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 zc=[`rules-changed`,`activity-updated`,`pending-changed`,`runtime-tick`,`limits-breach`],Bc={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 Vc({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 Hc({notification:e,onAction:t}){let[n,r]=(0,_.useState)(`idle`),[i,a]=(0,_.useState)(null),o=Bc[e.severity];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)(Vc,{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: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))}}},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 Uc({showEmptyState:e=!1,hideHeader:t=!1}={}){let n=Ge(zc),{data:r,refetch:i}=U(`/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`,...W()}});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)(Hc,{notification:e,onAction:a},e.id))})]})}var Wc=e=>Math.max(0,Math.round(e)).toLocaleString(void 0,{useGrouping:!0});function Gc(e,t){if(e===`spring`){let e=Ur();return{ease:e.fn,durationMs:e.duration}}return e===`quart`?{ease:Tr.out,durationMs:t}:{ease:wr.out,durationMs:t}}function Kc({value:e,duration:t=320,format:n=Wc,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)(Zr()),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{if(c.current===e)return;if(!p.current){p.current=!0,c.current=e,s.current=e,o(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:m}=Gc(i,t),h=e=>{let t=Math.min(1,(e-l.current)/m),n=r(t);o(s.current+(c.current-s.current)*n),t<1?u.current=requestAnimationFrame(h):u.current=null};return u.current=requestAnimationFrame(h),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,i,a]),(0,D.jsx)(`span`,{ref:f,className:G(`tabular-nums`,r),children:n(a)})}function qc({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=Zr();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}%`:hi(e,{width:[`${c}%`,`${s}%`],duration:480,ease:`outExpo`}),o.current[t]=s})},[i,r.find]),(0,D.jsxs)(`div`,{className:G(`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:G(`uppercase tracking-wide truncate`,e.textClass),children:e.label})]}),(0,D.jsx)(Kc,{value:e.value,className:`shrink-0 tabular-nums text-[var(--color-fg-1)]`})]},e.key))}):null]})}function Jc({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 Yc(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Xc({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)(Yc());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]=es(e);return t},[r,i,a,n]),(0,D.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 ${r} ${i}`,className:G(`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 Zc=sr(`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`}}),Qc={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)`},$c={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)`},el={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)]`},tl=1e3,nl=.35;function rl(e,t,n){let r=Date.now(),i=r-n,a=Math.max(2,Math.floor(n/tl)),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)/tl);e>=0&&e<a&&o[e]++}let s=Array(a),c=o[0];for(let e=0;e<a;e++)c=nl*o[e]+(1-nl)*c,s[e]={ts:i+(e+1)*tl,v:c};return s}function il({label:e,value:t,series:n,burstRing:r,filter:i,sparkWindowMs:a=6e4,sub:o,tone:s,format:c,href:l,className:u,...d}){let f=s??`neutral`,p=Qc[f]??Qc.neutral,m=$c[f]??$c.neutral,h=el[f]??el.neutral,g=(0,_.useRef)(null),v=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(v.current===t)return;v.current=t;let e=g.current;e&&hi(e,{"--tick":[0,1],duration:160,ease:`outCubic`,onComplete:()=>{hi(e,{"--tick":[1,0],duration:520,ease:`outCubic`,onComplete:e=>{e.style.removeProperty(`--tick`)}})}})},[t]);let y=(0,_.useMemo)(()=>r?rl(r,i,a):null,[r,i,a]),b=y!==null,x=!b&&n&&n.length>=2,S=(0,D.jsxs)(`div`,{ref:g,className:G(Zc({tone:s,className:u}),l&&`is-link cursor-pointer`),...d,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)(Kc,{value:t,format:c,className:G(`text-[2.4rem] leading-none font-semibold tracking-tight`,h)}),b?(0,D.jsx)(Xc,{samples:y,width:108,height:36,windowMs:a,color:p,fillColor:m,className:`shrink-0`}):x?(0,D.jsx)(Jc,{data:n,width:96,height:28,color:p}):null]})]});return l?(0,D.jsx)(`a`,{href:l,className:`contents`,"aria-label":`${e} — open Monitor`,children:S}):S}var al={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 ol(e,t,n=200){let r=Math.max(0,Math.floor(e)),i=Math.max(0,Math.floor(t)),a=Math.max(0,r-al.containerPaddingX),o=Math.max(0,i-al.containerPaddingY),s=o-(al.trendRowH*3+al.trendRowGap*2+al.trendTopPad+al.topToTrendGap),c=s-al.scatterHeaderH-al.scatterLegendH-al.scatterInnerGap>=al.scatterAcceptableMin,l=c?s:o,u=l-al.scatterHeaderH-al.scatterLegendH-al.scatterInnerGap,d=u>=al.scatterAbsoluteMin,f=u>=al.scatterAbsoluteMin&&l>=140,p=Math.floor(l/al.gaugeFootprintFactor),m=Math.floor(a*.45/al.gaugeFootprintFactor),h=Math.max(al.gaugeAbsoluteMin,Math.min(al.gaugeAbsoluteMax,n,p,m)),g=Math.ceil(h*al.gaugeFootprintFactor+8),_=l-(d?al.scatterHeaderH:0)-(f?al.scatterLegendH:0)-al.scatterInnerGap;return{gaugeSize:h,gaugeColumnMaxWidth:g,scatterMinHeight:Math.max(al.scatterAbsoluteMin,Math.min(160,_)),showTrendRows:c,showScatterHeader:d,showLegend:f,variant:o>=480?`wide`:o>=300?`normal`:`compact`}}var sl=135,cl=405,ll=cl-sl,ul=`#34d399`,dl=`#f59e0b`,fl=`#ef4444`;function pl(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 ml(e,t,n,r,i){let a=pl(e,t,n,r),o=pl(e,t,n,i),s=+(i-r>180);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 hl(e,t){return sl+Math.max(0,Math.min(1,e/Math.max(t,1e-9)))*ll}function gl(e,t,n){return e+(t-e)*n}function _l(e){let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}function vl(e,t,n){let[r,i,a]=_l(e),[o,s,c]=_l(t);return`rgb(${Math.round(gl(r,o,n))},${Math.round(gl(i,s,n))},${Math.round(gl(a,c,n))})`}function yl(e,t,n){let r=.04;return e<t-r?ul:e<t+r?vl(ul,dl,(e-(t-r))/(r*2)):e<n-r?dl:e<n+r?vl(dl,fl,(e-(n-r))/(r*2)):fl}function bl(){return typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var xl=0;function Sl(){return xl=xl+1|0,xl.toString(36)}function Cl({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)(()=>ml(x,S,C,sl,cl),[x,S,C]),E=(0,_.useMemo)(()=>ml(x,S,C-8,sl,cl),[x,S,C]),O=sl+n*ll,k=sl+r*ll,ee=(0,_.useMemo)(()=>ml(x,S,C,sl,O),[x,S,C,O]),A=(0,_.useMemo)(()=>ml(x,S,C,O,k),[x,S,C,O,k]),j=(0,_.useMemo)(()=>ml(x,S,C,k,cl),[x,S,C,k]),M=(0,_.useMemo)(()=>ml(x,S,C-14,300,420),[x,S,C]),N=sl+w*ll,P=(0,_.useMemo)(()=>ml(x,S,C,sl,Math.max(sl+.01,N)),[x,S,C,N]),F=yl(w,n,r),I=(0,_.useMemo)(()=>Sl(),[]),L=`lgf-${I}`,te=`lgb-${I}`,ne=`lgd-${I}`,R=`lgh-${I}`,z=`lgg-${I}`,B=`lgl-${I}`,re=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=10;t++)e.push(sl+t/10*ll);return e},[u]),ie=(0,_.useMemo)(()=>{if(u!==`needle`)return[];let e=[];for(let t=0;t<=40;t++)t%4!=0&&e.push(sl+t/40*ll);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=sl+(r+.5)/e*ll;n.push(pl(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),V=`${we},${S} ${Ce},${S-Te} ${Ce},${S+Te}`,Ee=d*.48,De=d*.17,Oe=x-Ee/2,ke=S+d*.16,Ae=ke+De*.68;return(0,_.useEffect)(()=>{let e=bl(),t=performance.now(),n=me.current,r=0,i=me.current,a=0,o=me.current,s=``,l=``,d=``,f=-1,m=``,h=``,[g]=es(()=>{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=sl+O*ll,ee=sl+Math.max(0,Math.min(1,i/Math.max(b,1e-9)))*ll,A=yl(O,w,T),j=`rotate(${(k-90).toFixed(3)} ${x} ${S})`;ae.current&&j!==s&&(ae.current.setAttribute(`transform`,j),s=j),A!==d&&(oe.current&&oe.current.setAttribute(`fill`,A),se.current&&se.current.setAttribute(`fill`,A),ce.current&&ce.current.setAttribute(`stroke`,A),ue.current&&ue.current.setAttribute(`fill`,A),d=A);let M=`rotate(${(ee-90).toFixed(3)} ${x} ${S})`;if(le.current&&M!==l&&(le.current.setAttribute(`transform`,M),l=M),de.current&&c){let e=c(o);e!==h&&(de.current.textContent=e,h=e)}if(fe.current&&u===`ring`){let e=ml(x,S,C,sl,Math.max(sl+.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`,yl(a,w,T)),i.setAttribute(`opacity`,s.toFixed(3))}}}}});return g},[x,S,C,u,p,c]),(0,D.jsxs)(`div`,{className:G(`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:L,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:te,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:ne,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:R,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:z,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:B,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(#${te})`,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(#${ne})`})]}):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:ee,fill:`none`,stroke:ul,strokeWidth:5,strokeLinecap:`round`,opacity:.78}),(0,D.jsx)(`path`,{d:A,fill:`none`,stroke:dl,strokeWidth:5,strokeLinecap:`round`,opacity:.82}),(0,D.jsx)(`path`,{d:j,fill:`none`,stroke:fl,strokeWidth:5,strokeLinecap:`round`,opacity:.9}),ie.map((e,t)=>{let n=pl(x,S,C-4,e),r=pl(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}`)}),re.map((e,t)=>{let n=pl(x,S,C-8,e),r=pl(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?ve.map((e,t)=>(0,D.jsx)(`circle`,{ref:e=>{pe.current[t]=e},cx:e.x,cy:e.y,r:Math.max(1.6,d*.013),fill:ul,opacity:0,filter:`url(#${L})`},t)):null,i===void 0?null:(0,D.jsx)(wl,{cx:x,cy:S,r:C,angle:hl(i,t),emphasis:!0}),a===void 0?null:(0,D.jsx)(wl,{cx:x,cy:S,r:C,angle:hl(a,t),emphasis:!0}),l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Tl,{cx:x,cy:S,r:C,angle:O,text:l(n),size:d}),(0,D.jsx)(Tl,{cx:x,cy:S,r:C,angle:k,text:l(r),size:d}),(0,D.jsx)(Tl,{cx:x,cy:S,r:C,angle:cl,text:l(1),size:d})]}):null,(0,D.jsx)(`path`,{d:M,fill:`none`,stroke:`url(#${z})`,strokeWidth:d*.14,strokeLinecap:`butt`}),c||s!==void 0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`rect`,{x:Oe,y:ke,width:Ee,height:De,rx:d*.022,ry:d*.022,fill:`url(#${B})`,stroke:`#242a33`,strokeWidth:1}),(0,D.jsx)(`rect`,{x:Oe+1,y:ke+1,width:Ee-2,height:1,fill:`#ffffff`,opacity:.08})]}):null,(0,D.jsx)(`g`,{ref:le,opacity:.28,children:(0,D.jsx)(`polygon`,{ref:ue,points:Se,fill:F})}),(0,D.jsxs)(`g`,{ref:ae,children:[(0,D.jsx)(`polygon`,{ref:oe,points:Se,fill:F,stroke:`#05070a`,strokeWidth:.6}),(0,D.jsx)(`polygon`,{ref:se,points:V,fill:F,opacity:.7})]}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.06,fill:`url(#${R})`,stroke:`#06080c`,strokeWidth:1}),(0,D.jsx)(`circle`,{ref:ce,cx:x,cy:S,r:d*.036,fill:`#0a0c11`,stroke:F,strokeWidth:1.4}),(0,D.jsx)(`circle`,{cx:x,cy:S,r:d*.012,fill:`#f5f7fb`,opacity:.9})]}):(0,D.jsx)(`path`,{ref:fe,d:P,fill:`none`,stroke:F,strokeWidth:12,strokeLinecap:`round`}),u===`needle`&&(c||s!==void 0)?c?(0,D.jsx)(`text`,{ref:de,x,y:Ae,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:Ae,textAnchor:`middle`,dominantBaseline:`middle`,className:`font-mono tabular-nums`,fontSize:d*.1,fontWeight:600,fill:`#e8ecf3`,children:s}):c?(0,D.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,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 wl({cx:e,cy:t,r:n,angle:r,emphasis:i=!1}){let a=pl(e,t,n-(i?10:6),r),o=pl(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 Tl({cx:e,cy:t,r:n,angle:r,text:i,size:a}){let o=pl(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 El={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`};function Dl(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${e} ns`:e<1e6?`${(e/1e3).toFixed(1)} µs`:`${(e/1e6).toFixed(2)} ms`}function Ol({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)(()=>ol(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(ol(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:El[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]=es(()=>{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,D.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,D.jsxs)(`div`,{className:G(`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)(Cl,{value:l,max:n,warnAt:Math.min(.85,.5/n),critAt:Math.min(.92,2/n),marker50:c,marker99:u,displayFormat:e=>Dl(e*1e6),scaleLabels:f.gaugeSize>=130?e=>Dl(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)(kl,{})}):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)(Al,{label:`p50 · median`,value:Dl(e?.p50_ns??0),color:`#34d399`,fill:`rgba(52, 211, 153, 0.14)`,samples:y.p50,windowMs:i*1e3}),(0,D.jsx)(Al,{label:`p95 · 95th`,value:Dl(e?.p95_ns??0),color:`#38bdf8`,fill:`rgba(56, 189, 248, 0.14)`,samples:y.p95,windowMs:i*1e3}),(0,D.jsx)(Al,{label:`p99 · 99th`,value:Dl(e?.p99_ns??0),color:`#6366f1`,fill:`rgba(99, 102, 241, 0.14)`,samples:y.p99,windowMs:i*1e3})]}):null]})}function kl(){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:El.allow},{key:`ask`,color:El.ask},{key:`block`,color:El.block},{key:`force`,color:El.force},{key:`log`,color:El.log},{key:`shadow`,color:El.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 Al({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)(Xc,{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 jl(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 Ml(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 Nl(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 Pl(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 Q({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=Ml(e,n),p=Ml(r,a),m=`var(--color-decision-log)`,h=(0,_.useMemo)(()=>Pl(t,d),[t]),g=(0,_.useMemo)(()=>Pl(i,d),[i]),v=(0,_.useMemo)(()=>Pl(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=hi(e,{translateY:[28,0],scale:[.94,1],opacity:[0,1],duration:720,delay:qr(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:G(`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)($,{registerRef:e=>y.current[0]=e,label:`CPU`,color:f,fill:Nl(f),pulse:b,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Kc,{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)($,{registerRef:e=>y.current[1]=e,label:`Memory`,color:p,fill:Nl(p),pulse:x,valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Kc,{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)($,{registerRef:e=>y.current[2]=e,label:`Heap`,color:m,fill:Nl(m),valueNode:(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Kc,{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)($,{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:jl(l)}),subText:`since daemon start`})]})})}function $({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=hi(u.current,{"--breach":[0,1],duration:420,ease:`outCubic`,onComplete:()=>{e||!u.current||(t=hi(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)(Xc,{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 Fl=sr(`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`}}),Il={allow:`#34d399`,block:`#ef4444`,ask:`#f59e0b`,log:`#a78bfa`,force:`#38bdf8`,shadow:`#6e7076`},Ll={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 Rl(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 zl(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 Bl(e){return e.variant===`raw`?(0,D.jsx)(Hl,{...e}):(0,D.jsx)(Vl,{...e})}function Vl({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&&(Zr()||hi(t,{translateX:[-10,0],opacity:[0,1],duration:220,ease:`outExpo`}))},[d,s]),(0,D.jsxs)(`div`,{className:G(Fl({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 ${Il[e.decision]??`#666`}`},children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums`,children:Rl(e.ts_ms)}),(0,D.jsx)(`span`,{className:G(`uppercase tracking-wide font-medium`,Ll[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} — ${na(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:zl(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)(Ul,{}):null]})}function Hl({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:G(Fl({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)(Ul,{}):null]})}function Ul(){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`})}var Wl=[`allow`,`ask`,`force`,`block`,`log`,`shadow`];function Gl(e){return e.audit_id??`${e.ts_ms}:${e.tool}`}function Kl(){return{allow:0,block:0,log:0,shadow:0,ask:0,force:0}}function ql(e,t=0){let n=new Map;for(let t of e){let e=n.get(t.tool);e||(e={tool:t.tool,count:0,totalDurationNs:0,byDecision:Kl(),dominant:t.decision},n.set(t.tool,e)),e.count+=1,e.totalDurationNs+=t.duration_ns,e.byDecision[t.decision]+=1}let r=Array.from(n.values());for(let e of r){let t=`allow`,n=-1;for(let r of Wl)e.byDecision[r]>n&&(n=e.byDecision[r],t=r);e.dominant=t}if(r.sort((e,t)=>t.count-e.count||e.tool.localeCompare(t.tool)),t>0&&r.length>t){let e=r.slice(0,t-1),n=r.slice(t-1),i={tool:`+${n.length} more`,count:0,totalDurationNs:0,byDecision:Kl(),dominant:`shadow`};for(let e of n){i.count+=e.count,i.totalDurationNs+=e.totalDurationNs;for(let t of Wl)i.byDecision[t]+=e.byDecision[t]}return e.push(i),e}return r}function Jl(e){if(e.length===0)return{rows:[],t0:0,t1:0,maxDurationNs:0};let t=[...e].sort((e,t)=>e.ts_ms-t.ts_ms),n=t[0].ts_ms,r=t[t.length-1].ts_ms,i=Math.max(1,r-n),a=0;for(let e of t)e.duration_ns>a&&(a=e.duration_ns);let o=Math.log10(Math.max(1,a)+1);return{rows:t.map(e=>{let t=(e.ts_ms-n)/i,r=Math.log10(Math.max(0,e.duration_ns)+1),a=.04+(o>0?r/o:0)*.96;return{id:Gl(e),tool:e.tool,decision:e.decision,rule_id:e.rule_id,ts_ms:e.ts_ms,durationNs:e.duration_ns,startFrac:t,widthFrac:a}}),t0:n,t1:r,maxDurationNs:a}}function Yl(e,t,n=`count`){let r=e=>n===`duration`?Math.max(0,e.duration_ns):1,i={name:t,value:0,depth:0,x0:0,x1:1,children:[]};if(e.length===0)return i;let a=new Map;for(let t of e){let e=r(t);i.value+=e;let n=a.get(t.tool);n||(n={value:0,byDecision:new Map},a.set(t.tool,n)),n.value+=e;let o=n.byDecision.get(t.decision);o||(o={value:0,ids:[]},n.byDecision.set(t.decision,o)),o.value+=e,o.ids.push(Gl(t))}if(i.value<=0)return i;let o=Array.from(a.entries()).sort((e,t)=>t[1].value-e[1].value||e[0].localeCompare(t[0])),s=0;for(let[e,t]of o){let n=t.value/i.value,r=s,a=Math.min(1,s+n);s=a;let o={name:e,value:t.value,depth:1,x0:r,x1:a,children:[]},c=Array.from(t.byDecision.entries()).sort((e,t)=>t[1].value-e[1].value),l=r,u=a-r;for(let[e,n]of c){let r=n.value/t.value*u,i=l,s=Math.min(a,l+r);l=s;let c={name:e,value:n.value,depth:2,x0:i,x1:s,decision:e,children:[]},d=n.ids.length===1?n.ids[0]:void 0;d!==void 0&&(c.id=d),o.children.push(c)}i.children.push(o)}return i}function Xl(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};return n(e),t}var Zl=8;function Ql(e,t){let n={id:`root`,label:t,depth:0,x:.5,y:.12,value:e.length,parent:null};if(e.length===0)return{nodes:[n],maxDepth:0};let r=new Map;for(let t of e){let e=r.get(t.tool);e||(e={value:0,byDecision:new Map},r.set(t.tool,e)),e.value+=1;let n=e.byDecision.get(t.decision);n||(n={value:0,ids:[]},e.byDecision.set(t.decision,n)),n.value+=1,n.ids.push(Gl(t))}let i=Array.from(r.entries()).sort((e,t)=>t[1].value-e[1].value||e[0].localeCompare(t[0])),a=0;if(i.length>Zl){let e=i.slice(Zl-1);for(let[,t]of e)a+=t.value;i=i.slice(0,Zl-1)}let o=i.map(([e,t])=>{let n=Array.from(t.byDecision.entries()).sort((e,t)=>t[1].value-e[1].value).map(([e,t])=>({decision:e,value:t.value,ids:t.ids}));return{name:e,value:t.value,dominant:n[0]?.decision??`allow`,leaves:n}});a>0&&o.push({name:`+${r.size-(Zl-1)} more`,value:a,dominant:`shadow`,leaves:[]});let s=.06;1-2*s;let c=o.reduce((e,t)=>e+Math.max(1,t.leaves.length),0),l=[n],u=0,d=[];return o.forEach((e,t)=>{let n=Math.max(1,e.leaves.length),r=[];for(let e=0;e<n;e++)r.push(s+(u+.5)/c*.88),u+=1;let i=r.reduce((e,t)=>e+t,0)/r.length;d.push(i);let a=`t${t}`;l.push({id:a,label:e.name,depth:1,x:i,y:.5,value:e.value,decision:e.dominant,parent:`root`}),e.leaves.forEach((e,t)=>{let n={id:`${a}d${t}`,label:e.decision,depth:2,x:r[t]??i,y:.88,value:e.value,decision:e.decision,parent:a},o=e.ids.length===1?e.ids[0]:void 0;o!==void 0&&(n.burstId=o),l.push(n)})}),d.length>0&&(n.x=d.reduce((e,t)=>e+t,0)/d.length),{nodes:l,maxDepth:l.reduce((e,t)=>Math.max(e,t.depth),0)}}function $l(e){return!Number.isFinite(e)||e<=0?`—`:e<1e3?`${Math.round(e)}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(2)}ms`}var eu={allow:`var(--color-decision-allow)`,ask:`var(--color-decision-ask)`,force:`var(--color-decision-force)`,block:`var(--color-decision-block)`,log:`var(--color-decision-log)`,shadow:`var(--color-decision-shadow)`},tu={allow:`text-emerald-300`,ask:`text-amber-300`,force:`text-sky-300`,block:`text-red-300`,log:`text-violet-300`,shadow:`text-[var(--color-fg-3)]`};function nu({bursts:e,limit:t=8,className:n}){let r=(0,_.useMemo)(()=>ql(e).slice(0,t),[e,t]);if(r.length===0)return(0,D.jsx)(`div`,{className:G(`rounded-sm border border-dashed border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-4 py-6 text-center text-[11px] font-mono text-[var(--color-fg-3)]`,n),children:`no tool-call data yet`});let i=Wl.filter(e=>r.some(t=>t.byDecision[e]>0));return(0,D.jsxs)(`div`,{className:G(`flex flex-col gap-2`,n),children:[r.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,D.jsx)(`span`,{className:`w-28 shrink-0 truncate text-[var(--color-fg-2)]`,title:e.tool,children:e.tool}),(0,D.jsx)(`div`,{className:`flex h-3 flex-1 overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-2)]`,children:e.count===0?null:Wl.map(t=>{let n=e.byDecision[t];return n?(0,D.jsx)(`div`,{style:{width:`${n/e.count*100}%`,background:eu[t]},title:`${e.tool} · ${t}: ${n}`},t):null})}),(0,D.jsx)(`span`,{className:`w-10 shrink-0 text-right tabular-nums text-[var(--color-fg-3)]`,children:e.count})]},e.tool)),i.length>0?(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] font-mono`,children:i.map(e=>(0,D.jsxs)(`span`,{className:G(`flex items-center gap-1 uppercase tracking-wide`,tu[e]),children:[(0,D.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-sm`,style:{background:eu[e]}}),e]},e))}):null]})}function ru(e,t){let n=e?.allow??0,r=e?.block??0,i=e?.ask??0,a=e?.log??0,o=e?.force??0,s=e?.shadow??0,c=n+r+i+a+o+s,l=t?.counters.total??0;return t&&l>0&&l>=c&&t?{...t.counters}:{allow:n,block:r,ask:i,log:a,force:o,shadow:s,total:c}}function iu(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,Zr()){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`}),hi(Array.from(i),{opacity:[0,1],translateY:[c,0],duration:l,ease:`outBack(1.2)`,delay:qr(s,{from:u}),onComplete:e=>{let t=e;t.style.willChange=``,t.style.transform=``}})},[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(!Zr()){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 au(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 ou(e,t){await fetch(`/api/decide/${e}?decision=${t}`,{method:`POST`,headers:W()})}var su=e=>!0,cu=e=>e.decision===`allow`,lu=e=>e.decision===`block`,uu=e=>e.decision===`ask`,du=e=>e.decision===`force`,fu=e=>e.decision===`log`;function pu(){let e=new Date;return e.setHours(0,0,0,0),e.getTime()}function mu(){history.pushState(null,``,`/approvals`),window.dispatchEvent(new PopStateEvent(`popstate`))}function hu({pendingCount:e}){let t=e>0;return(0,D.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-4 rounded-sm border p-4 ${t?`border-[var(--color-brand)] bg-[var(--color-accent-tint)]`:`border-[var(--color-line-1)] bg-[var(--color-surface-1)]`}`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{background:t?`var(--color-brand)`:`var(--color-decision-allow)`}}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`div`,{className:`font-semibold text-[var(--color-fg-0)]`,children:t?`${e} tool ${e===1?`call`:`calls`} waiting for your decision`:`You're all caught up`}),(0,D.jsx)(`div`,{className:`text-[13px] text-[var(--color-fg-2)]`,children:t?`Approve or block them so your agents can continue.`:`No tool calls are waiting. New requests appear here the moment an agent asks.`})]}),(0,D.jsx)(q,{variant:t?`primary`:`secondary`,onClick:mu,className:`shrink-0`,children:t?`Review pending →`:`View approvals`})]})}function gu(){let e=Ge([`counters-updated`,`activity-updated`,`pending-changed`,`runtime-tick`]),t=ja();Na();let n=Ma(),[r,i]=(0,_.useState)(()=>pu());(0,_.useEffect)(()=>{let e=()=>{if(document.visibilityState!==`visible`)return;let e=pu();i(t=>e===t?t:e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let{activeProject:a}=Ze(),{data:o}=U(Qe(`/api/state/counters?since_ms=${r}`,a),[e[`counters-updated`],r,a]),{data:s}=U(`/api/state/runtime`,[e[`runtime-tick`]]),{data:c}=U(`/api/json/limits`,[e[`runtime-tick`]]),{data:l,refetch:u}=U(`/api/json/pending`,[e[`pending-changed`]]),{data:d}=U(`/api/json/blocked`,[e[`activity-updated`]]),f=Rc(),[p,m]=(0,_.useState)(!1),h=(0,_.useMemo)(()=>ru(o,t),[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)(il,{label:`Total`,value:h.total,href:`/monitor`,tone:`amber`,sub:t&&t.counters.total>0?au(t.duration_ns):void 0,burstRing:n,filter:su}),(0,D.jsx)(il,{label:`Allow`,value:h.allow,href:`/monitor`,tone:`green`,burstRing:n,filter:cu}),(0,D.jsx)(il,{label:`Block`,value:h.block,href:`/monitor`,tone:`red`,burstRing:n,filter:lu}),(0,D.jsx)(il,{label:`Ask`,value:h.ask,href:`/monitor`,tone:`amber`,burstRing:n,filter:uu}),(0,D.jsx)(il,{label:`Force`,value:h.force,href:`/monitor`,tone:`blue`,burstRing:n,filter:du}),(0,D.jsx)(il,{label:`Log`,value:h.log,href:`/monitor`,tone:`purple`,burstRing:n,filter:fu})]})}),graph:()=>(0,D.jsx)(ks,{}),"latency-trace":()=>(0,D.jsx)(Ol,{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)(Xc,{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)(qc,{counters:{allow:h.allow,block:h.block,ask:h.ask,log:h.log,force:h.force,shadow:h.shadow}})})]}),"tool-decision-breakdown":()=>(0,D.jsxs)(J,{className:`h-full`,children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`overline`,children:`tool use · by decision`}),(0,D.jsx)(K,{variant:`gray`,children:n.length.toLocaleString()})]}),(0,D.jsx)(X,{children:(0,D.jsx)(nu,{bursts:n,limit:8})})]}),"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)(Bl,{variant:`decision`,bursts:n,windowSize:80,height:360,className:`border-0 rounded-none`})})]}),"system-pulse":()=>(0,D.jsx)(Q,{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:yr(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:()=>ou(e.id,`allow`).then(u),children:`allow`}),(0,D.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>ou(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:yr(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=iu({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.jsx)(hu,{pendingCount:l?.length??0}),(0,D.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,D.jsx)(`div`,{className:`flex-1`,"data-tutorial":`cb-layout`,children:(0,D.jsx)($s,{manager:f,isEditing:p,onToggleEditing:m})})}),(0,D.jsx)(Uc,{}),(0,D.jsx)(`div`,{"data-tutorial":`cb-grid`,children:(0,D.jsx)(Qs,{panels:f.activeLayout.panels,isEditing:p,renderers:S,onPanelsChange:f.updateActivePanels})})]})}var _u=[{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`}],vu={rca:{title:`Root Cause Analysis`,body:`When an eval errors, an ssqa finding arrives, or a daemon-level error fires, SSG auto-composes a diagnosis with ranked hypotheses, evidence, and suggested next actions — the same pack Claude reads through MCP.`,useWhen:`Something just broke and you want the short version before grepping logs.`},timeline:{title:`Eval Timeline`,body:`Flame-chart of the last 1024 frames across every rule and tool call. Each row is one tool call (trace_id); each bar is one pipeline stage colored by kind; a red outline means that stage errored.`,useWhen:`You want to see which stages a rule went through and how long each took. Click a bar to inspect the frame.`},watch:{title:`Live URI Watch`,body:`Subscribe to any ssg:// resource and watch it update as the daemon emits events. Every CLI, MCP, and dashboard surface ultimately reads through these same URIs.`,useWhen:`You know exactly which internal resource (rules, audit rows, frames, RCA pack, native stats) you want to inspect.`},state:{title:`Daemon Snapshot`,body:`Live vitals for the SSG daemon process — uptime, rules loaded, native FFI availability, frame ring size, eval quotas, audit worker readiness.`,useWhen:`The daemon feels off (slow, dropping events, refusing calls) and you want to confirm it's healthy.`},metrics:{title:`Performance Counters`,body:`Latency distributions and event counters for the eval pipeline (per-stage timings, native call overhead, audit throughput).`,useWhen:`Evals feel slow and you want to find the hot stage before optimizing.`}};function yu(){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:`space-y-2`,children:[(0,D.jsxs)(`div`,{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)(Tu,{})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`one surface · cli · mcp · dashboard`})]}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-3)] max-w-3xl leading-snug`,children:`See exactly what happened inside SSG during recent rule evaluations — which stage ran, which rule matched, how long each step took, and what went wrong. The same data Claude reads via MCP.`})]}),(0,D.jsx)(xu,{}),(0,D.jsx)(Cu,{}),(0,D.jsx)(`nav`,{"data-tutorial":`debug-tabs`,className:`flex items-center gap-1 border-b border-[var(--color-line-1)]`,children:_u.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.jsx)(wu,{tab:e}),(0,D.jsxs)(`section`,{"data-tutorial":`debug-pane`,className:`flex-1 min-h-0`,children:[e===`rca`&&(0,D.jsx)(Eu,{}),e===`timeline`&&(0,D.jsx)(ju,{}),e===`watch`&&(0,D.jsx)(zu,{}),e===`state`&&(0,D.jsx)(Bu,{uri:`ssg://daemon/state`}),e===`metrics`&&(0,D.jsx)(Bu,{uri:`ssg://daemon/metrics`})]})]})}var bu=`ssg.debug.intro.dismissed`;function xu(){let[e,t]=(0,_.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(bu)===`1`}catch{return!1}});return e?(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsx)(`button`,{type:`button`,onClick:()=>{t(!1);try{window.localStorage.removeItem(bu)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`,children:`what is this?`})}):(0,D.jsx)(`aside`,{className:`rounded-sm 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 justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-3 min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:`who this page is for`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-relaxed`,children:`SSG sits between your AI coding agent (Claude Code, Cursor, Copilot, …) and your filesystem/shell, deciding which tool calls to allow, block, or warn on. This page is the window into those decisions — useful any time SSG's behavior surprises you.`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] mb-1.5`,children:`what you'd use it for`}),(0,D.jsx)(`table`,{className:`text-[12px] text-[var(--color-fg-3)] w-full border-separate border-spacing-y-1`,children:(0,D.jsxs)(`tbody`,{children:[(0,D.jsx)(Su,{question:`Why did SSG block my agent from running this command?`,tab:`rca`,how:`open RCA — or find the trace in Timeline and read the deciding rule`}),(0,D.jsx)(Su,{question:`I just wrote a rule. Did it actually fire?`,tab:`timeline`,how:`trigger the tool call, find your trace, look for your rule_id in a match-stage bar`}),(0,D.jsx)(Su,{question:`Are my rules even loaded? Did a syntax error skip one?`,tab:`state`,how:`check the rules_loaded count — or open Watch and resolve ssg://rules/list`}),(0,D.jsx)(Su,{question:`My agent feels slow when SSG is on — is SSG the cause?`,tab:`metrics`,how:`look at per-stage latency; the hot stage tells you whether parse, match, native FFI, or audit is the culprit`}),(0,D.jsx)(Su,{question:`Something errored and I want a one-line diagnosis before reading logs`,tab:`rca`,how:`the latest RCA pack ranks hypotheses by confidence and suggests next actions`})]})})]}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-relaxed`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:`heads up ·`}),` `,`The Timeline (every frame of every eval) is opt-in because it adds overhead. Restart the daemon with`,` `,(0,D.jsx)(`code`,{className:`text-amber-300 font-mono`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),` `,`to turn it on. RCA, State, and Metrics work without it.`]})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{t(!0);try{window.localStorage.setItem(bu,`1`)}catch{}},className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)] shrink-0`,title:`Hide this panel`,children:`hide`})]})})}function Su({question:e,tab:t,how:n}){return(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{className:`align-top pr-3 text-[12px] text-[var(--color-fg-2)] w-[55%]`,children:e}),(0,D.jsx)(`td`,{className:`align-top pr-3 w-[80px]`,children:(0,D.jsx)(`span`,{className:`chip text-[10px] uppercase tracking-wider text-sky-300 border-sky-500/30`,children:t})}),(0,D.jsx)(`td`,{className:`align-top text-[11px] text-[var(--color-fg-4)] leading-snug`,children:n})]})}function Cu(){let{data:e}=U(`/api/json/debug?uri=ssg%3A%2F%2Fdaemon%2Fstate`,[]);return e?.data?.debug_enabled===!1?(0,D.jsxs)(`aside`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/5 p-3 text-[12px] text-amber-200 space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-amber-300`,children:`timeline disabled · frame collection is off`}),(0,D.jsx)(`p`,{className:`text-[12px] leading-snug`,children:`The daemon is running but not capturing per-stage eval frames — so the Timeline tab will stay empty no matter how many tool calls fire. RCA, State, and Metrics still work.`}),(0,D.jsxs)(`p`,{className:`text-[12px] leading-snug`,children:[`To turn frame capture on, restart with`,` `,(0,D.jsx)(`code`,{className:`text-amber-100 font-mono bg-amber-900/30 px-1.5 py-0.5 rounded-sm`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),`. It's opt-in because collecting every frame adds overhead on the hot path.`]})]}):null}function wu({tab:e}){let t=vu[e];return(0,D.jsxs)(`div`,{className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-2 space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:t.title}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] leading-snug`,children:t.body}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-snug`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:`use when ·`}),` `,t.useWhen]})]})}function Tu(){let e=Ge([`debug-frame`])[`debug-frame`]??0,{data:t}=U(`/api/json/debug?uri=ssg%3A%2F%2Fdaemon%2Fstate`,[e]),n=t?.data?.debug_enabled;return n===!1?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-amber-300`,title:`Frame collection is OFF. Restart the daemon with SSG_DEBUG_ENABLED=1 to capture frames.`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-sm bg-amber-400`}),`debug off`]}):n===void 0?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-sm bg-[var(--color-fg-4)]`}),`connecting…`]}):(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] font-mono uppercase tracking-wider text-emerald-300`,title:`Debug collection is on. ${e} debug-frame bursts received this session.`,children:[(0,D.jsx)(`span`,{className:`status-dot bg-emerald-400 pulse-soft`}),`live · `,e]})}function Eu(){let e=Ge([`debug-frame`,`activity-updated`]),{data:t,loading:n,error:r,refetch:i}=U(`/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)(Ou,{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`,`
14
14
  `,`# or via MCP:`,`
15
- `,`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 Eu(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 Du({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 `+Eu(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 Ou=[`hook-ingress`,`parse`,`match`,`ffi-call`,`decide`,`audit`,`respond`],ku={"hook-ingress":`#6ea8ff`,parse:`#a78bfa`,match:`#60d394`,"ffi-call":`#f59e0b`,decide:`#f472b6`,audit:`#94a3b8`,respond:`#22d3ee`};function Au(){let{data:e,loading:t,error:n}=U(`/api/json/debug?uri=ssg%3A%2F%2Fframes%2Frecent%3Flimit%3D1024`,[Ge([`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)(ju,{}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Nu,{frames:r,onSelect:o}),(0,D.jsx)(Mu,{})]})]}),(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)(Pu,{frame:a}):(0,D.jsx)(`p`,{className:`opacity-60`,children:`click a bar to inspect`})]})]})}function ju(){return(0,D.jsxs)(`div`,{className:`text-[12px] text-[var(--color-fg-3)] space-y-2 py-4`,children:[(0,D.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-2)]`,children:`no frames captured yet`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-relaxed`,children:`Frame collection is opt-in so it adds zero cost when off. Restart the daemon with the env var below, then any tool call (Bash, Read, Edit, MCP) will stream frames into this view in real time:`}),(0,D.jsx)(`pre`,{className:`text-[11px] text-amber-300 font-mono bg-[var(--color-surface-2)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Each bar = one stage of one eval. Click a bar to inspect the frame — rule that matched, duration, error type, input preview.`})]})}function Mu(){return(0,D.jsx)(`div`,{className:`flex flex-wrap gap-3 text-[10px] font-mono text-[var(--color-fg-4)]`,children:Ou.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:ku[e]}}),e]},e))})}function Nu({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)=>Iu(e.ts_start_ns,t.ts_start_ns))}));n.sort((e,t)=>Iu(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=ku[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 Pu({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)(Fu,{k:`stage`,children:[(0,D.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm mr-1 align-middle`,style:{background:ku[e.stage]??`#888`}}),e.stage]}),(0,D.jsx)(Fu,{k:`tool`,children:e.tool}),(0,D.jsx)(Fu,{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)(Fu,{k:`dur`,children:n}),e.rule_id&&(0,D.jsx)(Fu,{k:`rule`,children:e.rule_id}),e.error&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Fu,{k:`err.type`,children:(0,D.jsx)(`span`,{className:`text-rose-300`,children:e.error.type})}),(0,D.jsx)(Fu,{k:`err.msg`,children:(0,D.jsx)(`span`,{className:`text-rose-200`,children:e.error.message})})]}),e.input_preview&&(0,D.jsx)(Fu,{k:`input`,children:(0,D.jsx)(`code`,{className:`text-[10px] break-all`,children:e.input_preview})}),(0,D.jsx)(Fu,{k:`trace`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.trace_id})}),(0,D.jsx)(Fu,{k:`frame`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.frame_id})})]})}function Fu({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 Iu(e,t){let n=BigInt(e),r=BigInt(t);return n<r?-1:+(n>r)}var Lu=[`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 Ru(){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:Lu.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)(zu,{uri:n})]})}function zu({uri:e}){let t=Ge([`debug-frame`,`activity-updated`,`counters-updated`]),{data:n,loading:r,error:i,refetch:a}=U(`/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 Bu=200;function Vu(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 Hu(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 Uu(e){let{bursts:t,selectedId:n,onSelect:r}=e,i=(0,_.useMemo)(()=>{let e=new Map;for(let n of t){if(na(n.tool))continue;let t=Ma(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,o=t[t.length-1],s=o?Na[o.decision]??`#6b7280`:`#6b7280`,c=t.slice(-Bu).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:ta(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=Na[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:ea(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:[`↓`,Ba(o),` ↑`,Ba(s)]}),e.duration_ns>0&&(0,D.jsx)(`span`,{children:Hu(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:Vu(e.ts_ms)})]})]})]},t)})})]})]},e)})})}function Wu(e,t){let n=t.indexOf(`:`),r=n>0?t.slice(0,n):null;return{id:e.id,tool:e.tool,input:e.input,decision:e.decision,rule_id:e.rule_id,source_file:e.source_file,timestamp:Math.floor(e.ts_ms/1e3),client:e.client??r,duration_ns:e.duration_ns,rules_evaluated:e.rules_evaluated,rule_message:e.rule_message}}function Gu(e){let{sessionKey:t,entries:n,loading:r,error:i,playingIndex:a}=e,o=(0,_.useRef)(null),s=(0,_.useRef)(new Map),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),f=(0,_.useMemo)(()=>{let e=new Set;for(let t of n)e.add(t.decision);return[...e].sort()},[n]);(0,_.useEffect)(()=>{u&&!f.includes(u)&&d(null)},[u,f]);let p=(0,_.useMemo)(()=>{let e=c.trim().toLowerCase();return!e&&!u?n:n.filter(t=>u&&t.decision!==u?!1:e?t.tool.toLowerCase().includes(e)||t.decision.toLowerCase().includes(e)||(t.rule_id??``).toLowerCase().includes(e)||(t.rule_message??``).toLowerCase().includes(e)||t.input.toLowerCase().includes(e):!0)},[n,c,u]),m=c.trim().length>0||u!==null,h=a>=0?n[a]?.id??null:null;(0,_.useEffect)(()=>{if(!h)return;let e=s.current.get(h);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},[h]);let g=e=>t=>{t?s.current.set(e,t):s.current.delete(e)},v=r?`loading…`:i?`error`:m?`${p.length} / ${n.length}`:`${n.length} event${n.length===1?``:`s`}`;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)] tabular-nums`,children:v})]}),!i&&n.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/20 shrink-0`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,D.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search tool, rule, input…`,"aria-label":`Search audit log`,className:`w-full bg-black/40 border border-[var(--color-line-1)] rounded-sm pl-2 pr-6 py-1 text-[11px] font-mono text-[var(--color-fg-1)] placeholder:text-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-hig-blue)]/60`}),c&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>l(``),"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] text-[13px] leading-none px-1`,children:`×`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(null),className:`px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border transition-colors ${u===null?`border-[var(--color-hig-blue)]/60 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,children:`all`}),f.map(e=>{let t=Na[e]??`#6b7280`,n=u===e;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>d(n?null:e),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border transition-colors ${n?`bg-white/[0.06] text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,style:n?{borderColor:t}:void 0,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full shrink-0`,style:{background:t}}),e]},e)})]})]}),(0,D.jsxs)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto p-2 space-y-1.5`,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.`}),!i&&n.length>0&&p.length===0&&(0,D.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No events match the current filter.`}),p.map(e=>{let n=e.id===h;return(0,D.jsx)(`div`,{ref:g(e.id),className:n?`rounded-sm ring-1 ring-inset ring-sky-400/40`:void 0,children:(0,D.jsx)(ya,{row:Wu(e,t),defaultExpanded:n})},e.id)})]})]})}var Ku=[100,500,1e3,5e3,1e4,1e5];function qu(e){return e>=1e5||e>=1e3?`${e/1e3|0}k`:String(e)}function Ju(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 Yu(e){let t=Math.floor(e/100);return`${Math.floor(t/10)}.${t%10}s`}function Xu({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=ka(),C=ja(),w=Aa(),T=(0,_.useRef)(null),E=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(0),ee=(0,_.useRef)(0),A=(0,_.useRef)(new Set),j=(0,_.useRef)(performance.now());return(0,_.useEffect)(()=>{let e=performance.now();if(Yr()){let t=setInterval(()=>{let t=performance.now();r.current&&(r.current.textContent=Ju(t-e)),i.current&&(i.current.textContent=Yu(t-j.current))},1e3);return()=>clearInterval(t)}let[t]=Qo(()=>{let t=performance.now();r.current&&(r.current.textContent=Ju(t-e)),i.current&&(i.current.textContent=Yu(t-j.current))});return t},[]),(0,_.useEffect)(()=>{for(let e of w)e.rule_id&&A.current.add(e.rule_id);m(A.current.size)},[]),(0,_.useEffect)(()=>{let e=()=>{let e=Date.now(),t=w.filter(t=>e-t.ts_ms<=6e4),n=new Set(t.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size;f(n)};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[w]),(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=Ku.find(e=>e>ee.current&&r>=e);return i&&(ee.current=i,g(qu(i)),x(!0),t?.(),setTimeout(()=>{g(``),x(!1)},700)),r}),S?.rule_id&&A.current.add(S.rule_id),m(A.current.size),S&&(S.decision===`block`?(O.current=0,o(0),j.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,t,n]),(0,D.jsxs)(`div`,{className:mr(`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)(Zu,{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)(Zu,{label:`evals`,children:(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(Gc,{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)(Zu,{label:`since block`,children:(0,D.jsx)(`span`,{ref:i,className:`tabular-nums text-emerald-300 text-[15px]`,children:`0.0s`})}),(0,D.jsx)(Zu,{label:`streak / best`,children:(0,D.jsxs)(`span`,{className:mr(`tabular-nums text-[15px]`,v?`record-beat`:`text-[var(--color-fg-0,#e6e8ed)]`),children:[(0,D.jsx)(Gc,{value:a,curve:`spring`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4,#5a6071)] mx-1`,children:`/`}),(0,D.jsx)(Gc,{value:s})]})}),(0,D.jsx)(Zu,{label:`agents`,children:(0,D.jsx)(Gc,{value:d,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})}),(0,D.jsx)(Zu,{label:`rules`,children:(0,D.jsx)(Gc,{value:p,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})})]})}function Zu({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 Qu(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 $u(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)(()=>Qu(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 Na[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:Na[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 ed=320,td=8,nd=12;function rd(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+nd+ed>r?n.x-nd-ed:n.x+nd,l=n.y+nd+s>a?n.y-nd-s:n.y+nd;c=Math.min(Math.max(td,c),r-ed-td),l=Math.min(Math.max(td,l),a-s-td),o({left:c,top:l})},[t,n]),(0,_.useEffect)(()=>{o({left:-9999,top:-9999})},[]),!t||!n)return null;let s=Na[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:ed,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:od(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:id(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 id(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 ad(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 od(e,t){let n=[];return e!=null&&n.push(`${ad(e)} in`),t!=null&&n.push(`${ad(t)} out`),n.length>0?n.join(` · `):`—`}var sd=[`spiral`,`trace`,`flame`,`bars-h`,`bars-v`,`tree`],cd=`spiral`,ld={spiral:{label:`Spiral graph`,short:`spiral`,hint:`Single-arm tree-graph of tool calls (physics layout)`,glyph:`✺`},trace:{label:`Trace waterfall`,short:`trace`,hint:`Span timeline — one row per call, width by duration`,glyph:`≣`},flame:{label:`Flame graph`,short:`flame`,hint:`Stacked tool → decision hierarchy, width by share`,glyph:`🔥`},"bars-h":{label:`Horizontal bars`,short:`bars ↔`,hint:`Per-tool totals as horizontal bars, split by decision`,glyph:`▤`},"bars-v":{label:`Vertical bars`,short:`bars ↕`,hint:`Per-tool totals as vertical columns, split by decision`,glyph:`▥`},tree:{label:`Node tree`,short:`tree`,hint:`Linked node tree: root → tool → decision`,glyph:`🌳`}};function ud(e){return typeof e==`string`&&sd.includes(e)}function dd(e){return sd[(sd.indexOf(e)+1)%sd.length]??`spiral`}var fd=`graph.chartType.default.v1`,pd=`graph.chartType.bySession.v1`;function md(){if(typeof window>`u`)return cd;try{let e=window.localStorage.getItem(fd);return ud(e)?e:cd}catch{return cd}}function hd(e){if(!(typeof window>`u`))try{window.localStorage.setItem(fd,e)}catch{}}function gd(){if(typeof window>`u`)return new Map;try{let e=window.localStorage.getItem(pd);if(!e)return new Map;let t=JSON.parse(e),n=new Map;for(let[e,r]of Object.entries(t))ud(r)&&n.set(e,r);return n}catch{return new Map}}function _d(e){if(!(typeof window>`u`))try{let t={};for(let[n,r]of e)t[n]=r;window.localStorage.setItem(pd,JSON.stringify(t))}catch{}}function vd({value:e,onChange:t,large:n=!1,prefix:r,className:i}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useId)(),l=ld[e];(0,_.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let u=e=>{t(e),o(!1)};return(0,D.jsxs)(`div`,{ref:s,className:`relative ${i??``}`,children:[(0,D.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?c:void 0,onClick:()=>o(e=>!e),title:`Chart type — ${l.label}: ${l.hint}`,className:`inline-flex items-center gap-1 rounded border border-[var(--color-line-1)] font-mono uppercase tracking-wider text-[var(--color-fg-3)] transition-colors hover:border-sky-500/40 hover:text-sky-300 ${n?`px-2 py-1 text-[11px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[r&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:r}),(0,D.jsx)(`span`,{"aria-hidden":`true`,children:l.glyph}),(0,D.jsx)(`span`,{children:l.short}),(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`text-[var(--color-fg-4)]`,children:`▾`})]}),a&&(0,D.jsx)(`div`,{id:c,role:`menu`,className:`absolute right-0 z-50 mt-1 w-60 overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] shadow-lg`,children:sd.map(t=>{let n=ld[t],r=t===e;return(0,D.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>u(t),className:`flex w-full items-start gap-2 px-2.5 py-1.5 text-left transition-colors ${r?`bg-sky-500/10 text-sky-200`:`text-[var(--color-fg-2)] hover:bg-white/5`}`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 shrink-0 text-sm`,children:n.glyph}),(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsxs)(`span`,{className:`block font-mono text-[12px]`,children:[n.label,r&&(0,D.jsx)(`span`,{className:`ml-1 text-sky-400`,"aria-hidden":`true`,children:`●`})]}),(0,D.jsx)(`span`,{className:`block text-[10px] leading-tight text-[var(--color-fg-4)]`,children:n.hint})]})]},t)})})]})}var $=900,yd=180,bd=320,xd=800,Sd=4;function Cd({sessionKey:e}={}){let t=ka(),n=ja(),[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&&Ma(t)!==e)return;let u=Date.now(),d=s.current,f=d[0];if(f&&u-l.current<xd){f.extra+=1,f.burst=t,f.seq=n,l.current=u;return}if(d.length>=Sd&&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`),yd):a===`visible`?e=setTimeout(()=>o(`out`),$):a===`out`&&(e=setTimeout(()=>{let e=s.current.shift()??null;e?(i(e),o(`in`)):(i(null),o(`idle`))},bd)),u.current=e,()=>{e&&clearTimeout(e)}},[a]),!r)return null;let{burst:d,extra:f}=r,p=Na[d.decision]??`#ef4444`,m=Yr(),h=+(a===`in`||a===`visible`),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 ${yd}ms ease-out`:`opacity ${yd}ms ease-out, transform ${yd}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})]})]})})}function wd(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.tool===t)return r.audit_id??`${r.ts_ms}:${r.tool}`}return null}function Td({large:e}){return(0,D.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 ${e?`text-[11px]`:`text-[10px]`} font-mono text-[var(--color-fg-4)]`,children:Ul.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:Na[e]}}),(0,D.jsx)(`span`,{className:`uppercase tracking-wide`,children:e})]},e))})}var Ed=(0,_.memo)(function({bursts:e,orientation:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>Kl(e,i?12:8),[e,i]),o=(0,_.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.count),1),[a]);if(a.length===0)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let s=(t,r)=>{let i=wd(e,t.tool);i&&n(i,{x:r.clientX,y:r.clientY})},c=e=>Ul.filter(t=>e.byDecision[t]>0).map(t=>({d:t,frac:e.byDecision[t]/e.count}));return t===`horizontal`?(0,D.jsxs)(`div`,{className:`flex h-full flex-col gap-2 overflow-hidden p-2`,children:[(0,D.jsx)(Td,{large:i}),(0,D.jsx)(`div`,{className:`flex flex-1 flex-col gap-1.5 overflow-y-auto pr-1`,children:a.map(e=>{let t=e.count/o*100,n=c(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>s(e,t),className:`grid grid-cols-[minmax(64px,26%)_1fr_auto] items-center gap-2 text-left`,title:`${e.tool} · ${e.count} calls`,children:[(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[12px]`:`text-[11px]`} text-[var(--color-fg-2)]`,children:e.tool}),(0,D.jsx)(`span`,{className:`relative block h-4 overflow-hidden rounded-sm bg-[var(--color-surface-0)]`,children:(0,D.jsx)(`span`,{className:`absolute inset-y-0 left-0 flex overflow-hidden rounded-sm`,style:{width:`${t}%`},children:n.map(e=>(0,D.jsx)(`span`,{className:`h-full`,style:{width:`${e.frac*100}%`,background:Na[e.d]}},e.d))})}),(0,D.jsx)(`span`,{className:`tabular-nums font-mono ${i?`text-[12px]`:`text-[10px]`} text-[var(--color-fg-3)]`,children:e.count})]},e.tool)})})]}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col gap-2 overflow-hidden p-2`,children:[(0,D.jsx)(Td,{large:i}),(0,D.jsx)(`div`,{className:`flex flex-1 items-end gap-2 overflow-x-auto pb-1`,children:a.map(e=>{let t=e.count/o*100,n=c(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>s(e,t),className:`flex h-full min-w-[40px] flex-1 flex-col items-center justify-end gap-1`,title:`${e.tool} · ${e.count} calls`,children:[(0,D.jsx)(`span`,{className:`tabular-nums font-mono ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-3)]`,children:e.count}),(0,D.jsx)(`span`,{className:`flex w-full max-w-[56px] flex-col-reverse overflow-hidden rounded-sm bg-[var(--color-surface-0)]`,style:{height:`${t}%`,minHeight:4},children:n.map(e=>(0,D.jsx)(`span`,{className:`w-full`,style:{height:`${e.frac*100}%`,background:Na[e.d]}},e.d))}),(0,D.jsx)(`span`,{className:`w-full truncate text-center font-mono ${i?`text-[11px]`:`text-[9px]`} text-[var(--color-fg-2)]`,children:e.tool})]},e.tool)})})]})});function Dd(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return`hsl(${12+t%48} 78% 52%)`}var Od=26,kd=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,[a,o]=(0,_.useState)(`count`),s=(0,_.useMemo)(()=>e.length>0?Ma(e[0]):`session`,[e]),c=(0,_.useMemo)(()=>Yl(Jl(e,s,a)),[e,s,a]);if(e.length===0||c.length<=1)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let l=e=>e.depth===0?`var(--color-surface-2, #2a2a2a)`:e.depth===1?Dd(e.name):Na[e.decision??`shadow`]??`#6b7280`,u=e=>{let t=a===`duration`?Ql(e.value):`${e.value}`;return`${e.name} · ${t}`},d=(e,t)=>{e.id&&n(e.id,{x:t.clientX,y:t.clientY})},f=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*Od;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden p-2`,children:[(0,D.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-4)]`,children:`flame · root → tool → decision`}),(0,D.jsx)(`div`,{className:`inline-flex overflow-hidden rounded border border-[var(--color-line-1)] text-[9px] font-mono uppercase tracking-wider`,children:[`count`,`duration`].map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":a===e,className:`cursor-pointer px-1.5 py-0.5 transition-colors ${a===e?`bg-amber-500/15 text-amber-300`:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,children:e===`count`?`calls`:`time`},e))})]}),(0,D.jsx)(`div`,{className:`relative flex-1 overflow-auto`,children:(0,D.jsx)(`div`,{className:`relative w-full`,style:{height:f},children:c.map(e=>{let n=(e.x1-e.x0)*100;if(n<.4)return null;let r=e.id!=null&&t!=null&&t===e.id,a=n>(i?6:9);return(0,D.jsx)(`button`,{type:`button`,onClick:t=>d(e,t),title:u(e),className:`absolute flex items-center overflow-hidden rounded-[2px] border border-black/25 px-1 text-left ${e.id?`cursor-pointer`:`cursor-default`} ${r?`ring-1 ring-sky-300`:``}`,style:{left:`${e.x0*100}%`,width:`${n}%`,top:e.depth*Od,height:Od-2,background:l(e)},children:a&&(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[11px]`:`text-[10px]`} ${e.depth===0?`text-[var(--color-fg-2)]`:`text-black/80`}`,children:e.name})},`${e.depth}:${e.name}:${e.x0.toFixed(4)}`)})})})]})}),Ad=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>e.length>0?Ma(e[0]):`session`,[e]),o=(0,_.useMemo)(()=>Zl(e,a),[e,a]);if(e.length===0||o.nodes.length<=1)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let s=new Map;for(let e of o.nodes)s.set(e.id,e);let c=e=>e.depth===0?`var(--color-surface-2, #2a2a2a)`:Na[e.decision??`shadow`]??`#6b7280`,l=(e,t)=>{e.burstId&&n(e.burstId,{x:t.clientX,y:t.clientY})};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden p-2`,children:[(0,D.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center justify-between font-mono uppercase tracking-wider ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{children:`tree · root → tool → decision`}),(0,D.jsxs)(`span`,{className:`normal-case tracking-normal`,children:[o.nodes.length,` nodes`]})]}),(0,D.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,D.jsx)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:o.nodes.map(e=>{if(e.parent==null)return null;let n=s.get(e.parent);if(!n)return null;let r=e.burstId!=null&&t!=null&&t===e.burstId;return(0,D.jsx)(`line`,{x1:n.x*100,y1:n.y*100,x2:e.x*100,y2:e.y*100,stroke:r?`#7dd3fc`:`rgba(110,112,118,0.45)`,strokeWidth:r?1.6:.8,vectorEffect:`non-scaling-stroke`},`e-${e.id}`)})}),o.nodes.map(e=>{let n=e.depth===2,r=e.burstId!=null&&t!=null&&t===e.burstId,a=i?12:9;return(0,D.jsx)(`button`,{type:`button`,onClick:t=>l(e,t),title:`${e.label} · ${e.value} call${e.value===1?``:`s`}`,className:`absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center overflow-hidden ${n?`rounded-full`:`rounded border border-black/30`} ${e.burstId?`cursor-pointer`:`cursor-default`} ${r?`z-10 ring-2 ring-sky-300`:``}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,background:c(e),...n?{width:a,height:a}:{maxWidth:`26%`,padding:`2px 6px`}},children:!n&&(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[11px]`:`text-[9px]`} ${e.depth===0?`text-[var(--color-fg-1)]`:`text-black/85`}`,children:e.depth===0?e.label:`${e.label} · ${e.value}`})},e.id)})]})]})}),jd=34,Md=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>ql(e),[e]),o=(0,_.useRef)(null),s=(0,_.useRef)(!0);if((0,_.useEffect)(()=>{let e=o.current;!e||!s.current||(e.scrollTop=e.scrollHeight)},[a.rows.length]),a.rows.length===0)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let c=Math.max(1,a.t1-a.t0),l=e=>{let t=e.currentTarget;s.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},u=(e,t)=>{n(e.id,{x:t.clientX,y:t.clientY})},d=i?`h-6`:`h-5`;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,D.jsx)(`div`,{ref:o,onScroll:l,className:`flex-1 overflow-y-auto px-2 py-1.5`,children:(0,D.jsx)(`div`,{className:`flex flex-col gap-[3px]`,children:a.rows.map(e=>{let n=Math.max(1.5,e.widthFrac*jd),r=Math.min(e.startFrac*100,100-n),a=t!=null&&t===e.id,o=Na[e.decision]??`#6b7280`;return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>u(e,t),className:`grid grid-cols-[minmax(72px,24%)_1fr] items-center gap-2 rounded-sm ${d} ${a?`bg-white/5 ring-1 ring-sky-500/40`:``}`,title:`${e.tool} → ${e.decision} · ${Ql(e.durationNs)}${e.rule_id?` · ${e.rule_id}`:``}`,children:[(0,D.jsx)(`span`,{className:`truncate text-left font-mono ${i?`text-[12px]`:`text-[11px]`} text-[var(--color-fg-2)]`,children:e.tool}),(0,D.jsx)(`span`,{className:`relative h-full w-full`,children:(0,D.jsx)(`span`,{className:`absolute top-1/2 flex -translate-y-1/2 items-center rounded-sm px-1`,style:{left:`${r}%`,width:`${n}%`,minWidth:6,height:i?14:11,background:o},children:(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[10px]`:`text-[9px]`} text-black/70`,children:Ql(e.durationNs)})})})]},e.id)})})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t border-[var(--color-line-0)] px-2 py-1 text-[9px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,D.jsxs)(`span`,{children:[`← `,Math.round(c/1e3),`s span`]}),(0,D.jsxs)(`span`,{children:[a.rows.length,` spans · width = duration (log)`]}),(0,D.jsx)(`span`,{children:`now →`})]})]})}),Nd=(0,_.memo)(function(e){let{chartType:t,bursts:n,spiralBursts:r,paused:i,selectedId:a,onSelect:o,burstSeq:s,compact:c,activePanelCount:l,labelDensity:u,onFrameTime:d}=e;switch(t){case`trace`:return(0,D.jsx)(Md,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});case`flame`:return(0,D.jsx)(kd,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});case`bars-h`:return(0,D.jsx)(Ed,{bursts:n,orientation:`horizontal`,selectedId:a,onSelect:o,labelDensity:u});case`bars-v`:return(0,D.jsx)(Ed,{bursts:n,orientation:`vertical`,selectedId:a,onSelect:o,labelDensity:u});case`tree`:return(0,D.jsx)(Ad,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});default:return(0,D.jsx)(_s,{bursts:r,paused:i,selectedId:a,onSelect:o,burstSeq:s,compact:c,activePanelCount:l,labelDensity:u,onFrameTime:d})}}),Pd=(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,chartType:C=cd,onChartTypeChange:w}=e,T=p===`broadcast`,E=!m&&(p===`stream`||p===`broadcast`||f)?`large`:`normal`,O=t.indexOf(`:`),k=O>=0?t.slice(0,O):t,ee=O>=0?t.slice(O+1):``,A=ta(k),j=(0,_.useRef)(null),[M,N]=(0,_.useState)(!0),[P,F]=(0,_.useState)(null),I=()=>{let e=j.current;if(!e)return;let t=e.querySelector(`canvas`);t instanceof HTMLCanvasElement&&F(t.toDataURL(`image/png`))},L=()=>{if(!P)return;let e=document.createElement(`a`),n=t.replace(/[^a-z0-9._-]+/gi,`-`);e.href=P,e.download=`ssg-graph-${n}-${Date.now()}.png`,document.body.appendChild(e),e.click(),e.remove()},te=()=>{!P||!navigator.clipboard?.write||fetch(P).then(e=>e.blob()).then(e=>{let t=new ClipboardItem({"image/png":e});return navigator.clipboard.write([t])}).catch(()=>{})},ne=typeof navigator<`u`&&typeof navigator.clipboard?.write==`function`&&typeof ClipboardItem<`u`;(0,_.useEffect)(()=>{if(f){N(!0);return}let e=j.current;if(!e)return;let t=new IntersectionObserver(e=>{for(let t of e)N(t.isIntersecting)},{threshold:.01});return t.observe(e),()=>t.disconnect()},[f]);let R=n.length>0?n[n.length-1]:null,z=R?Na[R.decision]??`#6b7280`:`#6b7280`,B=R?.decision??null,re=R?.tool??null,ie=r||!M||d,ae=(0,_.useMemo)(()=>n.length>24?n.slice(n.length-24):n,[n]);return(0,D.jsxs)(`div`,{ref:j,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,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:[!T&&(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:A}),ee&&(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:ee})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono text-[var(--color-fg-4)] min-w-0`,children:[re&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 max-w-[180px] min-w-0`,title:B?`latest: ${re} → ${B}`:`latest: ${re}`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:z}}),(0,D.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:re})]}),(0,D.jsxs)(`span`,{className:`hidden md:inline text-[var(--color-fg-4)] shrink-0`,children:[n.length,`n`]}),s?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-amber-300 shrink-0`,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 shrink-0`,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 shrink-0`,children:[w&&(0,D.jsx)(vd,{value:C,onChange:w,large:p===`stream`||f}),(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:I,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&&!T&&(0,D.jsx)(ws,{sessionKey:t,className:`rounded-none border-x-0 border-t-0 border-b border-[var(--color-line-1)] shrink-0`}),P&&(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:P,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:[ne&&(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:`copy`}),(0,D.jsx)(`button`,{type:`button`,onClick:L,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:()=>F(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)(Cd,{sessionKey:t}),(0,D.jsx)(Nd,{chartType:C,bursts:n,spiralBursts:ae,paused:ie,selectedId:i,onSelect:a,burstSeq:o,compact:!0,activePanelCount:g,labelDensity:E,onFrameTime:S}),m&&(0,D.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Promote ${A} to spotlight`,title:`Spotlight ${A}${ee?` · ${ee}`:``}`,className:`absolute inset-0 cursor-pointer bg-transparent hover:bg-sky-400/5 transition-colors`})]})]})}),Fd=200,Id=.9,Ld=40,Rd=32,zd=480,Bd=`transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease-out, fill 320ms ease-out`;function Vd(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<Fd;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*(Fd-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 ${zd}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=`,Hd(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 ${Fd} ${Ld}`,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*Fd,x2:e*Fd,y1:0,y2:Ld,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(Rd,n*3),i=n===0?0:r/Rd,a=e.block>0?Na.block:e.ask>0?Na.ask:e.other>0&&e.allow===0?Na.log:Na.allow;return(0,D.jsx)(`rect`,{x:t+.05,y:Ld-Rd,width:Id,height:Rd,rx:.3,fill:a,style:{opacity:n===0?0:.78,transform:`scaleY(${i})`,transformOrigin:`50% 100%`,transformBox:`fill-box`,transition:Bd}},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:Ud(r)}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider transition-colors ${p?`text-sky-300`:``}`,children:p?`↳ ${Ud(p.ts)}`:`${Wd(t.window_ms)} window`}),(0,D.jsx)(`span`,{children:Ud(i)})]})]})}function Hd(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 Ud(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Wd(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}var Gd=`ssg.sfx.enabled`;function Kd(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Gd)===`true`}catch{return!1}}function qd(e){if(!(typeof window>`u`))try{window.localStorage.setItem(Gd,String(e))}catch{}}function Jd(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 Yd(){let[e,t]=(0,_.useState)(Kd),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(qd(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`:Jd(i,a,110,55,150,.08);break;case`force`:Jd(i,a,80,40,200,.1),Jd(i,a,160,80,200,.05,`square`);break;case`milestone`:{Jd(i,a,660,880,100,.06);let e=i,t=a;setTimeout(()=>{e.state!==`suspended`&&Jd(e,t,880,1320,100,.05)},115);break}case`record`:Jd(i,a,880,1320,350,.07);break}},[e])}}var Xd=80,Zd=600,Qd=Object.freeze({stop:()=>{},count:0}),$d=new Set([`allow`,`block`,`ask`,`log`,`force`,`shadow`]);function ef(e){if(!fo()||e.length===0)return Qd;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=Xd+Math.log2(1+n)*14;r+=Math.max(Xd,Math.min(Zd,o))}let o=$d.has(a.decision)?a.decision:null;if(!o)continue;let s=setTimeout(()=>{n||ho(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 tf=1200,nf=3e4,rf=3e3,af=6,of=3,sf=`graph.panelState.v1`,cf=14400*1e3;function lf(e,t){let n=new Map;for(let t of e){let e=Ma(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 uf(){if(typeof window>`u`)return new Map;try{let e=window.localStorage.getItem(sf);if(!e)return new Map;let t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function df(e){if(!(typeof window>`u`))try{let t={};for(let[n,r]of e)t[n]=r;window.localStorage.setItem(sf,JSON.stringify(t))}catch{}}function ff(){let e=$a(),t=ja(),n=ka(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),s=(0,_.useCallback)((e,t)=>{i(e),o(t??null)},[]),c=Yd();(0,_.useEffect)(()=>{n&&(n.decision===`block`?c.play(`block`):n.decision===`force`&&c.play(`force`))},[c.play,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)},[]),ee=(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 A=(0,_.useRef)(new Map),j=(0,_.useRef)(0),[M,N]=(0,_.useState)({fps:0,active:0,hitches:0}),P=(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:F,playback:I,oldest_known_ms:L,newest_known_ms:te,loading_backfill:ne}=e.snapshot,{activeProject:R}=Ze(),[z,B]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(R===`all`)return;let e=setInterval(()=>B(e=>e+1),15e3);return()=>clearInterval(e)},[R]);let{data:re}=U(`/api/json/sessions/list?limit=1000`,[R,z]),ie=(0,_.useMemo)(()=>{let e=new Map;for(let t of re?.sessions??[])e.set(t.session_key,t.project_id);return e},[re]),ae=(0,_.useRef)(new Map),oe=(0,_.useMemo)(()=>{let e=lf(F,ae.current);if(ae.current=e,R===`all`)return e;let t=new Map;for(let[n,r]of e){let e=ie.get(n);(e===void 0||e===R)&&t.set(n,r)}return t},[F,ie,R]),[se,ce]=(0,_.useState)(()=>uf()),[le,ue]=(0,_.useState)(null);(0,_.useEffect)(()=>{df(se)},[se]);let[de,fe]=(0,_.useState)(()=>md()),[pe,me]=(0,_.useState)(()=>gd());(0,_.useEffect)(()=>{hd(de)},[de]),(0,_.useEffect)(()=>{_d(pe)},[pe]);let he=(0,_.useCallback)((e,t)=>{me(n=>{let r=new Map(n);return r.set(e,t),r})},[]);(0,_.useEffect)(()=>{me(e=>{let t=!1,n=new Map(e);for(let r of e.keys())oe.has(r)||se.has(r)||(n.delete(r),t=!0);return t?n:e})},[oe,se]),(0,_.useEffect)(()=>{let e=e=>{if(e.key!==`g`&&e.key!==`G`)return;let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||fe(e=>dd(e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,_.useEffect)(()=>{let e=Date.now(),t=!1,n=new Map(se);for(let r of oe.keys())n.has(r)||(n.set(r,{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:e}),t=!0);for(let[r,i]of n)oe.has(r)||i.pinned||e-i.firstSeenAt<cf||(n.delete(r),t=!0);t&&ce(n)},[oe,se]);let ge=(0,_.useRef)(new Map),_e=(0,_.useRef)(new Set),ve=(0,_.useRef)(new Map),[,ye]=(0,_.useState)(0);(0,_.useEffect)(()=>{let e=performance.now(),t=ge.current,n=_e.current,r=ve.current,i=new Set;for(let[e,n]of oe)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>=tf&&(t.delete(n),r.delete(n));if(_e.current=i,t.size>0){let n=1/0;for(let e of t.values())n=Math.min(n,e.diedAt+tf);let r=Math.max(16,n-e+16),i=setTimeout(()=>ye(e=>e+1),r);return()=>clearTimeout(i)}},[oe]);let be=(0,_.useCallback)(e=>{ce(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})},[]),xe=(0,_.useCallback)(e=>{ce(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})},[]),Se=(0,_.useCallback)(e=>{ue(t=>t===e?null:e)},[]);(0,_.useEffect)(()=>{if(!le)return;let e=e=>{e.key===`Escape`&&ue(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[le]);let Ce=(0,_.useRef)(null),[we,Te]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!le){Ce.current?.stop(),Ce.current=null,Te(null);return}let e=!1;Te({sessionKey:le,entries:[],loading:!0,error:null});let t=`/api/json/graph/session-audit?session_key=${encodeURIComponent(le)}`;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:[];Te({sessionKey:le,entries:n,loading:!1,error:null});let r=n.map(e=>({ts_ms:e.ts_ms,decision:e.decision,tool:e.tool}));Ce.current?.stop(),Ce.current=ef(r)}).catch(t=>{e||Te({sessionKey:le,entries:[],loading:!1,error:t instanceof Error?t.message:`failed to load audit log`})}),()=>{e=!0,Ce.current?.stop(),Ce.current=null}},[le]);let V=(0,_.useMemo)(()=>{let e={pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()},t=[];for(let[n,r]of oe){let i=r[r.length-1]?.ts_ms??0;t.push({key:n,bursts:r,newestTs:i,fadingOutAt:null,state:se.get(n)??e})}for(let[n,r]of ge.current)oe.has(n)||t.push({key:n,bursts:r.bursts,newestTs:r.newestTs,fadingOutAt:r.diedAt,state:se.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},[oe,se]),Ee=(0,_.useMemo)(()=>{if(!r)return null;for(let e of F)if((e.audit_id??`${e.ts_ms}:${e.tool}`)===r||r.startsWith(`${e.ts_ms}:${e.tool}`))return e;return null},[F,r]),[De,Oe]=(0,_.useState)(null),ke=(0,_.useRef)(null),Ae=(0,_.useMemo)(()=>{if(V.length===0)return ke.current=null,null;if(De!=null&&V.some(e=>e.key===De))return ke.current=De,De;let e=V.filter(e=>e.state.pinned);if(e.length>0)return e.sort((e,t)=>t.state.pinnedAt-e.state.pinnedAt),ke.current=e[0].key,e[0].key;let t=V[0];for(let e of V)e.newestTs>t.newestTs&&(t=e);let n=ke.current;if(n!=null&&n!==t.key){let e=V.find(e=>e.key===n);if(e&&Date.now()-e.newestTs<rf)return n}return ke.current=t.key,t.key},[V,De]);(0,_.useEffect)(()=>{De!=null&&(V.some(e=>e.key===De)||Oe(null))},[De,V]),(0,_.useEffect)(()=>{Oe(null)},[]);let H=(0,_.useMemo)(()=>{if(V.length===0)return{hero:null,grid:[],rail:[],overflow:[]};if(d===`full`||d===`feed`)return{hero:null,grid:V.slice(0,af),rail:V.slice(af),overflow:[]};let e=V.find(e=>e.key===Ae)??V[V.length-1],t=V.filter(t=>t.key!==e.key);return d===`broadcast`?{hero:e,grid:[],rail:[],overflow:t}:{hero:e,grid:[],rail:t.slice(0,of),overflow:t.slice(of)}},[V,d,Ae]),je=(0,_.useCallback)(e=>{Oe(e)},[]),Me=(0,_.useCallback)(()=>{Oe(null)},[]),Ne=(0,_.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;for(let s of V){let c=s.key;e.set(c,()=>be(c)),t.set(c,()=>xe(c)),n.set(c,()=>Se(c)),r.set(c,()=>void k([c])),i.set(c,e=>P(c,e)),a.set(c,()=>je(c)),o.set(c,e=>he(c,e))}return{onTogglePin:e,onToggleMinimize:t,onToggleFullscreen:n,onClose:r,onFrameTime:i,onPromote:a,onChartType:o}},[be,xe,Se,k,P,je,he,V]);(0,_.useEffect)(()=>{let e=new Set(V.map(e=>e.key)),t=A.current;for(let n of Array.from(t.keys()))e.has(n)||t.delete(n)},[V]);let Pe=(0,_.useMemo)(()=>{let e=n?.counters,t=e?.total??0,r=(e?.block??0)+(e?.force??0),i=0;if(F.length>0){let e=0,t=F.slice(-100);for(let n of t)e+=n.duration_ns;i=e/t.length/1e6}return{evals:t,blocks:r,avgMs:i,agents:V.length}},[n,F,V.length]),Fe=Math.min(L,I.playhead_ms-I.window_ms),Ie=Math.max(te,I.playhead_ms),Le=H.grid.length,Re=C||Le<=1?1:Le<=4?2:3,ze=Math.max(1,Math.ceil(Math.max(1,Le)/Re)),Be=Le<=1||C?360:180,Ve=le?V.find(e=>e.key===le):null,He=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`}),I.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`}),I.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:He(Pe.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:He(Pe.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:Pe.avgMs<1?`${(Pe.avgMs*1e3).toFixed(0)}µs`:`${Pe.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:Pe.agents}),` `,(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`agent`,Pe.agents===1?``:`s`]})]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-2 gap-y-1.5`,children:[!p&&(0,D.jsxs)(`p`,{className:`hidden lg:block text-[11px] font-mono text-[var(--color-fg-4)]`,children:[F.length,`n · window `,Math.round(I.window_ms/1e3),`s`]}),(0,D.jsxs)(`span`,{className:`hidden lg:inline 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,`/`,V.length]}),!p&&(0,D.jsx)(vd,{value:de,onChange:fe,prefix:`chart`,className:`hidden sm:block`}),(0,D.jsx)(`div`,{role:`group`,"aria-label":`Graph view mode`,"data-tutorial":`graph-views`,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;return(0,D.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":t,title: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)`,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:e===`broadcast`?`cast`:e},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&&V.length>0&&(0,D.jsx)(`div`,{"aria-live":`polite`,children:(0,D.jsx)(`button`,{type:`button`,"aria-label":`Clear all visible graph sessions`,"data-tutorial":`graph-clear`,onClick:()=>ee(V.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 ${V.filter(e=>!e.fadingOutAt).length}`:`clear`})})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`graph-panels`,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)(Uu,{bursts:F,selectedId:r,onSelect:s})}):V.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:[H.hero&&(le==null||le===H.hero.key)&&(0,D.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2`,children:[De!=null&&(0,D.jsx)(`button`,{type:`button`,onClick:Me,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)(Pd,{sessionKey:H.hero.key,bursts:H.hero.bursts,paused:I.mode!==`live`||H.hero.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:H.hero.fadingOutAt!=null||I.playhead_ms-H.hero.newestTs>nf,isFadingOut:H.hero.fadingOutAt!=null,minHeight:0,pinned:H.hero.state.pinned,minimized:H.hero.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:1,onTogglePin:Ne.onTogglePin.get(H.hero.key),onToggleMinimize:Ne.onToggleMinimize.get(H.hero.key),onToggleFullscreen:Ne.onToggleFullscreen.get(H.hero.key),onClose:Ne.onClose.get(H.hero.key),onFrameTime:Ne.onFrameTime.get(H.hero.key),chartType:pe.get(H.hero.key)??de,onChartTypeChange:Ne.onChartType.get(H.hero.key)},H.hero.key)})]}),H.grid.length>0&&(0,D.jsx)(`div`,{className:`flex-1 grid gap-3 min-h-0 min-w-0`,style:{gridTemplateColumns:`repeat(${Re}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${ze}, minmax(180px, 1fr))`},children:H.grid.map(e=>{let n=e.fadingOutAt!=null||I.playhead_ms-e.newestTs>nf;return le!=null&&le!==e.key?null:(0,D.jsx)(Pd,{sessionKey:e.key,bursts:e.bursts,paused:I.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:Be,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:H.grid.length,onTogglePin:Ne.onTogglePin.get(e.key),onToggleMinimize:Ne.onToggleMinimize.get(e.key),onToggleFullscreen:Ne.onToggleFullscreen.get(e.key),onClose:Ne.onClose.get(e.key),onFrameTime:Ne.onFrameTime.get(e.key),chartType:pe.get(e.key)??de,onChartTypeChange:Ne.onChartType.get(e.key)},e.key)})}),H.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`,` · `,H.rail.length,` session`,H.rail.length===1?``:`s`]}),H.overflow.length>0&&(0,D.jsxs)(`span`,{title:H.overflow.map(e=>e.key).join(`
16
- `),children:[`+`,H.overflow.length,` more`]})]}),(0,D.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${Math.min(H.rail.length,4)}, minmax(0, 1fr))`,gridAutoRows:`110px`},children:H.rail.map(e=>{let n=e.fadingOutAt!=null||I.playhead_ms-e.newestTs>nf;return le!=null&&le!==e.key?null:(0,D.jsx)(Pd,{sessionKey:e.key,bursts:e.bursts,paused:I.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:Ne.onPromote.get(e.key),activePanelCount:H.rail.length+1,onTogglePin:Ne.onTogglePin.get(e.key),onToggleMinimize:Ne.onToggleMinimize.get(e.key),onToggleFullscreen:Ne.onToggleFullscreen.get(e.key),onClose:Ne.onClose.get(e.key),onFrameTime:Ne.onFrameTime.get(e.key),chartType:pe.get(e.key)??de},e.key)})})]}),d===`broadcast`&&H.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:[`+`,H.overflow.length,` more session`,H.overflow.length===1?``:`s`,` off-screen`]})]})}),!v&&(0,D.jsxs)(`aside`,{"data-tutorial":`graph-inspector`,className:`flex flex-col gap-2 min-w-0 min-h-0 overflow-y-auto`,children:[(0,D.jsx)(Xu,{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)($u,{bursts:F,allBursts:e.allBursts})}),(0,D.jsx)(rd,{burst:Ee,anchor:a,onClose:()=>{i(null),o(null)}})]})]}),!g&&(0,D.jsx)(`section`,{"data-tutorial":`graph-timeline`,className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,D.jsx)(Vd,{playback:I,bursts:e.allBursts,rangeStart:Fe,rangeEnd:Ie,loading:ne,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`})]}),Ve&&(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)(Pd,{sessionKey:Ve.key,bursts:Ve.bursts,paused:I.mode!==`live`||Ve.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Ve.fadingOutAt!=null||I.playhead_ms-Ve.newestTs>nf,isFadingOut:!1,minHeight:0,pinned:Ve.state.pinned,minimized:!1,isFullscreen:!0,viewMode:d,onTogglePin:()=>be(Ve.key),onToggleMinimize:()=>xe(Ve.key),onToggleFullscreen:()=>Se(Ve.key),chartType:pe.get(Ve.key)??de,onChartTypeChange:e=>he(Ve.key,e)},`fs-${Ve.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)(Gu,{sessionKey:Ve.key,entries:we?.sessionKey===Ve.key?we.entries:[],loading:we?.sessionKey===Ve.key?we.loading:!0,error:we?.sessionKey===Ve.key?we.error:null,playingIndex:-1})})]})]})}function pf(){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`,...W()}}),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)(q,{children:(0,D.jsxs)(Y,{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)(q,{children:(0,D.jsxs)(Y,{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)(K,{onClick:u,disabled:c,variant:`primary`,children:c?`starting…`:`connect with github`})]})}),e&&n===`polling`&&(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{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 mf={deny:`red`,block:`red`,ask:`amber`,allow:`green`,log:`gray`,force:`blue`};function hf({id:e}){let{data:t,error:n}=U(`/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`,...W()},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)(K,{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)(G,{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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`rules · `,t.rules.length]})}),(0,D.jsx)(Y,{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)(G,{variant:mf[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)(G,{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)(_i,{children:e.raw_text})]},e.id))})]})]})}var gf=[{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 _f(e){return e?gf.filter(t=>t.scenario===`any`||t.scenario===e):gf}function vf({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 yf({installedIds:e,onInstall:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(new Set);if((0,_.useEffect)(()=>{let e=!0;return fetch(`/api/json/detect-stack`).then(e=>e.ok?e.json():null).then(t=>{e&&t&&r(t)}).catch(()=>{}),()=>{e=!1}},[]),!n||i)return null;let c=n.rulesets.filter(t=>!t.already_installed&&!e.has(t.id));return c.length===0?null:(0,D.jsx)(`section`,{className:`rounded-2xl p-4`,style:{border:`1px solid color-mix(in oklab, var(--color-brand) 35%, var(--color-line-1))`,background:`color-mix(in oklab, var(--color-brand) 7%, var(--color-surface-1))`},children:(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)]`,children:`Detected automatically`}),(0,D.jsxs)(`p`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)] mt-0.5`,children:[`We detected `,n.summary,` in this project`]}),(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-0.5 leading-snug`,children:[`You probably want`,` `,c.length===1?`this ruleset`:`these rulesets`,` — SSG matched your stack so you don't have to.`]}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2.5`,children:c.map(e=>{let n=o.has(e.id);return(0,D.jsx)(`button`,{type:`button`,disabled:n,onClick:async()=>{s(t=>new Set([...t,e.id]));try{await t(e.id)}finally{s(t=>{let n=new Set(t);return n.delete(e.id),n})}},className:`text-[11px] font-mono uppercase tracking-wider bg-[var(--color-brand)]/15 border border-[var(--color-brand)]/40 text-[var(--color-fg-0)] hover:bg-[var(--color-brand)]/25 rounded-sm px-2.5 py-1 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:n?`installing…`:`install ${e.id}`},e.id)})})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`shrink-0 text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] text-[16px] leading-none cursor-pointer`,"aria-label":`Dismiss stack suggestions`,children:`×`})]})})}function bf(){let e=new URLSearchParams(window.location.search).get(`starter`),{setMode:t}=Ht(),n=_f(e),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)({}),[s,c]=(0,_.useState)(new Set),[l,u]=(0,_.useState)(null);function d(e){c(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||i(new Set(t.installed))}).catch(()=>{}),()=>{e=!0}},[]);function f(e,t){u({msg:e,type:t}),setTimeout(()=>u(null),5e3)}async function p(){try{let e=await(await fetch(`/api/json/hub/installed`)).json();i(new Set(e.installed))}catch{}}async function m(e){let t=gf.find(t=>t.id===e);if(t){o(t=>({...t,[e]:`installing`}));try{let n=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:t.hubRulesetId})}),r=await n.text(),a=n.headers.get(`Content-Type`)??``,o=null;if(a.includes(`application/json`))try{o=JSON.parse(r)}catch{}o?.ok?(i(e=>new Set([...e,t.hubRulesetId])),c(t=>new Set([...t,e])),f(o.already_installed?`${t.title} — already installed`:`${t.title} — installed`,`ok`)):f(o?o.error??`Could not install ${t.title}`:r.replace(/<[^>]+>/g,``).trim()||`Could not install ${t.title} (HTTP ${n.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{o(t=>({...t,[e]:`idle`})),p()}}}async function h(e){try{let t=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:e})}),n=await t.text(),r=t.headers.get(`Content-Type`)??``,a=null;if(r.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok?(i(t=>new Set([...t,e])),f(a.already_installed?`${e} — already installed`:`${e} — installed`,`ok`)):f(a?a.error??`Could not install ${e}`:n.replace(/<[^>]+>/g,``).trim()||`Could not install ${e} (HTTP ${t.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{p()}}async function g(e){let t=gf.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.`)){o(t=>({...t,[e]:`uninstalling`}));try{let e=await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:t.hubRulesetId})}),n=await e.text(),r=e.headers.get(`Content-Type`)??``,a=null;if(r.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok||e.ok&&!a?(i(e=>{let n=new Set(e);return n.delete(t.hubRulesetId),n}),f(`${t.title} — removed`,`ok`)):f(a?a.error??`Could not remove ${t.title}`:n.replace(/<[^>]+>/g,``).trim()||`Could not remove ${t.title} (HTTP ${e.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{o(t=>({...t,[e]:`idle`})),p()}}}let v={coding:`for coding with AI`,"knowledge-work":`for email and docs`},y=n.filter(e=>r.has(e.hubRulesetId)).length;return(0,D.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,D.jsxs)(`section`,{"data-tutorial":`guard-hero`,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&&v[e]?` ${v[e]}`:``]}),(0,D.jsxs)(`button`,{type:`button`,"data-tutorial":`guard-advanced`,onClick:()=>t(`pro`),className:`mt-2 inline-flex items-center gap-1.5 text-[12px] text-[var(--color-brand)] hover:underline cursor-pointer`,title:`Switch to Advanced mode — unlocks the full rule library, audit, graph, and per-rule controls.`,children:[(0,D.jsx)(`span`,{children:`Switch to Advanced mode for full settings`}),(0,D.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-2 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:[y,` of `,n.length,` active`]})]}),l&&(0,D.jsx)(`div`,{className:`rounded-xl px-4 py-2.5 text-[12px]`,style:{border:`1px solid ${l.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 36%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 36%, transparent)`}`,background:l.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:l.type===`ok`?`var(--color-hig-green)`:`var(--color-hig-red)`,backdropFilter:`saturate(180%) blur(10px)`},children:l.msg}),(0,D.jsx)(yf,{installedIds:r,onInstall:h}),(0,D.jsx)(`div`,{"data-tutorial":`guard-packs`,className:`ss-list`,children:n.map(e=>(0,D.jsx)(vf,{pack:e,installed:r.has(e.hubRulesetId),state:a[e.id]??`idle`,expanded:s.has(e.id),onInstall:m,onUninstall:g,onToggleDetails:d},e.id))})]})}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
15
+ `,`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 Du(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 Ou({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 `+Du(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 ku=[`hook-ingress`,`parse`,`match`,`ffi-call`,`decide`,`audit`,`respond`],Au={"hook-ingress":`#6ea8ff`,parse:`#a78bfa`,match:`#60d394`,"ffi-call":`#f59e0b`,decide:`#f472b6`,audit:`#94a3b8`,respond:`#22d3ee`};function ju(){let{data:e,loading:t,error:n}=U(`/api/json/debug?uri=ssg%3A%2F%2Fframes%2Frecent%3Flimit%3D1024`,[Ge([`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)(Mu,{}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Pu,{frames:r,onSelect:o}),(0,D.jsx)(Nu,{})]})]}),(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)(Fu,{frame:a}):(0,D.jsx)(`p`,{className:`opacity-60`,children:`click a bar to inspect`})]})]})}function Mu(){return(0,D.jsxs)(`div`,{className:`text-[12px] text-[var(--color-fg-3)] space-y-2 py-4`,children:[(0,D.jsx)(`p`,{className:`text-[13px] text-[var(--color-fg-2)]`,children:`no frames captured yet`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] leading-relaxed`,children:`Frame collection is opt-in so it adds zero cost when off. Restart the daemon with the env var below, then any tool call (Bash, Read, Edit, MCP) will stream frames into this view in real time:`}),(0,D.jsx)(`pre`,{className:`text-[11px] text-amber-300 font-mono bg-[var(--color-surface-2)] border border-[var(--color-line-1)] rounded-sm px-2 py-1.5`,children:`SSG_DEBUG_ENABLED=1 ./ssg daemon`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)]`,children:`Each bar = one stage of one eval. Click a bar to inspect the frame — rule that matched, duration, error type, input preview.`})]})}function Nu(){return(0,D.jsx)(`div`,{className:`flex flex-wrap gap-3 text-[10px] font-mono text-[var(--color-fg-4)]`,children:ku.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:Au[e]}}),e]},e))})}function Pu({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)=>Lu(e.ts_start_ns,t.ts_start_ns))}));n.sort((e,t)=>Lu(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=Au[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 Fu({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)(Iu,{k:`stage`,children:[(0,D.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm mr-1 align-middle`,style:{background:Au[e.stage]??`#888`}}),e.stage]}),(0,D.jsx)(Iu,{k:`tool`,children:e.tool}),(0,D.jsx)(Iu,{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)(Iu,{k:`dur`,children:n}),e.rule_id&&(0,D.jsx)(Iu,{k:`rule`,children:e.rule_id}),e.error&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Iu,{k:`err.type`,children:(0,D.jsx)(`span`,{className:`text-rose-300`,children:e.error.type})}),(0,D.jsx)(Iu,{k:`err.msg`,children:(0,D.jsx)(`span`,{className:`text-rose-200`,children:e.error.message})})]}),e.input_preview&&(0,D.jsx)(Iu,{k:`input`,children:(0,D.jsx)(`code`,{className:`text-[10px] break-all`,children:e.input_preview})}),(0,D.jsx)(Iu,{k:`trace`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.trace_id})}),(0,D.jsx)(Iu,{k:`frame`,children:(0,D.jsx)(`code`,{className:`text-[10px]`,children:e.frame_id})})]})}function Iu({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 Lu(e,t){let n=BigInt(e),r=BigInt(t);return n<r?-1:+(n>r)}var Ru=[`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 zu(){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:Ru.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)(Bu,{uri:n})]})}function Bu({uri:e}){let t=Ge([`debug-frame`,`activity-updated`,`counters-updated`]),{data:n,loading:r,error:i,refetch:a}=U(`/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 Vu=200;function Hu(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 Uu(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 Wu(e){let{bursts:t,selectedId:n,onSelect:r}=e,i=(0,_.useMemo)(()=>{let e=new Map;for(let n of t){if(ia(n.tool))continue;let t=Pa(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,o=t[t.length-1],s=o?Fa[o.decision]??`#6b7280`:`#6b7280`,c=t.slice(-Vu).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:ra(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=Fa[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:na(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:[`↓`,Ha(o),` ↑`,Ha(s)]}),e.duration_ns>0&&(0,D.jsx)(`span`,{children:Uu(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:Hu(e.ts_ms)})]})]})]},t)})})]})]},e)})})}function Gu(e,t){let n=t.indexOf(`:`),r=n>0?t.slice(0,n):null;return{id:e.id,tool:e.tool,input:e.input,decision:e.decision,rule_id:e.rule_id,source_file:e.source_file,timestamp:Math.floor(e.ts_ms/1e3),client:e.client??r,duration_ns:e.duration_ns,rules_evaluated:e.rules_evaluated,rule_message:e.rule_message}}function Ku(e){let{sessionKey:t,entries:n,loading:r,error:i,playingIndex:a}=e,o=(0,_.useRef)(null),s=(0,_.useRef)(new Map),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),f=(0,_.useMemo)(()=>{let e=new Set;for(let t of n)e.add(t.decision);return[...e].sort()},[n]);(0,_.useEffect)(()=>{u&&!f.includes(u)&&d(null)},[u,f]);let p=(0,_.useMemo)(()=>{let e=c.trim().toLowerCase();return!e&&!u?n:n.filter(t=>u&&t.decision!==u?!1:e?t.tool.toLowerCase().includes(e)||t.decision.toLowerCase().includes(e)||(t.rule_id??``).toLowerCase().includes(e)||(t.rule_message??``).toLowerCase().includes(e)||t.input.toLowerCase().includes(e):!0)},[n,c,u]),m=c.trim().length>0||u!==null,h=a>=0?n[a]?.id??null:null;(0,_.useEffect)(()=>{if(!h)return;let e=s.current.get(h);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},[h]);let g=e=>t=>{t?s.current.set(e,t):s.current.delete(e)},v=r?`loading…`:i?`error`:m?`${p.length} / ${n.length}`:`${n.length} event${n.length===1?``:`s`}`;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)] tabular-nums`,children:v})]}),!i&&n.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-1.5 border-b border-[var(--color-line-1)] bg-black/20 shrink-0`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,D.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search tool, rule, input…`,"aria-label":`Search audit log`,className:`w-full bg-black/40 border border-[var(--color-line-1)] rounded-sm pl-2 pr-6 py-1 text-[11px] font-mono text-[var(--color-fg-1)] placeholder:text-[var(--color-fg-4)] focus:outline-none focus:border-[var(--color-hig-blue)]/60`}),c&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>l(``),"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)] text-[13px] leading-none px-1`,children:`×`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(null),className:`px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border transition-colors ${u===null?`border-[var(--color-hig-blue)]/60 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,children:`all`}),f.map(e=>{let t=Fa[e]??`#6b7280`,n=u===e;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>d(n?null:e),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-sm text-[10px] font-mono uppercase tracking-wider border transition-colors ${n?`bg-white/[0.06] text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,style:n?{borderColor:t}:void 0,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full shrink-0`,style:{background:t}}),e]},e)})]})]}),(0,D.jsxs)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto p-2 space-y-1.5`,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.`}),!i&&n.length>0&&p.length===0&&(0,D.jsx)(`div`,{className:`px-3 py-4 text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No events match the current filter.`}),p.map(e=>{let n=e.id===h;return(0,D.jsx)(`div`,{ref:g(e.id),className:n?`rounded-sm ring-1 ring-inset ring-sky-400/40`:void 0,children:(0,D.jsx)(xa,{row:Gu(e,t),defaultExpanded:n})},e.id)})]})]})}var qu=[100,500,1e3,5e3,1e4,1e5];function Ju(e){return e>=1e5||e>=1e3?`${e/1e3|0}k`:String(e)}function Yu(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 Xu(e){let t=Math.floor(e/100);return`${Math.floor(t/10)}.${t%10}s`}function Zu({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=ja(),C=Na(),w=Ma(),T=(0,_.useRef)(null),E=(0,_.useRef)(0),O=(0,_.useRef)(0),k=(0,_.useRef)(0),ee=(0,_.useRef)(0),A=(0,_.useRef)(new Set),j=(0,_.useRef)(performance.now());return(0,_.useEffect)(()=>{let e=performance.now();if(Zr()){let t=setInterval(()=>{let t=performance.now();r.current&&(r.current.textContent=Yu(t-e)),i.current&&(i.current.textContent=Xu(t-j.current))},1e3);return()=>clearInterval(t)}let[t]=es(()=>{let t=performance.now();r.current&&(r.current.textContent=Yu(t-e)),i.current&&(i.current.textContent=Xu(t-j.current))});return t},[]),(0,_.useEffect)(()=>{for(let e of w)e.rule_id&&A.current.add(e.rule_id);m(A.current.size)},[]),(0,_.useEffect)(()=>{let e=()=>{let e=Date.now(),t=w.filter(t=>e-t.ts_ms<=6e4),n=new Set(t.map(e=>`${e.client}:${e.agent_id??`solo`}`)).size;f(n)};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[w]),(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=qu.find(e=>e>ee.current&&r>=e);return i&&(ee.current=i,g(Ju(i)),x(!0),t?.(),setTimeout(()=>{g(``),x(!1)},700)),r}),S?.rule_id&&A.current.add(S.rule_id),m(A.current.size),S&&(S.decision===`block`?(O.current=0,o(0),j.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,t,n]),(0,D.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,D.jsx)(Qu,{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)(Qu,{label:`evals`,children:(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(Kc,{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)(Qu,{label:`since block`,children:(0,D.jsx)(`span`,{ref:i,className:`tabular-nums text-emerald-300 text-[15px]`,children:`0.0s`})}),(0,D.jsx)(Qu,{label:`streak / best`,children:(0,D.jsxs)(`span`,{className:G(`tabular-nums text-[15px]`,v?`record-beat`:`text-[var(--color-fg-0,#e6e8ed)]`),children:[(0,D.jsx)(Kc,{value:a,curve:`spring`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4,#5a6071)] mx-1`,children:`/`}),(0,D.jsx)(Kc,{value:s})]})}),(0,D.jsx)(Qu,{label:`agents`,children:(0,D.jsx)(Kc,{value:d,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})}),(0,D.jsx)(Qu,{label:`rules`,children:(0,D.jsx)(Kc,{value:p,className:`text-[var(--color-fg-0,#e6e8ed)] text-[15px]`})})]})}function Qu({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 $u(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)(()=>$u(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 Fa[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:Fa[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 td=320,nd=8,rd=12;function id(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+rd+td>r?n.x-rd-td:n.x+rd,l=n.y+rd+s>a?n.y-rd-s:n.y+rd;c=Math.min(Math.max(nd,c),r-td-nd),l=Math.min(Math.max(nd,l),a-s-nd),o({left:c,top:l})},[t,n]),(0,_.useEffect)(()=>{o({left:-9999,top:-9999})},[]),!t||!n)return null;let s=Fa[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:td,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:sd(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:ad(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 ad(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 od(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 sd(e,t){let n=[];return e!=null&&n.push(`${od(e)} in`),t!=null&&n.push(`${od(t)} out`),n.length>0?n.join(` · `):`—`}var cd=[`spiral`,`trace`,`flame`,`bars-h`,`bars-v`,`tree`],ld=`spiral`,ud={spiral:{label:`Spiral graph`,short:`spiral`,hint:`Single-arm tree-graph of tool calls (physics layout)`,glyph:`✺`},trace:{label:`Trace waterfall`,short:`trace`,hint:`Span timeline — one row per call, width by duration`,glyph:`≣`},flame:{label:`Flame graph`,short:`flame`,hint:`Stacked tool → decision hierarchy, width by share`,glyph:`🔥`},"bars-h":{label:`Horizontal bars`,short:`bars ↔`,hint:`Per-tool totals as horizontal bars, split by decision`,glyph:`▤`},"bars-v":{label:`Vertical bars`,short:`bars ↕`,hint:`Per-tool totals as vertical columns, split by decision`,glyph:`▥`},tree:{label:`Node tree`,short:`tree`,hint:`Linked node tree: root → tool → decision`,glyph:`🌳`}};function dd(e){return typeof e==`string`&&cd.includes(e)}function fd(e){return cd[(cd.indexOf(e)+1)%cd.length]??`spiral`}var pd=`graph.chartType.default.v1`,md=`graph.chartType.bySession.v1`;function hd(){if(typeof window>`u`)return ld;try{let e=window.localStorage.getItem(pd);return dd(e)?e:ld}catch{return ld}}function gd(e){if(!(typeof window>`u`))try{window.localStorage.setItem(pd,e)}catch{}}function _d(){if(typeof window>`u`)return new Map;try{let e=window.localStorage.getItem(md);if(!e)return new Map;let t=JSON.parse(e),n=new Map;for(let[e,r]of Object.entries(t))dd(r)&&n.set(e,r);return n}catch{return new Map}}function vd(e){if(!(typeof window>`u`))try{let t={};for(let[n,r]of e)t[n]=r;window.localStorage.setItem(md,JSON.stringify(t))}catch{}}function yd({value:e,onChange:t,large:n=!1,prefix:r,className:i}){let[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useId)(),l=ud[e];(0,_.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let u=e=>{t(e),o(!1)};return(0,D.jsxs)(`div`,{ref:s,className:`relative ${i??``}`,children:[(0,D.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?c:void 0,onClick:()=>o(e=>!e),title:`Chart type — ${l.label}: ${l.hint}`,className:`inline-flex items-center gap-1 rounded border border-[var(--color-line-1)] font-mono uppercase tracking-wider text-[var(--color-fg-3)] transition-colors hover:border-sky-500/40 hover:text-sky-300 ${n?`px-2 py-1 text-[11px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[r&&(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:r}),(0,D.jsx)(`span`,{"aria-hidden":`true`,children:l.glyph}),(0,D.jsx)(`span`,{children:l.short}),(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`text-[var(--color-fg-4)]`,children:`▾`})]}),a&&(0,D.jsx)(`div`,{id:c,role:`menu`,className:`absolute right-0 z-50 mt-1 w-60 overflow-hidden rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] shadow-lg`,children:cd.map(t=>{let n=ud[t],r=t===e;return(0,D.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>u(t),className:`flex w-full items-start gap-2 px-2.5 py-1.5 text-left transition-colors ${r?`bg-sky-500/10 text-sky-200`:`text-[var(--color-fg-2)] hover:bg-white/5`}`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 shrink-0 text-sm`,children:n.glyph}),(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsxs)(`span`,{className:`block font-mono text-[12px]`,children:[n.label,r&&(0,D.jsx)(`span`,{className:`ml-1 text-sky-400`,"aria-hidden":`true`,children:`●`})]}),(0,D.jsx)(`span`,{className:`block text-[10px] leading-tight text-[var(--color-fg-4)]`,children:n.hint})]})]},t)})})]})}var bd=900,xd=180,Sd=320,Cd=800,wd=4;function Td({sessionKey:e}={}){let t=ja(),n=Na(),[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&&Pa(t)!==e)return;let u=Date.now(),d=s.current,f=d[0];if(f&&u-l.current<Cd){f.extra+=1,f.burst=t,f.seq=n,l.current=u;return}if(d.length>=wd&&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`),xd):a===`visible`?e=setTimeout(()=>o(`out`),bd):a===`out`&&(e=setTimeout(()=>{let e=s.current.shift()??null;e?(i(e),o(`in`)):(i(null),o(`idle`))},Sd)),u.current=e,()=>{e&&clearTimeout(e)}},[a]),!r)return null;let{burst:d,extra:f}=r,p=Fa[d.decision]??`#ef4444`,m=Zr(),h=+(a===`in`||a===`visible`),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 ${xd}ms ease-out`:`opacity ${xd}ms ease-out, transform ${xd}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})]})]})})}function Ed(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.tool===t)return r.audit_id??`${r.ts_ms}:${r.tool}`}return null}function Dd({large:e}){return(0,D.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 ${e?`text-[11px]`:`text-[10px]`} font-mono text-[var(--color-fg-4)]`,children:Wl.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:Fa[e]}}),(0,D.jsx)(`span`,{className:`uppercase tracking-wide`,children:e})]},e))})}var Od=(0,_.memo)(function({bursts:e,orientation:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>ql(e,i?12:8),[e,i]),o=(0,_.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.count),1),[a]);if(a.length===0)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let s=(t,r)=>{let i=Ed(e,t.tool);i&&n(i,{x:r.clientX,y:r.clientY})},c=e=>Wl.filter(t=>e.byDecision[t]>0).map(t=>({d:t,frac:e.byDecision[t]/e.count}));return t===`horizontal`?(0,D.jsxs)(`div`,{className:`flex h-full flex-col gap-2 overflow-hidden p-2`,children:[(0,D.jsx)(Dd,{large:i}),(0,D.jsx)(`div`,{className:`flex flex-1 flex-col gap-1.5 overflow-y-auto pr-1`,children:a.map(e=>{let t=e.count/o*100,n=c(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>s(e,t),className:`grid grid-cols-[minmax(64px,26%)_1fr_auto] items-center gap-2 text-left`,title:`${e.tool} · ${e.count} calls`,children:[(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[12px]`:`text-[11px]`} text-[var(--color-fg-2)]`,children:e.tool}),(0,D.jsx)(`span`,{className:`relative block h-4 overflow-hidden rounded-sm bg-[var(--color-surface-0)]`,children:(0,D.jsx)(`span`,{className:`absolute inset-y-0 left-0 flex overflow-hidden rounded-sm`,style:{width:`${t}%`},children:n.map(e=>(0,D.jsx)(`span`,{className:`h-full`,style:{width:`${e.frac*100}%`,background:Fa[e.d]}},e.d))})}),(0,D.jsx)(`span`,{className:`tabular-nums font-mono ${i?`text-[12px]`:`text-[10px]`} text-[var(--color-fg-3)]`,children:e.count})]},e.tool)})})]}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col gap-2 overflow-hidden p-2`,children:[(0,D.jsx)(Dd,{large:i}),(0,D.jsx)(`div`,{className:`flex flex-1 items-end gap-2 overflow-x-auto pb-1`,children:a.map(e=>{let t=e.count/o*100,n=c(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>s(e,t),className:`flex h-full min-w-[40px] flex-1 flex-col items-center justify-end gap-1`,title:`${e.tool} · ${e.count} calls`,children:[(0,D.jsx)(`span`,{className:`tabular-nums font-mono ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-3)]`,children:e.count}),(0,D.jsx)(`span`,{className:`flex w-full max-w-[56px] flex-col-reverse overflow-hidden rounded-sm bg-[var(--color-surface-0)]`,style:{height:`${t}%`,minHeight:4},children:n.map(e=>(0,D.jsx)(`span`,{className:`w-full`,style:{height:`${e.frac*100}%`,background:Fa[e.d]}},e.d))}),(0,D.jsx)(`span`,{className:`w-full truncate text-center font-mono ${i?`text-[11px]`:`text-[9px]`} text-[var(--color-fg-2)]`,children:e.tool})]},e.tool)})})]})});function kd(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return`hsl(${12+t%48} 78% 52%)`}var Ad=26,jd=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,[a,o]=(0,_.useState)(`count`),s=(0,_.useMemo)(()=>e.length>0?Pa(e[0]):`session`,[e]),c=(0,_.useMemo)(()=>Xl(Yl(e,s,a)),[e,s,a]);if(e.length===0||c.length<=1)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let l=e=>e.depth===0?`var(--color-surface-2, #2a2a2a)`:e.depth===1?kd(e.name):Fa[e.decision??`shadow`]??`#6b7280`,u=e=>{let t=a===`duration`?$l(e.value):`${e.value}`;return`${e.name} · ${t}`},d=(e,t)=>{e.id&&n(e.id,{x:t.clientX,y:t.clientY})},f=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*Ad;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden p-2`,children:[(0,D.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`font-mono uppercase tracking-wider ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-4)]`,children:`flame · root → tool → decision`}),(0,D.jsx)(`div`,{className:`inline-flex overflow-hidden rounded border border-[var(--color-line-1)] text-[9px] font-mono uppercase tracking-wider`,children:[`count`,`duration`].map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":a===e,className:`cursor-pointer px-1.5 py-0.5 transition-colors ${a===e?`bg-amber-500/15 text-amber-300`:`text-[var(--color-fg-4)] hover:text-[var(--color-fg-2)]`}`,children:e===`count`?`calls`:`time`},e))})]}),(0,D.jsx)(`div`,{className:`relative flex-1 overflow-auto`,children:(0,D.jsx)(`div`,{className:`relative w-full`,style:{height:f},children:c.map(e=>{let n=(e.x1-e.x0)*100;if(n<.4)return null;let r=e.id!=null&&t!=null&&t===e.id,a=n>(i?6:9);return(0,D.jsx)(`button`,{type:`button`,onClick:t=>d(e,t),title:u(e),className:`absolute flex items-center overflow-hidden rounded-[2px] border border-black/25 px-1 text-left ${e.id?`cursor-pointer`:`cursor-default`} ${r?`ring-1 ring-sky-300`:``}`,style:{left:`${e.x0*100}%`,width:`${n}%`,top:e.depth*Ad,height:Ad-2,background:l(e)},children:a&&(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[11px]`:`text-[10px]`} ${e.depth===0?`text-[var(--color-fg-2)]`:`text-black/80`}`,children:e.name})},`${e.depth}:${e.name}:${e.x0.toFixed(4)}`)})})})]})}),Md=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>e.length>0?Pa(e[0]):`session`,[e]),o=(0,_.useMemo)(()=>Ql(e,a),[e,a]);if(e.length===0||o.nodes.length<=1)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let s=new Map;for(let e of o.nodes)s.set(e.id,e);let c=e=>e.depth===0?`var(--color-surface-2, #2a2a2a)`:Fa[e.decision??`shadow`]??`#6b7280`,l=(e,t)=>{e.burstId&&n(e.burstId,{x:t.clientX,y:t.clientY})};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden p-2`,children:[(0,D.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center justify-between font-mono uppercase tracking-wider ${i?`text-[11px]`:`text-[10px]`} text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{children:`tree · root → tool → decision`}),(0,D.jsxs)(`span`,{className:`normal-case tracking-normal`,children:[o.nodes.length,` nodes`]})]}),(0,D.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,D.jsx)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:o.nodes.map(e=>{if(e.parent==null)return null;let n=s.get(e.parent);if(!n)return null;let r=e.burstId!=null&&t!=null&&t===e.burstId;return(0,D.jsx)(`line`,{x1:n.x*100,y1:n.y*100,x2:e.x*100,y2:e.y*100,stroke:r?`#7dd3fc`:`rgba(110,112,118,0.45)`,strokeWidth:r?1.6:.8,vectorEffect:`non-scaling-stroke`},`e-${e.id}`)})}),o.nodes.map(e=>{let n=e.depth===2,r=e.burstId!=null&&t!=null&&t===e.burstId,a=i?12:9;return(0,D.jsx)(`button`,{type:`button`,onClick:t=>l(e,t),title:`${e.label} · ${e.value} call${e.value===1?``:`s`}`,className:`absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center overflow-hidden ${n?`rounded-full`:`rounded border border-black/30`} ${e.burstId?`cursor-pointer`:`cursor-default`} ${r?`z-10 ring-2 ring-sky-300`:``}`,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,background:c(e),...n?{width:a,height:a}:{maxWidth:`26%`,padding:`2px 6px`}},children:!n&&(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[11px]`:`text-[9px]`} ${e.depth===0?`text-[var(--color-fg-1)]`:`text-black/85`}`,children:e.depth===0?e.label:`${e.label} · ${e.value}`})},e.id)})]})]})}),Nd=34,Pd=(0,_.memo)(function({bursts:e,selectedId:t,onSelect:n,labelDensity:r=`normal`}){let i=r===`large`,a=(0,_.useMemo)(()=>Jl(e),[e]),o=(0,_.useRef)(null),s=(0,_.useRef)(!0);if((0,_.useEffect)(()=>{let e=o.current;!e||!s.current||(e.scrollTop=e.scrollHeight)},[a.rows.length]),a.rows.length===0)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] font-mono text-[var(--color-fg-4)]`,children:`no tool calls in window`});let c=Math.max(1,a.t1-a.t0),l=e=>{let t=e.currentTarget;s.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},u=(e,t)=>{n(e.id,{x:t.clientX,y:t.clientY})},d=i?`h-6`:`h-5`;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,D.jsx)(`div`,{ref:o,onScroll:l,className:`flex-1 overflow-y-auto px-2 py-1.5`,children:(0,D.jsx)(`div`,{className:`flex flex-col gap-[3px]`,children:a.rows.map(e=>{let n=Math.max(1.5,e.widthFrac*Nd),r=Math.min(e.startFrac*100,100-n),a=t!=null&&t===e.id,o=Fa[e.decision]??`#6b7280`;return(0,D.jsxs)(`button`,{type:`button`,onClick:t=>u(e,t),className:`grid grid-cols-[minmax(72px,24%)_1fr] items-center gap-2 rounded-sm ${d} ${a?`bg-white/5 ring-1 ring-sky-500/40`:``}`,title:`${e.tool} → ${e.decision} · ${$l(e.durationNs)}${e.rule_id?` · ${e.rule_id}`:``}`,children:[(0,D.jsx)(`span`,{className:`truncate text-left font-mono ${i?`text-[12px]`:`text-[11px]`} text-[var(--color-fg-2)]`,children:e.tool}),(0,D.jsx)(`span`,{className:`relative h-full w-full`,children:(0,D.jsx)(`span`,{className:`absolute top-1/2 flex -translate-y-1/2 items-center rounded-sm px-1`,style:{left:`${r}%`,width:`${n}%`,minWidth:6,height:i?14:11,background:o},children:(0,D.jsx)(`span`,{className:`truncate font-mono ${i?`text-[10px]`:`text-[9px]`} text-black/70`,children:$l(e.durationNs)})})})]},e.id)})})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t border-[var(--color-line-0)] px-2 py-1 text-[9px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:[(0,D.jsxs)(`span`,{children:[`← `,Math.round(c/1e3),`s span`]}),(0,D.jsxs)(`span`,{children:[a.rows.length,` spans · width = duration (log)`]}),(0,D.jsx)(`span`,{children:`now →`})]})]})}),Fd=(0,_.memo)(function(e){let{chartType:t,bursts:n,spiralBursts:r,paused:i,selectedId:a,onSelect:o,burstSeq:s,compact:c,activePanelCount:l,labelDensity:u,onFrameTime:d}=e;switch(t){case`trace`:return(0,D.jsx)(Pd,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});case`flame`:return(0,D.jsx)(jd,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});case`bars-h`:return(0,D.jsx)(Od,{bursts:n,orientation:`horizontal`,selectedId:a,onSelect:o,labelDensity:u});case`bars-v`:return(0,D.jsx)(Od,{bursts:n,orientation:`vertical`,selectedId:a,onSelect:o,labelDensity:u});case`tree`:return(0,D.jsx)(Md,{bursts:n,selectedId:a,onSelect:o,labelDensity:u});default:return(0,D.jsx)(ys,{bursts:r,paused:i,selectedId:a,onSelect:o,burstSeq:s,compact:c,activePanelCount:l,labelDensity:u,onFrameTime:d})}}),Id=(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,chartType:C=ld,onChartTypeChange:w}=e,T=p===`broadcast`,E=!m&&(p===`stream`||p===`broadcast`||f)?`large`:`normal`,O=t.indexOf(`:`),k=O>=0?t.slice(0,O):t,ee=O>=0?t.slice(O+1):``,A=ra(k),j=(0,_.useRef)(null),[M,N]=(0,_.useState)(!0),[P,F]=(0,_.useState)(null),I=()=>{let e=j.current;if(!e)return;let t=e.querySelector(`canvas`);t instanceof HTMLCanvasElement&&F(t.toDataURL(`image/png`))},L=()=>{if(!P)return;let e=document.createElement(`a`),n=t.replace(/[^a-z0-9._-]+/gi,`-`);e.href=P,e.download=`ssg-graph-${n}-${Date.now()}.png`,document.body.appendChild(e),e.click(),e.remove()},te=()=>{!P||!navigator.clipboard?.write||fetch(P).then(e=>e.blob()).then(e=>{let t=new ClipboardItem({"image/png":e});return navigator.clipboard.write([t])}).catch(()=>{})},ne=typeof navigator<`u`&&typeof navigator.clipboard?.write==`function`&&typeof ClipboardItem<`u`;(0,_.useEffect)(()=>{if(f){N(!0);return}let e=j.current;if(!e)return;let t=new IntersectionObserver(e=>{for(let t of e)N(t.isIntersecting)},{threshold:.01});return t.observe(e),()=>t.disconnect()},[f]);let R=n.length>0?n[n.length-1]:null,z=R?Fa[R.decision]??`#6b7280`:`#6b7280`,B=R?.decision??null,re=R?.tool??null,ie=r||!M||d,ae=(0,_.useMemo)(()=>n.length>24?n.slice(n.length-24):n,[n]);return(0,D.jsxs)(`div`,{ref:j,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,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:[!T&&(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:A}),ee&&(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:ee})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono text-[var(--color-fg-4)] min-w-0`,children:[re&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 max-w-[180px] min-w-0`,title:B?`latest: ${re} → ${B}`:`latest: ${re}`,children:[(0,D.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:z}}),(0,D.jsx)(`span`,{className:`truncate text-[var(--color-fg-2)]`,children:re})]}),(0,D.jsxs)(`span`,{className:`hidden md:inline text-[var(--color-fg-4)] shrink-0`,children:[n.length,`n`]}),s?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 text-amber-300 shrink-0`,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 shrink-0`,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 shrink-0`,children:[w&&(0,D.jsx)(yd,{value:C,onChange:w,large:p===`stream`||f}),(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:I,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&&!T&&(0,D.jsx)(Es,{sessionKey:t,className:`rounded-none border-x-0 border-t-0 border-b border-[var(--color-line-1)] shrink-0`}),P&&(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:P,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:[ne&&(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:`copy`}),(0,D.jsx)(`button`,{type:`button`,onClick:L,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:()=>F(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)(Td,{sessionKey:t}),(0,D.jsx)(Fd,{chartType:C,bursts:n,spiralBursts:ae,paused:ie,selectedId:i,onSelect:a,burstSeq:o,compact:!0,activePanelCount:g,labelDensity:E,onFrameTime:S}),m&&(0,D.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Promote ${A} to spotlight`,title:`Spotlight ${A}${ee?` · ${ee}`:``}`,className:`absolute inset-0 cursor-pointer bg-transparent hover:bg-sky-400/5 transition-colors`})]})]})}),Ld=200,Rd=.9,zd=40,Bd=32,Vd=480,Hd=`transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease-out, fill 320ms ease-out`;function Ud(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<Ld;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*(Ld-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 ${Vd}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=`,Wd(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 ${Ld} ${zd}`,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*Ld,x2:e*Ld,y1:0,y2:zd,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(Bd,n*3),i=n===0?0:r/Bd,a=e.block>0?Fa.block:e.ask>0?Fa.ask:e.other>0&&e.allow===0?Fa.log:Fa.allow;return(0,D.jsx)(`rect`,{x:t+.05,y:zd-Bd,width:Rd,height:Bd,rx:.3,fill:a,style:{opacity:n===0?0:.78,transform:`scaleY(${i})`,transformOrigin:`50% 100%`,transformBox:`fill-box`,transition:Hd}},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:Gd(r)}),(0,D.jsx)(`span`,{className:`uppercase tracking-wider transition-colors ${p?`text-sky-300`:``}`,children:p?`↳ ${Gd(p.ts)}`:`${Kd(t.window_ms)} window`}),(0,D.jsx)(`span`,{children:Gd(i)})]})]})}function Wd(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 Gd(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Kd(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}var qd=`ssg.sfx.enabled`;function Jd(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(qd)===`true`}catch{return!1}}function Yd(e){if(!(typeof window>`u`))try{window.localStorage.setItem(qd,String(e))}catch{}}function Xd(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 Zd(){let[e,t]=(0,_.useState)(Jd),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(Yd(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`:Xd(i,a,110,55,150,.08);break;case`force`:Xd(i,a,80,40,200,.1),Xd(i,a,160,80,200,.05,`square`);break;case`milestone`:{Xd(i,a,660,880,100,.06);let e=i,t=a;setTimeout(()=>{e.state!==`suspended`&&Xd(e,t,880,1320,100,.05)},115);break}case`record`:Xd(i,a,880,1320,350,.07);break}},[e])}}var Qd=80,$d=600,ef=Object.freeze({stop:()=>{},count:0}),tf=new Set([`allow`,`block`,`ask`,`log`,`force`,`shadow`]);function nf(e){if(!mo()||e.length===0)return ef;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=Qd+Math.log2(1+n)*14;r+=Math.max(Qd,Math.min($d,o))}let o=tf.has(a.decision)?a.decision:null;if(!o)continue;let s=setTimeout(()=>{n||_o(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 rf=1200,af=3e4,of=3e3,sf=6,cf=3,lf=`graph.panelState.v1`,uf=14400*1e3;function df(e,t){let n=new Map;for(let t of e){let e=Pa(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 ff(){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 pf(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 mf(){let e=to(),t=Na(),n=ja(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),s=(0,_.useCallback)((e,t)=>{i(e),o(t??null)},[]),c=Zd();(0,_.useEffect)(()=>{n&&(n.decision===`block`?c.play(`block`):n.decision===`force`&&c.play(`force`))},[c.play,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)},[]),ee=(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 A=(0,_.useRef)(new Map),j=(0,_.useRef)(0),[M,N]=(0,_.useState)({fps:0,active:0,hitches:0}),P=(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:F,playback:I,oldest_known_ms:L,newest_known_ms:te,loading_backfill:ne}=e.snapshot,{activeProject:R}=Ze(),[z,B]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(R===`all`)return;let e=setInterval(()=>B(e=>e+1),15e3);return()=>clearInterval(e)},[R]);let{data:re}=U(`/api/json/sessions/list?limit=1000`,[R,z]),ie=(0,_.useMemo)(()=>{let e=new Map;for(let t of re?.sessions??[])e.set(t.session_key,t.project_id);return e},[re]),ae=(0,_.useRef)(new Map),oe=(0,_.useMemo)(()=>{let e=df(F,ae.current);if(ae.current=e,R===`all`)return e;let t=new Map;for(let[n,r]of e){let e=ie.get(n);(e===void 0||e===R)&&t.set(n,r)}return t},[F,ie,R]),[se,ce]=(0,_.useState)(()=>ff()),[le,ue]=(0,_.useState)(null);(0,_.useEffect)(()=>{pf(se)},[se]);let[de,fe]=(0,_.useState)(()=>hd()),[pe,me]=(0,_.useState)(()=>_d());(0,_.useEffect)(()=>{gd(de)},[de]),(0,_.useEffect)(()=>{vd(pe)},[pe]);let he=(0,_.useCallback)((e,t)=>{me(n=>{let r=new Map(n);return r.set(e,t),r})},[]);(0,_.useEffect)(()=>{me(e=>{let t=!1,n=new Map(e);for(let r of e.keys())oe.has(r)||se.has(r)||(n.delete(r),t=!0);return t?n:e})},[oe,se]),(0,_.useEffect)(()=>{let e=e=>{if(e.key!==`g`&&e.key!==`G`)return;let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||fe(e=>fd(e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,_.useEffect)(()=>{let e=Date.now(),t=!1,n=new Map(se);for(let r of oe.keys())n.has(r)||(n.set(r,{pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:e}),t=!0);for(let[r,i]of n)oe.has(r)||i.pinned||e-i.firstSeenAt<uf||(n.delete(r),t=!0);t&&ce(n)},[oe,se]);let ge=(0,_.useRef)(new Map),_e=(0,_.useRef)(new Set),ve=(0,_.useRef)(new Map),[,ye]=(0,_.useState)(0);(0,_.useEffect)(()=>{let e=performance.now(),t=ge.current,n=_e.current,r=ve.current,i=new Set;for(let[e,n]of oe)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>=rf&&(t.delete(n),r.delete(n));if(_e.current=i,t.size>0){let n=1/0;for(let e of t.values())n=Math.min(n,e.diedAt+rf);let r=Math.max(16,n-e+16),i=setTimeout(()=>ye(e=>e+1),r);return()=>clearTimeout(i)}},[oe]);let be=(0,_.useCallback)(e=>{ce(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})},[]),xe=(0,_.useCallback)(e=>{ce(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})},[]),Se=(0,_.useCallback)(e=>{ue(t=>t===e?null:e)},[]);(0,_.useEffect)(()=>{if(!le)return;let e=e=>{e.key===`Escape`&&ue(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[le]);let Ce=(0,_.useRef)(null),[we,Te]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!le){Ce.current?.stop(),Ce.current=null,Te(null);return}let e=!1;Te({sessionKey:le,entries:[],loading:!0,error:null});let t=`/api/json/graph/session-audit?session_key=${encodeURIComponent(le)}`;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:[];Te({sessionKey:le,entries:n,loading:!1,error:null});let r=n.map(e=>({ts_ms:e.ts_ms,decision:e.decision,tool:e.tool}));Ce.current?.stop(),Ce.current=nf(r)}).catch(t=>{e||Te({sessionKey:le,entries:[],loading:!1,error:t instanceof Error?t.message:`failed to load audit log`})}),()=>{e=!0,Ce.current?.stop(),Ce.current=null}},[le]);let V=(0,_.useMemo)(()=>{let e={pinned:!1,pinnedAt:0,minimized:!1,firstSeenAt:Date.now()},t=[];for(let[n,r]of oe){let i=r[r.length-1]?.ts_ms??0;t.push({key:n,bursts:r,newestTs:i,fadingOutAt:null,state:se.get(n)??e})}for(let[n,r]of ge.current)oe.has(n)||t.push({key:n,bursts:r.bursts,newestTs:r.newestTs,fadingOutAt:r.diedAt,state:se.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},[oe,se]),Ee=(0,_.useMemo)(()=>{if(!r)return null;for(let e of F)if((e.audit_id??`${e.ts_ms}:${e.tool}`)===r||r.startsWith(`${e.ts_ms}:${e.tool}`))return e;return null},[F,r]),[De,Oe]=(0,_.useState)(null),ke=(0,_.useRef)(null),Ae=(0,_.useMemo)(()=>{if(V.length===0)return ke.current=null,null;if(De!=null&&V.some(e=>e.key===De))return ke.current=De,De;let e=V.filter(e=>e.state.pinned);if(e.length>0)return e.sort((e,t)=>t.state.pinnedAt-e.state.pinnedAt),ke.current=e[0].key,e[0].key;let t=V[0];for(let e of V)e.newestTs>t.newestTs&&(t=e);let n=ke.current;if(n!=null&&n!==t.key){let e=V.find(e=>e.key===n);if(e&&Date.now()-e.newestTs<of)return n}return ke.current=t.key,t.key},[V,De]);(0,_.useEffect)(()=>{De!=null&&(V.some(e=>e.key===De)||Oe(null))},[De,V]),(0,_.useEffect)(()=>{Oe(null)},[]);let H=(0,_.useMemo)(()=>{if(V.length===0)return{hero:null,grid:[],rail:[],overflow:[]};if(d===`full`||d===`feed`)return{hero:null,grid:V.slice(0,sf),rail:V.slice(sf),overflow:[]};let e=V.find(e=>e.key===Ae)??V[V.length-1],t=V.filter(t=>t.key!==e.key);return d===`broadcast`?{hero:e,grid:[],rail:[],overflow:t}:{hero:e,grid:[],rail:t.slice(0,cf),overflow:t.slice(cf)}},[V,d,Ae]),je=(0,_.useCallback)(e=>{Oe(e)},[]),Me=(0,_.useCallback)(()=>{Oe(null)},[]),Ne=(0,_.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;for(let s of V){let c=s.key;e.set(c,()=>be(c)),t.set(c,()=>xe(c)),n.set(c,()=>Se(c)),r.set(c,()=>void k([c])),i.set(c,e=>P(c,e)),a.set(c,()=>je(c)),o.set(c,e=>he(c,e))}return{onTogglePin:e,onToggleMinimize:t,onToggleFullscreen:n,onClose:r,onFrameTime:i,onPromote:a,onChartType:o}},[be,xe,Se,k,P,je,he,V]);(0,_.useEffect)(()=>{let e=new Set(V.map(e=>e.key)),t=A.current;for(let n of Array.from(t.keys()))e.has(n)||t.delete(n)},[V]);let Pe=(0,_.useMemo)(()=>{let e=n?.counters,t=e?.total??0,r=(e?.block??0)+(e?.force??0),i=0;if(F.length>0){let e=0,t=F.slice(-100);for(let n of t)e+=n.duration_ns;i=e/t.length/1e6}return{evals:t,blocks:r,avgMs:i,agents:V.length}},[n,F,V.length]),Fe=Math.min(L,I.playhead_ms-I.window_ms),Ie=Math.max(te,I.playhead_ms),Le=H.grid.length,Re=C||Le<=1?1:Le<=4?2:3,ze=Math.max(1,Math.ceil(Math.max(1,Le)/Re)),Be=Le<=1||C?360:180,Ve=le?V.find(e=>e.key===le):null,He=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`}),I.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`}),I.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:He(Pe.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:He(Pe.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:Pe.avgMs<1?`${(Pe.avgMs*1e3).toFixed(0)}µs`:`${Pe.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:Pe.agents}),` `,(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`agent`,Pe.agents===1?``:`s`]})]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-2 gap-y-1.5`,children:[!p&&(0,D.jsxs)(`p`,{className:`hidden lg:block text-[11px] font-mono text-[var(--color-fg-4)]`,children:[F.length,`n · window `,Math.round(I.window_ms/1e3),`s`]}),(0,D.jsxs)(`span`,{className:`hidden lg:inline 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,`/`,V.length]}),!p&&(0,D.jsx)(yd,{value:de,onChange:fe,prefix:`chart`,className:`hidden sm:block`}),(0,D.jsx)(`div`,{role:`group`,"aria-label":`Graph view mode`,"data-tutorial":`graph-views`,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;return(0,D.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":t,title: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)`,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:e===`broadcast`?`cast`:e},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&&V.length>0&&(0,D.jsx)(`div`,{"aria-live":`polite`,children:(0,D.jsx)(`button`,{type:`button`,"aria-label":`Clear all visible graph sessions`,"data-tutorial":`graph-clear`,onClick:()=>ee(V.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 ${V.filter(e=>!e.fadingOutAt).length}`:`clear`})})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`graph-panels`,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)(Wu,{bursts:F,selectedId:r,onSelect:s})}):V.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:[H.hero&&(le==null||le===H.hero.key)&&(0,D.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2`,children:[De!=null&&(0,D.jsx)(`button`,{type:`button`,onClick:Me,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)(Id,{sessionKey:H.hero.key,bursts:H.hero.bursts,paused:I.mode!==`live`||H.hero.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:H.hero.fadingOutAt!=null||I.playhead_ms-H.hero.newestTs>af,isFadingOut:H.hero.fadingOutAt!=null,minHeight:0,pinned:H.hero.state.pinned,minimized:H.hero.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:1,onTogglePin:Ne.onTogglePin.get(H.hero.key),onToggleMinimize:Ne.onToggleMinimize.get(H.hero.key),onToggleFullscreen:Ne.onToggleFullscreen.get(H.hero.key),onClose:Ne.onClose.get(H.hero.key),onFrameTime:Ne.onFrameTime.get(H.hero.key),chartType:pe.get(H.hero.key)??de,onChartTypeChange:Ne.onChartType.get(H.hero.key)},H.hero.key)})]}),H.grid.length>0&&(0,D.jsx)(`div`,{className:`flex-1 grid gap-3 min-h-0 min-w-0`,style:{gridTemplateColumns:`repeat(${Re}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${ze}, minmax(180px, 1fr))`},children:H.grid.map(e=>{let n=e.fadingOutAt!=null||I.playhead_ms-e.newestTs>af;return le!=null&&le!==e.key?null:(0,D.jsx)(Id,{sessionKey:e.key,bursts:e.bursts,paused:I.mode!==`live`||e.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:n,isFadingOut:e.fadingOutAt!=null,minHeight:Be,pinned:e.state.pinned,minimized:e.state.minimized,isFullscreen:!1,viewMode:d,activePanelCount:H.grid.length,onTogglePin:Ne.onTogglePin.get(e.key),onToggleMinimize:Ne.onToggleMinimize.get(e.key),onToggleFullscreen:Ne.onToggleFullscreen.get(e.key),onClose:Ne.onClose.get(e.key),onFrameTime:Ne.onFrameTime.get(e.key),chartType:pe.get(e.key)??de,onChartTypeChange:Ne.onChartType.get(e.key)},e.key)})}),H.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`,` · `,H.rail.length,` session`,H.rail.length===1?``:`s`]}),H.overflow.length>0&&(0,D.jsxs)(`span`,{title:H.overflow.map(e=>e.key).join(`
16
+ `),children:[`+`,H.overflow.length,` more`]})]}),(0,D.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${Math.min(H.rail.length,4)}, minmax(0, 1fr))`,gridAutoRows:`110px`},children:H.rail.map(e=>{let n=e.fadingOutAt!=null||I.playhead_ms-e.newestTs>af;return le!=null&&le!==e.key?null:(0,D.jsx)(Id,{sessionKey:e.key,bursts:e.bursts,paused:I.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:Ne.onPromote.get(e.key),activePanelCount:H.rail.length+1,onTogglePin:Ne.onTogglePin.get(e.key),onToggleMinimize:Ne.onToggleMinimize.get(e.key),onToggleFullscreen:Ne.onToggleFullscreen.get(e.key),onClose:Ne.onClose.get(e.key),onFrameTime:Ne.onFrameTime.get(e.key),chartType:pe.get(e.key)??de},e.key)})})]}),d===`broadcast`&&H.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:[`+`,H.overflow.length,` more session`,H.overflow.length===1?``:`s`,` off-screen`]})]})}),!v&&(0,D.jsxs)(`aside`,{"data-tutorial":`graph-inspector`,className:`flex flex-col gap-2 min-w-0 min-h-0 overflow-y-auto`,children:[(0,D.jsx)(Zu,{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:F,allBursts:e.allBursts})}),(0,D.jsx)(id,{burst:Ee,anchor:a,onClose:()=>{i(null),o(null)}})]})]}),!g&&(0,D.jsx)(`section`,{"data-tutorial":`graph-timeline`,className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:(0,D.jsx)(Ud,{playback:I,bursts:e.allBursts,rangeStart:Fe,rangeEnd:Ie,loading:ne,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`})]}),Ve&&(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)(Id,{sessionKey:Ve.key,bursts:Ve.bursts,paused:I.mode!==`live`||Ve.fadingOutAt!=null,selectedId:r,onSelect:s,burstSeq:t,isStale:Ve.fadingOutAt!=null||I.playhead_ms-Ve.newestTs>af,isFadingOut:!1,minHeight:0,pinned:Ve.state.pinned,minimized:!1,isFullscreen:!0,viewMode:d,onTogglePin:()=>be(Ve.key),onToggleMinimize:()=>xe(Ve.key),onToggleFullscreen:()=>Se(Ve.key),chartType:pe.get(Ve.key)??de,onChartTypeChange:e=>he(Ve.key,e)},`fs-${Ve.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)(Ku,{sessionKey:Ve.key,entries:we?.sessionKey===Ve.key?we.entries:[],loading:we?.sessionKey===Ve.key?we.loading:!0,error:we?.sessionKey===Ve.key?we.error:null,playingIndex:-1})})]})]})}function hf(){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`,...W()}}),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 gf={deny:`red`,block:`red`,ask:`amber`,allow:`green`,log:`gray`,force:`blue`};function _f({id:e}){let{data:t,error:n}=U(`/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`,...W()},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:gf[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)(yi,{children:e.raw_text})]},e.id))})]})]})}var vf=[{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 yf(e){return e?vf.filter(t=>t.scenario===`any`||t.scenario===e):vf}function bf({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 xf({installedIds:e,onInstall:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(new Set);if((0,_.useEffect)(()=>{let e=!0;return fetch(`/api/json/detect-stack`).then(e=>e.ok?e.json():null).then(t=>{e&&t&&r(t)}).catch(()=>{}),()=>{e=!1}},[]),!n||i)return null;let c=n.rulesets.filter(t=>!t.already_installed&&!e.has(t.id));return c.length===0?null:(0,D.jsx)(`section`,{className:`rounded-2xl p-4`,style:{border:`1px solid color-mix(in oklab, var(--color-brand) 35%, var(--color-line-1))`,background:`color-mix(in oklab, var(--color-brand) 7%, var(--color-surface-1))`},children:(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-brand)]`,children:`Detected automatically`}),(0,D.jsxs)(`p`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)] mt-0.5`,children:[`We detected `,n.summary,` in this project`]}),(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-0.5 leading-snug`,children:[`You probably want`,` `,c.length===1?`this ruleset`:`these rulesets`,` — SSG matched your stack so you don't have to.`]}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2.5`,children:c.map(e=>{let n=o.has(e.id);return(0,D.jsx)(`button`,{type:`button`,disabled:n,onClick:async()=>{s(t=>new Set([...t,e.id]));try{await t(e.id)}finally{s(t=>{let n=new Set(t);return n.delete(e.id),n})}},className:`text-[11px] font-mono uppercase tracking-wider bg-[var(--color-brand)]/15 border border-[var(--color-brand)]/40 text-[var(--color-fg-0)] hover:bg-[var(--color-brand)]/25 rounded-sm px-2.5 py-1 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:n?`installing…`:`install ${e.id}`},e.id)})})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`shrink-0 text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] text-[16px] leading-none cursor-pointer`,"aria-label":`Dismiss stack suggestions`,children:`×`})]})})}function Sf(){let e=new URLSearchParams(window.location.search).get(`starter`),{setMode:t}=Ht(),n=yf(e),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)({}),[s,c]=(0,_.useState)(new Set),[l,u]=(0,_.useState)(null);function d(e){c(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||i(new Set(t.installed))}).catch(()=>{}),()=>{e=!0}},[]);function f(e,t){u({msg:e,type:t}),setTimeout(()=>u(null),5e3)}async function p(){try{let e=await(await fetch(`/api/json/hub/installed`)).json();i(new Set(e.installed))}catch{}}async function m(e){let t=vf.find(t=>t.id===e);if(t){o(t=>({...t,[e]:`installing`}));try{let n=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:t.hubRulesetId})}),r=await n.text(),a=n.headers.get(`Content-Type`)??``,o=null;if(a.includes(`application/json`))try{o=JSON.parse(r)}catch{}o?.ok?(i(e=>new Set([...e,t.hubRulesetId])),c(t=>new Set([...t,e])),f(o.already_installed?`${t.title} — already installed`:`${t.title} — installed`,`ok`)):f(o?o.error??`Could not install ${t.title}`:r.replace(/<[^>]+>/g,``).trim()||`Could not install ${t.title} (HTTP ${n.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{o(t=>({...t,[e]:`idle`})),p()}}}async function h(e){try{let t=await fetch(`/api/hub/install`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:e})}),n=await t.text(),r=t.headers.get(`Content-Type`)??``,a=null;if(r.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok?(i(t=>new Set([...t,e])),f(a.already_installed?`${e} — already installed`:`${e} — installed`,`ok`)):f(a?a.error??`Could not install ${e}`:n.replace(/<[^>]+>/g,``).trim()||`Could not install ${e} (HTTP ${t.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{p()}}async function g(e){let t=vf.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.`)){o(t=>({...t,[e]:`uninstalling`}));try{let e=await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:t.hubRulesetId})}),n=await e.text(),r=e.headers.get(`Content-Type`)??``,a=null;if(r.includes(`application/json`))try{a=JSON.parse(n)}catch{}a?.ok||e.ok&&!a?(i(e=>{let n=new Set(e);return n.delete(t.hubRulesetId),n}),f(`${t.title} — removed`,`ok`)):f(a?a.error??`Could not remove ${t.title}`:n.replace(/<[^>]+>/g,``).trim()||`Could not remove ${t.title} (HTTP ${e.status})`,`error`)}catch(e){f(`Could not reach the dashboard server (${e instanceof Error?e.message:String(e)})`,`error`)}finally{o(t=>({...t,[e]:`idle`})),p()}}}let v={coding:`for coding with AI`,"knowledge-work":`for email and docs`},y=n.filter(e=>r.has(e.hubRulesetId)).length;return(0,D.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-6`,children:[(0,D.jsxs)(`section`,{"data-tutorial":`guard-hero`,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&&v[e]?` ${v[e]}`:``]}),(0,D.jsxs)(`button`,{type:`button`,"data-tutorial":`guard-advanced`,onClick:()=>t(`pro`),className:`mt-2 inline-flex items-center gap-1.5 text-[12px] text-[var(--color-brand)] hover:underline cursor-pointer`,title:`Switch to Advanced mode — unlocks the full rule library, audit, graph, and per-rule controls.`,children:[(0,D.jsx)(`span`,{children:`Switch to Advanced mode for full settings`}),(0,D.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-2)] mt-2 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:[y,` of `,n.length,` active`]})]}),l&&(0,D.jsx)(`div`,{className:`rounded-xl px-4 py-2.5 text-[12px]`,style:{border:`1px solid ${l.type===`ok`?`color-mix(in oklab, var(--color-hig-green) 36%, transparent)`:`color-mix(in oklab, var(--color-hig-red) 36%, transparent)`}`,background:l.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:l.type===`ok`?`var(--color-hig-green)`:`var(--color-hig-red)`,backdropFilter:`saturate(180%) blur(10px)`},children:l.msg}),(0,D.jsx)(xf,{installedIds:r,onInstall:h}),(0,D.jsx)(`div`,{"data-tutorial":`guard-packs`,className:`ss-list`,children:n.map(e=>(0,D.jsx)(bf,{pack:e,installed:r.has(e.hubRulesetId),state:a[e.id]??`idle`,expanded:s.has(e.id),onInstall:m,onUninstall:g,onToggleDetails:d},e.id))})]})}function Cf(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function wf(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 Tf=[{value:`downloads`,label:`most downloaded`},{value:`newest`,label:`newest`},{value:`rules`,label:`most rules`}],Ef=[``,`critical`,`high`,`medium`,`low`],Df=[``,`deny`,`ask`,`allow`,`log`];function Of(){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 kf({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 Af({install:e,onRemove:t,removing:n}){let r=wf(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 jf({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
17
17
  bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30 border-r-0
18
18
  hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
19
19
  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
20
20
  bg-[var(--color-brand)]/8 text-[var(--color-brand)] border border-[var(--color-brand)]/30
21
21
  hover:bg-[var(--color-brand)]/15 hover:border-[var(--color-brand)]/50
22
- 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
+ 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 Mf({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
23
23
  ${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)]`}
24
24
  ${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
25
- ${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}=Ht();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)(!1),[ee,A]=(0,_.useState)(null),[j,M]=(0,_.useState)(null),N=(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]),P=(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{}},[]),F=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/rules-dir`);if(!e.ok)return;E(await e.json())}catch{}},[]);(0,_.useEffect)(()=>{P(),F()},[P,F]),(0,_.useEffect)(()=>{let e=!1;return v(!0),h(0),fetch(`/api/json/hub?${N(0)}`).then(e=>e.json()).then(t=>{e||(d(t.data),p(t.has_more),h(0))}).catch(()=>{}).finally(()=>{e||v(!1)}),()=>{e=!0}},[N]);async function I(){let e=m+1;v(!0);try{let t=await fetch(`/api/json/hub?${N(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 L(){let e=await fetch(`/api/json/hub?${N(0)}`);if(!e.ok)return;let t=await e.json();d(t.data),p(t.has_more),h(0)}async function te(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`,...W()},body:JSON.stringify(n)})).json();r.ok?(A(e),setTimeout(()=>A(null),2e3),M({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([P(),L()])):M({msg:r.error??`install failed`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{S(null),setTimeout(()=>M(null),5e3)}}async function ne(e){await te(e)}async function R(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{M({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>M(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 te(e,t)}async function z(e){k(!0);try{let t=await(await fetch(`/api/json/rules-dir`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify(e)})).json();t.ok?(M({msg:e.reset?`default rules folder reset → ${Sf(t.dir)}`:`default rules folder set → ${Sf(t.dir)}`,type:`ok`}),await Promise.all([F(),P(),L()])):M({msg:t.error??`could not set folder`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{k(!1),setTimeout(()=>M(null),5e3)}}async function B(){let e=null;try{let t=await fetch(`/api/json/pick-dir`,{method:`POST`});if(t.ok){let n=await t.json();if(n.ok&&n.path)e=n.path;else if(n.reason===`user_cancelled`)return;else if(n.reason===`no_display`||n.reason===`no_picker_found`){let t=prompt(`Folder picker is unavailable on this host. Type the absolute path to use as your default rules folder:`);t?.trim()&&(e=t.trim())}else{M({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>M(null),5e3);return}}}catch{let t=prompt(`Folder picker is unavailable. Type the absolute path to use as your default rules folder:`);t?.trim()&&(e=t.trim())}e&&await z({path:e})}async function re(e,t){w(`${e}::${t}`);try{let n=await(await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:e,path:t})})).json();n.ok?(M({msg:`removed ${e} from ${Sf(t)}`,type:`ok`}),await Promise.all([P(),L()])):M({msg:n.error??`uninstall failed`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{w(null),setTimeout(()=>M(null),5e3)}}let ie=c===`installed`?u.filter(e=>(y[e.id]?.length??0)>0):u,ae=u.filter(e=>(y[e.id]?.length??0)>0).length,oe=`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:`rules hub`}),(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:[`install community rule packs from hub.sigmashake.com ·`,` `,(0,D.jsx)(`a`,{href:`/plugins`,className:`text-[var(--color-fg-2)] hover:text-[var(--color-brand)] transition-colors underline decoration-dotted`,children:`looking for plugins?`})]})]}),(0,D.jsxs)(`a`,{href:`/hub/connect`,"data-tutorial":`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`]})]}),T&&(0,D.jsxs)(`div`,{"data-tutorial":`hub-rules-dir`,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.5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:`rules install to`}),(0,D.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-xs text-[var(--color-fg-1)] truncate`,title:T.dir,children:Sf(T.dir)}),T.is_custom&&(0,D.jsx)(`span`,{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider bg-[var(--color-brand)]/15 text-[var(--color-brand)] rounded-sm px-1 py-0.5`,children:`custom`})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:B,disabled:O,title:`Choose a folder where all rules install by default`,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 cursor-pointer 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`,children:(0,D.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})}),O?`saving…`:`change folder`]}),T.is_custom&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>z({reset:!0}),disabled:O,title:`Reset to the built-in default location`,className:`inline-flex items-center text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] transition-colors border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-3 h-7 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`,children:`reset`})]})]}),j&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-3 py-2 text-[11px] font-mono border
25
+ ${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)(kf,{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:Cf(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)(Af,{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)(jf,{isInstalling:c,hasInstalls:u>0,onInstallDefault:()=>i(e.id),onPickPath:()=>o(e.id)})})]})}function Nf(){let{mode:e}=Ht();return e===`newcomer`?(0,D.jsx)(Sf,{}):(0,D.jsx)(Pf,{})}function Pf(){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)(!1),[ee,A]=(0,_.useState)(null),[j,M]=(0,_.useState)(null),N=(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]),P=(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{}},[]),F=(0,_.useCallback)(async()=>{try{let e=await fetch(`/api/json/rules-dir`);if(!e.ok)return;E(await e.json())}catch{}},[]);(0,_.useEffect)(()=>{P(),F()},[P,F]),(0,_.useEffect)(()=>{let e=!1;return v(!0),h(0),fetch(`/api/json/hub?${N(0)}`).then(e=>e.json()).then(t=>{e||(d(t.data),p(t.has_more),h(0))}).catch(()=>{}).finally(()=>{e||v(!1)}),()=>{e=!0}},[N]);async function I(){let e=m+1;v(!0);try{let t=await fetch(`/api/json/hub?${N(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 L(){let e=await fetch(`/api/json/hub?${N(0)}`);if(!e.ok)return;let t=await e.json();d(t.data),p(t.has_more),h(0)}async function te(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`,...W()},body:JSON.stringify(n)})).json();r.ok?(A(e),setTimeout(()=>A(null),2e3),M({msg:r.already_installed?`${r.title??e} — already installed${r.path?` at ${wf(r.path)}`:``}`:`installed ${r.title??e}${r.path?` → ${wf(r.path)}`:``}`,type:`ok`}),await Promise.all([P(),L()])):M({msg:r.error??`install failed`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{S(null),setTimeout(()=>M(null),5e3)}}async function ne(e){await te(e)}async function R(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{M({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>M(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 te(e,t)}async function z(e){k(!0);try{let t=await(await fetch(`/api/json/rules-dir`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify(e)})).json();t.ok?(M({msg:e.reset?`default rules folder reset → ${wf(t.dir)}`:`default rules folder set → ${wf(t.dir)}`,type:`ok`}),await Promise.all([F(),P(),L()])):M({msg:t.error??`could not set folder`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{k(!1),setTimeout(()=>M(null),5e3)}}async function B(){let e=null;try{let t=await fetch(`/api/json/pick-dir`,{method:`POST`});if(t.ok){let n=await t.json();if(n.ok&&n.path)e=n.path;else if(n.reason===`user_cancelled`)return;else if(n.reason===`no_display`||n.reason===`no_picker_found`){let t=prompt(`Folder picker is unavailable on this host. Type the absolute path to use as your default rules folder:`);t?.trim()&&(e=t.trim())}else{M({msg:n.error??`could not open folder picker`,type:`error`}),setTimeout(()=>M(null),5e3);return}}}catch{let t=prompt(`Folder picker is unavailable. Type the absolute path to use as your default rules folder:`);t?.trim()&&(e=t.trim())}e&&await z({path:e})}async function re(e,t){w(`${e}::${t}`);try{let n=await(await fetch(`/api/hub/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({id:e,path:t})})).json();n.ok?(M({msg:`removed ${e} from ${wf(t)}`,type:`ok`}),await Promise.all([P(),L()])):M({msg:n.error??`uninstall failed`,type:`error`})}catch(e){M({msg:e instanceof Error?e.message:`network error`,type:`error`})}finally{w(null),setTimeout(()=>M(null),5e3)}}let ie=c===`installed`?u.filter(e=>(y[e.id]?.length??0)>0):u,ae=u.filter(e=>(y[e.id]?.length??0)>0).length,oe=`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:`rules hub`}),(0,D.jsxs)(`p`,{className:`text-xs text-[var(--color-fg-3)] mt-1 font-mono`,children:[`install community rule packs from hub.sigmashake.com ·`,` `,(0,D.jsx)(`a`,{href:`/plugins`,className:`text-[var(--color-fg-2)] hover:text-[var(--color-brand)] transition-colors underline decoration-dotted`,children:`looking for plugins?`})]})]}),(0,D.jsxs)(`a`,{href:`/hub/connect`,"data-tutorial":`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`]})]}),T&&(0,D.jsxs)(`div`,{"data-tutorial":`hub-rules-dir`,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.5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)]`,children:`rules install to`}),(0,D.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-xs text-[var(--color-fg-1)] truncate`,title:T.dir,children:wf(T.dir)}),T.is_custom&&(0,D.jsx)(`span`,{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider bg-[var(--color-brand)]/15 text-[var(--color-brand)] rounded-sm px-1 py-0.5`,children:`custom`})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:B,disabled:O,title:`Choose a folder where all rules install by default`,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 cursor-pointer 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`,children:(0,D.jsx)(`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`})}),O?`saving…`:`change folder`]}),T.is_custom&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>z({reset:!0}),disabled:O,title:`Reset to the built-in default location`,className:`inline-flex items-center text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] transition-colors border border-[var(--color-line-1)] hover:border-[var(--color-line-2)] rounded-sm px-3 h-7 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed`,children:`reset`})]})]}),j&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-sm px-3 py-2 text-[11px] font-mono border
26
26
  ${j.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:[j.type===`ok`?`✓ `:`✗ `,j.msg]}),(0,D.jsx)(`button`,{onClick:()=>M(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`,{"data-tutorial":`hub-tabs`,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
27
27
  ${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
28
- ${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`,ae>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:ae})]})]}),(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`,{"data-tutorial":`hub-search`,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:oe,children:Cf.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,D.jsxs)(`select`,{"data-tutorial":`hub-filters`,value:i,onChange:e=>a(e.target.value),className:oe,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:oe,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))}):ie.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`,{"data-tutorial":`hub-grid`,className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:ie.map(e=>(0,D.jsx)(Af,{rs:e,installs:y[e.id]??[],installingId:x,uninstallingKey:C,onInstall:ne,onUninstall:re,onPickAndInstall:R,flashId:ee},e.id))}),f&&c===`all`&&(0,D.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,D.jsx)(`button`,{onClick:I,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`,...W()},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)(q,{children:(0,D.jsx)(Y,{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`,{"data-tutorial":`hubpub-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)(K,{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`})]})}var Pf={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)]`},Ff={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)]`},If=[{label:`User code`,color:`#451a03`},{label:`Runtime (bun:/node:)`,color:`#172554`},{label:`Native/other`,color:`#1f2937`},{label:`GC/idle`,color:`#450a0a`}],Lf={neutral:`#d0d0d0`,green:`#34d399`,red:`#f87171`,amber:`#fbbf24`,blue:`#38bdf8`,purple:`#a78bfa`,gray:`#6e7076`};function Rf({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:mr(a===`above`?`overline mb-1.5`:`mt-1 text-[11px] text-[var(--color-fg-3)]`,o),children:e}),f=(0,D.jsx)(`div`,{className:mr(`font-mono font-medium tabular-nums`,i===`center`&&`text-center`,Pf[r],s),children:t}),p=l&&l.length>1,m=u??Lf[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)(qc,{data:l,width:48,height:18,color:m})]}):f,a===`below`&&d,n&&(0,D.jsx)(`div`,{className:mr(`mt-1 text-[10px] font-mono text-[var(--color-fg-3)]`,i===`center`&&`text-center`,c),children:n})]})}function zf({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)(q,{className:e,...p,children:(0,D.jsx)(Y,{className:mr(`py-3`,o===`center`&&`text-center`,t),children:(0,D.jsx)(Rf,{label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f})})})}function Bf({className:e,...t}){return(0,D.jsx)(`div`,{className:mr(`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)(Rf,{...t})})}function Vf({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:mr(`relative w-full overflow-hidden rounded-sm bg-[var(--color-surface-3)]`,r),children:[(0,D.jsx)(`div`,{className:mr(`h-full rounded-sm transition-all duration-500`,Ff[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 Hf({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:If.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 Uf({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)(Bf,{align:`center`,label:e.label,value:e.value,valueClassName:`text-lg font-medium text-[var(--color-fg-0)]`},e.label))})}function Wf(e){return e===0?`—`:e<1e3?`${e}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(1)}ms`}function Gf(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 Kf(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 qf(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 Jf={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)]`},Yf={allow:`✓`,block:`✗`,force:`→`,log:`·`,ask:`?`,shadow:`~`};function Xf({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)(Vf,{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:Wf(t)})]})}function Zf({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)(Vf,{pct:i,tone:r?`red`:e/t>=.6?`amber`:`green`,markerPct:a,markerTitle:`limit: ${n}`,className:`h-1`})}function Qf({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`,...W()},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)(K,{onClick:f,disabled:c,variant:`primary`,size:`sm`,children:c?`saving…`:`save limits`})]})}var $f={running:`green`,hibernating:`amber`,exhausted:`red`,stopped:`gray`,idle:`gray`};function ep(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 tp({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)(q,{children:[(0,D.jsxs)(J,{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)(G,{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)(Y,{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)(G,{variant:$f[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?qf(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:ep(e.nextRetryAt,t)}):`—`})]},e.name))})]})})})]})}function np(){let e=Ge([`runtime-tick`,`activity-updated`,`limits-breach`,`supervisor-changed`]),t=Aa(),[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}=U(`/api/state/runtime`,[e[`runtime-tick`]]),{data:m,refetch:h}=U(`/api/json/limits`,[e[`limits-breach`]]),{data:g}=U(`/api/state/activity-tail?after=${i}&limit=50`,[e[`activity-updated`]]),{data:v}=U(`/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?Gf(p.uptime_ms):null,b=p&&p.last_eval_at>0?qf(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)(G,{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:Kf(n)})]})]}),(0,D.jsx)(rp,{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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`daemon status`})}),(0,D.jsx)(Y,{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)(tp,{supervisors:v?.supervisors??[]}),(0,D.jsxs)(q,{"data-tutorial":`monitor-resources`,children:[(0,D.jsxs)(J,{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)(G,{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)(Y,{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)(qc,{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)(Zf,{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)(qc,{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)(Zf,{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)(Vf,{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)(Qf,{limitsData:m,onSaved:()=>{h(),d(!1)}})]})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`monitor-counters`,className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2`,children:[(0,D.jsx)(Bf,{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)(Bf,{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)(Bf,{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)(Bf,{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)(Bf,{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)(Bf,{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)(q,{children:[(0,D.jsxs)(J,{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)(Y,{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)(Xf,{label:`p50`,ns:p.latency.p50_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Xf,{label:`p95`,ns:p.latency.p95_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Xf,{label:`p99`,ns:p.latency.p99_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Xf,{label:`max`,ns:p.latency.max_ns,maxNs:p.latency.max_ns})]})})]}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`engine`})}),(0,D.jsx)(Y,{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)(q,{"data-tutorial":`monitor-tail`,children:[(0,D.jsxs)(J,{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)(Y,{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:Kf(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] ${Jf[e.decision]??`text-[var(--color-fg-3)]`}`,children:[Yf[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:Wf(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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`ai agent debug endpoints`})}),(0,D.jsxs)(Y,{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 rp({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)(Sl,{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)(Yc,{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)(Sl,{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)(Yc,{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)(Dl,{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)(rl,{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)(Yc,{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)(Kc,{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)(zl,{variant:`decision`,bursts:s,windowSize:300,height:260})]})]})}function ip(){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)(`div`,{"data-tutorial":`notif-list`,children:(0,D.jsx)(Vc,{showEmptyState:!0,hideHeader:!0})})]})}var ap=18,op=5e-4;function sp(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 cp(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 lp(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<op)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 up(e){return e<1e3?`${e}µs`:e<1e6?`${(e/1e3).toFixed(1)}ms`:`${(e/1e6).toFixed(2)}s`}function dp({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=lp(e,i),l=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*ap+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*ap+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:ap-1,fill:f?`#92400e`:sp(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+ap-5,fontSize:9,fill:cp(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:ap})})]},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:up(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 fp={ok:`green`,warn:`amber`,error:`red`,unknown:`gray`},pp={ok:`OK`,warn:`Warn`,error:`Error`,unknown:`Idle`};function mp({title:e,status:t=`unknown`,statusLabel:n,className:r,children:i}){return(0,D.jsxs)(q,{className:mr(`flex flex-col`,r),children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`overline text-[var(--color-fg-2)]`,children:e}),(0,D.jsx)(G,{variant:fp[t],children:n??pp[t]})]}),(0,D.jsx)(Y,{className:`flex flex-col gap-2 text-[12px]`,children:i})]})}function hp({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:mr(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 gp(){let{data:e,refetch:t}=U(`/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 _p(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 vp(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function yp(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 bp(e){return e?new Date(e*1e3).toLocaleString():`—`}function xp(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 Sp({children:e,className:t}){return(0,D.jsx)(`div`,{className:`overline mb-2.5 ${t??``}`,children:e})}function Cp({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 wp({ok:e,label:t,badLabel:n}){return e?(0,D.jsx)(G,{variant:`green`,children:t}):(0,D.jsx)(G,{variant:`red`,children:n??t})}function Tp({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)(Vf,{pct:e,tone:r,className:`h-1.5`})]})}var Ep=3e3,Dp={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 Op(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function kp(){let e=gp(),[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)}},Ep)}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)(q,{children:[(0,D.jsxs)(J,{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)(K,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`})]})]}),e.error&&(0,D.jsx)(Y,{children:(0,D.jsx)(`p`,{className:`text-xs text-red-300 font-mono`,children:e.error})})]}),(0,D.jsxs)(q,{children:[(0,D.jsxs)(J,{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)(K,{variant:`danger`,size:`sm`,onClick:v,children:`stop & render`}):(0,D.jsx)(K,{variant:`primary`,size:`sm`,onClick:g,children:`start recording`})]})]}),(0,D.jsx)(Y,{children:r?(0,D.jsx)(Hf,{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)(dp,{profile:r})})}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording cpu profile (auto-captures ${Ep/1e3}s)… perform actions in ssg to generate data.`:`click start recording, or wait for auto-capture on page load.`})})]}),(0,D.jsxs)(q,{children:[(0,D.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`memory`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:y,disabled:l,children:l?`…`:`refresh`})]}),(0,D.jsx)(Y,{children:s?(0,D.jsx)(Uf,{memory:s,formatValue:vp}):(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)(q,{children:[(0,D.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`console`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,D.jsx)(Y,{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)] ${Dp[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(Op).join(` `)]},e.id)),(0,D.jsx)(`div`,{ref:p})]})})]})]}):(0,D.jsxs)(q,{children:[(0,D.jsxs)(J,{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)(G,{variant:`amber`,children:e.connecting?`connecting…`:`available`}),!e.connecting&&(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:b,children:`connect`})]})]}),(0,D.jsx)(Y,{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)(q,{children:[(0,D.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`runtime inspector`}),(0,D.jsx)(G,{variant:`outline`,children:`inactive`})]}),(0,D.jsx)(Y,{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 Ap(){let[e,t]=(0,_.useState)(0),{data:n}=U(`/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)(q,{children:[(0,D.jsxs)(J,{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)(Y,{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(`
29
- `),(0,D.jsx)(`div`,{ref:r})]})]})]})}function jp(){let e=Ge([`runtime-tick`,`rules-changed`]),{data:t,refetch:n}=U(`/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:W()})).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:W()}),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 `,xp(s)]}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:n,children:`refresh`})]})]}),(0,D.jsx)(Mp,{db:v,audit:b,proc:x,flight:S,driftDetected:C}),(0,D.jsxs)(q,{"data-tutorial":`observ-drift`,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)(J,{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)(G,{variant:`red`,children:`⚠ drift detected`}):(0,D.jsx)(G,{variant:`green`,children:`✓ in sync`}))]}),(0,D.jsxs)(Y,{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)(Bf,{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)(K,{variant:`primary`,size:`sm`,onClick:h,disabled:l===`loading`,children:l===`loading`?`syncing…`:`↑ sync files → db`}),(0,D.jsx)(K,{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:xp(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)(q,{children:[(0,D.jsxs)(J,{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)(wp,{ok:v.journal_mode===`wal`,label:`wal`,badLabel:`no wal`}),(0,D.jsx)(wp,{ok:v.synchronous===`NORMAL`,label:`normal`,badLabel:v.synchronous})]})]}),(0,D.jsx)(Y,{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)(Sp,{children:`storage`}),(0,D.jsx)(Cp,{label:`file path`,value:v.path}),(0,D.jsx)(Cp,{label:`file size`,value:_p(v.file_size_bytes)}),(0,D.jsx)(Cp,{label:`allocated`,value:`${_p(v.allocated_bytes)} (${v.page_count.toLocaleString()} pages × ${v.page_size}B)`}),(0,D.jsx)(Sp,{className:`mt-4`,children:`pragma configuration`}),(0,D.jsx)(Cp,{label:`journal_mode`,value:v.journal_mode,accent:v.journal_mode===`wal`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(Cp,{label:`synchronous`,value:v.synchronous,accent:v.synchronous===`NORMAL`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(Cp,{label:`cache_size`,value:`${v.cache_size_kb.toLocaleString()} KB (${Math.round(v.cache_size_kb/1024)} MB)`}),(0,D.jsx)(Cp,{label:`page_size`,value:`${v.page_size.toLocaleString()} B`}),v.wal_checkpoint&&(0,D.jsx)(Cp,{label:`wal checkpoint`,value:`log ${v.wal_checkpoint.log}, checkpointed ${v.wal_checkpoint.checkpointed}, busy ${v.wal_checkpoint.busy}`}),(0,D.jsx)(Sp,{className:`mt-4`,children:`table row counts`}),v.tables.map(e=>(0,D.jsx)(Cp,{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)(q,{"data-tutorial":`observ-capacity`,children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`audit log capacity`})}),(0,D.jsx)(Y,{children:b?(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(Tp,{pct:b.utilization_pct,total:b.total_rows,max:b.max_rows}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(Cp,{label:`total rows`,value:b.total_rows.toLocaleString()}),(0,D.jsx)(Cp,{label:`rotation limit`,value:b.max_rows.toLocaleString()}),(0,D.jsx)(Cp,{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)(Cp,{label:`oldest entry`,value:bp(b.oldest_timestamp)}),(0,D.jsx)(Cp,{label:`newest entry`,value:bp(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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`process & runtime`})}),(0,D.jsx)(Y,{children:x?(0,D.jsxs)(`div`,{children:[(0,D.jsx)(Cp,{label:`pid`,value:x.pid}),(0,D.jsx)(Cp,{label:`uptime`,value:yp(x.uptime_ms)}),(0,D.jsx)(Cp,{label:`memory (rss)`,value:`${x.memory_rss_mb} MB`}),(0,D.jsx)(Cp,{label:`bun version`,value:x.bun_version}),(0,D.jsx)(Cp,{label:`node compat`,value:x.node_version}),(0,D.jsx)(Cp,{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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`flight recorder`})}),(0,D.jsx)(Y,{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:_p(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)(kp,{}),(0,D.jsx)(Ap,{}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`observability api`})}),(0,D.jsxs)(Y,{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 Mp({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)(mp,{title:`sqlite`,status:a,statusLabel:e?.journal_mode?.toUpperCase()??`idle`,children:[(0,D.jsx)(hp,{label:`size`,value:e?(0,D.jsx)(Gc,{value:e.file_size_bytes,format:e=>vp(e)}):`—`,mono:!0}),(0,D.jsx)(hp,{label:`journal`,value:e?.journal_mode??`—`,mono:!0}),(0,D.jsx)(hp,{label:`sync`,value:e?.synchronous??`—`,mono:!0}),(0,D.jsx)(hp,{label:`tables`,value:e?.tables.length??0,tone:i?`warn`:`neutral`})]}),(0,D.jsxs)(mp,{title:`audit log`,status:o,statusLabel:t?`${t.utilization_pct}%`:`idle`,children:[(0,D.jsx)(hp,{label:`rows`,value:t?(0,D.jsx)(Gc,{value:t.total_rows}):`—`}),(0,D.jsx)(hp,{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)(hp,{label:`oldest`,value:bp(t?.oldest_timestamp??null),mono:!0}),(0,D.jsx)(hp,{label:`newest`,value:bp(t?.newest_timestamp??null),mono:!0})]}),(0,D.jsxs)(mp,{title:`process`,status:s,statusLabel:n?`pid ${n.pid}`:`idle`,children:[(0,D.jsx)(hp,{label:`uptime`,value:n?yp(n.uptime_ms):`—`,mono:!0}),(0,D.jsx)(hp,{label:`rss`,value:n?(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Gc,{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)(hp,{label:`bun`,value:n?.bun_version??`—`,mono:!0}),(0,D.jsx)(hp,{label:`platform`,value:n?`${n.platform}/${n.arch}`:`—`,mono:!0})]}),(0,D.jsxs)(mp,{title:`flight recorder`,status:r&&r.file_size_bytes>0?`ok`:`unknown`,statusLabel:r?`${r.approx_entries.toLocaleString()} entries`:`idle`,children:[(0,D.jsx)(hp,{label:`size`,value:r?(0,D.jsx)(Gc,{value:r.file_size_bytes,format:e=>vp(e)}):`—`,mono:!0}),(0,D.jsx)(hp,{label:`entries`,value:r?(0,D.jsx)(Gc,{value:r.approx_entries}):`—`})]})]})}var Np=`ssg:autostart-changed`;async function Pp(e){return await(await fetch(`/api/json/autostart`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify(e)})).json()}function Fp(){let{data:e,loading:t,error:n,refetch:r}=U(`/api/json/autostart`),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)({kind:`idle`});(0,_.useEffect)(()=>{let e=()=>r();return window.addEventListener(Np,e),()=>window.removeEventListener(Np,e)},[r]);let c=(0,_.useCallback)(()=>s({kind:`idle`}),[]),l=(0,_.useCallback)(async e=>{a(!0);try{await Pp({action:e,confirm:!0})}finally{a(!1),s({kind:`idle`}),window.dispatchEvent(new Event(Np))}},[]),u=(0,_.useCallback)(async e=>{a(!0);try{let t=await Pp({action:e});if(!t||t.status!==`ask`){window.dispatchEvent(new Event(Np));return}let n=t;if(n.askMode===`dashboard`){let t=await(await fetch(`/api/pending`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({toolCall:{tool:`ssg.autostart`,input:{action:e}},ruleId:n.ruleId,ruleMessage:n.prompt,prompt:n.prompt})})).json();t.id?s({kind:`dashboard-pending`,env:n,id:t.id}):s({kind:`native-confirm`,env:n})}else s({kind:`native-confirm`,env:n})}finally{a(!1)}},[]),d=(0,_.useCallback)(()=>{o.kind===`native-confirm`&&l(o.env.action)},[o,l]),f=(0,_.useCallback)(async e=>{if(o.kind===`dashboard-pending`){try{await fetch(`/api/decide/${encodeURIComponent(o.id)}?decision=${e}`,{method:`POST`,headers:{...W()}})}catch{}e===`allow`?await l(o.env.action):c()}},[o,l,c]);return(0,_.useEffect)(()=>{if(o.kind!==`dashboard-pending`)return;let e=!1,t,n=async()=>{try{let t=await(await fetch(`/api/pending/${encodeURIComponent(o.id)}/status`)).json();if(e)return;if(t.status===`decided`){t.decision===`allow`?l(o.env.action):c();return}}catch{}e||(t=setTimeout(n,1500))};return t=setTimeout(n,1500),()=>{e=!0,clearTimeout(t)}},[o,l,c]),{status:e,loading:t,error:n,saving:i,flow:o,begin:u,confirmNative:d,approveDashboard:()=>f(`allow`),denyDashboard:()=>f(`block`),cancel:c,refetch:r}}var Ip={healthy:`var(--color-decision-allow)`,degraded:`var(--color-decision-ask)`,disabled:`var(--color-fg-3)`,unsupported:`var(--color-fg-3)`},Lp={healthy:`Healthy`,degraded:`Needs attention`,disabled:`Disabled`,unsupported:`Unsupported`},Rp={launchd:`launchd LaunchAgent (macOS)`,systemd:`systemd user service (Linux)`,schtasks:`Task Scheduler (Windows)`,unsupported:`unsupported platform`};function zp({color:e,className:t=``}){return(0,D.jsx)(`span`,{className:`status-dot ${t}`,style:{background:e},"aria-hidden":`true`})}function Bp({v:e,trueIsGood:t=!0}){return(0,D.jsx)(`span`,{style:{color:(t?e:!e)?`var(--color-decision-allow)`:`var(--color-decision-ask)`},children:e?`yes`:`no`})}function Vp({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-[140px]`,children:e}),(0,D.jsx)(`span`,{className:`flex-1 text-[var(--color-fg-1)] ${n?`font-mono text-[11px] break-all`:``}`,children:t})]})}function Hp({flow:e,saving:t,confirmNative:n,approveDashboard:r,denyDashboard:i,cancel:a}){return e.kind===`idle`?null:e.kind===`native-confirm`?(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded border-[var(--color-decision-ask)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,D.jsx)(zp,{color:`var(--color-decision-ask)`,className:`mt-1`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Confirm system change`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:e.env.prompt}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1`,children:`Ask routing: native (in-app confirm)`})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{onClick:n,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Confirm`}),(0,D.jsx)(`button`,{onClick:a,disabled:t,className:`hig-button hig-button-small`,children:`Cancel`})]})]}):(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded border-[var(--color-hig-purple)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,D.jsx)(zp,{color:`var(--color-hig-purple)`,className:`mt-1`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Queued for approval`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:e.env.prompt}),(0,D.jsxs)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1`,children:[`Ask routing: dashboard — also visible on the`,` `,(0,D.jsx)(`a`,{href:`/approvals`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Approvals`}),` `,`page. Approve there or here.`]})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{onClick:r,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Approve`}),(0,D.jsx)(`button`,{onClick:i,disabled:t,className:`hig-button hig-button-small`,children:`Deny`})]})]})}function Up({status:e,saving:t,onRepair:n}){if(!e.enabled)return null;let r=e.drift,i=!e.running&&!r;return!r&&!i?null:(0,D.jsx)(`section`,{className:`hig-card hig-card-padded border-[var(--color-decision-ask)]`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(zp,{color:`var(--color-decision-ask)`,className:`mt-1`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:r?`Autostart unit drifted`:`Service not running`}),(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:[r?`The installed unit points at an ssg binary that no longer exists (${e.referencedBinary||`unknown`}). It will fail to launch at next login.`:`The autostart unit is installed but the daemon is not currently running.`,` `,`Repair reinstalls/re-kicks the service.`]})]}),(0,D.jsx)(`button`,{onClick:n,disabled:t,className:`hig-button hig-button-small`,children:t?`Working…`:`Repair`})]})})}function Wp(){let{status:e,loading:t,error:n,saving:r,flow:i,begin:a,confirmNative:o,approveDashboard:s,denyDashboard:c,cancel:l,refetch:u}=Fp();if(t&&!e)return(0,D.jsx)(`div`,{className:`py-12 text-center text-[var(--color-fg-3)] text-[12px]`,children:`Reading persistence 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/autostart: `,n??`no response`]}),(0,D.jsx)(`button`,{onClick:u,className:`hig-button hig-button-small`,children:`Retry`})]});let d=e.mechanism===`unsupported`,f=r||i.kind!==`idle`;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:`Persistence`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`Make SigmaShake launch on startup and always run on the system. One OS-level service —`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`launchd`}),` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`systemd`}),` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`Task\xA0Scheduler`}),` — managed from here or via `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg autostart`}),`.`]})]}),(0,D.jsx)(`button`,{onClick:u,className:`hig-button hig-button-small`,children:`Refresh`})]}),d?(0,D.jsx)(`section`,{className:`hig-card hig-card-padded text-[12px]`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(zp,{color:`var(--color-fg-3)`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[`Autostart is not supported on this platform (`,(0,D.jsx)(`span`,{className:`font-mono`,children:e.platform}),`). Start the daemon manually with`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg daemon`}),`.`]})]})}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded flex items-center gap-4`,children:[(0,D.jsx)(In,{checked:e.enabled,onChange:e=>a(e?`enable`:`disable`),disabled:f,size:`md`,tone:`brand`,label:`Launch on startup and always run`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`div`,{className:`text-[14px] font-semibold text-[var(--color-fg-0)]`,children:`Launch on startup & always running`}),(0,D.jsxs)(`div`,{className:`text-[11.5px] text-[var(--color-fg-3)] mt-0.5`,children:[Rp[e.mechanism]??e.mechanism,e.enabled?` · installed`:` · not installed`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(zp,{color:Ip[e.health],className:`!w-3 !h-3`}),(0,D.jsx)(`span`,{className:`text-[12px] font-semibold`,style:{color:Ip[e.health]},children:Lp[e.health]})]})]}),(0,D.jsx)(Hp,{flow:i,saving:r,confirmNative:o,approveDashboard:s,denyDashboard:c,cancel:l}),(0,D.jsx)(Up,{status:e,saving:r,onRepair:()=>a(`repair`)}),(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.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Service status`}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:e.platform})]}),(0,D.jsx)(Vp,{k:`Health`,v:Lp[e.health]}),(0,D.jsx)(Vp,{k:`Installed`,v:(0,D.jsx)(Bp,{v:e.enabled})}),(0,D.jsx)(Vp,{k:`Loaded`,v:(0,D.jsx)(Bp,{v:e.loaded})}),(0,D.jsx)(Vp,{k:`Running`,v:(0,D.jsx)(Bp,{v:e.running})}),(0,D.jsx)(Vp,{k:`Binary drift`,v:(0,D.jsx)(Bp,{v:e.drift,trueIsGood:!1})}),(0,D.jsx)(Vp,{k:`Mechanism`,v:Rp[e.mechanism]??e.mechanism}),(0,D.jsx)(Vp,{k:`Ask routing`,v:e.askMode===`dashboard`?`dashboard (/approvals queue)`:`native (in-app confirm)`}),(0,D.jsx)(Vp,{k:`Unit`,v:e.unitPath||`—`,mono:!0}),e.referencedBinary&&(0,D.jsx)(Vp,{k:`Installed binary`,v:e.referencedBinary,mono:!0}),e.resolvedBinary&&(0,D.jsx)(Vp,{k:`Current binary`,v:e.resolvedBinary,mono:!0}),(0,D.jsx)(Vp,{k:`Detail`,v:e.message})]})]})]})}var Gp=`https://hub.sigmashake.com/submit-plugin`,Kp=`https://docs.sigmashake.com/plugins/publishing`,qp=[{cmd:`ssg plugins init my-plugin`,title:`Scaffold`,detail:`Creates plugin.toml plus a src/ template you can edit.`},{cmd:`ssg plugins build`,title:`Build & sign`,detail:`Bundles src/ into dist/<id>-<version>.tar.gz and an Ed25519-signed plugin.json.`},{cmd:`ssg plugins publish`,title:`Publish`,detail:`Pushes the source, cuts a GitHub release for the artifact, and opens the hub submission form prefilled.`}];function Jp(){return(0,D.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`a`,{href:`/plugins`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← plugins`}),(0,D.jsx)(`h1`,{className:`mt-2 text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Publish a plugin`}),(0,D.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-[var(--color-fg-3)]`,children:`build, sign, and submit a dashboard plugin to hub.sigmashake.com`})]}),(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{children:[(0,D.jsx)(`h2`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Build it with the ssg CLI`}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:`Plugins are built, signed, and released from your machine — the CLI runs the whole flow. Run these from your plugin's directory:`}),(0,D.jsx)(`ol`,{className:`mt-3 space-y-3`,children:qp.map((e,t)=>(0,D.jsxs)(`li`,{className:`flex gap-3`,children:[(0,D.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-[var(--color-line-1)] font-mono text-[11px] text-[var(--color-fg-3)]`,children:t+1}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-[var(--color-fg-1)]`,children:e.title}),(0,D.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-2.5 py-1.5 text-xs`,children:(0,D.jsx)(`code`,{className:`font-mono text-[var(--color-fg-1)]`,children:e.cmd})}),(0,D.jsx)(`p`,{className:`mt-1 text-[11px] text-[var(--color-fg-3)]`,children:e.detail})]})]},e.cmd))})]})}),(0,D.jsxs)(`div`,{className:`rounded-sm border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-200`,children:[`First time publishing? Register your signing key with`,` `,(0,D.jsx)(`code`,{className:`font-mono text-amber-100`,children:`ssg keys register`}),` so the hub can verify your plugin's Ed25519 signature against your account.`]}),(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{children:[(0,D.jsx)(`h2`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Submit to the marketplace`}),(0,D.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`code`,{className:`font-mono text-[var(--color-fg-2)]`,children:`ssg plugins publish`}),` `,`opens the hub submission form automatically once your release is up. If you've already built your plugin, open the form directly:`]}),(0,D.jsxs)(`a`,{href:Gp,"data-tutorial":`pubplug-submit`,target:`_blank`,rel:`noreferrer`,className:`mt-3 inline-flex items-center gap-1.5 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-1.5 text-xs font-medium text-[var(--color-fg-1)] transition-colors hover:border-[var(--color-hig-blue)] hover:text-[var(--color-hig-blue)]`,children:[`Open hub submission form`,(0,D.jsx)(`span`,{"aria-hidden":!0,children:`↗`})]}),(0,D.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--color-fg-4)]`,children:`Submitting needs a GitHub sign-in on hub.sigmashake.com — it opens in a new tab.`})]})}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:[`New to plugin authoring? Read the`,` `,(0,D.jsx)(`a`,{href:Kp,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`plugin documentation ↗`}),`.`]})]})}async function Yp(){let e=await fetch(`/api/json/plugins`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}async function Xp(e=``,t={}){let n=new URLSearchParams;e&&n.set(`q`,e),t.category&&n.set(`category`,t.category),t.featured&&n.set(`featured`,`1`),t.sort&&n.set(`sort`,t.sort),t.page&&t.page>1&&n.set(`page`,String(t.page));let r=await fetch(`/api/json/plugins/available?${n.toString()}`,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Zp(){let e=await fetch(`/api/json/plugins/categories`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}async function Qp(){let e=await fetch(`/api/json/license`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}function $p(e){return e===`pro`||e===`enterprise`?`private`:`public`}async function em(e,t){let n=await fetch(e,{method:`POST`,headers:{...W(),"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.text(),i=null;if(r)try{i=JSON.parse(r)}catch{i={error:r}}if(!n.ok){let e=i&&typeof i==`object`&&i&&`error`in i&&typeof i.error==`string`?i.error:`HTTP ${n.status}`;throw Error(e)}return i}function tm(e){return em(`/api/json/plugins/install`,{packId:e})}function nm(e){return em(`/api/json/plugins/uninstall`,{id:e})}function rm(e){return em(`/api/json/plugins/enable`,{id:e})}function im(e){return em(`/api/json/plugins/disable`,{id:e})}var am=5e3,om=200,sm=5,cm=4e3,lm={tools:`bg-sky-500/10 text-sky-300 border-sky-500/25`,observability:`bg-violet-500/10 text-violet-300 border-violet-500/25`,productivity:`bg-emerald-500/10 text-emerald-300 border-emerald-500/25`,integrations:`bg-amber-500/10 text-amber-300 border-amber-500/30`,developer:`bg-rose-500/10 text-rose-300 border-rose-500/25`};function um(e){return e?lm[e]??`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`:`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`}function dm(e){if(!e)return``;let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}function fm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pm(e){let t=e.split(/[\s\-_]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function mm({icon:e,name:t,avatarUrl:n,large:r}){let i=r?`h-14 w-14 text-2xl`:`h-10 w-10 text-lg`,a=r?`text-sm`:`text-[11px]`;return e?(0,D.jsx)(`div`,{className:`flex ${i} shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] leading-none`,children:(0,D.jsx)(`span`,{"aria-hidden":!0,children:e})}):n?(0,D.jsx)(`img`,{src:n,alt:``,className:`${i} shrink-0 rounded-md object-cover`,loading:`lazy`}):(0,D.jsx)(`div`,{className:`flex ${i} shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] ${a} font-mono uppercase text-[var(--color-fg-3)]`,children:pm(t)})}function hm(){return(0,D.jsxs)(`svg`,{"aria-label":`Verified publisher`,width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,className:`inline-block shrink-0 text-sky-400`,children:[(0,D.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5.5`,stroke:`currentColor`,strokeWidth:`1`}),(0,D.jsx)(`path`,{d:`M3.5 6l1.8 1.8 3.2-3.6`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function gm(){return(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex animate-pulse items-start gap-3`,children:[(0,D.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-md bg-[var(--color-surface-2)]`}),(0,D.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,D.jsx)(`div`,{className:`h-3 w-1/3 rounded bg-[var(--color-surface-2)]`}),(0,D.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-[var(--color-surface-2)]`}),(0,D.jsx)(`div`,{className:`h-3 w-1/4 rounded bg-[var(--color-surface-2)]`})]}),(0,D.jsx)(`div`,{className:`h-7 w-20 shrink-0 rounded bg-[var(--color-surface-2)]`})]})})})}function _m({license:e}){let t=e?.tier??`unlicensed`,n=$p(t),r=t===`pro`||t===`enterprise`,i=e?.tier_label??`Free (Starter)`;return(0,D.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 text-xs`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-medium text-[var(--color-fg-2)]`,children:`Publishing visibility`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`Plan: `,i]}),(0,D.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-sm border px-1.5 py-px font-mono text-[10px] uppercase tracking-wide ${n===`public`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`:`border-amber-500/30 bg-amber-500/10 text-amber-300`}`,children:n===`public`?`🌐 public by default`:`🔒 private by default`})]}),(0,D.jsxs)(`p`,{className:`mt-1.5 leading-relaxed text-[var(--color-fg-3)]`,children:[r?`Plugins and rulesets you publish stay private to protect your governance IP. Share one publicly with `:`Plugins and rulesets you publish go to the public marketplace so others can install and fork them. Keep one private with `,(0,D.jsx)(`code`,{className:`rounded bg-[var(--color-surface-2)] px-1 py-px font-mono text-[10px]`,children:r?`ssg plugins publish --public`:`ssg plugins publish --private`}),r?`. A confirmation is required before anything becomes public.`:`.`]})]})}function vm(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(!0),[x,S]=(0,_.useState)(`browse`),[C,w]=(0,_.useState)(`all`),[T,E]=(0,_.useState)(`popular`),[O,k]=(0,_.useState)([]),[ee,A]=(0,_.useState)(null),{features:j,setFeature:M}=en(),N=(0,_.useMemo)(()=>qt.filter(e=>j[e.id]).length,[j]),P=(0,_.useRef)(null),F=(0,_.useCallback)((e,t)=>{h({kind:e,message:t}),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{h(null),P.current=null},am)},[]),I=(0,_.useCallback)(e=>{let t=`ssg plugins fork ${e}`,n=navigator.clipboard;n?.writeText?n.writeText(t).then(()=>F(`ok`,`Copied: ${t}`)).catch(()=>F(`ok`,t)):F(`ok`,t)},[F]);(0,_.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]),(0,_.useEffect)(()=>{let e=setTimeout(()=>d(c),om);return()=>clearTimeout(e)},[c]),(0,_.useEffect)(()=>{Zp().then(e=>k(e.categories)).catch(()=>{})},[]),(0,_.useEffect)(()=>{Qp().then(A).catch(()=>{})},[]);let L=(0,_.useCallback)(async()=>{v(!0);try{let e=await Yp();t(e.plugins),r(e.errors)}catch(e){F(`err`,e instanceof Error?e.message:String(e))}finally{v(!1)}},[F]),te=(0,_.useCallback)(async(e,t,n)=>{b(!0),s(null);try{a((await Xp(e,{category:t===`all`?void 0:t,sort:n})).data??[])}catch(e){s(e instanceof Error?e.message:String(e)),a([])}finally{b(!1)}},[]);(0,_.useEffect)(()=>{L()},[L]),(0,_.useEffect)(()=>{te(u,C,T)},[u,C,T,te]);let ne=(0,_.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),R=(0,_.useMemo)(()=>e.filter(e=>e.enabled).length,[e]),z=async(e,t,n,r)=>{p(n=>({...n,[e]:t}));try{await n(),F(`ok`,r),await Promise.all([L(),te(u,C,T)])}catch(e){F(`err`,e instanceof Error?e.message:String(e))}finally{p(t=>({...t,[e]:void 0}))}},B=(0,_.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,t.icon);return e},[i]),re=(0,_.useMemo)(()=>i.filter(e=>e.featured),[i]),ie=C===`all`&&re.length>0;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-5 p-6`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Plugin Marketplace`}),(0,D.jsxs)(`p`,{className:`max-w-2xl text-sm text-[var(--color-fg-3)]`,children:[`Extend the dashboard with Ed25519-signed plugins from`,` `,(0,D.jsx)(`a`,{href:`https://hub.sigmashake.com`,className:`text-[var(--color-hig-blue)] hover:underline`,target:`_blank`,rel:`noreferrer`,children:`hub.sigmashake.com`}),`. Each plugin is hash-verified and signature-checked before extraction; disable to hide from the sidebar without uninstalling.`]})]}),(0,D.jsx)(`a`,{href:`/publish-plugin`,className:`text-xs text-[var(--color-hig-blue)] hover:underline`,children:`Publish a plugin →`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{"data-tutorial":`plugins-tabs`,role:`tablist`,className:`inline-flex overflow-hidden rounded-md border border-[var(--color-line-1)]`,children:[(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`browse`,className:`px-3 py-1.5 text-xs transition-colors ${x===`browse`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`browse`),children:[`Browse`,i.length>0?` · ${i.length}`:``]}),(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`installed`,className:`border-l border-[var(--color-line-1)] px-3 py-1.5 text-xs transition-colors ${x===`installed`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`installed`),children:[`Installed · `,e.length,e.length>0&&R<e.length&&(0,D.jsxs)(`span`,{className:`ml-1 text-amber-300`,children:[`(`,e.length-R,` off)`]})]}),(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`builtin`,className:`border-l border-[var(--color-line-1)] px-3 py-1.5 text-xs transition-colors ${x===`builtin`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`builtin`),title:`Bundled features that behave like plugins — opt-in`,children:[`Built-in · `,N,`/`,qt.length]})]}),x===`browse`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`relative ml-auto`,children:[(0,D.jsx)(`input`,{"data-tutorial":`plugins-search`,type:`search`,placeholder:`Search plugins…`,className:`w-64 rounded-sm border border-[var(--color-line-1)] bg-transparent px-2 py-1 text-xs focus:border-[var(--color-hig-blue)] focus:outline-none`,value:c,onChange:e=>l(e.target.value),"aria-label":`Search plugins`}),c&&(0,D.jsx)(`button`,{className:`absolute right-1 top-1/2 -translate-y-1/2 px-1 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)]`,onClick:()=>l(``),"aria-label":`Clear search`,children:`×`})]}),i.length>sm&&(0,D.jsxs)(`select`,{value:T,onChange:e=>E(e.target.value),"aria-label":`Sort plugins`,className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-2 py-1 text-xs text-[var(--color-fg-2)] focus:outline-none`,children:[(0,D.jsx)(`option`,{value:`popular`,children:`Popular`}),(0,D.jsx)(`option`,{value:`recent`,children:`Recent`}),(0,D.jsx)(`option`,{value:`name`,children:`Name`})]})]}),x===`installed`&&(0,D.jsx)(K,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>void L(),children:`Refresh`})]}),x===`browse`&&O.length>0&&(0,D.jsxs)(`div`,{"data-tutorial":`plugins-categories`,className:`flex flex-wrap gap-1.5`,role:`group`,"aria-label":`Filter by category`,children:[(0,D.jsx)(`button`,{onClick:()=>w(`all`),className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${C===`all`?`border-[var(--color-hig-blue)] bg-sky-500/10 text-sky-300`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,"aria-pressed":C===`all`,children:`All`}),O.map(e=>(0,D.jsxs)(`button`,{onClick:()=>w(C===e.name?`all`:e.name),className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] font-medium capitalize transition-colors ${C===e.name?`border-transparent ${um(e.name)}`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,"aria-pressed":C===e.name,children:[e.name,(0,D.jsx)(`span`,{className:`text-[10px] opacity-60`,children:e.count})]},e.name))]})]}),m&&(0,D.jsx)(`div`,{role:`status`,className:m.kind===`ok`?`rounded-md border border-emerald-700/40 bg-emerald-900/20 px-3 py-2 text-xs text-emerald-200`:`rounded-md border border-red-700/40 bg-red-900/20 px-3 py-2 text-xs text-red-200`,children:m.message}),(0,D.jsx)(_m,{license:ee}),n.length>0&&(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsxs)(`div`,{className:`text-xs uppercase tracking-wider text-amber-300`,children:[`Load errors (`,n.length,`)`]})}),(0,D.jsx)(Y,{children:(0,D.jsx)(`ul`,{className:`space-y-1 text-xs text-amber-100/80`,children:n.map(e=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`font-mono text-amber-300`,children:e.id}),` ·`,` `,e.error]},e.id))})})]}),x===`browse`&&(0,D.jsx)(bm,{loading:y,error:o,available:i,featuredPlugins:re,showFeatured:ie,installedIds:ne,busy:f,query:u,selectedCategory:C,onInstall:e=>z(e.id,`install`,()=>tm(e.id),`Installed ${e.name}`),onRetry:()=>void te(u,C,T),onFork:e=>I(e.id)}),x===`installed`&&(0,D.jsx)(Sm,{loading:g,installed:e,iconById:B,busy:f,onEnable:e=>z(e.id,`toggle`,()=>rm(e.id),`Enabled ${e.name}`),onDisable:e=>z(e.id,`toggle`,()=>im(e.id),`Disabled ${e.name}`),onUninstall:e=>z(e.id,`uninstall`,()=>nm(e.id),`Uninstalled ${e.name}`)}),x===`builtin`&&(0,D.jsx)(xm,{features:j,onToggle:(e,t)=>{M(e,t);let n=qt.find(t=>t.id===e),r=n?n.name:e;F(`ok`,t?`Enabled ${r}`:`Disabled ${r}`)}})]})}function ym({plugin:e,installed:t,busy:n,onInstall:r,onFork:i}){return(0,D.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col gap-2 rounded-lg border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsx)(mm,{name:e.name,icon:e.icon,large:!0}),e.verified&&(0,D.jsx)(`span`,{className:`mt-0.5`,children:(0,D.jsx)(hm,{})})]}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,D.jsx)(`span`,{className:`truncate text-sm font-semibold leading-tight`,children:e.name}),e.category&&(0,D.jsx)(`span`,{className:`inline-flex w-fit items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${um(e.category)}`,children:e.category})]}),e.description&&(0,D.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-relaxed text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-[var(--color-fg-4)]`,children:[(0,D.jsxs)(`span`,{children:[fm(e.install_count),` installs`]}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`hover:text-[var(--color-hig-blue)] hover:underline`,title:`Copy: ssg plugins fork ${e.id}`,children:`Fork`})]}),(0,D.jsx)(K,{variant:t?`ghost`:`primary`,size:`sm`,disabled:t||n,onClick:r,children:t?`Installed`:n?`Installing…`:`Install`})]})]})}function bm({loading:e,error:t,available:n,featuredPlugins:r,showFeatured:i,installedIds:a,busy:o,query:s,selectedCategory:c,onInstall:l,onRetry:u,onFork:d}){return e&&n.length===0?(0,D.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,D.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-1`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(`div`,{className:`h-40 w-56 shrink-0 animate-pulse rounded-lg bg-[var(--color-surface-2)]`},t))}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:Array.from({length:4}).map((e,t)=>(0,D.jsx)(gm,{},t))})]}):t?(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,D.jsx)(`div`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Hub unreachable`}),(0,D.jsx)(`div`,{className:`text-xs text-red-300`,children:t}),(0,D.jsx)(K,{variant:`secondary`,size:`sm`,onClick:u,children:`Retry`})]})})}):n.length===0?(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsx)(`div`,{className:`flex flex-col gap-2 py-4 text-sm text-[var(--color-fg-3)]`,children:s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:[`No plugins match "`,s,`".`]}),(0,D.jsx)(`div`,{children:`Try a different search term, or browse the full catalog by clearing the search box.`})]}):c===`all`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins on the hub yet.`}),(0,D.jsxs)(`div`,{children:[`The marketplace is brand new.`,` `,(0,D.jsx)(`a`,{href:`/publish-plugin`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Publish the first plugin →`})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins in this category yet.`}),(0,D.jsx)(`div`,{children:`Try another category or view all plugins.`})]})})})}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[i&&(0,D.jsxs)(`section`,{"data-tutorial":`plugins-featured`,children:[(0,D.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-[var(--color-fg-4)]`,children:`Featured`}),(0,D.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:r.map(e=>(0,D.jsx)(ym,{plugin:e,installed:a.has(e.id),busy:o[e.id]===`install`,onInstall:()=>l(e),onFork:()=>d(e)},e.id))})]}),(0,D.jsxs)(`section`,{children:[i&&(0,D.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-[var(--color-fg-4)]`,children:`All Plugins`}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:n.map(e=>{let t=a.has(e.id),n=o[e.id]===`install`;return(0,D.jsx)(q,{variant:t?`default`:`interactive`,children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(mm,{name:e.name,icon:e.icon}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.verified&&(0,D.jsx)(hm,{}),(0,D.jsxs)(G,{variant:`outline`,children:[`v`,e.version]}),t&&(0,D.jsx)(G,{variant:`green`,children:`Installed`})]}),e.category&&(0,D.jsx)(`div`,{className:`mt-1`,children:(0,D.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${um(e.category)}`,children:e.category})}),e.description&&(0,D.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-[var(--color-fg-4)]`,children:[e.author_github&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{children:[`by`,` `,(0,D.jsxs)(`a`,{href:`https://github.com/${e.author_github}`,target:`_blank`,rel:`noreferrer`,className:`hover:text-[var(--color-fg-2)] hover:underline`,children:[`@`,e.author_github]})]}),(0,D.jsx)(`span`,{children:`·`})]}),(0,D.jsxs)(`span`,{children:[fm(e.install_count),` installs`]}),e.platforms.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{children:`·`}),(0,D.jsx)(`span`,{title:`Supports ${e.platforms.join(`, `)}`,children:e.platforms.length===1?e.platforms[0]:`${e.platforms.length} platforms`})]})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,D.jsx)(K,{variant:t?`ghost`:`primary`,size:`sm`,disabled:t||n,onClick:()=>l(e),children:t?`Installed`:n?`Installing…`:`Install`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`hover:text-[var(--color-hig-blue)] hover:underline`,title:`Copy: ssg plugins fork ${e.id}`,children:`Fork`}),(0,D.jsx)(`a`,{href:`https://hub.sigmashake.com/plugin/${e.id}`,target:`_blank`,rel:`noreferrer`,className:`hover:text-[var(--color-hig-blue)] hover:underline`,children:`View source`})]})]})]})})},e.id)})})]})]})}function xm({features:e,onToggle:t}){return(0,D.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)]`,children:`Bundled with the dashboard but opt-in. These features ship inside the ssg binary and run in-process; they don't need a separate install but stay dormant until enabled here.`}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:qt.map(n=>{let r=e[n.id];return(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] text-lg leading-none`,children:(0,D.jsx)(`span`,{"aria-hidden":!0,children:n.icon})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:n.name}),(0,D.jsx)(G,{variant:`gray`,children:`Built-in`}),r?(0,D.jsx)(G,{variant:`green`,children:`Enabled`}):(0,D.jsx)(G,{variant:`amber`,children:`Disabled`})]}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:n.description}),(0,D.jsx)(`div`,{className:`mt-2 text-[11px] text-[var(--color-fg-4)]`,children:`No download · runs in your browser`})]}),(0,D.jsx)(`div`,{className:`shrink-0`,children:(0,D.jsx)(K,{variant:r?`ghost`:`primary`,size:`sm`,onClick:()=>t(n.id,!r),children:r?`Disable`:`Enable`})})]})})},n.id)})})]})}function Sm({loading:e,installed:t,iconById:n,busy:r,onEnable:i,onDisable:a,onUninstall:o}){let[s,c]=(0,_.useState)(null),l=(0,_.useRef)(null),u=(0,_.useCallback)(e=>{c(e),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>c(null),cm)},[]),d=(0,_.useCallback)(()=>{l.current&&clearTimeout(l.current),l.current=null,c(null)},[]);return(0,_.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),e&&t.length===0?(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:Array.from({length:2}).map((e,t)=>(0,D.jsx)(gm,{},t))}):t.length===0?(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 py-4 text-sm text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins installed yet.`}),(0,D.jsx)(`div`,{children:`Switch to the Browse tab to discover plugins from the hub.`})]})})}):(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:t.map(e=>{let t=r[e.id]===`toggle`,c=r[e.id]===`uninstall`,l=s===e.id;return(0,D.jsx)(q,{children:(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(mm,{name:e.name,icon:e.icon??n.get(e.id)??null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,D.jsxs)(G,{variant:`outline`,children:[`v`,e.version]}),e.enabled?(0,D.jsx)(G,{variant:`green`,children:`Enabled`}):(0,D.jsx)(G,{variant:`amber`,children:`Disabled`})]}),e.category&&(0,D.jsx)(`div`,{className:`mt-1`,children:(0,D.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${um(e.category)}`,children:e.category})}),e.description&&(0,D.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:e.id}),(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{title:e.signing_fingerprint,children:[`sig`,` `,(0,D.jsxs)(`span`,{className:`font-mono`,children:[e.signing_fingerprint.slice(0,12),`…`]})]}),(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{title:e.installed_at,children:[`installed `,dm(e.installed_at)]}),e.nav.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{children:[e.nav.length,` nav`,` `,e.nav.length===1?`entry`:`entries`]})]})]}),(e.homepage_url||e.repo_url)&&(0,D.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px]`,children:[e.homepage_url&&(0,D.jsx)(`a`,{href:e.homepage_url,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Homepage`}),e.repo_url&&(0,D.jsx)(`a`,{href:e.repo_url,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Repository`})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1.5`,children:[e.enabled?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(K,{variant:`primary`,size:`sm`,onClick:()=>{window.location.href=`/plugins/${e.id}`},children:`Open`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,disabled:t,onClick:()=>a(e),children:t?`Disabling…`:`Disable`})]}):(0,D.jsx)(K,{variant:`secondary`,size:`sm`,disabled:t,onClick:()=>i(e),children:t?`Enabling…`:`Enable`}),c?(0,D.jsx)(K,{variant:`ghost`,size:`sm`,disabled:!0,children:`Removing…`}):l?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(K,{variant:`danger`,size:`sm`,onClick:()=>{d(),o(e)},children:`Confirm remove`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:d,children:`Cancel`})]}):(0,D.jsx)(K,{variant:`ghost`,size:`sm`,title:`Remove this plugin from disk`,onClick:()=>u(e.id),children:`Uninstall`})]})]})})},e.id)})})}function Cm(e){return e<1e6?`${(e/1e3).toFixed(0)}µs`:e<1e9?`${(e/1e6).toFixed(1)}ms`:`${(e/1e9).toFixed(2)}s`}function wm(e){return new Date(e*1e3).toLocaleString()}var Tm={critical:`red`,high:`red`,medium:`amber`,low:`blue`},Em={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 Dm(){let{data:e}=U(`/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`,{"data-tutorial":`profile-metrics`,className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[{label:`evals analyzed`,value:String(t.analyzed_evals)},{label:`median (inside)`,value:Cm(t.median_eval_ns)},{label:`p99 (inside)`,value:Cm(t.p99_eval_ns)},{label:`bottleneck`,value:t.bottleneck??`—`}].map(e=>(0,D.jsx)(zf,{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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`overline`,children:`phase breakdown`})}),(0,D.jsx)(Y,{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)(Vf,{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:Cm(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 `,Cm(e.p95_ns)]})]},e.name)})})})]}),t.recommendations.length>0&&(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`recommendations · `,t.recommendations.length]})}),(0,D.jsx)(Y,{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 ${Em[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)(G,{variant:Tm[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)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsxs)(`span`,{className:`overline`,children:[`anomalies · `,t.anomalies.length]})}),(0,D.jsx)(Y,{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)(q,{children:[(0,D.jsxs)(J,{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)(Y,{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:wm(e.start_ts)}),e.is_current&&(0,D.jsx)(G,{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 `,Cm(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 Om={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 km(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function Am(){let e=gp(),[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)(q,{children:[(0,D.jsxs)(J,{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)(K,{variant:`ghost`,size:`sm`,onClick:e.disconnect,children:`disconnect`}):(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:e.preconfiguredTarget?p:e.refetch,disabled:e.connecting,children:e.preconfiguredTarget?`reconnect`:`refresh`})]})]}),e.error&&(0,D.jsx)(Y,{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)(q,{children:[(0,D.jsxs)(J,{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)(K,{variant:`danger`,size:`sm`,onClick:h,children:`stop & render`}):(0,D.jsx)(K,{variant:`primary`,size:`sm`,onClick:m,children:`start recording`})]})]}),(0,D.jsx)(Y,{children:r?(0,D.jsx)(Hf,{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)(dp,{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)(q,{children:[(0,D.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`memory`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:g,disabled:l,children:l?`…`:`refresh`})]}),(0,D.jsx)(Y,{children:s?(0,D.jsx)(Uf,{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)(q,{children:[(0,D.jsxs)(J,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`console`}),(0,D.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>o([]),children:`clear`})]}),(0,D.jsx)(Y,{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)] ${Om[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(km).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 jm({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 Mm(){let[e,t]=(0,_.useState)(`eval`);return(0,D.jsxs)(`div`,{className:`space-y-0`,children:[(0,D.jsxs)(`div`,{"data-tutorial":`profile-tabs`,className:`flex items-center border-b border-[var(--color-line-0)] mb-5`,children:[(0,D.jsx)(jm,{active:e===`eval`,onClick:()=>t(`eval`),children:`eval profile`}),(0,D.jsx)(jm,{active:e===`inspector`,onClick:()=>t(`inspector`),children:`runtime inspector`})]}),e===`eval`?(0,D.jsx)(Dm,{}):(0,D.jsx)(Am,{})]})}var Nm=[{id:`destructive-ops`,title:`Destructive Operations`,description:`Commands that delete, overwrite, truncate, or irreversibly destroy files, data, or infrastructure.`,icon:`💥`,color:`#FF3B30`,attack:{id:`TA0040`,name:`Impact`},d3fend:`Harden`,security:!0,order:1},{id:`privilege-escalation`,title:`Privilege Escalation`,description:`sudo, permission and ownership changes, setuid manipulation, and capability grants.`,icon:`⬆️`,color:`#FF9500`,attack:{id:`TA0004`,name:`Privilege Escalation`},d3fend:`Isolate`,security:!0,order:2},{id:`code-execution`,title:`Untrusted Code Execution`,description:`Piping remote content into a shell, dynamic interpreters, and execution of unvetted code.`,icon:`⚙️`,color:`#FFCC00`,attack:{id:`TA0002`,name:`Execution`},d3fend:`Harden`,security:!0,order:3},{id:`credential-access`,title:`Credential & Secret Access`,description:`Reads of secrets, private keys, tokens, .env files, and cloud credentials.`,icon:`🔑`,color:`#AF52DE`,attack:{id:`TA0006`,name:`Credential Access`},d3fend:`Detect`,security:!0,order:4},{id:`network-egress`,title:`Network Egress & Exfiltration`,description:`Outbound network calls, uploads, reverse shells, and data leaving the machine.`,icon:`🌐`,color:`#5AC8FA`,attack:{id:`TA0010`,name:`Exfiltration`},d3fend:`Isolate`,security:!0,order:5},{id:`supply-chain`,title:`Supply Chain & Dependencies`,description:`Package installs, lockfile edits, registry changes, and dependency tampering.`,icon:`📦`,color:`#34C759`,attack:{id:`TA0042`,name:`Resource Development`},d3fend:`Harden`,security:!0,order:6},{id:`process-control`,title:`Process & System Control`,description:`Killing processes, daemonizing, service control, and resource exhaustion.`,icon:`🔌`,color:`#FF6482`,attack:{id:`TA0003`,name:`Persistence`},d3fend:`Isolate`,security:!0,order:7},{id:`version-control`,title:`Version Control Integrity`,description:`Force pushes, history rewrites, branch deletion, and git remote safety.`,icon:`🔀`,color:`#30B0C7`,attack:{id:`TA0005`,name:`Defense Evasion`},d3fend:`Harden`,security:!0,order:8},{id:`source-integrity`,title:`Source & Config Integrity`,description:`Edits to protected, generated, CI/CD, or governance-critical files.`,icon:`📐`,color:`#A2845E`,attack:{id:`TA0003`,name:`Persistence`},d3fend:`Harden`,security:!0,order:9},{id:`data-handling`,title:`Sensitive Data Handling`,description:`Database mutations, PII handling, and redaction of sensitive output.`,icon:`🗄️`,color:`#BF5AF2`,attack:{id:`TA0009`,name:`Collection`},d3fend:`Detect`,security:!0,order:10},{id:`agent-hygiene`,title:`Agent Hygiene & Efficiency`,description:`Tool-use best practices, token efficiency, and prompt hygiene — operational, not a security control.`,icon:`🧭`,color:`#8E8E93`,attack:null,d3fend:`Model`,security:!1,order:11},{id:`uncategorized`,title:`Uncategorized`,description:`Rules that have not declared a category.`,icon:`▫️`,color:`#636366`,attack:null,d3fend:`Model`,security:!1,order:99}],Pm=new Map(Nm.map(e=>[e.id,e]));Nm.filter(e=>e.id!==`uncategorized`).map(e=>e.id);function Fm(e){return typeof e==`string`&&e!==`uncategorized`&&Pm.has(e)}function Im(e){return e!==void 0&&Pm.get(e)||Pm.get(`uncategorized`)}var Lm=[{token:`destructive`,category:`destructive-ops`},{token:`exfil`,category:`network-egress`},{token:`credential`,category:`credential-access`},{token:`secret`,category:`credential-access`},{token:`privilege`,category:`privilege-escalation`},{token:`privesc`,category:`privilege-escalation`},{token:`powergate`,category:`process-control`},{token:`process`,category:`process-control`},{token:`powersafety`,category:`process-control`},{token:`injection`,category:`code-execution`},{token:`untrusted`,category:`code-execution`},{token:`supply`,category:`supply-chain`},{token:`dependenc`,category:`supply-chain`},{token:`npm`,category:`supply-chain`},{token:`pnpm`,category:`supply-chain`},{token:`cargo`,category:`supply-chain`},{token:`cicd`,category:`supply-chain`},{token:`publish`,category:`supply-chain`},{token:`git`,category:`version-control`},{token:`network`,category:`network-egress`},{token:`egress`,category:`network-egress`},{token:`database`,category:`data-handling`},{token:`sql`,category:`data-handling`},{token:`critical`,category:`source-integrity`},{token:`drm`,category:`source-integrity`},{token:`config`,category:`source-integrity`},{token:`integrity`,category:`source-integrity`},{token:`infra`,category:`source-integrity`},{token:`agent`,category:`agent-hygiene`},{token:`efficiency`,category:`agent-hygiene`},{token:`hygiene`,category:`agent-hygiene`}];function Rm(e,t){let n=(t??e.source_file??``).toLowerCase(),r=n?n.split(/[\\/]/).pop()??n:``,i=`${e.id.toLowerCase()} ${r}`;for(let e of Lm)if(i.includes(e.token))return e.category;return e.target===`agent`?`agent-hygiene`:e.target===`network`?`network-egress`:`uncategorized`}function zm(e,t){return e.category!==void 0&&Fm(e.category)?e.category:Rm(e,t)}function Bm(e,t){let n=new Map;for(let e of Nm)n.set(e.id,{id:e.id,meta:e,total:0,enabled:0,enabledShell:0,decisions:{},status:`gap`});let r=0;for(let i of e){let e=zm(i,t?.(i)),a=n.get(e);a.total++,e===`uncategorized`&&r++,i.enabled!==!1&&(a.enabled++,a.decisions[i.decision]=(a.decisions[i.decision]??0)+1,(i.target===`execution`||i.target===`any`)&&a.enabledShell++)}for(let e of n.values())e.status=e.enabled>0?`covered`:e.total>0?`inactive`:`gap`;let i=[...n.values()].sort((e,t)=>e.meta.order-t.meta.order),a=i.filter(e=>e.meta.security&&e.id!==`uncategorized`);return{categories:i,covered:a.filter(e=>e.status===`covered`).length,total:a.length,uncategorized:r}}var Vm=new Set([`block`,`ask`,`force`,`deny`]),Hm=[`rules-changed`],Um=[`block`,`ask`,`log`,`allow`,`force`,`shadow`],Wm={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`,ambient:`text-teal-300`},Gm={block:`#fca5a5`,deny:`#fca5a5`,ask:`#7dd3fc`,allow:`#6ee7b7`,log:`#a8a29e`,force:`#fcd34d`,shadow:`#c4b5fd`},Km=[{value:`today`,label:`today`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`all`,label:`all`}],qm=5e3;function Jm(e,t){return t<=0?e:`${e}${e.includes(`?`)?`&`:`?`}_t=${t}`}async function Ym(e,t){await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t})})}async function Xm(e,t,n){await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t,decision:n})})}async function Zm(e,t){return fetch(`/api/rules/bulk-set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e,enabled:t})}).then(e=>e.json())}async function Qm(e,t){return fetch(`/api/rules/bulk-update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e,decision:t})}).then(e=>e.json())}async function $m(e){return fetch(`/api/rules/bulk-delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e})}).then(e=>e.json())}async function eh(e,t={}){return fetch(`/api/rules/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify(t)}).then(e=>e.json())}function th(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 nh(e,t,n,r){let i=Array(t).fill(0);if(!e||e.length===0)return i;let a=Date.now(),o=a-n,s=n/t;for(let n of e){let e=n.timestamp*1e3;if(e<o||e>a||r&&!r(n))continue;let c=Math.min(t-1,Math.floor((e-o)/s));i[c]+=1}return i}function rh({active:e}){return(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsxs)(`span`,{className:`relative inline-flex h-2 w-2`,children:[e&&(0,D.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400/60`}),(0,D.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full ${e?`bg-emerald-400`:`bg-[var(--color-fg-4)]`}`})]}),(0,D.jsx)(`span`,{className:e?`text-emerald-300`:`text-[var(--color-fg-4)]`,children:e?`live`:`paused`})]})}function ih({mode:e,onChange:t}){return(0,D.jsxs)(`div`,{className:`flex items-center text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm overflow-hidden`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`newcomer`),className:`px-2 py-1 cursor-pointer transition-colors ${e===`newcomer`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Hide advanced controls (firewall, raw source, audit, AI hints)`,children:`simple`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`pro`),className:`px-2 py-1 cursor-pointer transition-colors border-l border-[var(--color-line-1)] ${e===`pro`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Show everything: top-rules chart, performance, firewall, audit trails, raw source, curl recipes`,children:`advanced`})]})}function ah({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)(In,{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 oh(){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`,...W()},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)(q,{className:s?`border-amber-500/40 bg-amber-500/5`:`border-[var(--color-line-1)]`,children:(0,D.jsx)(Y,{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 sh({perf:e,triggers:t,decisionAggregates:n,livePoll:r,onTogglePoll:i,statsWindow:a,onWindowChange:o,mode:s,onModeChange:c}){let l=t?.evalsLast60s??0,u=t?.evalsLastHour??0,d=(0,_.useMemo)(()=>nh(t?.rows,30,3600*1e3),[t?.rows]),f=(0,_.useMemo)(()=>nh(t?.rows,30,3600*1e3,e=>Vm.has(e.decision)),[t?.rows]),p={allow:n.hits.allow??0,block:n.hits.block??0,ask:n.hits.ask??0,log:n.hits.log??0,force:n.hits.force??0,shadow:n.hits.shadow??0},m=Object.values(p).reduce((e,t)=>e+t,0),h=e?.totalRules??0,g=e?.activeRules??0,v=h>0?g/h*100:0,y=l/60;return(0,D.jsx)(q,{className:`border-[var(--color-line-1)]`,children:(0,D.jsxs)(Y,{className:`px-4 py-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`rules active`}),(0,D.jsxs)(`div`,{className:`font-mono text-2xl text-[var(--color-fg-0)] tabular-nums leading-none mt-0.5`,children:[(0,D.jsx)(Gc,{value:g}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] text-base`,children:[`/`,h]})]}),(0,D.jsxs)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:[v.toFixed(0),`% on`]})]}),(0,D.jsx)(`div`,{className:`h-12 w-px bg-[var(--color-line-1)] hidden md:block`}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`evals · last 60s`}),(0,D.jsx)(rh,{active:r})]}),(0,D.jsx)(`div`,{className:`font-mono text-2xl text-emerald-300 tabular-nums leading-none mt-0.5`,children:(0,D.jsx)(Gc,{value:l,curve:`spring`})}),(0,D.jsxs)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:[`~`,y.toFixed(1),`/s`]})]}),(0,D.jsx)(`div`,{className:`h-12 w-px bg-[var(--color-line-1)] hidden md:block`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`last hour`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,D.jsx)(`span`,{className:`font-mono text-2xl text-[var(--color-fg-1)] tabular-nums leading-none`,children:(0,D.jsx)(Gc,{value:u})}),(0,D.jsx)(qc,{data:d,width:120,height:32,color:`var(--color-brand)`})]}),(0,D.jsx)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:`evals · 2-min buckets`})]}),(0,D.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,D.jsx)(ih,{mode:s,onChange:c}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`text-[10px] font-mono uppercase tracking-wider px-2 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer transition-colors`,title:r?`Pause auto-refresh`:`Resume auto-refresh`,children:r?`⏸ pause`:`▶ resume`}),(0,D.jsx)(`div`,{className:`flex items-center text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm`,children:Km.map((e,t)=>(0,D.jsx)(`button`,{onClick:()=>o(e.value),className:`px-1.5 py-1 cursor-pointer transition-colors ${t>0?`border-l border-[var(--color-line-1)]`:``} ${a===e.value?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e.label},e.value))})]})]}),(m>0||f.some(e=>e>0))&&(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1.4fr_1fr] gap-4 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,D.jsxs)(`span`,{className:`overline text-[10px]`,children:[`decision mix · `,a]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[m.toLocaleString(),` hits`]})]}),(0,D.jsx)(Kc,{counters:p,showLegend:!0})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`block/ask/force · last hour`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-amber-300 tabular-nums`,children:[f.reduce((e,t)=>e+t,0),` actionable`]})]}),(0,D.jsx)(qc,{data:f,width:400,height:48,color:`#fca5a5`})]})]})]})})}function ch({perf:e}){if(!e)return null;let t=e.avgEvalMs>50?`text-amber-300`:e.avgEvalMs>100?`text-red-300`:`text-emerald-300`;return(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{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:`avg eval`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm tabular-nums ${t}`,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 lh({stats:e,ruleIndex:t,triggers:n,statsWindow:r,onJump:i}){let a=(0,_.useMemo)(()=>{let r=Object.entries(e).filter(([,e])=>e.hits>0).sort(([,e],[,t])=>t.hits-e.hits).slice(0,10),i=r[0]?.[1].hits??1;return r.map(([e,r])=>{let a=t.get(e),o=nh(n,20,3600*1e3,t=>t.ruleId===e);return{id:e,stat:r,entry:a,pct:r.hits/i*100,sparkData:o,color:a?Gm[a.rule.decision]??`#a8a29e`:`#a8a29e`}})},[e,t,n]);return a.length===0?(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{className:`px-3 py-3`,children:[(0,D.jsxs)(`div`,{className:`overline text-[10px] mb-1`,children:[`top rules · `,r]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no rules have fired in this window yet`})]})}):(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{className:`px-3 py-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsxs)(`span`,{className:`overline text-[10px]`,children:[`top rules · `,r]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`top `,a.length,` · click to jump`]})]}),(0,D.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`w-full text-left group cursor-pointer`,children:[(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 ${e.entry?Wm[e.entry.rule.decision]??`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:e.entry?.rule.decision??`—`}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-1)] group-hover:text-[var(--color-fg-0)] truncate flex-1 min-w-0`,children:e.id}),(0,D.jsx)(qc,{data:e.sparkData,width:60,height:16,color:e.color}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums shrink-0 w-10 text-right`,children:e.stat.hits}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-14 text-right`,children:[e.stat.avgDurationMs.toFixed(1),`ms`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums shrink-0 w-14 text-right`,children:th(e.stat.lastSeen)})]}),(0,D.jsx)(`div`,{className:`relative h-1 mt-1 mb-1 bg-[var(--color-surface-2)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-sm transition-[width] duration-500 ease-out`,style:{width:`${e.pct}%`,background:e.color,opacity:.6}})})]},e.id))})]})})}function uh({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 eh(`disable-all`):e===`enable`?await eh(`enable-all`):e===`reset`?await eh(`reset-db`):await eh(`uninstall-all`,{confirm:`UNINSTALL_ALL_RULES`}),n()}finally{i(null),o(null)}}return(0,D.jsx)(q,{className:`border-[var(--color-line-1)]`,children:(0,D.jsx)(Y,{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/`}),`. Reset DB clears the rules table in the database (audit log + cost history are kept) and re-imports your `,(0,D.jsx)(`code`,{children:`.rules`}),` files — use it to flush stale or phantom rows a file sync won't remove.`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[a===`disable`?(0,D.jsx)(dh,{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)(dh,{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)(dh,{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`}),a===`reset`?(0,D.jsx)(dh,{onConfirm:()=>void s(`reset`),onCancel:()=>o(null),tone:`amber`,label:`reset rules DB`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>o(`reset`),disabled:r!==null,title:`Clear the rules table in the database and re-import from .rules files. Audit log + cost history are preserved.`,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===`reset`?`resetting…`:`reset DB`})]})]})})})}function dh({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 fh({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)(q,{className:`border-sky-500/40 bg-sky-500/5 backdrop-blur`,children:(0,D.jsx)(Y,{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 ${Wm[a]??`text-[var(--color-fg-2)]`}`,children:Um.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)(dh,{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 ph({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 ${Wm[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:th(e.timestamp)})]},e.id))})]})}function mh(){let[e,t]=(0,_.useState)(!1);return(0,D.jsx)(q,{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)(Y,{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
28
+ ${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`,ae>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:ae})]})]}),(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`,{"data-tutorial":`hub-search`,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:oe,children:Tf.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,D.jsxs)(`select`,{"data-tutorial":`hub-filters`,value:i,onChange:e=>a(e.target.value),className:oe,children:[(0,D.jsx)(`option`,{value:``,children:`any decision`}),Df.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:oe,children:[(0,D.jsx)(`option`,{value:``,children:`any severity`}),Ef.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)(Of,{},t))}):ie.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`,{"data-tutorial":`hub-grid`,className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:ie.map(e=>(0,D.jsx)(Mf,{rs:e,installs:y[e.id]??[],installingId:x,uninstallingKey:C,onInstall:ne,onUninstall:re,onPickAndInstall:R,flashId:ee},e.id))}),f&&c===`all`&&(0,D.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,D.jsx)(`button`,{onClick:I,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 Ff(){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`,...W()},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`,{"data-tutorial":`hubpub-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`})]})}var If={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)]`},Lf={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)]`},Rf=[{label:`User code`,color:`#451a03`},{label:`Runtime (bun:/node:)`,color:`#172554`},{label:`Native/other`,color:`#1f2937`},{label:`GC/idle`,color:`#450a0a`}],zf={neutral:`#d0d0d0`,green:`#34d399`,red:`#f87171`,amber:`#fbbf24`,blue:`#38bdf8`,purple:`#a78bfa`,gray:`#6e7076`};function Bf({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:G(a===`above`?`overline mb-1.5`:`mt-1 text-[11px] text-[var(--color-fg-3)]`,o),children:e}),f=(0,D.jsx)(`div`,{className:G(`font-mono font-medium tabular-nums`,i===`center`&&`text-center`,If[r],s),children:t}),p=l&&l.length>1,m=u??zf[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)(Jc,{data:l,width:48,height:18,color:m})]}):f,a===`below`&&d,n&&(0,D.jsx)(`div`,{className:G(`mt-1 text-[10px] font-mono text-[var(--color-fg-3)]`,i===`center`&&`text-center`,c),children:n})]})}function Vf({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:G(`py-3`,o===`center`&&`text-center`,t),children:(0,D.jsx)(Bf,{label:n,value:r,sub:i,tone:a,align:o,labelPlacement:s,labelClassName:c,valueClassName:l,subClassName:u,trend:d,trendColor:f})})})}function Hf({className:e,...t}){return(0,D.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,D.jsx)(Bf,{...t})})}function Uf({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:G(`relative w-full overflow-hidden rounded-sm bg-[var(--color-surface-3)]`,r),children:[(0,D.jsx)(`div`,{className:G(`h-full rounded-sm transition-all duration-500`,Lf[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 Wf({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:Rf.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 Gf({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)(Hf,{align:`center`,label:e.label,value:e.value,valueClassName:`text-lg font-medium text-[var(--color-fg-0)]`},e.label))})}function Kf(e){return e===0?`—`:e<1e3?`${e}ns`:e<1e6?`${(e/1e3).toFixed(1)}µs`:`${(e/1e6).toFixed(1)}ms`}function qf(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 Jf(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 Yf(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 Xf={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 Qf({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)(Uf,{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:Kf(t)})]})}function $f({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)(Uf,{pct:i,tone:r?`red`:e/t>=.6?`amber`:`green`,markerPct:a,markerTitle:`limit: ${n}`,className:`h-1`})}function ep({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`,...W()},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 tp={running:`green`,hibernating:`amber`,exhausted:`red`,stopped:`gray`,idle:`gray`};function np(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 rp({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:tp[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?Yf(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:np(e.nextRetryAt,t)}):`—`})]},e.name))})]})})})]})}function ip(){let e=Ge([`runtime-tick`,`activity-updated`,`limits-breach`,`supervisor-changed`]),t=Ma(),[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}=U(`/api/state/runtime`,[e[`runtime-tick`]]),{data:m,refetch:h}=U(`/api/json/limits`,[e[`limits-breach`]]),{data:g}=U(`/api/state/activity-tail?after=${i}&limit=50`,[e[`activity-updated`]]),{data:v}=U(`/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?qf(p.uptime_ms):null,b=p&&p.last_eval_at>0?Yf(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:Jf(n)})]})]}),(0,D.jsx)(ap,{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)(rp,{supervisors:v?.supervisors??[]}),(0,D.jsxs)(J,{"data-tutorial":`monitor-resources`,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)(Jc,{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)($f,{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)(Jc,{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)($f,{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)(Uf,{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)(ep,{limitsData:m,onSaved:()=>{h(),d(!1)}})]})]})]}),(0,D.jsxs)(`div`,{"data-tutorial":`monitor-counters`,className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2`,children:[(0,D.jsx)(Hf,{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)(Hf,{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)(Hf,{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)(Hf,{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)(Hf,{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)(Hf,{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)(Qf,{label:`p50`,ns:p.latency.p50_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Qf,{label:`p95`,ns:p.latency.p95_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Qf,{label:`p99`,ns:p.latency.p99_ns,maxNs:p.latency.max_ns}),(0,D.jsx)(Qf,{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,{"data-tutorial":`monitor-tail`,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:Jf(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] ${Xf[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:Kf(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 ap({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)(Cl,{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)(Xc,{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)(Cl,{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)(Xc,{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)(Ol,{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)(il,{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)(Xc,{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)(qc,{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)(Bl,{variant:`decision`,bursts:s,windowSize:300,height:260})]})]})}function op(){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)(`div`,{"data-tutorial":`notif-list`,children:(0,D.jsx)(Uc,{showEmptyState:!0,hideHeader:!0})})]})}var sp=18,cp=5e-4;function lp(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 up(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 dp(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<cp)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 fp(e){return e<1e3?`${e}µs`:e<1e6?`${(e/1e3).toFixed(1)}ms`:`${(e/1e6).toFixed(2)}s`}function pp({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=dp(e,i),l=(c.reduce((e,t)=>Math.max(e,t.depth),0)+1)*sp+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*sp+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:sp-1,fill:f?`#92400e`:lp(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+sp-5,fontSize:9,fill:up(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:sp})})]},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:fp(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 mp={ok:`green`,warn:`amber`,error:`red`,unknown:`gray`},hp={ok:`OK`,warn:`Warn`,error:`Error`,unknown:`Idle`};function gp({title:e,status:t=`unknown`,statusLabel:n,className:r,children:i}){return(0,D.jsxs)(J,{className:G(`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:mp[t],children:n??hp[t]})]}),(0,D.jsx)(X,{className:`flex flex-col gap-2 text-[12px]`,children:i})]})}function _p({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: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 vp(){let{data:e,refetch:t}=U(`/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 yp(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 bp(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function xp(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 Sp(e){return e?new Date(e*1e3).toLocaleString():`—`}function Cp(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 wp({children:e,className:t}){return(0,D.jsx)(`div`,{className:`overline mb-2.5 ${t??``}`,children:e})}function Tp({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 Ep({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 Dp({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)(Uf,{pct:e,tone:r,className:`h-1.5`})]})}var Op=3e3,kp={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 Ap(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function jp(){let e=vp(),[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)}},Op)}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)(Wf,{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)(pp,{profile:r})})}):(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:t?`recording cpu profile (auto-captures ${Op/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)(Gf,{memory:s,formatValue:bp}):(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)] ${kp[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(Ap).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 Mp(){let[e,t]=(0,_.useState)(0),{data:n}=U(`/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(`
29
+ `),(0,D.jsx)(`div`,{ref:r})]})]})]})}function Np(){let e=Ge([`runtime-tick`,`rules-changed`]),{data:t,refetch:n}=U(`/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:W()})).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:W()}),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 `,Cp(s)]}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n,children:`refresh`})]})]}),(0,D.jsx)(Pp,{db:v,audit:b,proc:x,flight:S,driftDetected:C}),(0,D.jsxs)(J,{"data-tutorial":`observ-drift`,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)(Hf,{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:Cp(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)(Ep,{ok:v.journal_mode===`wal`,label:`wal`,badLabel:`no wal`}),(0,D.jsx)(Ep,{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)(wp,{children:`storage`}),(0,D.jsx)(Tp,{label:`file path`,value:v.path}),(0,D.jsx)(Tp,{label:`file size`,value:yp(v.file_size_bytes)}),(0,D.jsx)(Tp,{label:`allocated`,value:`${yp(v.allocated_bytes)} (${v.page_count.toLocaleString()} pages × ${v.page_size}B)`}),(0,D.jsx)(wp,{className:`mt-4`,children:`pragma configuration`}),(0,D.jsx)(Tp,{label:`journal_mode`,value:v.journal_mode,accent:v.journal_mode===`wal`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(Tp,{label:`synchronous`,value:v.synchronous,accent:v.synchronous===`NORMAL`?`text-emerald-300`:`text-amber-300`}),(0,D.jsx)(Tp,{label:`cache_size`,value:`${v.cache_size_kb.toLocaleString()} KB (${Math.round(v.cache_size_kb/1024)} MB)`}),(0,D.jsx)(Tp,{label:`page_size`,value:`${v.page_size.toLocaleString()} B`}),v.wal_checkpoint&&(0,D.jsx)(Tp,{label:`wal checkpoint`,value:`log ${v.wal_checkpoint.log}, checkpointed ${v.wal_checkpoint.checkpointed}, busy ${v.wal_checkpoint.busy}`}),(0,D.jsx)(wp,{className:`mt-4`,children:`table row counts`}),v.tables.map(e=>(0,D.jsx)(Tp,{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,{"data-tutorial":`observ-capacity`,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)(Dp,{pct:b.utilization_pct,total:b.total_rows,max:b.max_rows}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(Tp,{label:`total rows`,value:b.total_rows.toLocaleString()}),(0,D.jsx)(Tp,{label:`rotation limit`,value:b.max_rows.toLocaleString()}),(0,D.jsx)(Tp,{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)(Tp,{label:`oldest entry`,value:Sp(b.oldest_timestamp)}),(0,D.jsx)(Tp,{label:`newest entry`,value:Sp(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)(Tp,{label:`pid`,value:x.pid}),(0,D.jsx)(Tp,{label:`uptime`,value:xp(x.uptime_ms)}),(0,D.jsx)(Tp,{label:`memory (rss)`,value:`${x.memory_rss_mb} MB`}),(0,D.jsx)(Tp,{label:`bun version`,value:x.bun_version}),(0,D.jsx)(Tp,{label:`node compat`,value:x.node_version}),(0,D.jsx)(Tp,{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:yp(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)(jp,{}),(0,D.jsx)(Mp,{}),(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 Pp({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)(gp,{title:`sqlite`,status:a,statusLabel:e?.journal_mode?.toUpperCase()??`idle`,children:[(0,D.jsx)(_p,{label:`size`,value:e?(0,D.jsx)(Kc,{value:e.file_size_bytes,format:e=>bp(e)}):`—`,mono:!0}),(0,D.jsx)(_p,{label:`journal`,value:e?.journal_mode??`—`,mono:!0}),(0,D.jsx)(_p,{label:`sync`,value:e?.synchronous??`—`,mono:!0}),(0,D.jsx)(_p,{label:`tables`,value:e?.tables.length??0,tone:i?`warn`:`neutral`})]}),(0,D.jsxs)(gp,{title:`audit log`,status:o,statusLabel:t?`${t.utilization_pct}%`:`idle`,children:[(0,D.jsx)(_p,{label:`rows`,value:t?(0,D.jsx)(Kc,{value:t.total_rows}):`—`}),(0,D.jsx)(_p,{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)(_p,{label:`oldest`,value:Sp(t?.oldest_timestamp??null),mono:!0}),(0,D.jsx)(_p,{label:`newest`,value:Sp(t?.newest_timestamp??null),mono:!0})]}),(0,D.jsxs)(gp,{title:`process`,status:s,statusLabel:n?`pid ${n.pid}`:`idle`,children:[(0,D.jsx)(_p,{label:`uptime`,value:n?xp(n.uptime_ms):`—`,mono:!0}),(0,D.jsx)(_p,{label:`rss`,value:n?(0,D.jsxs)(`span`,{children:[(0,D.jsx)(Kc,{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)(_p,{label:`bun`,value:n?.bun_version??`—`,mono:!0}),(0,D.jsx)(_p,{label:`platform`,value:n?`${n.platform}/${n.arch}`:`—`,mono:!0})]}),(0,D.jsxs)(gp,{title:`flight recorder`,status:r&&r.file_size_bytes>0?`ok`:`unknown`,statusLabel:r?`${r.approx_entries.toLocaleString()} entries`:`idle`,children:[(0,D.jsx)(_p,{label:`size`,value:r?(0,D.jsx)(Kc,{value:r.file_size_bytes,format:e=>bp(e)}):`—`,mono:!0}),(0,D.jsx)(_p,{label:`entries`,value:r?(0,D.jsx)(Kc,{value:r.approx_entries}):`—`})]})]})}var Fp={healthy:`var(--color-decision-allow)`,degraded:`var(--color-decision-ask)`,disabled:`var(--color-fg-3)`,unsupported:`var(--color-fg-3)`},Ip={healthy:`Healthy`,degraded:`Needs attention`,disabled:`Disabled`,unsupported:`Unsupported`},Lp={launchd:`launchd LaunchAgent (macOS)`,systemd:`systemd user service (Linux)`,schtasks:`Task Scheduler (Windows)`,"registry-run":`Startup Run key (Windows, HKCU)`,unsupported:`unsupported platform`};function Rp({color:e,className:t=``}){return(0,D.jsx)(`span`,{className:`status-dot ${t}`,style:{background:e},"aria-hidden":`true`})}function zp({v:e,trueIsGood:t=!0}){return(0,D.jsx)(`span`,{style:{color:(t?e:!e)?`var(--color-decision-allow)`:`var(--color-decision-ask)`},children:e?`yes`:`no`})}function Bp({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-[140px]`,children:e}),(0,D.jsx)(`span`,{className:`flex-1 text-[var(--color-fg-1)] ${n?`font-mono text-[11px] break-all`:``}`,children:t})]})}function Vp({flow:e,saving:t,confirmNative:n,approveDashboard:r,denyDashboard:i,cancel:a}){return e.kind===`idle`?null:e.kind===`native-confirm`?(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded border-[var(--color-decision-ask)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,D.jsx)(Rp,{color:`var(--color-decision-ask)`,className:`mt-1`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Confirm system change`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:e.env.prompt}),(0,D.jsx)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1`,children:`Ask routing: native (in-app confirm)`})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{onClick:n,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Confirm`}),(0,D.jsx)(`button`,{onClick:a,disabled:t,className:`hig-button hig-button-small`,children:`Cancel`})]})]}):(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded border-[var(--color-hig-purple)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,D.jsx)(Rp,{color:`var(--color-hig-purple)`,className:`mt-1`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Queued for approval`}),(0,D.jsx)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:e.env.prompt}),(0,D.jsxs)(`p`,{className:`text-[10.5px] text-[var(--color-fg-3)] mt-1`,children:[`Ask routing: dashboard — also visible on the`,` `,(0,D.jsx)(`a`,{href:`/approvals`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Approvals`}),` `,`page. Approve there or here.`]})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{onClick:r,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Approve`}),(0,D.jsx)(`button`,{onClick:i,disabled:t,className:`hig-button hig-button-small`,children:`Deny`})]})]})}function Hp({status:e,saving:t,onRepair:n}){if(!e.enabled)return null;let r=e.drift,i=!e.running&&!r;return!r&&!i?null:(0,D.jsx)(`section`,{className:`hig-card hig-card-padded border-[var(--color-decision-ask)]`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(Rp,{color:`var(--color-decision-ask)`,className:`mt-1`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:r?`Autostart unit drifted`:`Service not running`}),(0,D.jsxs)(`p`,{className:`text-[12px] text-[var(--color-fg-2)] mt-1 leading-relaxed`,children:[r?`The installed unit points at an ssg binary that no longer exists (${e.referencedBinary||`unknown`}). It will fail to launch at next login.`:`The autostart unit is installed but the daemon is not currently running.`,` `,`Repair reinstalls/re-kicks the service.`]})]}),(0,D.jsx)(`button`,{onClick:n,disabled:t,className:`hig-button hig-button-small`,children:t?`Working…`:`Repair`})]})})}function Up(){let{status:e,loading:t,error:n,saving:r,flow:i,begin:a,confirmNative:o,approveDashboard:s,denyDashboard:c,cancel:l,refetch:u}=On();if(t&&!e)return(0,D.jsx)(`div`,{className:`py-12 text-center text-[var(--color-fg-3)] text-[12px]`,children:`Reading persistence 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/autostart: `,n??`no response`]}),(0,D.jsx)(`button`,{onClick:u,className:`hig-button hig-button-small`,children:`Retry`})]});let d=e.mechanism===`unsupported`,f=r||i.kind!==`idle`;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:`Persistence`}),(0,D.jsxs)(`p`,{className:`text-[12.5px] text-[var(--color-fg-3)] mt-1 leading-relaxed`,children:[`Make SigmaShake launch on startup and always run on the system. One OS-level service —`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`launchd`}),` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`systemd`}),` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:`Task\xA0Scheduler`}),` — managed from here or via `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg autostart`}),`.`]})]}),(0,D.jsx)(`button`,{onClick:u,className:`hig-button hig-button-small`,children:`Refresh`})]}),d?(0,D.jsx)(`section`,{className:`hig-card hig-card-padded text-[12px]`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(Rp,{color:`var(--color-fg-3)`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-1)]`,children:[`Autostart is not supported on this platform (`,(0,D.jsx)(`span`,{className:`font-mono`,children:e.platform}),`). Start the daemon manually with`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg daemon`}),`.`]})]})}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`section`,{className:`hig-card hig-card-padded flex items-center gap-4`,children:[(0,D.jsx)(zn,{checked:e.enabled,onChange:e=>a(e?`enable`:`disable`),disabled:f,size:`md`,tone:`brand`,label:`Launch on startup and always run`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`div`,{className:`text-[14px] font-semibold text-[var(--color-fg-0)]`,children:`Launch on startup & always running`}),(0,D.jsxs)(`div`,{className:`text-[11.5px] text-[var(--color-fg-3)] mt-0.5`,children:[Lp[e.mechanism]??e.mechanism,e.enabled?` · installed`:` · not installed`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(Rp,{color:Fp[e.health],className:`!w-3 !h-3`}),(0,D.jsx)(`span`,{className:`text-[12px] font-semibold`,style:{color:Fp[e.health]},children:Ip[e.health]})]})]}),(0,D.jsx)(Vp,{flow:i,saving:r,confirmNative:o,approveDashboard:s,denyDashboard:c,cancel:l}),(0,D.jsx)(Hp,{status:e,saving:r,onRepair:()=>a(`repair`)}),(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.jsx)(`h2`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Service status`}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)]`,children:e.platform})]}),(0,D.jsx)(Bp,{k:`Health`,v:Ip[e.health]}),(0,D.jsx)(Bp,{k:`Installed`,v:(0,D.jsx)(zp,{v:e.enabled})}),(0,D.jsx)(Bp,{k:`Loaded`,v:(0,D.jsx)(zp,{v:e.loaded})}),(0,D.jsx)(Bp,{k:`Running`,v:(0,D.jsx)(zp,{v:e.running})}),(0,D.jsx)(Bp,{k:`Binary drift`,v:(0,D.jsx)(zp,{v:e.drift,trueIsGood:!1})}),(0,D.jsx)(Bp,{k:`Mechanism`,v:Lp[e.mechanism]??e.mechanism}),(0,D.jsx)(Bp,{k:`Ask routing`,v:e.askMode===`dashboard`?`dashboard (/approvals queue)`:`native (in-app confirm)`}),(0,D.jsx)(Bp,{k:`Unit`,v:e.unitPath||`—`,mono:!0}),e.referencedBinary&&(0,D.jsx)(Bp,{k:`Installed binary`,v:e.referencedBinary,mono:!0}),e.resolvedBinary&&(0,D.jsx)(Bp,{k:`Current binary`,v:e.resolvedBinary,mono:!0}),(0,D.jsx)(Bp,{k:`Detail`,v:e.message})]})]})]})}var Wp=`https://hub.sigmashake.com/submit-plugin`,Gp=`https://docs.sigmashake.com/plugins/publishing`,Kp=[{cmd:`ssg plugins init my-plugin`,title:`Scaffold`,detail:`Creates plugin.toml plus a src/ template you can edit.`},{cmd:`ssg plugins build`,title:`Build & sign`,detail:`Bundles src/ into dist/<id>-<version>.tar.gz and an Ed25519-signed plugin.json.`},{cmd:`ssg plugins publish`,title:`Publish`,detail:`Pushes the source, cuts a GitHub release for the artifact, and opens the hub submission form prefilled.`}];function qp(){return(0,D.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`a`,{href:`/plugins`,className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-brand)]`,children:`← plugins`}),(0,D.jsx)(`h1`,{className:`mt-2 text-xl font-medium tracking-tight text-[var(--color-fg-0)]`,children:`Publish a plugin`}),(0,D.jsx)(`p`,{className:`mt-1 font-mono text-[12px] text-[var(--color-fg-3)]`,children:`build, sign, and submit a dashboard plugin to hub.sigmashake.com`})]}),(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsx)(`h2`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Build it with the ssg CLI`}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:`Plugins are built, signed, and released from your machine — the CLI runs the whole flow. Run these from your plugin's directory:`}),(0,D.jsx)(`ol`,{className:`mt-3 space-y-3`,children:Kp.map((e,t)=>(0,D.jsxs)(`li`,{className:`flex gap-3`,children:[(0,D.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-[var(--color-line-1)] font-mono text-[11px] text-[var(--color-fg-3)]`,children:t+1}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-[var(--color-fg-1)]`,children:e.title}),(0,D.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-0)] px-2.5 py-1.5 text-xs`,children:(0,D.jsx)(`code`,{className:`font-mono text-[var(--color-fg-1)]`,children:e.cmd})}),(0,D.jsx)(`p`,{className:`mt-1 text-[11px] text-[var(--color-fg-3)]`,children:e.detail})]})]},e.cmd))})]})}),(0,D.jsxs)(`div`,{className:`rounded-sm border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-200`,children:[`First time publishing? Register your signing key with`,` `,(0,D.jsx)(`code`,{className:`font-mono text-amber-100`,children:`ssg keys register`}),` so the hub can verify your plugin's Ed25519 signature against your account.`]}),(0,D.jsx)(J,{children:(0,D.jsxs)(X,{children:[(0,D.jsx)(`h2`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Submit to the marketplace`}),(0,D.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`code`,{className:`font-mono text-[var(--color-fg-2)]`,children:`ssg plugins publish`}),` `,`opens the hub submission form automatically once your release is up. If you've already built your plugin, open the form directly:`]}),(0,D.jsxs)(`a`,{href:Wp,"data-tutorial":`pubplug-submit`,target:`_blank`,rel:`noreferrer`,className:`mt-3 inline-flex items-center gap-1.5 rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-3 py-1.5 text-xs font-medium text-[var(--color-fg-1)] transition-colors hover:border-[var(--color-hig-blue)] hover:text-[var(--color-hig-blue)]`,children:[`Open hub submission form`,(0,D.jsx)(`span`,{"aria-hidden":!0,children:`↗`})]}),(0,D.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--color-fg-4)]`,children:`Submitting needs a GitHub sign-in on hub.sigmashake.com — it opens in a new tab.`})]})}),(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:[`New to plugin authoring? Read the`,` `,(0,D.jsx)(`a`,{href:Gp,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`plugin documentation ↗`}),`.`]})]})}async function Jp(){let e=await fetch(`/api/json/plugins`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}async function Yp(e=``,t={}){let n=new URLSearchParams;e&&n.set(`q`,e),t.category&&n.set(`category`,t.category),t.featured&&n.set(`featured`,`1`),t.sort&&n.set(`sort`,t.sort),t.page&&t.page>1&&n.set(`page`,String(t.page));let r=await fetch(`/api/json/plugins/available?${n.toString()}`,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Xp(){let e=await fetch(`/api/json/plugins/categories`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}async function Zp(){let e=await fetch(`/api/json/license`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}function Qp(e){return e===`pro`||e===`enterprise`?`private`:`public`}async function $p(e,t){let n=await fetch(e,{method:`POST`,headers:{...W(),"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.text(),i=null;if(r)try{i=JSON.parse(r)}catch{i={error:r}}if(!n.ok){let e=i&&typeof i==`object`&&i&&`error`in i&&typeof i.error==`string`?i.error:`HTTP ${n.status}`;throw Error(e)}return i}function em(e){return $p(`/api/json/plugins/install`,{packId:e})}function tm(e){return $p(`/api/json/plugins/uninstall`,{id:e})}function nm(e){return $p(`/api/json/plugins/enable`,{id:e})}function rm(e){return $p(`/api/json/plugins/disable`,{id:e})}var im=5e3,am=200,om=5,sm=12e3,cm={tools:`bg-sky-500/10 text-sky-300 border-sky-500/25`,observability:`bg-violet-500/10 text-violet-300 border-violet-500/25`,productivity:`bg-emerald-500/10 text-emerald-300 border-emerald-500/25`,integrations:`bg-amber-500/10 text-amber-300 border-amber-500/30`,developer:`bg-rose-500/10 text-rose-300 border-rose-500/25`};function lm(e){return e?cm[e]??`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`:`bg-[var(--color-surface-2)] text-[var(--color-fg-3)] border-[var(--color-line-1)]`}function um(e){if(!e)return``;let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}function dm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function fm(e){let t=e.split(/[\s\-_]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function pm({icon:e,name:t,avatarUrl:n,large:r}){let i=r?`h-14 w-14 text-2xl`:`h-10 w-10 text-lg`,a=r?`text-sm`:`text-[11px]`;return e?(0,D.jsx)(`div`,{className:`flex ${i} shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] leading-none`,children:(0,D.jsx)(`span`,{"aria-hidden":!0,children:e})}):n?(0,D.jsx)(`img`,{src:n,alt:``,className:`${i} shrink-0 rounded-md object-cover`,loading:`lazy`}):(0,D.jsx)(`div`,{className:`flex ${i} shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] ${a} font-mono uppercase text-[var(--color-fg-3)]`,children:fm(t)})}function mm(){return(0,D.jsxs)(`svg`,{"aria-label":`Verified publisher`,width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,className:`inline-block shrink-0 text-sky-400`,children:[(0,D.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5.5`,stroke:`currentColor`,strokeWidth:`1`}),(0,D.jsx)(`path`,{d:`M3.5 6l1.8 1.8 3.2-3.6`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function hm(){return(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex animate-pulse items-start gap-3`,children:[(0,D.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-md bg-[var(--color-surface-2)]`}),(0,D.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,D.jsx)(`div`,{className:`h-3 w-1/3 rounded bg-[var(--color-surface-2)]`}),(0,D.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-[var(--color-surface-2)]`}),(0,D.jsx)(`div`,{className:`h-3 w-1/4 rounded bg-[var(--color-surface-2)]`})]}),(0,D.jsx)(`div`,{className:`h-7 w-20 shrink-0 rounded bg-[var(--color-surface-2)]`})]})})})}function gm({license:e}){let t=e?.tier??`unlicensed`,n=Qp(t),r=t===`pro`||t===`enterprise`,i=e?.tier_label??`Free (Starter)`;return(0,D.jsxs)(`div`,{className:`rounded-lg border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3 text-xs`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-medium text-[var(--color-fg-2)]`,children:`Publishing visibility`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[`Plan: `,i]}),(0,D.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-sm border px-1.5 py-px font-mono text-[10px] uppercase tracking-wide ${n===`public`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`:`border-amber-500/30 bg-amber-500/10 text-amber-300`}`,children:n===`public`?`🌐 public by default`:`🔒 private by default`})]}),(0,D.jsxs)(`p`,{className:`mt-1.5 leading-relaxed text-[var(--color-fg-3)]`,children:[r?`Plugins and rulesets you publish stay private to protect your governance IP. Share one publicly with `:`Plugins and rulesets you publish go to the public marketplace so others can install and fork them. Keep one private with `,(0,D.jsx)(`code`,{className:`rounded bg-[var(--color-surface-2)] px-1 py-px font-mono text-[10px]`,children:r?`ssg plugins publish --public`:`ssg plugins publish --private`}),r?`. A confirmation is required before anything becomes public.`:`.`]})]})}function _m(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)({}),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(!0),[x,S]=(0,_.useState)(`browse`),[C,w]=(0,_.useState)(`all`),[T,E]=(0,_.useState)(`popular`),[O,k]=(0,_.useState)([]),[ee,A]=(0,_.useState)(null),{features:j,setFeature:M}=en(),N=(0,_.useMemo)(()=>qt.filter(e=>j[e.id]).length,[j]),P=(0,_.useRef)(null),F=(0,_.useCallback)((e,t)=>{h({kind:e,message:t}),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{h(null),P.current=null},im)},[]),I=(0,_.useCallback)(e=>{let t=`ssg plugins fork ${e}`,n=navigator.clipboard;n?.writeText?n.writeText(t).then(()=>F(`ok`,`Copied: ${t}`)).catch(()=>F(`ok`,t)):F(`ok`,t)},[F]);(0,_.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]),(0,_.useEffect)(()=>{let e=setTimeout(()=>d(c),am);return()=>clearTimeout(e)},[c]),(0,_.useEffect)(()=>{Xp().then(e=>k(e.categories)).catch(()=>{})},[]),(0,_.useEffect)(()=>{Zp().then(A).catch(()=>{})},[]);let L=(0,_.useCallback)(async()=>{v(!0);try{let e=await Jp();t(e.plugins),r(e.errors)}catch(e){F(`err`,e instanceof Error?e.message:String(e))}finally{v(!1)}},[F]),te=(0,_.useCallback)(async(e,t,n)=>{b(!0),s(null);try{a((await Yp(e,{category:t===`all`?void 0:t,sort:n})).data??[])}catch(e){s(e instanceof Error?e.message:String(e)),a([])}finally{b(!1)}},[]);(0,_.useEffect)(()=>{L()},[L]),(0,_.useEffect)(()=>{te(u,C,T)},[u,C,T,te]);let ne=(0,_.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),R=(0,_.useMemo)(()=>e.filter(e=>e.enabled).length,[e]),z=async(e,t,n,r)=>{p(n=>({...n,[e]:t}));try{await n(),F(`ok`,r),await Promise.all([L(),te(u,C,T)])}catch(e){F(`err`,e instanceof Error?e.message:String(e))}finally{p(t=>({...t,[e]:void 0}))}},B=(0,_.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,t.icon);return e},[i]),re=(0,_.useMemo)(()=>i.filter(e=>e.featured),[i]),ie=C===`all`&&re.length>0;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-5 p-6`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Plugin Marketplace`}),(0,D.jsxs)(`p`,{className:`max-w-2xl text-sm text-[var(--color-fg-3)]`,children:[`Extend the dashboard with Ed25519-signed plugins from`,` `,(0,D.jsx)(`a`,{href:`https://hub.sigmashake.com`,className:`text-[var(--color-hig-blue)] hover:underline`,target:`_blank`,rel:`noreferrer`,children:`hub.sigmashake.com`}),`. Each plugin is hash-verified and signature-checked before extraction; disable to hide from the sidebar without uninstalling.`]})]}),(0,D.jsx)(`a`,{href:`/publish-plugin`,className:`text-xs text-[var(--color-hig-blue)] hover:underline`,children:`Publish a plugin →`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{"data-tutorial":`plugins-tabs`,role:`tablist`,className:`inline-flex overflow-hidden rounded-md border border-[var(--color-line-1)]`,children:[(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`browse`,className:`px-3 py-1.5 text-xs transition-colors ${x===`browse`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`browse`),children:[`Browse`,i.length>0?` · ${i.length}`:``]}),(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`installed`,className:`border-l border-[var(--color-line-1)] px-3 py-1.5 text-xs transition-colors ${x===`installed`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`installed`),children:[`Installed · `,e.length,e.length>0&&R<e.length&&(0,D.jsxs)(`span`,{className:`ml-1 text-amber-300`,children:[`(`,e.length-R,` off)`]})]}),(0,D.jsxs)(`button`,{role:`tab`,"aria-selected":x===`builtin`,className:`border-l border-[var(--color-line-1)] px-3 py-1.5 text-xs transition-colors ${x===`builtin`?`bg-[var(--color-surface-2)] text-[var(--color-fg-1)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,onClick:()=>S(`builtin`),title:`Bundled features that behave like plugins — opt-in`,children:[`Built-in · `,N,`/`,qt.length]})]}),x===`browse`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`relative ml-auto`,children:[(0,D.jsx)(`input`,{"data-tutorial":`plugins-search`,type:`search`,placeholder:`Search plugins…`,className:`w-64 rounded-sm border border-[var(--color-line-1)] bg-transparent px-2 py-1 text-xs focus:border-[var(--color-hig-blue)] focus:outline-none`,value:c,onChange:e=>l(e.target.value),"aria-label":`Search plugins`}),c&&(0,D.jsx)(`button`,{className:`absolute right-1 top-1/2 -translate-y-1/2 px-1 text-[var(--color-fg-4)] hover:text-[var(--color-fg-1)]`,onClick:()=>l(``),"aria-label":`Clear search`,children:`×`})]}),i.length>om&&(0,D.jsxs)(`select`,{value:T,onChange:e=>E(e.target.value),"aria-label":`Sort plugins`,className:`rounded-sm border border-[var(--color-line-1)] bg-[var(--color-surface-1)] px-2 py-1 text-xs text-[var(--color-fg-2)] focus:outline-none`,children:[(0,D.jsx)(`option`,{value:`popular`,children:`Popular`}),(0,D.jsx)(`option`,{value:`recent`,children:`Recent`}),(0,D.jsx)(`option`,{value:`name`,children:`Name`})]})]}),x===`installed`&&(0,D.jsx)(q,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>void L(),children:`Refresh`})]}),x===`browse`&&O.length>0&&(0,D.jsxs)(`div`,{"data-tutorial":`plugins-categories`,className:`flex flex-wrap gap-1.5`,role:`group`,"aria-label":`Filter by category`,children:[(0,D.jsx)(`button`,{onClick:()=>w(`all`),className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${C===`all`?`border-[var(--color-hig-blue)] bg-sky-500/10 text-sky-300`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,"aria-pressed":C===`all`,children:`All`}),O.map(e=>(0,D.jsxs)(`button`,{onClick:()=>w(C===e.name?`all`:e.name),className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] font-medium capitalize transition-colors ${C===e.name?`border-transparent ${lm(e.name)}`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,"aria-pressed":C===e.name,children:[e.name,(0,D.jsx)(`span`,{className:`text-[10px] opacity-60`,children:e.count})]},e.name))]})]}),m&&(0,D.jsx)(`div`,{role:`status`,className:m.kind===`ok`?`rounded-md border border-emerald-700/40 bg-emerald-900/20 px-3 py-2 text-xs text-emerald-200`:`rounded-md border border-red-700/40 bg-red-900/20 px-3 py-2 text-xs text-red-200`,children:m.message}),(0,D.jsx)(gm,{license:ee}),n.length>0&&(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsxs)(`div`,{className:`text-xs uppercase tracking-wider text-amber-300`,children:[`Load errors (`,n.length,`)`]})}),(0,D.jsx)(X,{children:(0,D.jsx)(`ul`,{className:`space-y-1 text-xs text-amber-100/80`,children:n.map(e=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`span`,{className:`font-mono text-amber-300`,children:e.id}),` ·`,` `,e.error]},e.id))})})]}),x===`browse`&&(0,D.jsx)(ym,{loading:y,error:o,available:i,featuredPlugins:re,showFeatured:ie,installedIds:ne,busy:f,query:u,selectedCategory:C,onInstall:e=>z(e.id,`install`,()=>em(e.id),`Installed ${e.name}`),onRetry:()=>void te(u,C,T),onFork:e=>I(e.id)}),x===`installed`&&(0,D.jsx)(xm,{loading:g,installed:e,iconById:B,busy:f,onEnable:e=>z(e.id,`toggle`,()=>nm(e.id),`Enabled ${e.name}`),onDisable:e=>z(e.id,`toggle`,()=>rm(e.id),`Disabled ${e.name}`),onUninstall:e=>z(e.id,`uninstall`,()=>tm(e.id),`Uninstalled ${e.name}`)}),x===`builtin`&&(0,D.jsx)(bm,{features:j,onToggle:(e,t)=>{M(e,t);let n=qt.find(t=>t.id===e),r=n?n.name:e;F(`ok`,t?`Enabled ${r}`:`Disabled ${r}`)}})]})}function vm({plugin:e,installed:t,busy:n,onInstall:r,onFork:i}){return(0,D.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col gap-2 rounded-lg border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsx)(pm,{name:e.name,icon:e.icon,large:!0}),e.verified&&(0,D.jsx)(`span`,{className:`mt-0.5`,children:(0,D.jsx)(mm,{})})]}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,D.jsx)(`span`,{className:`truncate text-sm font-semibold leading-tight`,children:e.name}),e.category&&(0,D.jsx)(`span`,{className:`inline-flex w-fit items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${lm(e.category)}`,children:e.category})]}),e.description&&(0,D.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-relaxed text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-[var(--color-fg-4)]`,children:[(0,D.jsxs)(`span`,{children:[dm(e.install_count),` installs`]}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`hover:text-[var(--color-hig-blue)] hover:underline`,title:`Copy: ssg plugins fork ${e.id}`,children:`Fork`})]}),(0,D.jsx)(q,{variant:t?`ghost`:`primary`,size:`sm`,disabled:t||n,onClick:r,children:t?`Installed`:n?`Installing…`:`Install`})]})]})}function ym({loading:e,error:t,available:n,featuredPlugins:r,showFeatured:i,installedIds:a,busy:o,query:s,selectedCategory:c,onInstall:l,onRetry:u,onFork:d}){return e&&n.length===0?(0,D.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,D.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-1`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(`div`,{className:`h-40 w-56 shrink-0 animate-pulse rounded-lg bg-[var(--color-surface-2)]`},t))}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:Array.from({length:4}).map((e,t)=>(0,D.jsx)(hm,{},t))})]}):t?(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,D.jsx)(`div`,{className:`text-sm font-medium text-[var(--color-fg-1)]`,children:`Hub unreachable`}),(0,D.jsx)(`div`,{className:`text-xs text-red-300`,children:t}),(0,D.jsx)(q,{variant:`secondary`,size:`sm`,onClick:u,children:`Retry`})]})})}):n.length===0?(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsx)(`div`,{className:`flex flex-col gap-2 py-4 text-sm text-[var(--color-fg-3)]`,children:s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:[`No plugins match "`,s,`".`]}),(0,D.jsx)(`div`,{children:`Try a different search term, or browse the full catalog by clearing the search box.`})]}):c===`all`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins on the hub yet.`}),(0,D.jsxs)(`div`,{children:[`The marketplace is brand new.`,` `,(0,D.jsx)(`a`,{href:`/publish-plugin`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Publish the first plugin →`})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins in this category yet.`}),(0,D.jsx)(`div`,{children:`Try another category or view all plugins.`})]})})})}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[i&&(0,D.jsxs)(`section`,{"data-tutorial":`plugins-featured`,children:[(0,D.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-[var(--color-fg-4)]`,children:`Featured`}),(0,D.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:r.map(e=>(0,D.jsx)(vm,{plugin:e,installed:a.has(e.id),busy:o[e.id]===`install`,onInstall:()=>l(e),onFork:()=>d(e)},e.id))})]}),(0,D.jsxs)(`section`,{children:[i&&(0,D.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-[var(--color-fg-4)]`,children:`All Plugins`}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:n.map(e=>{let t=a.has(e.id),n=o[e.id]===`install`;return(0,D.jsx)(J,{variant:t?`default`:`interactive`,children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(pm,{name:e.name,icon:e.icon}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.verified&&(0,D.jsx)(mm,{}),(0,D.jsxs)(K,{variant:`outline`,children:[`v`,e.version]}),t&&(0,D.jsx)(K,{variant:`green`,children:`Installed`})]}),e.category&&(0,D.jsx)(`div`,{className:`mt-1`,children:(0,D.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${lm(e.category)}`,children:e.category})}),e.description&&(0,D.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-[var(--color-fg-4)]`,children:[e.author_github&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{children:[`by`,` `,(0,D.jsxs)(`a`,{href:`https://github.com/${e.author_github}`,target:`_blank`,rel:`noreferrer`,className:`hover:text-[var(--color-fg-2)] hover:underline`,children:[`@`,e.author_github]})]}),(0,D.jsx)(`span`,{children:`·`})]}),(0,D.jsxs)(`span`,{children:[dm(e.install_count),` installs`]}),e.platforms.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{children:`·`}),(0,D.jsx)(`span`,{title:`Supports ${e.platforms.join(`, `)}`,children:e.platforms.length===1?e.platforms[0]:`${e.platforms.length} platforms`})]})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,D.jsx)(q,{variant:t?`ghost`:`primary`,size:`sm`,disabled:t||n,onClick:()=>l(e),children:t?`Installed`:n?`Installing…`:`Install`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`hover:text-[var(--color-hig-blue)] hover:underline`,title:`Copy: ssg plugins fork ${e.id}`,children:`Fork`}),(0,D.jsx)(`a`,{href:`https://hub.sigmashake.com/plugin/${e.id}`,target:`_blank`,rel:`noreferrer`,className:`hover:text-[var(--color-hig-blue)] hover:underline`,children:`View source`})]})]})]})})},e.id)})})]})]})}function bm({features:e,onToggle:t}){return(0,D.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,D.jsx)(`p`,{className:`text-xs text-[var(--color-fg-3)]`,children:`Bundled with the dashboard but opt-in. These features ship inside the ssg binary and run in-process; they don't need a separate install but stay dormant until enabled here.`}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:qt.map(n=>{let r=e[n.id];return(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-[var(--color-surface-2)] text-lg leading-none`,children:(0,D.jsx)(`span`,{"aria-hidden":!0,children:n.icon})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:n.name}),(0,D.jsx)(K,{variant:`gray`,children:`Built-in`}),r?(0,D.jsx)(K,{variant:`green`,children:`Enabled`}):(0,D.jsx)(K,{variant:`amber`,children:`Disabled`})]}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-[var(--color-fg-3)]`,children:n.description}),(0,D.jsx)(`div`,{className:`mt-2 text-[11px] text-[var(--color-fg-4)]`,children:`No download · runs in your browser`})]}),(0,D.jsx)(`div`,{className:`shrink-0`,children:(0,D.jsx)(q,{variant:r?`ghost`:`primary`,size:`sm`,onClick:()=>t(n.id,!r),children:r?`Disable`:`Enable`})})]})})},n.id)})})]})}function xm({loading:e,installed:t,iconById:n,busy:r,onEnable:i,onDisable:a,onUninstall:o}){let[s,c]=(0,_.useState)(null),l=(0,_.useRef)(null),u=(0,_.useCallback)(e=>{c(e),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>c(null),sm)},[]),d=(0,_.useCallback)(()=>{l.current&&clearTimeout(l.current),l.current=null,c(null)},[]);return(0,_.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),e&&t.length===0?(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:Array.from({length:2}).map((e,t)=>(0,D.jsx)(hm,{},t))}):t.length===0?(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 py-4 text-sm text-[var(--color-fg-3)]`,children:[(0,D.jsx)(`div`,{className:`font-medium text-[var(--color-fg-1)]`,children:`No plugins installed yet.`}),(0,D.jsx)(`div`,{children:`Switch to the Browse tab to discover plugins from the hub.`})]})})}):(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:t.map(e=>{let t=r[e.id]===`toggle`,c=r[e.id]===`uninstall`,l=s===e.id;return(0,D.jsx)(J,{children:(0,D.jsx)(X,{children:(0,D.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,D.jsx)(pm,{name:e.name,icon:e.icon??n.get(e.id)??null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,D.jsxs)(K,{variant:`outline`,children:[`v`,e.version]}),e.enabled?(0,D.jsx)(K,{variant:`green`,children:`Enabled`}):(0,D.jsx)(K,{variant:`amber`,children:`Disabled`})]}),e.category&&(0,D.jsx)(`div`,{className:`mt-1`,children:(0,D.jsx)(`span`,{className:`inline-flex items-center rounded-sm border px-1 py-px text-[9px] font-mono font-medium uppercase tracking-wide ${lm(e.category)}`,children:e.category})}),e.description&&(0,D.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--color-fg-3)]`,children:e.description}),(0,D.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-[var(--color-fg-4)]`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:e.id}),(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{title:e.signing_fingerprint,children:[`sig`,` `,(0,D.jsxs)(`span`,{className:`font-mono`,children:[e.signing_fingerprint.slice(0,12),`…`]})]}),(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{title:e.installed_at,children:[`installed `,um(e.installed_at)]}),e.nav.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{children:`·`}),(0,D.jsxs)(`span`,{children:[e.nav.length,` nav`,` `,e.nav.length===1?`entry`:`entries`]})]})]}),(e.homepage_url||e.repo_url)&&(0,D.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px]`,children:[e.homepage_url&&(0,D.jsx)(`a`,{href:e.homepage_url,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Homepage`}),e.repo_url&&(0,D.jsx)(`a`,{href:e.repo_url,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Repository`})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1.5`,children:[e.enabled?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(q,{variant:`primary`,size:`sm`,onClick:()=>{window.location.href=`/plugins/${e.id}`},children:`Open`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,disabled:t,onClick:()=>a(e),children:t?`Disabling…`:`Disable`})]}):(0,D.jsx)(q,{variant:`secondary`,size:`sm`,disabled:t,onClick:()=>i(e),children:t?`Enabling…`:`Enable`}),c?(0,D.jsx)(q,{variant:`ghost`,size:`sm`,disabled:!0,children:`Removing…`}):l?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>{d(),o(e)},children:`Confirm remove`}),(0,D.jsx)(q,{variant:`ghost`,size:`sm`,onClick:d,children:`Cancel`})]}):(0,D.jsx)(q,{variant:`ghost`,size:`sm`,title:`Remove this plugin from disk`,onClick:()=>u(e.id),children:`Uninstall`})]})]})})},e.id)})})}function Sm(e){return e<1e6?`${(e/1e3).toFixed(0)}µs`:e<1e9?`${(e/1e6).toFixed(1)}ms`:`${(e/1e9).toFixed(2)}s`}function Cm(e){return new Date(e*1e3).toLocaleString()}var wm={critical:`red`,high:`red`,medium:`amber`,low:`blue`},Tm={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 Em(){let{data:e}=U(`/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`,{"data-tutorial":`profile-metrics`,className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[{label:`evals analyzed`,value:String(t.analyzed_evals)},{label:`median (inside)`,value:Sm(t.median_eval_ns)},{label:`p99 (inside)`,value:Sm(t.p99_eval_ns)},{label:`bottleneck`,value:t.bottleneck??`—`}].map(e=>(0,D.jsx)(Vf,{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)(Uf,{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:Sm(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 `,Sm(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 ${Tm[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:wm[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:Cm(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 `,Sm(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 Dm={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 Om(e){return e.value==null?e.description?e.description:`[${e.type}]`:String(e.value)}function km(){let e=vp(),[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)(Wf,{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)(pp,{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)(Gf,{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)] ${Dm[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(Om).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 Am({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 jm(){let[e,t]=(0,_.useState)(`eval`);return(0,D.jsxs)(`div`,{className:`space-y-0`,children:[(0,D.jsxs)(`div`,{"data-tutorial":`profile-tabs`,className:`flex items-center border-b border-[var(--color-line-0)] mb-5`,children:[(0,D.jsx)(Am,{active:e===`eval`,onClick:()=>t(`eval`),children:`eval profile`}),(0,D.jsx)(Am,{active:e===`inspector`,onClick:()=>t(`inspector`),children:`runtime inspector`})]}),e===`eval`?(0,D.jsx)(Em,{}):(0,D.jsx)(km,{})]})}var Mm=[{id:`destructive-ops`,title:`Destructive Operations`,description:`Commands that delete, overwrite, truncate, or irreversibly destroy files, data, or infrastructure.`,icon:`💥`,color:`#FF3B30`,attack:{id:`TA0040`,name:`Impact`},d3fend:`Harden`,security:!0,order:1},{id:`privilege-escalation`,title:`Privilege Escalation`,description:`sudo, permission and ownership changes, setuid manipulation, and capability grants.`,icon:`⬆️`,color:`#FF9500`,attack:{id:`TA0004`,name:`Privilege Escalation`},d3fend:`Isolate`,security:!0,order:2},{id:`code-execution`,title:`Untrusted Code Execution`,description:`Piping remote content into a shell, dynamic interpreters, and execution of unvetted code.`,icon:`⚙️`,color:`#FFCC00`,attack:{id:`TA0002`,name:`Execution`},d3fend:`Harden`,security:!0,order:3},{id:`credential-access`,title:`Credential & Secret Access`,description:`Reads of secrets, private keys, tokens, .env files, and cloud credentials.`,icon:`🔑`,color:`#AF52DE`,attack:{id:`TA0006`,name:`Credential Access`},d3fend:`Detect`,security:!0,order:4},{id:`network-egress`,title:`Network Egress & Exfiltration`,description:`Outbound network calls, uploads, reverse shells, and data leaving the machine.`,icon:`🌐`,color:`#5AC8FA`,attack:{id:`TA0010`,name:`Exfiltration`},d3fend:`Isolate`,security:!0,order:5},{id:`supply-chain`,title:`Supply Chain & Dependencies`,description:`Package installs, lockfile edits, registry changes, and dependency tampering.`,icon:`📦`,color:`#34C759`,attack:{id:`TA0042`,name:`Resource Development`},d3fend:`Harden`,security:!0,order:6},{id:`process-control`,title:`Process & System Control`,description:`Killing processes, daemonizing, service control, and resource exhaustion.`,icon:`🔌`,color:`#FF6482`,attack:{id:`TA0003`,name:`Persistence`},d3fend:`Isolate`,security:!0,order:7},{id:`version-control`,title:`Version Control Integrity`,description:`Force pushes, history rewrites, branch deletion, and git remote safety.`,icon:`🔀`,color:`#30B0C7`,attack:{id:`TA0005`,name:`Defense Evasion`},d3fend:`Harden`,security:!0,order:8},{id:`source-integrity`,title:`Source & Config Integrity`,description:`Edits to protected, generated, CI/CD, or governance-critical files.`,icon:`📐`,color:`#A2845E`,attack:{id:`TA0003`,name:`Persistence`},d3fend:`Harden`,security:!0,order:9},{id:`data-handling`,title:`Sensitive Data Handling`,description:`Database mutations, PII handling, and redaction of sensitive output.`,icon:`🗄️`,color:`#BF5AF2`,attack:{id:`TA0009`,name:`Collection`},d3fend:`Detect`,security:!0,order:10},{id:`agent-hygiene`,title:`Agent Hygiene & Efficiency`,description:`Tool-use best practices, token efficiency, and prompt hygiene — operational, not a security control.`,icon:`🧭`,color:`#8E8E93`,attack:null,d3fend:`Model`,security:!1,order:11},{id:`uncategorized`,title:`Uncategorized`,description:`Rules that have not declared a category.`,icon:`▫️`,color:`#636366`,attack:null,d3fend:`Model`,security:!1,order:99}],Nm=new Map(Mm.map(e=>[e.id,e]));Mm.filter(e=>e.id!==`uncategorized`).map(e=>e.id);function Pm(e){return typeof e==`string`&&e!==`uncategorized`&&Nm.has(e)}function Fm(e){return e!==void 0&&Nm.get(e)||Nm.get(`uncategorized`)}var Im=[{token:`destructive`,category:`destructive-ops`},{token:`exfil`,category:`network-egress`},{token:`credential`,category:`credential-access`},{token:`secret`,category:`credential-access`},{token:`privilege`,category:`privilege-escalation`},{token:`privesc`,category:`privilege-escalation`},{token:`powergate`,category:`process-control`},{token:`process`,category:`process-control`},{token:`powersafety`,category:`process-control`},{token:`injection`,category:`code-execution`},{token:`untrusted`,category:`code-execution`},{token:`supply`,category:`supply-chain`},{token:`dependenc`,category:`supply-chain`},{token:`npm`,category:`supply-chain`},{token:`pnpm`,category:`supply-chain`},{token:`cargo`,category:`supply-chain`},{token:`cicd`,category:`supply-chain`},{token:`publish`,category:`supply-chain`},{token:`git`,category:`version-control`},{token:`network`,category:`network-egress`},{token:`egress`,category:`network-egress`},{token:`database`,category:`data-handling`},{token:`sql`,category:`data-handling`},{token:`critical`,category:`source-integrity`},{token:`drm`,category:`source-integrity`},{token:`config`,category:`source-integrity`},{token:`integrity`,category:`source-integrity`},{token:`infra`,category:`source-integrity`},{token:`agent`,category:`agent-hygiene`},{token:`efficiency`,category:`agent-hygiene`},{token:`hygiene`,category:`agent-hygiene`}];function Lm(e,t){let n=(t??e.source_file??``).toLowerCase(),r=n?n.split(/[\\/]/).pop()??n:``,i=`${e.id.toLowerCase()} ${r}`;for(let e of Im)if(i.includes(e.token))return e.category;return e.target===`agent`?`agent-hygiene`:e.target===`network`?`network-egress`:`uncategorized`}function Rm(e,t){return e.category!==void 0&&Pm(e.category)?e.category:Lm(e,t)}function zm(e,t){let n=new Map;for(let e of Mm)n.set(e.id,{id:e.id,meta:e,total:0,enabled:0,enabledShell:0,decisions:{},status:`gap`});let r=0;for(let i of e){let e=Rm(i,t?.(i)),a=n.get(e);a.total++,e===`uncategorized`&&r++,i.enabled!==!1&&(a.enabled++,a.decisions[i.decision]=(a.decisions[i.decision]??0)+1,(i.target===`execution`||i.target===`any`)&&a.enabledShell++)}for(let e of n.values())e.status=e.enabled>0?`covered`:e.total>0?`inactive`:`gap`;let i=[...n.values()].sort((e,t)=>e.meta.order-t.meta.order),a=i.filter(e=>e.meta.security&&e.id!==`uncategorized`);return{categories:i,covered:a.filter(e=>e.status===`covered`).length,total:a.length,uncategorized:r}}var Bm=new Set([`block`,`ask`,`force`,`deny`]),Vm=[`rules-changed`],Hm=[`block`,`ask`,`log`,`allow`,`force`,`shadow`],Um={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`,ambient:`text-teal-300`},Wm={block:`#fca5a5`,deny:`#fca5a5`,ask:`#7dd3fc`,allow:`#6ee7b7`,log:`#a8a29e`,force:`#fcd34d`,shadow:`#c4b5fd`},Gm=[{value:`today`,label:`today`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`all`,label:`all`}],Km=5e3;function qm(e,t){return t<=0?e:`${e}${e.includes(`?`)?`&`:`?`}_t=${t}`}async function Jm(e,t){await fetch(`/api/rules/toggle`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t})})}async function Ym(e,t,n){await fetch(`/api/rules/update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({ruleId:e,file:t,decision:n})})}async function Xm(e,t){return fetch(`/api/rules/bulk-set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e,enabled:t})}).then(e=>e.json())}async function Zm(e,t){return fetch(`/api/rules/bulk-update-decision`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e,decision:t})}).then(e=>e.json())}async function Qm(e){return fetch(`/api/rules/bulk-delete`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({targets:e})}).then(e=>e.json())}async function $m(e,t={}){return fetch(`/api/rules/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify(t)}).then(e=>e.json())}function eh(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 th(e,t,n,r){let i=Array(t).fill(0);if(!e||e.length===0)return i;let a=Date.now(),o=a-n,s=n/t;for(let n of e){let e=n.timestamp*1e3;if(e<o||e>a||r&&!r(n))continue;let c=Math.min(t-1,Math.floor((e-o)/s));i[c]+=1}return i}function nh({active:e}){return(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsxs)(`span`,{className:`relative inline-flex h-2 w-2`,children:[e&&(0,D.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400/60`}),(0,D.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full ${e?`bg-emerald-400`:`bg-[var(--color-fg-4)]`}`})]}),(0,D.jsx)(`span`,{className:e?`text-emerald-300`:`text-[var(--color-fg-4)]`,children:e?`live`:`paused`})]})}function rh({mode:e,onChange:t}){return(0,D.jsxs)(`div`,{className:`flex items-center text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm overflow-hidden`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`newcomer`),className:`px-2 py-1 cursor-pointer transition-colors ${e===`newcomer`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Hide advanced controls (firewall, raw source, audit, AI hints)`,children:`simple`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`pro`),className:`px-2 py-1 cursor-pointer transition-colors border-l border-[var(--color-line-1)] ${e===`pro`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,title:`Show everything: top-rules chart, performance, firewall, audit trails, raw source, curl recipes`,children:`advanced`})]})}function ih({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)(zn,{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 ah(){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`,...W()},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 oh({perf:e,triggers:t,decisionAggregates:n,livePoll:r,onTogglePoll:i,statsWindow:a,onWindowChange:o,mode:s,onModeChange:c}){let l=t?.evalsLast60s??0,u=t?.evalsLastHour??0,d=(0,_.useMemo)(()=>th(t?.rows,30,3600*1e3),[t?.rows]),f=(0,_.useMemo)(()=>th(t?.rows,30,3600*1e3,e=>Bm.has(e.decision)),[t?.rows]),p={allow:n.hits.allow??0,block:n.hits.block??0,ask:n.hits.ask??0,log:n.hits.log??0,force:n.hits.force??0,shadow:n.hits.shadow??0},m=Object.values(p).reduce((e,t)=>e+t,0),h=e?.totalRules??0,g=e?.activeRules??0,v=h>0?g/h*100:0,y=l/60;return(0,D.jsx)(J,{className:`border-[var(--color-line-1)]`,children:(0,D.jsxs)(X,{className:`px-4 py-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`rules active`}),(0,D.jsxs)(`div`,{className:`font-mono text-2xl text-[var(--color-fg-0)] tabular-nums leading-none mt-0.5`,children:[(0,D.jsx)(Kc,{value:g}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] text-base`,children:[`/`,h]})]}),(0,D.jsxs)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:[v.toFixed(0),`% on`]})]}),(0,D.jsx)(`div`,{className:`h-12 w-px bg-[var(--color-line-1)] hidden md:block`}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`evals · last 60s`}),(0,D.jsx)(nh,{active:r})]}),(0,D.jsx)(`div`,{className:`font-mono text-2xl text-emerald-300 tabular-nums leading-none mt-0.5`,children:(0,D.jsx)(Kc,{value:l,curve:`spring`})}),(0,D.jsxs)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:[`~`,y.toFixed(1),`/s`]})]}),(0,D.jsx)(`div`,{className:`h-12 w-px bg-[var(--color-line-1)] hidden md:block`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`overline text-[10px]`,children:`last hour`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,D.jsx)(`span`,{className:`font-mono text-2xl text-[var(--color-fg-1)] tabular-nums leading-none`,children:(0,D.jsx)(Kc,{value:u})}),(0,D.jsx)(Jc,{data:d,width:120,height:32,color:`var(--color-brand)`})]}),(0,D.jsx)(`div`,{className:`overline text-[10px] mt-1 text-[var(--color-fg-3)]`,children:`evals · 2-min buckets`})]}),(0,D.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,D.jsx)(rh,{mode:s,onChange:c}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`text-[10px] font-mono uppercase tracking-wider px-2 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer transition-colors`,title:r?`Pause auto-refresh`:`Resume auto-refresh`,children:r?`⏸ pause`:`▶ resume`}),(0,D.jsx)(`div`,{className:`flex items-center text-[10px] font-mono uppercase tracking-wider border border-[var(--color-line-1)] rounded-sm`,children:Gm.map((e,t)=>(0,D.jsx)(`button`,{onClick:()=>o(e.value),className:`px-1.5 py-1 cursor-pointer transition-colors ${t>0?`border-l border-[var(--color-line-1)]`:``} ${a===e.value?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)]`}`,children:e.label},e.value))})]})]}),(m>0||f.some(e=>e>0))&&(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1.4fr_1fr] gap-4 pt-2 border-t border-[var(--color-line-0)]`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,D.jsxs)(`span`,{className:`overline text-[10px]`,children:[`decision mix · `,a]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[m.toLocaleString(),` hits`]})]}),(0,D.jsx)(qc,{counters:p,showLegend:!0})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`block/ask/force · last hour`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-amber-300 tabular-nums`,children:[f.reduce((e,t)=>e+t,0),` actionable`]})]}),(0,D.jsx)(Jc,{data:f,width:400,height:48,color:`#fca5a5`})]})]})]})})}function sh({perf:e}){if(!e)return null;let t=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:`avg eval`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm tabular-nums ${t}`,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 ch({stats:e,ruleIndex:t,triggers:n,statsWindow:r,onJump:i}){let a=(0,_.useMemo)(()=>{let r=Object.entries(e).filter(([,e])=>e.hits>0).sort(([,e],[,t])=>t.hits-e.hits).slice(0,10),i=r[0]?.[1].hits??1;return r.map(([e,r])=>{let a=t.get(e),o=th(n,20,3600*1e3,t=>t.ruleId===e);return{id:e,stat:r,entry:a,pct:r.hits/i*100,sparkData:o,color:a?Wm[a.rule.decision]??`#a8a29e`:`#a8a29e`}})},[e,t,n]);return a.length===0?(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`px-3 py-3`,children:[(0,D.jsxs)(`div`,{className:`overline text-[10px] mb-1`,children:[`top rules · `,r]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:`no rules have fired in this window yet`})]})}):(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`px-3 py-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsxs)(`span`,{className:`overline text-[10px]`,children:[`top rules · `,r]}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[`top `,a.length,` · click to jump`]})]}),(0,D.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`w-full text-left group cursor-pointer`,children:[(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 ${e.entry?Um[e.entry.rule.decision]??`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:e.entry?.rule.decision??`—`}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-1)] group-hover:text-[var(--color-fg-0)] truncate flex-1 min-w-0`,children:e.id}),(0,D.jsx)(Jc,{data:e.sparkData,width:60,height:16,color:e.color}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-1)] tabular-nums shrink-0 w-10 text-right`,children:e.stat.hits}),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-14 text-right`,children:[e.stat.avgDurationMs.toFixed(1),`ms`]}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)] tabular-nums shrink-0 w-14 text-right`,children:eh(e.stat.lastSeen)})]}),(0,D.jsx)(`div`,{className:`relative h-1 mt-1 mb-1 bg-[var(--color-surface-2)] rounded-sm overflow-hidden`,children:(0,D.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-sm transition-[width] duration-500 ease-out`,style:{width:`${e.pct}%`,background:e.color,opacity:.6}})})]},e.id))})]})})}function lh({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 $m(`disable-all`):e===`enable`?await $m(`enable-all`):e===`reset`?await $m(`reset-db`):await $m(`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/`}),`. Reset DB clears the rules table in the database (audit log + cost history are kept) and re-imports your `,(0,D.jsx)(`code`,{children:`.rules`}),` files — use it to flush stale or phantom rows a file sync won't remove.`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[a===`disable`?(0,D.jsx)(uh,{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)(uh,{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)(uh,{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`}),a===`reset`?(0,D.jsx)(uh,{onConfirm:()=>void s(`reset`),onCancel:()=>o(null),tone:`amber`,label:`reset rules DB`,disabled:r!==null}):(0,D.jsx)(`button`,{onClick:()=>o(`reset`),disabled:r!==null,title:`Clear the rules table in the database and re-import from .rules files. Audit log + cost history are preserved.`,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===`reset`?`resetting…`:`reset DB`})]})]})})})}function uh({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 dh({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 ${Um[a]??`text-[var(--color-fg-2)]`}`,children:Hm.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)(uh,{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 fh({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 ${Um[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:eh(e.timestamp)})]},e.id))})]})}function ph(){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
30
30
  curl :7901/api/json/rules
31
31
  curl :7901/api/json/rules-stats?window=7d
32
32
  curl :7901/api/json/rules-performance
@@ -48,12 +48,12 @@ curl -X POST :7901/api/rules/disable-all
48
48
  curl -X POST :7901/api/rules/enable-all
49
49
  curl -X POST :7901/api/rules/uninstall-all \\
50
50
  -H 'content-type: application/json' \\
51
- -d '{"confirm":"UNINSTALL_ALL_RULES"}'`})]})]})})}function hh({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 Xm(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 Ym(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 gh({stats:e,ruleIndex:t,onJump:n,onChanged:r}){let i=(0,_.useMemo)(()=>{let n=[];for(let[r,i]of Object.entries(e)){let e=i.lastBlockAskSeen??0;e<=0||n.push({ruleId:r,lastBlockAskSeen:e,entry:t.get(r)})}return n.sort((e,t)=>t.lastBlockAskSeen-e.lastBlockAskSeen),n.slice(0,5)},[e,t]);return i.length===0?null:(0,D.jsx)(q,{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`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent block/ask activity`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[i.length,` rule`,i.length===1?``:`s`,` — newest first`]})]}),(0,D.jsx)(Y,{className:`py-2`,children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:i.map(e=>{let t=e.entry?.rule.decision??`—`,i=e.entry?.rule.message??``;return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono py-1.5`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider w-12 shrink-0 ${Wm[t]??`text-[var(--color-fg-2)]`}`,children:t}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-0)] shrink-0 truncate w-48`,children:e.ruleId}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate flex-1 min-w-0 hidden md:inline`,children:i}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-16 text-right`,children:th(e.lastBlockAskSeen)}),(0,D.jsx)(hh,{entry:e.entry,ruleId:e.ruleId,onJump:n,onChanged:r})]},e.ruleId)})})})]})})}function _h({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&&Vm.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)(q,{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:Wm[c.decision]??`text-[var(--color-fg-2)]`,children:c.decision}),` `,`· `,th(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)(Y,{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 ${Wm[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:th(c.timestamp)}),(0,D.jsx)(hh,{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 ${Wm[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:th(e.lastSeen)}),(0,D.jsx)(hh,{entry:i,ruleId:e.ruleId,onJump:n,onChanged:r})]},e.ruleId)})})]})]})]})}):(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{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 vh({chip:e,onChange:t,counts:n}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px] mr-1`,children:`quick filters`}),[{key:`hot`,label:`🔥 hot now`,hint:`Rules that fired in the last hour`,color:`text-amber-300 border-amber-500/40 bg-amber-500/5 hover:bg-amber-500/10`},{key:`blocked`,label:`⛔ blocking`,hint:`Rules set to block and currently enabled`,color:`text-red-300 border-red-500/40 bg-red-500/5 hover:bg-red-500/10`},{key:`noisy`,label:`📢 noisy`,hint:`Fired ≥3 times in 24h — candidates to soften`,color:`text-amber-300 border-amber-500/40 bg-amber-500/5 hover:bg-amber-500/10`},{key:`slow`,label:`🐢 slow >50ms`,hint:`Rules with avg eval time over 50ms`,color:`text-rose-300 border-rose-500/40 bg-rose-500/5 hover:bg-rose-500/10`},{key:`never`,label:`💤 never fired`,hint:`Enabled rules that have never matched — possible dead code`,color:`text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]`},{key:`disabled`,label:`⏸ disabled`,hint:`Rules toggled off — not currently enforced`,color:`text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]`}].map(r=>{let i=e===r.key,a=n[r.key];return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(i?`none`:r.key),title:r.hint,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors ${i?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:r.color}`,children:[r.label,(0,D.jsx)(`span`,{className:`ml-1.5 tabular-nums normal-case ${i?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:a})]},r.key)}),e!==`none`&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`none`),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer ml-1`,children:`✕ clear`})]})}function yh({value:e,onChange:t,matchCount:n,sortKey:r,onSortChange:i}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[260px]`,children:[(0,D.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-brand)]/70 pointer-events-none`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,D.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),(0,D.jsx)(`input`,{type:`text`,placeholder:`Search rules — id, message, or paste a blocked command…`,title:`Searches rule id, message, AND recent audit-log inputs/tools — paste a blocked command to find its rule`,"aria-label":`Search rules`,value:e,onChange:e=>t(e.target.value),className:`bg-[var(--color-surface-1)] border-2 border-[var(--color-brand)]/35 text-[var(--color-fg-1)] text-sm rounded-md pl-10 pr-28 py-2.5 w-full shadow-sm transition-colors focus:outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand)]/25 placeholder:text-[var(--color-fg-4)] font-mono`}),e&&(0,D.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2`,children:[n!==null&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] tabular-nums`,children:[n,` match`,n===1?``:`es`]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,title:`Clear search`,"aria-label":`Clear search`,children:`✕`})]})]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`sort`}),(0,D.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] rounded-sm px-1.5 py-1 cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50`,children:[(0,D.jsx)(`option`,{value:`default`,children:`default · by file`}),(0,D.jsx)(`option`,{value:`hits`,children:`most hits`}),(0,D.jsx)(`option`,{value:`slowest`,children:`slowest`}),(0,D.jsx)(`option`,{value:`recent`,children:`recently fired`}),(0,D.jsx)(`option`,{value:`alpha`,children:`alphabetical`})]})]})]})}function bh({decisionFilter:e,onChange:t,totalRules:n,ruleCount:r,hits:i,window:a}){let o=Object.values(i).reduce((e,t)=>e+t,0);return(0,D.jsx)(q,{children:(0,D.jsx)(Y,{className:`px-3 py-2`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`filter by decision`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:[`rules · applied in `,a]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(`all`),title:`Show all ${n} rules — ${o.toLocaleString()} applied in ${a}`,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors ${e===`all`?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:border-[var(--color-brand)]/30 hover:text-[var(--color-fg-0)]`}`,children:[`all`,(0,D.jsx)(`span`,{className:`ml-1.5 text-[var(--color-fg-4)] tabular-nums normal-case`,children:n}),o>0&&(0,D.jsxs)(`span`,{className:`ml-1 text-[var(--color-fg-3)] tabular-nums normal-case`,children:[`· `,o.toLocaleString()]})]}),Um.map(n=>{let o=r[n]??0,s=i[n]??0,c=e===n,l=o===0,u=Wm[n]??`text-[var(--color-fg-2)]`;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(n),disabled:l,title:`${o} rule${o===1?``:`s`} set to ${n} · ${s.toLocaleString()} applied in ${a}`,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed ${c?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 ${u}`:`border-[var(--color-line-1)] ${u} hover:border-[var(--color-brand)]/30`}`,children:[n,(0,D.jsx)(`span`,{className:`ml-1.5 text-[var(--color-fg-4)] tabular-nums normal-case`,children:o}),s>0&&(0,D.jsxs)(`span`,{className:`ml-1 text-[var(--color-fg-3)] tabular-nums normal-case`,children:[`· `,s.toLocaleString()]})]},n)})]})]})})})}var xh={covered:{label:`covered`,color:`var(--color-decision-allow)`},inactive:{label:`all off`,color:`var(--color-decision-ask)`},gap:{label:`no rules`,color:`var(--color-decision-block)`}};function Sh({cov:e,active:t,onClick:n}){let r=xh[e.status];return(0,D.jsxs)(`button`,{type:`button`,onClick:n,title:e.meta.description,className:`text-left rounded-sm border px-2 py-1.5 transition-colors cursor-pointer ${t?`border-[var(--color-brand)] bg-[var(--color-brand)]/10`:`border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]/70`}`,style:{borderLeft:`2px solid ${e.meta.color}`},children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:e.meta.icon}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-0)] font-medium truncate flex-1`,children:e.meta.title})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between mt-1 gap-1`,children:[(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[e.total,` rule`,e.total===1?``:`s`,e.enabledShell>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[` · `,e.enabledShell,` shell`]})]}),(0,D.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider font-mono`,style:{color:r.color},children:r.label})]}),e.meta.attack&&(0,D.jsxs)(`div`,{className:`text-[9px] font-mono text-[var(--color-fg-4)] mt-0.5 truncate`,children:[e.meta.attack.id,` `,e.meta.attack.name]})]})}function Ch({coverage:e,activeCategory:t,onPick:n}){let r=e.total>0?Math.round(e.covered/e.total*100):0,i=e.categories.filter(e=>e.meta.security||e.total>0),a=e.categories.reduce((e,t)=>e+t.enabledShell,0);return(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{className:`px-3 py-2.5 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`overline text-[11px]`,children:`tool-use coverage`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-0.5`,children:`rules categorized like Sigma detections · mapped to MITRE ATT&CK tactics`})]}),(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,D.jsxs)(`span`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:[e.covered,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,e.total]})]}),(0,D.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:`aspects governed`})]})]}),(0,D.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--color-surface-3)] overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${r}%`,background:r>=80?`var(--color-decision-allow)`:r>=50?`var(--color-decision-ask)`:`var(--color-decision-block)`}})}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[a,` active rule`,a===1?``:`s`,` govern shell / command execution`,e.uncategorized>0&&(0,D.jsxs)(D.Fragment,{children:[` · `,(0,D.jsxs)(`span`,{className:`text-amber-300`,children:[e.uncategorized,` uncategorized`]})]})]}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-1.5`,children:i.map(e=>(0,D.jsx)(Sh,{cov:e,active:t===e.id,onClick:()=>n(e.id)},e.id))})]})})}function wh({category:e,inferred:t,onPick:n}){let r=Im(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>n(e),title:`${r.title}${t?` (inferred — add an explicit CATEGORY directive)`:``} — ${r.description}`,className:`text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded-sm border cursor-pointer shrink-0 inline-flex items-center gap-0.5`,style:{color:r.color,borderColor:`${r.color}55`},children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:r.icon}),(0,D.jsx)(`span`,{children:r.title}),t&&(0,D.jsx)(`span`,{className:`opacity-50`,children:`~`})]})}function Th(){let{mode:e,setMode:t}=Ht(),n=e===`pro`,r=Ge(Hm)[`rules-changed`],[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(!i)return;let e=setInterval(()=>{s(e=>e+1)},qm);return()=>clearInterval(e)},[i]);let{data:c,refetch:l}=U(Jm(`/api/json/rules`,r+o),[r,o]),[u,d]=(0,_.useState)(`7d`),{data:f,refetch:p}=U(Jm(`/api/json/rules-stats?window=${u}`,o),[r,u,o]),{data:m,refetch:h}=U(Jm(`/api/json/rules-performance`,o),[r,o]),{data:g,refetch:v}=U(Jm(`/api/json/rule-triggers/recent?limit=500`,o),[r,o]),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(`all`),[T,E]=(0,_.useState)(`none`),[O,k]=(0,_.useState)(`default`),[ee,A]=(0,_.useState)(`file`),[j,M]=(0,_.useState)(``),[N,P]=(0,_.useState)(new Set),[F,I]=(0,_.useState)(new Set),[L,te]=(0,_.useState)(()=>new URLSearchParams(window.location.search).get(`highlight`)??``),ne=(0,_.useRef)(null);(0,_.useEffect)(()=>{ne.current&&ne.current.scrollIntoView({behavior:`smooth`,block:`center`})},[]);let R=f?.stats??{},z=(0,_.useMemo)(()=>{let e=new Map;if(!c)return e;for(let t of c.rulesets)for(let n of t.rules)e.set(n.id,{rule:n,file:t.file});return e},[c]),B=(0,_.useMemo)(()=>{let e=[];if(c)for(let t of c.rulesets)for(let n of t.rules)e.push({id:n.id,target:n.target??`any`,decision:n.decision,category:n.category,enabled:n.enabled});return Bm(e)},[c]);function re(){l(),p(),h(),v(),s(e=>e+1)}function ie(e){b(``),S(`all`),w(`all`),E(`none`),M(``),te(e);let t=new URL(window.location.href);t.searchParams.set(`highlight`,e),window.history.replaceState(null,``,t.toString())}let ae=(0,_.useMemo)(()=>{let e=new Set;if(!g)return e;let t=Math.floor(Date.now()/1e3)-3600;for(let n of g.rows)n.ruleId&&n.timestamp>=t&&e.add(n.ruleId);return e},[g]),oe=(0,_.useMemo)(()=>{let e=new Set;if(!g)return e;let t=Math.floor(Date.now()/1e3)-24*3600,n=new Map;for(let e of g.rows)!e.ruleId||e.timestamp<t||Vm.has(e.decision)&&n.set(e.ruleId,(n.get(e.ruleId)??0)+1);for(let[t,r]of n)r>=3&&e.add(t);return e},[g]);if(!c)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading rules…`});if(c.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 se=y.toLowerCase(),ce=(()=>{let e=new Set;if(!se||!g)return e;for(let t of g.rows){if(!t.ruleId)continue;let n=(t.input??``).toLowerCase(),r=(t.tool??``).toLowerCase();(n.includes(se)||r.includes(se))&&e.add(t.ruleId)}return e})();function le(e){if(x===`enabled`&&!e.enabled||x===`disabled`&&e.enabled)return!1;let t=R[e.id],n=t?.hits??0;return!(x===`hit`&&n===0||x===`never`&&n>0||C!==`all`&&e.decision!==C||j&&(e.category??`uncategorized`)!==j||T===`hot`&&!ae.has(e.id)||T===`noisy`&&!oe.has(e.id)||T===`blocked`&&!(e.decision===`block`&&e.enabled)||T===`slow`&&!(t&&t.avgDurationMs>50)||T===`never`&&!(e.enabled&&(!t||t.hits===0))||T===`disabled`&&e.enabled)}let ue=(()=>{let e={},t={};for(let n of c.rulesets)for(let r of n.rules){e[r.decision]=(e[r.decision]??0)+1;let n=R[r.id]?.hits??0;n>0&&(t[r.decision]=(t[r.decision]??0)+n)}return{ruleCount:e,hits:t}})(),de={hot:0,blocked:0,noisy:oe.size,slow:0,never:0,disabled:0};for(let e of c.rulesets)for(let t of e.rules){ae.has(t.id)&&de.hot++,t.decision===`block`&&t.enabled&&de.blocked++;let e=R[t.id];e&&e.avgDurationMs>50&&de.slow++,t.enabled&&(!e||e.hits===0)&&de.never++,t.enabled||de.disabled++}let fe=!!se||x!==`all`||C!==`all`||T!==`none`||j!==``;function pe(e){return O===`default`?e:[...e].sort((e,t)=>O===`hits`?(R[t.id]?.hits??0)-(R[e.id]?.hits??0):O===`slowest`?(R[t.id]?.avgDurationMs??0)-(R[e.id]?.avgDurationMs??0):O===`recent`?(R[t.id]?.lastSeen??0)-(R[e.id]?.lastSeen??0):O===`alpha`?e.id.localeCompare(t.id):0)}let me=[];for(let e of c.rulesets)for(let t of e.rules)me.push({...t,file:e.file});let he=me.filter(e=>se&&!e.id.toLowerCase().includes(se)&&!e.message.toLowerCase().includes(se)&&!ce.has(e.id)?!1:le(e)),ge;if(ee===`category`){let e=new Map;for(let t of he){let n=t.category??`uncategorized`,r=e.get(n);r?r.push(t):e.set(n,[t])}ge=Nm.filter(t=>e.has(t.id)).map(t=>({key:t.id,kind:`category`,label:t.title,icon:t.icon,accent:t.color,sublabel:t.attack?`${t.attack.id} · ${t.attack.name}`:`D3FEND · ${t.d3fend}`,rules:pe(e.get(t.id)??[])}))}else{let e=new Map;for(let t of he){let n=e.get(t.file);n?n.push(t):e.set(t.file,[t])}ge=c.rulesets.map(t=>({key:t.file,kind:`file`,label:t.file,content:t.content,rules:pe(e.get(t.file)??[])})).filter(e=>e.rules.length>0||!fe)}let _e=me.length,ve=me.filter(e=>e.enabled).length,ye=new Set;for(let e of ge)for(let t of e.rules)ye.add(t.id);let be=fe?ye.size:null,xe=[];for(let e of N){let t=z.get(e);t&&xe.push({ruleId:e,file:t.file})}function Se(e){P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Ce(e){P(t=>{let n=new Set(t);if(e.length>0&&e.every(e=>n.has(e.id)))for(let t of e)n.delete(t.id);else for(let t of e)n.add(t.id);return n})}function we(e){if(j===e){M(``);return}M(e),A(`category`),te(``)}function Te(){P(e=>{let t=new Set(e);for(let e of ye)t.add(e);return t})}function V(e){I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function Ee(e,t){xe.length!==0&&(e===`enable`?await Zm(xe,!0):e===`disable`?await Zm(xe,!1):e===`delete`?(await $m(xe),P(new Set)):e===`decision`&&t&&await Qm(xe,t),re())}return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`div`,{className:`sticky top-[52px] z-[9] -mx-6 -mt-6 border-b border-[var(--color-line-1)] bg-[var(--color-surface-0)]/95 px-6 py-3 backdrop-blur`,children:(0,D.jsx)(yh,{value:y,onChange:b,matchCount:be,sortKey:O,onSortChange:k})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-firewall`,children:(0,D.jsx)(uh,{totalRules:_e,activeRules:ve,onChanged:re})}),(0,D.jsx)(oh,{}),(0,D.jsx)(`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:[ve,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,_e]}),(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:[c.files.length,` file`,c.files.length===1?``:`s`]})]})]})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-coverage`,children:(0,D.jsx)(Ch,{coverage:B,activeCategory:j,onPick:we})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-stats`,children:(0,D.jsx)(sh,{perf:m,triggers:g,decisionAggregates:ue,livePoll:i,onTogglePoll:()=>a(e=>!e),statsWindow:u,onWindowChange:d,mode:e,onModeChange:t})}),(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{className:`px-3 py-2.5 space-y-2.5`,children:[(0,D.jsx)(vh,{chip:T,onChange:E,counts:de}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap pt-1 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`state`}),(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:()=>S(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${x===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)(`span`,{className:`overline text-[10px] ml-1`,children:`group`}),(0,D.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider`,children:[`file`,`category`].map(e=>(0,D.jsxs)(`button`,{onClick:()=>A(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${ee===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:[`by `,e]},e))})]}),j&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap pt-1 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`category`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono px-1.5 py-0.5 rounded-sm border`,style:{color:Im(j).color,borderColor:`${Im(j).color}66`},children:[Im(j).icon,` `,Im(j).title]}),(0,D.jsx)(`button`,{onClick:()=>M(``),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear ✕`})]})]})}),(0,D.jsx)(bh,{decisionFilter:C,onChange:w,totalRules:_e,ruleCount:ue.ruleCount,hits:ue.hits,window:u}),n&&(0,D.jsx)(`div`,{"data-tutorial":`rules-top`,children:(0,D.jsx)(lh,{stats:R,ruleIndex:z,triggers:g?.rows,statsWindow:u,onJump:ie})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-activity`,children:(0,D.jsx)(gh,{stats:R,ruleIndex:z,onJump:ie,onChanged:re})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-recent`,children:(0,D.jsx)(_h,{triggers:g?.rows,ruleIndex:z,onJump:ie,onChanged:re})}),n&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ch,{perf:m}),(0,D.jsx)(mh,{})]}),(0,D.jsx)(fh,{selected:xe,onClear:()=>P(new Set),onApply:Ee}),ye.size>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono`,children:[(0,D.jsxs)(`button`,{onClick:Te,className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:[`select `,ye.size,` visible`]}),N.size>0&&(0,D.jsx)(`button`,{onClick:()=>P(new Set),className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear selection`})]}),ge.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:ge.map(e=>{let t=e.rules.some(e=>e.id===L),r=e.rules.filter(e=>e.enabled).length,i=e.rules.length>0&&e.rules.every(e=>N.has(e.id)),a=!i&&e.rules.some(e=>N.has(e.id)),o=nh(g?.rows,20,3600*1e3,t=>t.ruleId?e.rules.some(e=>e.id===t.ruleId):!1),s=o.some(e=>e>0);return(0,D.jsx)(q,{children:(0,D.jsxs)(`details`,{open:t||fe||O!==`default`,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:i,ref:e=>{e&&(e.indeterminate=a)},onChange:()=>Ce(e.rules),onClick:e=>e.stopPropagation(),className:`accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select all rules in ${e.label}`}),e.kind===`category`?(0,D.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-xs`,children:e.icon}):(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`,style:e.accent?{color:e.accent}:void 0,children:e.label}),e.sublabel&&(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] shrink-0`,children:e.sublabel}),s&&(0,D.jsx)(qc,{data:o,width:60,height:16,color:`var(--color-brand)`}),(0,D.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-[var(--color-fg-3)] tabular-nums`,children:[r,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,e.rules.length]})]})]}),(0,D.jsxs)(Y,{className:`py-0`,children:[e.rules.length===0?(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] py-3`,children:[`no rules in this `,e.kind]}):(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:e.rules.map(e=>{let t=e.id===L,r=N.has(e.id),i=R[e.id],a=F.has(e.id),o=i&&i.hits>0?nh(g?.rows,20,3600*1e3,t=>t.ruleId===e.id):null;return(0,D.jsx)(`div`,{ref:t?ne:null,className:`py-2.5 ${t?`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:()=>Se(e.id),className:`mt-1 accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select rule ${e.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:[e.ambient?(0,D.jsx)(`span`,{className:`bg-[var(--color-surface-0)] border border-teal-500/40 rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider text-teal-300`,title:`Ambient knowledge rule — carries always-on project context surfaced to the agent at session start. It never gates a tool call, so it has no decision.`,children:`ambient`}):(0,D.jsx)(`select`,{value:e.decision,onChange:async t=>{await Xm(e.id,e.file,t.target.value),re()},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 ${Wm[e.decision]??`text-[var(--color-fg-2)]`}`,children:Um.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))}),(0,D.jsx)(Si,{ruleId:e.id,children:(0,D.jsx)(`code`,{className:`text-xs font-mono text-[var(--color-fg-0)] break-all`,children:e.id})}),ee===`file`&&e.category&&(0,D.jsx)(wh,{category:e.category,inferred:e.categoryInferred,onPick:we}),n&&e.tags&&e.tags.length>0&&e.tags.slice(0,5).map(e=>(0,D.jsx)(`span`,{className:`text-[9px] font-mono px-1 py-px rounded-sm bg-[var(--color-surface-3)] text-[var(--color-fg-3)] shrink-0`,children:e},e)),o&&(0,D.jsx)(qc,{data:o,width:50,height:14,color:Gm[e.decision]??`#a8a29e`}),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:i.avgDurationMs>50?`text-amber-300`:`text-[var(--color-fg-1)]`,children:[i.avgDurationMs.toFixed(1),`ms`]}),` `,`avg`]}),` · `,th(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`}),n&&(0,D.jsx)(`button`,{onClick:()=>V(e.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:e.message}),n&&a&&(0,D.jsx)(ph,{ruleId:e.id})]})]}),(0,D.jsx)(ah,{rule:e,file:e.file,onToggle:async()=>{await Ym(e.id,e.file),re()}})]})},e.id)})}),n&&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.key)})})]})}var Eh={allow:`#4ade80`,block:`#f87171`,ask:`#fbbf24`,force:`#a78bfa`,log:`#7dd3fc`,shadow:`#94a3b8`},Dh=[`<1ms`,`1-10ms`,`10-100ms`,`100ms-1s`,`>1s`],Oh=64;function kh(e){return e?new Date(e*1e3).toLocaleString():`—`}function Ah(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 jh({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 Mh({allowed:e,blocked:t,asked:n,forced:r}){let i=Math.max(0,e),a=Math.max(0,t),o=Math.max(0,n),s=Math.max(0,r),c=i+a+o+s;if(c===0)return(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No evals recorded.`});let l=[{label:`allow`,value:i,color:Eh.allow},{label:`block`,value:a,color:Eh.block},{label:`ask`,value:o,color:Eh.ask},{label:`force`,value:s,color:Eh.force}].filter(e=>e.value>0),u=2*Math.PI*32,d=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`}),l.map(e=>{let t=e.value/c*u,n=(0,D.jsx)(`circle`,{r:32,fill:`none`,stroke:e.color,strokeWidth:`12`,strokeDasharray:`${t} ${u-t}`,strokeDashoffset:-d,transform:`rotate(-90)`},e.label);return d+=t,n}),(0,D.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:`14`,fontFamily:`ui-monospace, monospace`,fill:`var(--color-fg-1)`,children:c})]}),(0,D.jsx)(`ul`,{className:`flex-1 flex flex-col gap-1 text-[11px] font-mono`,children:l.map(e=>{let t=Math.round(e.value/c*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 Nh({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).map(e=>({...e,value:Math.max(0,e.value)})),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 Ph({latency:e}){let t={};for(let n of e)t[n.bucket]=Math.max(0,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`,children:Dh.map(e=>{let r=t[e]??0,i=Math.round(r/n*Oh);return(0,D.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-1`,children:[(0,D.jsx)(`div`,{className:`flex w-full items-end`,style:{height:`${Oh}px`},children:(0,D.jsx)(`div`,{className:`w-full rounded-sm bg-[var(--color-hig-blue)]/60`,style:{height:`${i}px`,minHeight:r>0?`4px`:`0px`},title:`${r} evals in ${e}`})}),(0,D.jsx)(`span`,{className:`w-full truncate text-center text-[10px] font-mono leading-tight text-[var(--color-fg-3)]`,title:e,children:e}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono leading-tight text-[var(--color-fg-4)] tabular-nums`,children:r})]},e)})})}function Fh({sessionKey:e}){let[t,n]=(0,_.useState)(0),{data:r,loading:i,error:a}=U(`/api/json/sessions/detail?session_key=${encodeURIComponent(e)}&audit_limit=500`,[t]),o=Ge([`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:Math.max(0,e.hits)}));return r.tools.other>0&&e.push({label:`(${r.tools.other} other)`,value:Math.max(0,r.tools.other)}),e},[r]),c=(0,_.useMemo)(()=>{if(!r)return[];if(r.rules.length>0)return r.rules.map(e=>({label:e.rule_id,sublabel:e.rule_message,value:Math.max(0,e.hits)}));let e=new Map;for(let t of r.audit){if(!t.rule_id)continue;let n=e.get(t.rule_id);n?n.hits+=1:e.set(t.rule_id,{message:t.rule_message,hits:1})}return[...e.entries()].map(([e,t])=>({label:e,sublabel:t.message,value:t.hits})).sort((e,t)=>t.value-e.value)},[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:Math.max(0,l.evals),allowed:Math.max(0,l.allowed),blocked:Math.max(0,l.blocked),asked:Math.max(0,l.asked),forced:Math.max(0,l.forced),duration_s:Math.max(0,l.duration_s)},p=f.evals>0?Math.round(f.blocked/f.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`,"data-tutorial":`sd-back`,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:f.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:[f.client,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] font-mono text-[14px] ml-2`,children:f.agent_id})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 break-all`,children:f.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 ${f.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 ${f.is_active?`bg-emerald-400 animate-pulse`:`bg-[var(--color-fg-4)]`}`}),f.is_active?`Live`:`Closed`]}),(0,D.jsx)(Ih,{label:`Evals`,value:f.evals.toLocaleString()}),(0,D.jsx)(Ih,{label:`Blocked`,value:f.blocked>0?`${f.blocked} (${p}%)`:`0`,color:f.blocked>0?`text-rose-300`:void 0}),(0,D.jsx)(Ih,{label:`Asked`,value:f.asked.toLocaleString(),color:`text-amber-300`}),(0,D.jsx)(Ih,{label:`Started`,value:kh(f.started_at)}),(0,D.jsx)(Ih,{label:`Duration`,value:Ah(f.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)(jh,{title:`Decisions`,hint:`${f.evals} evals`,children:(0,D.jsx)(Mh,{allowed:f.allowed,blocked:f.blocked,asked:f.asked,forced:f.forced})}),(0,D.jsx)(jh,{title:`Top tools`,hint:`${r.tools.top.length+ +(r.tools.other>0)} buckets`,children:(0,D.jsx)(Nh,{rows:s,emptyMessage:`No tool activity.`})}),(0,D.jsx)(jh,{title:`Top rules`,hint:`${c.length} rule${c.length===1?``:`s`}`,children:(0,D.jsx)(Nh,{rows:c,emptyMessage:f.evals>0?`No rule matched any of the ${f.evals} tool call${f.evals===1?``:`s`} in this session — all allowed by the default policy.`:`No rule activity recorded for this session.`})}),(0,D.jsx)(jh,{title:`Latency`,hint:`duration buckets`,children:(0,D.jsx)(Ph,{latency:d})})]}),(0,D.jsx)(`div`,{"data-tutorial":`sd-audit`,className:`flex-1 min-h-[400px]`,children:(0,D.jsx)(Gu,{sessionKey:e,entries:u,loading:i,error:null,playingIndex:-1})})]})}function Ih({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 Lh=100,Rh={"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 zh(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 Bh(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 Vh({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 ${Rh[e]??`bg-white/5 text-[var(--color-fg-3)] border-white/10`}`,children:e})}function Hh({onOpenSession:e}={}){let{activeProject:t}=Ze(),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(0);(0,_.useEffect)(()=>{r(0)},[t]);let{data:c,loading:l,error:u,refetch:d}=U(Qe(`/api/json/sessions/list?limit=${Lh}&offset=${n}`,t),[o,t]),f=Ge([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{f>0&&s(e=>e+1)},[f]);let p=c?.sessions??[],m=c?.total??0,h=(0,_.useMemo)(()=>{if(!i.trim())return p;let e=i.toLowerCase();return p.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))},[p,i]),g=p.filter(e=>e.is_active).length,v=p.reduce((e,t)=>e+Math.max(0,t.evals),0),y=p.reduce((e,t)=>e+Math.max(0,t.blocked),0),b=v>0?Math.round(y/v*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:m.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:g}),` `,`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:v.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:b>0?`text-rose-300 font-semibold`:`text-emerald-300`,children:[b,`%`]}),` `,`blocked`]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{"data-tutorial":`sessions-filter`,type:`search`,value:i,onChange:e=>a(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`,{"data-tutorial":`sessions-refresh`,type:`button`,onClick:()=>d(),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`,{"data-tutorial":`sessions-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:[l&&h.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…`})}),u&&(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: `,u]})}),!l&&!u&&h.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:p.length===0?`No sessions recorded yet.`:`No sessions match "${i}".`})}),h.map(t=>{let n={...t,evals:Math.max(0,t.evals),allowed:Math.max(0,t.allowed),blocked:Math.max(0,t.blocked),asked:Math.max(0,t.asked),forced:Math.max(0,t.forced),duration_s:Math.max(0,t.duration_s)},r=n.evals>0?Math.round(n.blocked/n.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(n.session_key)}`,className:`flex items-center gap-1.5 no-underline`,onClick:t=>{e&&(t.preventDefault(),e(n.session_key,n.agent_id))},children:n.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)(Vh,{client:n.client})}),(0,D.jsx)(`td`,{className:`px-3 py-2`,children:(0,D.jsx)(`a`,{href:`/sessions/${encodeURIComponent(n.session_key)}`,className:`text-[var(--color-fg-1)] hover:text-[var(--color-hig-blue)] hover:underline`,onClick:t=>{e&&(t.preventDefault(),e(n.session_key,n.agent_id))},children:n.agent_id})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:zh(n.started_at)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:Bh(n.duration_s)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right font-semibold`,children:n.evals.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right text-emerald-300`,children:n.allowed.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right`,children:n.blocked>0?(0,D.jsxs)(`span`,{className:`text-rose-300`,children:[n.blocked.toLocaleString(),r>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[10px]`,children:[`(`,r,`%)`]})]}):(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:n.asked>0?n.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:n.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:n.top_rule??(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})})]},n.session_key)})]})]})})}),m>Lh&&(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:[n+1,`–`,Math.min(n+Lh,m),` of`,` `,m.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,disabled:n===0,onClick:()=>r(Math.max(0,n-Lh)),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:n+Lh>=m,onClick:()=>r(n+Lh),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`Next →`})]})]})]})}function Uh(e){return`ssg:session-subtabs:${e}`}function Wh(e){try{let t=localStorage.getItem(Uh(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.key==`string`&&typeof e.label==`string`):[]}catch{return[]}}function Gh(e){return`shrink-0 rounded-sm border px-2.5 py-1 text-[11px] font-mono transition-colors ${e?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`}function Kh(){let{activeProject:e}=Ze(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{n(Wh(e)),i(null)},[e]);let a=(0,_.useCallback)(t=>{try{localStorage.setItem(Uh(e),JSON.stringify(t))}catch{}},[e]),o=(0,_.useCallback)((e,t)=>{n(n=>{let r=n.some(t=>t.key===e)?n:[...n,{key:e,label:t}];return a(r),r}),i(e)},[a]),s=(0,_.useCallback)(e=>{n(t=>{let n=t.findIndex(t=>t.key===e),r=t.filter(t=>t.key!==e);return a(r),i(t=>t===e?r.length===0?null:r[Math.max(0,n-1)].key:t),r})},[a]);return(0,D.jsxs)(`div`,{className:`flex flex-col`,children:[t.length>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto border-b border-[var(--color-line-1)] px-4 py-1.5`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:Gh(r===null),children:`Sessions list`}),t.map(e=>(0,D.jsxs)(`span`,{className:`group inline-flex items-center gap-1.5 ${Gh(r===e.key)}`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>i(e.key),className:`max-w-[160px] truncate`,children:e.label}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>s(e.key),"aria-label":`Close ${e.label}`,className:`text-[var(--color-fg-4)] hover:text-rose-300`,children:`×`})]},e.key))]}),r===null?(0,D.jsx)(Hh,{onOpenSession:o}):(0,D.jsx)(Fh,{sessionKey:r})]})}function qh({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 Jh({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 Yh(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Xh(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 Zh(e,t){return t&&e.startsWith(`${t}/`)?`~/${e.slice(t.length+1)}`:e===t?`~`:e}function Qh({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)(qh,{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:Zh(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:Yh(e.size)}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] min-w-[60px] text-right`,children:Xh(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 $h({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)(qh,{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 eg({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 tg={"claude-code":`Claude Code`,cursor:`Cursor`,codex:`Codex CLI`,pi:`Pi Agent`,gemini:`Gemini CLI`,antigravity:`Antigravity`,copilot:`GitHub Copilot`};function ng({adapter:e,home:t}){let n=tg[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)(qh,{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)(Qh,{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 rg(){let{data:e,loading:t,error:n,refetch:r}=U(`/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`,{"data-tutorial":`setup-summary`,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)(qh,{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:Zh(_,g)})]})]}),(0,D.jsx)($h,{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)(qh,{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)(Jh,{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)($h,{title:`License & authentication`,status:a.status===`healthy`||a.status===`healthy_free`?`ok`:`warn`,children:[(0,D.jsx)(eg,{k:`Tier`,v:a.tier_label}),(0,D.jsx)(eg,{k:`Status`,v:a.status}),(0,D.jsx)(eg,{k:`Account`,v:a.email??`—`}),(0,D.jsx)(eg,{k:`Auth method`,v:a.auth_method??`—`}),(0,D.jsx)(eg,{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)(Qh,{file:a.license_file,home:g}),(0,D.jsx)(Qh,{file:a.hosts_file,home:g})]})]}),(0,D.jsxs)($h,{title:`Runtime processes`,status:o.alive&&s.alive?`ok`:`warn`,children:[(0,D.jsx)(eg,{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)(eg,{k:`Daemon socket`,v:o.socket_exists?`present`:`missing`,mono:!0}),(0,D.jsx)(eg,{k:`Dashboard (serve)`,v:s.alive?`running — PID ${s.pid}`:`not running`}),(0,D.jsx)(eg,{k:`Native engine`,v:c.available?`loaded — sub-ms eval available`:`unavailable — TypeScript fallback`})]}),(0,D.jsxs)($h,{title:`Database & MCP`,status:l.status,children:[(0,D.jsx)(eg,{k:`Rules in DB`,v:l.rules.toLocaleString()}),(0,D.jsx)(eg,{k:`Audit log rows`,v:l.audit_rows.toLocaleString()}),(0,D.jsx)(eg,{k:`DB path`,v:Zh(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)(eg,{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)(eg,{k:`All-time calls`,v:u.total.toLocaleString()})]})]}),(0,D.jsxs)($h,{title:`Rules directories`,status:d.local_count>0?`ok`:`warn`,children:[(0,D.jsx)(eg,{k:`Local`,v:`${d.local_count} .rules file${d.local_count===1?``:`s`}`}),(0,D.jsx)(eg,{k:`Local path`,v:Zh(d.local_dir,g),mono:!0}),(0,D.jsx)(eg,{k:`Global`,v:`${d.global_count} .rules file${d.global_count===1?``:`s`}`}),(0,D.jsx)(eg,{k:`Global path`,v:Zh(d.global_dir,g),mono:!0})]}),(0,D.jsx)($h,{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)(Qh,{file:e,home:g},e.path))})}),(0,D.jsx)($h,{title:`Adapters, hooks & MCP files`,hint:e.active_adapter?`Active: ${tg[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)(ng,{adapter:e,home:g},e.id))})}),(0,D.jsxs)($h,{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)(Qh,{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)(qh,{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:Xh(e.installed_at)})]}),(0,D.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--color-fg-2)]`,title:e.path,children:Zh(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 ig=[{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`}],ag=[{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`}}],og=`ssg.tryit.intro-dismissed.v1`,sg=`ssg.tryit.os.v1`,cg={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 lg(){if(typeof window>`u`)return`linux`;try{let e=window.localStorage.getItem(sg);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 ug(e){return e===`windows`?`Windows`:e===`macos`?`Mac`:`Linux`}function dg(e){return e===`windows`?`⊞`:e===`macos`?`🍎`:`🐧`}function fg(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 pg({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 mg({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 ${ug(n)}`,children:[dg(n),` `,ug(n)]},n))})}function hg({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)(pg,{n:1,label:`Pick a scenario below`}),(0,D.jsx)(pg,{n:2,label:`Click Run`}),(0,D.jsx)(pg,{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)(mg,{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 gg({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:fg(e,n)})]})}function _g(){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(og)===`1`}catch{return!1}}),[g,v]=(0,_.useState)(()=>lg()),[y,b]=(0,_.useState)(!1);function x(e){v(e);try{window.localStorage.setItem(sg,e)}catch{}}function S(){h(!0);try{window.localStorage.setItem(og,`1`)}catch{}}function C(){h(!1);try{window.localStorage.removeItem(og)}catch{}}let w=ag.find(t=>t.id===e),T=(0,_.useMemo)(()=>{let e=new Map;for(let t of ag){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return ig.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&&ag.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`,...W()},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 ee(){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 A=n?cg[n.decision]??cg.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)(hg,{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)(mg,{os:g,setOs:x})]}),(0,D.jsx)(`div`,{"data-tutorial":`try-scenarios`,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)(gg,{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`,{"data-tutorial":`try-detail`,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 · `,ug(g)]}),(0,D.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--color-fg-1)] break-all`,children:fg(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
51
+ -d '{"confirm":"UNINSTALL_ALL_RULES"}'`})]})]})})}function mh({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 Ym(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 Jm(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 hh({stats:e,ruleIndex:t,onJump:n,onChanged:r}){let i=(0,_.useMemo)(()=>{let n=[];for(let[r,i]of Object.entries(e)){let e=i.lastBlockAskSeen??0;e<=0||n.push({ruleId:r,lastBlockAskSeen:e,entry:t.get(r)})}return n.sort((e,t)=>t.lastBlockAskSeen-e.lastBlockAskSeen),n.slice(0,5)},[e,t]);return i.length===0?null:(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`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`recent block/ask activity`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[i.length,` rule`,i.length===1?``:`s`,` — newest first`]})]}),(0,D.jsx)(X,{className:`py-2`,children:(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:i.map(e=>{let t=e.entry?.rule.decision??`—`,i=e.entry?.rule.message??``;return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono py-1.5`,children:[(0,D.jsx)(`span`,{className:`uppercase tracking-wider w-12 shrink-0 ${Um[t]??`text-[var(--color-fg-2)]`}`,children:t}),(0,D.jsx)(`code`,{className:`text-[var(--color-fg-0)] shrink-0 truncate w-48`,children:e.ruleId}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] truncate flex-1 min-w-0 hidden md:inline`,children:i}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] tabular-nums shrink-0 w-16 text-right`,children:eh(e.lastBlockAskSeen)}),(0,D.jsx)(mh,{entry:e.entry,ruleId:e.ruleId,onJump:n,onChanged:r})]},e.ruleId)})})})]})})}function gh({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&&Bm.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:Um[c.decision]??`text-[var(--color-fg-2)]`,children:c.decision}),` `,`· `,eh(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 ${Um[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:eh(c.timestamp)}),(0,D.jsx)(mh,{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 ${Um[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:eh(e.lastSeen)}),(0,D.jsx)(mh,{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 _h({chip:e,onChange:t,counts:n}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px] mr-1`,children:`quick filters`}),[{key:`hot`,label:`🔥 hot now`,hint:`Rules that fired in the last hour`,color:`text-amber-300 border-amber-500/40 bg-amber-500/5 hover:bg-amber-500/10`},{key:`blocked`,label:`⛔ blocking`,hint:`Rules set to block and currently enabled`,color:`text-red-300 border-red-500/40 bg-red-500/5 hover:bg-red-500/10`},{key:`noisy`,label:`📢 noisy`,hint:`Fired ≥3 times in 24h — candidates to soften`,color:`text-amber-300 border-amber-500/40 bg-amber-500/5 hover:bg-amber-500/10`},{key:`slow`,label:`🐢 slow >50ms`,hint:`Rules with avg eval time over 50ms`,color:`text-rose-300 border-rose-500/40 bg-rose-500/5 hover:bg-rose-500/10`},{key:`never`,label:`💤 never fired`,hint:`Enabled rules that have never matched — possible dead code`,color:`text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]`},{key:`disabled`,label:`⏸ disabled`,hint:`Rules toggled off — not currently enforced`,color:`text-[var(--color-fg-3)] border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]`}].map(r=>{let i=e===r.key,a=n[r.key];return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(i?`none`:r.key),title:r.hint,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors ${i?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:r.color}`,children:[r.label,(0,D.jsx)(`span`,{className:`ml-1.5 tabular-nums normal-case ${i?`text-[var(--color-fg-2)]`:`text-[var(--color-fg-4)]`}`,children:a})]},r.key)}),e!==`none`&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(`none`),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer ml-1`,children:`✕ clear`})]})}function vh({value:e,onChange:t,matchCount:n,sortKey:r,onSortChange:i}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[260px]`,children:[(0,D.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-brand)]/70 pointer-events-none`,children:[(0,D.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,D.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),(0,D.jsx)(`input`,{type:`text`,placeholder:`Search rules — id, message, or paste a blocked command…`,title:`Searches rule id, message, AND recent audit-log inputs/tools — paste a blocked command to find its rule`,"aria-label":`Search rules`,value:e,onChange:e=>t(e.target.value),className:`bg-[var(--color-surface-1)] border-2 border-[var(--color-brand)]/35 text-[var(--color-fg-1)] text-sm rounded-md pl-10 pr-28 py-2.5 w-full shadow-sm transition-colors focus:outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand)]/25 placeholder:text-[var(--color-fg-4)] font-mono`}),e&&(0,D.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2`,children:[n!==null&&(0,D.jsxs)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] tabular-nums`,children:[n,` match`,n===1?``:`es`]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,title:`Clear search`,"aria-label":`Clear search`,children:`✕`})]})]}),(0,D.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`sort`}),(0,D.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`bg-[var(--color-surface-1)] border border-[var(--color-line-1)] text-[var(--color-fg-1)] rounded-sm px-1.5 py-1 cursor-pointer focus:outline-none focus:border-[var(--color-brand)]/50`,children:[(0,D.jsx)(`option`,{value:`default`,children:`default · by file`}),(0,D.jsx)(`option`,{value:`hits`,children:`most hits`}),(0,D.jsx)(`option`,{value:`slowest`,children:`slowest`}),(0,D.jsx)(`option`,{value:`recent`,children:`recently fired`}),(0,D.jsx)(`option`,{value:`alpha`,children:`alphabetical`})]})]})]})}function yh({decisionFilter:e,onChange:t,totalRules:n,ruleCount:r,hits:i,window:a}){let o=Object.values(i).reduce((e,t)=>e+t,0);return(0,D.jsx)(J,{children:(0,D.jsx)(X,{className:`px-3 py-2`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col`,children:[(0,D.jsx)(`span`,{className:`overline`,children:`filter by decision`}),(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-4)] uppercase tracking-wider`,children:[`rules · applied in `,a]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(`all`),title:`Show all ${n} rules — ${o.toLocaleString()} applied in ${a}`,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors ${e===`all`?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 text-[var(--color-fg-0)]`:`border-[var(--color-line-1)] text-[var(--color-fg-2)] hover:border-[var(--color-brand)]/30 hover:text-[var(--color-fg-0)]`}`,children:[`all`,(0,D.jsx)(`span`,{className:`ml-1.5 text-[var(--color-fg-4)] tabular-nums normal-case`,children:n}),o>0&&(0,D.jsxs)(`span`,{className:`ml-1 text-[var(--color-fg-3)] tabular-nums normal-case`,children:[`· `,o.toLocaleString()]})]}),Hm.map(n=>{let o=r[n]??0,s=i[n]??0,c=e===n,l=o===0,u=Um[n]??`text-[var(--color-fg-2)]`;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>t(n),disabled:l,title:`${o} rule${o===1?``:`s`} set to ${n} · ${s.toLocaleString()} applied in ${a}`,className:`px-2 py-1 rounded-sm border text-[11px] font-mono uppercase tracking-wider cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed ${c?`border-[var(--color-brand)]/60 bg-[var(--color-brand)]/10 ${u}`:`border-[var(--color-line-1)] ${u} hover:border-[var(--color-brand)]/30`}`,children:[n,(0,D.jsx)(`span`,{className:`ml-1.5 text-[var(--color-fg-4)] tabular-nums normal-case`,children:o}),s>0&&(0,D.jsxs)(`span`,{className:`ml-1 text-[var(--color-fg-3)] tabular-nums normal-case`,children:[`· `,s.toLocaleString()]})]},n)})]})]})})})}var bh={covered:{label:`covered`,color:`var(--color-decision-allow)`},inactive:{label:`all off`,color:`var(--color-decision-ask)`},gap:{label:`no rules`,color:`var(--color-decision-block)`}};function xh({cov:e,active:t,onClick:n}){let r=bh[e.status];return(0,D.jsxs)(`button`,{type:`button`,onClick:n,title:e.meta.description,className:`text-left rounded-sm border px-2 py-1.5 transition-colors cursor-pointer ${t?`border-[var(--color-brand)] bg-[var(--color-brand)]/10`:`border-[var(--color-line-1)] hover:bg-[var(--color-surface-2)]/70`}`,style:{borderLeft:`2px solid ${e.meta.color}`},children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:e.meta.icon}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-0)] font-medium truncate flex-1`,children:e.meta.title})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between mt-1 gap-1`,children:[(0,D.jsxs)(`span`,{className:`text-[10px] font-mono text-[var(--color-fg-3)] tabular-nums`,children:[e.total,` rule`,e.total===1?``:`s`,e.enabledShell>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[` · `,e.enabledShell,` shell`]})]}),(0,D.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider font-mono`,style:{color:r.color},children:r.label})]}),e.meta.attack&&(0,D.jsxs)(`div`,{className:`text-[9px] font-mono text-[var(--color-fg-4)] mt-0.5 truncate`,children:[e.meta.attack.id,` `,e.meta.attack.name]})]})}function Sh({coverage:e,activeCategory:t,onPick:n}){let r=e.total>0?Math.round(e.covered/e.total*100):0,i=e.categories.filter(e=>e.meta.security||e.total>0),a=e.categories.reduce((e,t)=>e+t.enabledShell,0);return(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`px-3 py-2.5 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 flex-wrap`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`overline text-[11px]`,children:`tool-use coverage`}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)] mt-0.5`,children:`rules categorized like Sigma detections · mapped to MITRE ATT&CK tactics`})]}),(0,D.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,D.jsxs)(`span`,{className:`font-mono text-sm text-[var(--color-fg-0)] tabular-nums`,children:[e.covered,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,e.total]})]}),(0,D.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:`aspects governed`})]})]}),(0,D.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--color-surface-3)] overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${r}%`,background:r>=80?`var(--color-decision-allow)`:r>=50?`var(--color-decision-ask)`:`var(--color-decision-block)`}})}),(0,D.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)]`,children:[a,` active rule`,a===1?``:`s`,` govern shell / command execution`,e.uncategorized>0&&(0,D.jsxs)(D.Fragment,{children:[` · `,(0,D.jsxs)(`span`,{className:`text-amber-300`,children:[e.uncategorized,` uncategorized`]})]})]}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-1.5`,children:i.map(e=>(0,D.jsx)(xh,{cov:e,active:t===e.id,onClick:()=>n(e.id)},e.id))})]})})}function Ch({category:e,inferred:t,onPick:n}){let r=Fm(e);return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>n(e),title:`${r.title}${t?` (inferred — add an explicit CATEGORY directive)`:``} — ${r.description}`,className:`text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded-sm border cursor-pointer shrink-0 inline-flex items-center gap-0.5`,style:{color:r.color,borderColor:`${r.color}55`},children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:r.icon}),(0,D.jsx)(`span`,{children:r.title}),t&&(0,D.jsx)(`span`,{className:`opacity-50`,children:`~`})]})}function wh(){let{mode:e,setMode:t}=Ht(),n=e===`pro`,r=Ge(Vm)[`rules-changed`],[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(!i)return;let e=setInterval(()=>{s(e=>e+1)},Km);return()=>clearInterval(e)},[i]);let{data:c,refetch:l}=U(qm(`/api/json/rules`,r+o),[r,o]),[u,d]=(0,_.useState)(`7d`),{data:f,refetch:p}=U(qm(`/api/json/rules-stats?window=${u}`,o),[r,u,o]),{data:m,refetch:h}=U(qm(`/api/json/rules-performance`,o),[r,o]),{data:g,refetch:v}=U(qm(`/api/json/rule-triggers/recent?limit=500`,o),[r,o]),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(`all`),[T,E]=(0,_.useState)(`none`),[O,k]=(0,_.useState)(`default`),[ee,A]=(0,_.useState)(`file`),[j,M]=(0,_.useState)(``),[N,P]=(0,_.useState)(new Set),[F,I]=(0,_.useState)(new Set),[L,te]=(0,_.useState)(()=>new URLSearchParams(window.location.search).get(`highlight`)??``),ne=(0,_.useRef)(null);(0,_.useEffect)(()=>{ne.current&&ne.current.scrollIntoView({behavior:`smooth`,block:`center`})},[]);let R=f?.stats??{},z=(0,_.useMemo)(()=>{let e=new Map;if(!c)return e;for(let t of c.rulesets)for(let n of t.rules)e.set(n.id,{rule:n,file:t.file});return e},[c]),B=(0,_.useMemo)(()=>{let e=[];if(c)for(let t of c.rulesets)for(let n of t.rules)e.push({id:n.id,target:n.target??`any`,decision:n.decision,category:n.category,enabled:n.enabled});return zm(e)},[c]);function re(){l(),p(),h(),v(),s(e=>e+1)}function ie(e){b(``),S(`all`),w(`all`),E(`none`),M(``),te(e);let t=new URL(window.location.href);t.searchParams.set(`highlight`,e),window.history.replaceState(null,``,t.toString())}let ae=(0,_.useMemo)(()=>{let e=new Set;if(!g)return e;let t=Math.floor(Date.now()/1e3)-3600;for(let n of g.rows)n.ruleId&&n.timestamp>=t&&e.add(n.ruleId);return e},[g]),oe=(0,_.useMemo)(()=>{let e=new Set;if(!g)return e;let t=Math.floor(Date.now()/1e3)-24*3600,n=new Map;for(let e of g.rows)!e.ruleId||e.timestamp<t||Bm.has(e.decision)&&n.set(e.ruleId,(n.get(e.ruleId)??0)+1);for(let[t,r]of n)r>=3&&e.add(t);return e},[g]);if(!c)return(0,D.jsx)(`p`,{className:`text-[11px] font-mono uppercase tracking-wider text-[var(--color-fg-3)]`,children:`loading rules…`});if(c.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 se=y.toLowerCase(),ce=(()=>{let e=new Set;if(!se||!g)return e;for(let t of g.rows){if(!t.ruleId)continue;let n=(t.input??``).toLowerCase(),r=(t.tool??``).toLowerCase();(n.includes(se)||r.includes(se))&&e.add(t.ruleId)}return e})();function le(e){if(x===`enabled`&&!e.enabled||x===`disabled`&&e.enabled)return!1;let t=R[e.id],n=t?.hits??0;return!(x===`hit`&&n===0||x===`never`&&n>0||C!==`all`&&e.decision!==C||j&&(e.category??`uncategorized`)!==j||T===`hot`&&!ae.has(e.id)||T===`noisy`&&!oe.has(e.id)||T===`blocked`&&!(e.decision===`block`&&e.enabled)||T===`slow`&&!(t&&t.avgDurationMs>50)||T===`never`&&!(e.enabled&&(!t||t.hits===0))||T===`disabled`&&e.enabled)}let ue=(()=>{let e={},t={};for(let n of c.rulesets)for(let r of n.rules){e[r.decision]=(e[r.decision]??0)+1;let n=R[r.id]?.hits??0;n>0&&(t[r.decision]=(t[r.decision]??0)+n)}return{ruleCount:e,hits:t}})(),de={hot:0,blocked:0,noisy:oe.size,slow:0,never:0,disabled:0};for(let e of c.rulesets)for(let t of e.rules){ae.has(t.id)&&de.hot++,t.decision===`block`&&t.enabled&&de.blocked++;let e=R[t.id];e&&e.avgDurationMs>50&&de.slow++,t.enabled&&(!e||e.hits===0)&&de.never++,t.enabled||de.disabled++}let fe=!!se||x!==`all`||C!==`all`||T!==`none`||j!==``;function pe(e){return O===`default`?e:[...e].sort((e,t)=>O===`hits`?(R[t.id]?.hits??0)-(R[e.id]?.hits??0):O===`slowest`?(R[t.id]?.avgDurationMs??0)-(R[e.id]?.avgDurationMs??0):O===`recent`?(R[t.id]?.lastSeen??0)-(R[e.id]?.lastSeen??0):O===`alpha`?e.id.localeCompare(t.id):0)}let me=[];for(let e of c.rulesets)for(let t of e.rules)me.push({...t,file:e.file});let he=me.filter(e=>se&&!e.id.toLowerCase().includes(se)&&!e.message.toLowerCase().includes(se)&&!ce.has(e.id)?!1:le(e)),ge;if(ee===`category`){let e=new Map;for(let t of he){let n=t.category??`uncategorized`,r=e.get(n);r?r.push(t):e.set(n,[t])}ge=Mm.filter(t=>e.has(t.id)).map(t=>({key:t.id,kind:`category`,label:t.title,icon:t.icon,accent:t.color,sublabel:t.attack?`${t.attack.id} · ${t.attack.name}`:`D3FEND · ${t.d3fend}`,rules:pe(e.get(t.id)??[])}))}else{let e=new Map;for(let t of he){let n=e.get(t.file);n?n.push(t):e.set(t.file,[t])}ge=c.rulesets.map(t=>({key:t.file,kind:`file`,label:t.file,content:t.content,rules:pe(e.get(t.file)??[])})).filter(e=>e.rules.length>0||!fe)}let _e=me.length,ve=me.filter(e=>e.enabled).length,ye=new Set;for(let e of ge)for(let t of e.rules)ye.add(t.id);let be=fe?ye.size:null,xe=[];for(let e of N){let t=z.get(e);t&&xe.push({ruleId:e,file:t.file})}function Se(e){P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Ce(e){P(t=>{let n=new Set(t);if(e.length>0&&e.every(e=>n.has(e.id)))for(let t of e)n.delete(t.id);else for(let t of e)n.add(t.id);return n})}function we(e){if(j===e){M(``);return}M(e),A(`category`),te(``)}function Te(){P(e=>{let t=new Set(e);for(let e of ye)t.add(e);return t})}function V(e){I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function Ee(e,t){xe.length!==0&&(e===`enable`?await Xm(xe,!0):e===`disable`?await Xm(xe,!1):e===`delete`?(await Qm(xe),P(new Set)):e===`decision`&&t&&await Zm(xe,t),re())}return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`div`,{className:`sticky top-[52px] z-[9] -mx-6 -mt-6 border-b border-[var(--color-line-1)] bg-[var(--color-surface-0)]/95 px-6 py-3 backdrop-blur`,children:(0,D.jsx)(vh,{value:y,onChange:b,matchCount:be,sortKey:O,onSortChange:k})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-firewall`,children:(0,D.jsx)(lh,{totalRules:_e,activeRules:ve,onChanged:re})}),(0,D.jsx)(ah,{}),(0,D.jsx)(`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:[ve,(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)]`,children:[`/`,_e]}),(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:[c.files.length,` file`,c.files.length===1?``:`s`]})]})]})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-coverage`,children:(0,D.jsx)(Sh,{coverage:B,activeCategory:j,onPick:we})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-stats`,children:(0,D.jsx)(oh,{perf:m,triggers:g,decisionAggregates:ue,livePoll:i,onTogglePoll:()=>a(e=>!e),statsWindow:u,onWindowChange:d,mode:e,onModeChange:t})}),(0,D.jsx)(J,{children:(0,D.jsxs)(X,{className:`px-3 py-2.5 space-y-2.5`,children:[(0,D.jsx)(_h,{chip:T,onChange:E,counts:de}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap pt-1 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`state`}),(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:()=>S(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${x===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)(`span`,{className:`overline text-[10px] ml-1`,children:`group`}),(0,D.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider`,children:[`file`,`category`].map(e=>(0,D.jsxs)(`button`,{onClick:()=>A(e),className:`px-1.5 py-0.5 rounded-sm border cursor-pointer transition-colors ${ee===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:[`by `,e]},e))})]}),j&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap pt-1 border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`span`,{className:`overline text-[10px]`,children:`category`}),(0,D.jsxs)(`span`,{className:`text-[11px] font-mono px-1.5 py-0.5 rounded-sm border`,style:{color:Fm(j).color,borderColor:`${Fm(j).color}66`},children:[Fm(j).icon,` `,Fm(j).title]}),(0,D.jsx)(`button`,{onClick:()=>M(``),className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear ✕`})]})]})}),(0,D.jsx)(yh,{decisionFilter:C,onChange:w,totalRules:_e,ruleCount:ue.ruleCount,hits:ue.hits,window:u}),n&&(0,D.jsx)(`div`,{"data-tutorial":`rules-top`,children:(0,D.jsx)(ch,{stats:R,ruleIndex:z,triggers:g?.rows,statsWindow:u,onJump:ie})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-activity`,children:(0,D.jsx)(hh,{stats:R,ruleIndex:z,onJump:ie,onChanged:re})}),(0,D.jsx)(`div`,{"data-tutorial":`rules-recent`,children:(0,D.jsx)(gh,{triggers:g?.rows,ruleIndex:z,onJump:ie,onChanged:re})}),n&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(sh,{perf:m}),(0,D.jsx)(ph,{})]}),(0,D.jsx)(dh,{selected:xe,onClear:()=>P(new Set),onApply:Ee}),ye.size>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] font-mono`,children:[(0,D.jsxs)(`button`,{onClick:Te,className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:[`select `,ye.size,` visible`]}),N.size>0&&(0,D.jsx)(`button`,{onClick:()=>P(new Set),className:`uppercase tracking-wider text-[var(--color-fg-3)] hover:text-[var(--color-fg-1)] cursor-pointer`,children:`clear selection`})]}),ge.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:ge.map(e=>{let t=e.rules.some(e=>e.id===L),r=e.rules.filter(e=>e.enabled).length,i=e.rules.length>0&&e.rules.every(e=>N.has(e.id)),a=!i&&e.rules.some(e=>N.has(e.id)),o=th(g?.rows,20,3600*1e3,t=>t.ruleId?e.rules.some(e=>e.id===t.ruleId):!1),s=o.some(e=>e>0);return(0,D.jsx)(J,{children:(0,D.jsxs)(`details`,{open:t||fe||O!==`default`,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:i,ref:e=>{e&&(e.indeterminate=a)},onChange:()=>Ce(e.rules),onClick:e=>e.stopPropagation(),className:`accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select all rules in ${e.label}`}),e.kind===`category`?(0,D.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-xs`,children:e.icon}):(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`,style:e.accent?{color:e.accent}:void 0,children:e.label}),e.sublabel&&(0,D.jsx)(`span`,{className:`text-[10px] font-mono uppercase tracking-wider text-[var(--color-fg-4)] shrink-0`,children:e.sublabel}),s&&(0,D.jsx)(Jc,{data:o,width:60,height:16,color:`var(--color-brand)`}),(0,D.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-[var(--color-fg-3)] tabular-nums`,children:[r,(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.jsxs)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] py-3`,children:[`no rules in this `,e.kind]}):(0,D.jsx)(`div`,{className:`divide-y divide-[var(--color-line-0)]`,children:e.rules.map(e=>{let t=e.id===L,r=N.has(e.id),i=R[e.id],a=F.has(e.id),o=i&&i.hits>0?th(g?.rows,20,3600*1e3,t=>t.ruleId===e.id):null;return(0,D.jsx)(`div`,{ref:t?ne:null,className:`py-2.5 ${t?`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:()=>Se(e.id),className:`mt-1 accent-[var(--color-brand)] cursor-pointer`,"aria-label":`Select rule ${e.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:[e.ambient?(0,D.jsx)(`span`,{className:`bg-[var(--color-surface-0)] border border-teal-500/40 rounded-sm px-1.5 py-0.5 text-[11px] font-mono uppercase tracking-wider text-teal-300`,title:`Ambient knowledge rule — carries always-on project context surfaced to the agent at session start. It never gates a tool call, so it has no decision.`,children:`ambient`}):(0,D.jsx)(`select`,{value:e.decision,onChange:async t=>{await Ym(e.id,e.file,t.target.value),re()},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 ${Um[e.decision]??`text-[var(--color-fg-2)]`}`,children:Hm.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))}),(0,D.jsx)(wi,{ruleId:e.id,children:(0,D.jsx)(`code`,{className:`text-xs font-mono text-[var(--color-fg-0)] break-all`,children:e.id})}),ee===`file`&&e.category&&(0,D.jsx)(Ch,{category:e.category,inferred:e.categoryInferred,onPick:we}),n&&e.tags&&e.tags.length>0&&e.tags.slice(0,5).map(e=>(0,D.jsx)(`span`,{className:`text-[9px] font-mono px-1 py-px rounded-sm bg-[var(--color-surface-3)] text-[var(--color-fg-3)] shrink-0`,children:e},e)),o&&(0,D.jsx)(Jc,{data:o,width:50,height:14,color:Wm[e.decision]??`#a8a29e`}),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:i.avgDurationMs>50?`text-amber-300`:`text-[var(--color-fg-1)]`,children:[i.avgDurationMs.toFixed(1),`ms`]}),` `,`avg`]}),` · `,eh(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`}),n&&(0,D.jsx)(`button`,{onClick:()=>V(e.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:e.message}),n&&a&&(0,D.jsx)(fh,{ruleId:e.id})]})]}),(0,D.jsx)(ih,{rule:e,file:e.file,onToggle:async()=>{await Jm(e.id,e.file),re()}})]})},e.id)})}),n&&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.key)})})]})}var Th={allow:`#4ade80`,block:`#f87171`,ask:`#fbbf24`,force:`#a78bfa`,log:`#7dd3fc`,shadow:`#94a3b8`},Eh=[`<1ms`,`1-10ms`,`10-100ms`,`100ms-1s`,`>1s`],Dh=64;function Oh(e){return e?new Date(e*1e3).toLocaleString():`—`}function kh(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 Ah({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 jh({allowed:e,blocked:t,asked:n,forced:r}){let i=Math.max(0,e),a=Math.max(0,t),o=Math.max(0,n),s=Math.max(0,r),c=i+a+o+s;if(c===0)return(0,D.jsx)(`div`,{className:`text-[11px] font-mono text-[var(--color-fg-4)]`,children:`No evals recorded.`});let l=[{label:`allow`,value:i,color:Th.allow},{label:`block`,value:a,color:Th.block},{label:`ask`,value:o,color:Th.ask},{label:`force`,value:s,color:Th.force}].filter(e=>e.value>0),u=2*Math.PI*32,d=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`}),l.map(e=>{let t=e.value/c*u,n=(0,D.jsx)(`circle`,{r:32,fill:`none`,stroke:e.color,strokeWidth:`12`,strokeDasharray:`${t} ${u-t}`,strokeDashoffset:-d,transform:`rotate(-90)`},e.label);return d+=t,n}),(0,D.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:`14`,fontFamily:`ui-monospace, monospace`,fill:`var(--color-fg-1)`,children:c})]}),(0,D.jsx)(`ul`,{className:`flex-1 flex flex-col gap-1 text-[11px] font-mono`,children:l.map(e=>{let t=Math.round(e.value/c*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 Mh({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).map(e=>({...e,value:Math.max(0,e.value)})),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 Nh({latency:e}){let t={};for(let n of e)t[n.bucket]=Math.max(0,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`,children:Eh.map(e=>{let r=t[e]??0,i=Math.round(r/n*Dh);return(0,D.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-1`,children:[(0,D.jsx)(`div`,{className:`flex w-full items-end`,style:{height:`${Dh}px`},children:(0,D.jsx)(`div`,{className:`w-full rounded-sm bg-[var(--color-hig-blue)]/60`,style:{height:`${i}px`,minHeight:r>0?`4px`:`0px`},title:`${r} evals in ${e}`})}),(0,D.jsx)(`span`,{className:`w-full truncate text-center text-[10px] font-mono leading-tight text-[var(--color-fg-3)]`,title:e,children:e}),(0,D.jsx)(`span`,{className:`text-[10px] font-mono leading-tight text-[var(--color-fg-4)] tabular-nums`,children:r})]},e)})})}function Ph({sessionKey:e}){let[t,n]=(0,_.useState)(0),{data:r,loading:i,error:a}=U(`/api/json/sessions/detail?session_key=${encodeURIComponent(e)}&audit_limit=500`,[t]),o=Ge([`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:Math.max(0,e.hits)}));return r.tools.other>0&&e.push({label:`(${r.tools.other} other)`,value:Math.max(0,r.tools.other)}),e},[r]),c=(0,_.useMemo)(()=>{if(!r)return[];if(r.rules.length>0)return r.rules.map(e=>({label:e.rule_id,sublabel:e.rule_message,value:Math.max(0,e.hits)}));let e=new Map;for(let t of r.audit){if(!t.rule_id)continue;let n=e.get(t.rule_id);n?n.hits+=1:e.set(t.rule_id,{message:t.rule_message,hits:1})}return[...e.entries()].map(([e,t])=>({label:e,sublabel:t.message,value:t.hits})).sort((e,t)=>t.value-e.value)},[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:Math.max(0,l.evals),allowed:Math.max(0,l.allowed),blocked:Math.max(0,l.blocked),asked:Math.max(0,l.asked),forced:Math.max(0,l.forced),duration_s:Math.max(0,l.duration_s)},p=f.evals>0?Math.round(f.blocked/f.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`,"data-tutorial":`sd-back`,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:f.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:[f.client,` `,(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)] font-mono text-[14px] ml-2`,children:f.agent_id})]}),(0,D.jsx)(`p`,{className:`text-[11px] font-mono text-[var(--color-fg-3)] mt-1 break-all`,children:f.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 ${f.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 ${f.is_active?`bg-emerald-400 animate-pulse`:`bg-[var(--color-fg-4)]`}`}),f.is_active?`Live`:`Closed`]}),(0,D.jsx)(Fh,{label:`Evals`,value:f.evals.toLocaleString()}),(0,D.jsx)(Fh,{label:`Blocked`,value:f.blocked>0?`${f.blocked} (${p}%)`:`0`,color:f.blocked>0?`text-rose-300`:void 0}),(0,D.jsx)(Fh,{label:`Asked`,value:f.asked.toLocaleString(),color:`text-amber-300`}),(0,D.jsx)(Fh,{label:`Started`,value:Oh(f.started_at)}),(0,D.jsx)(Fh,{label:`Duration`,value:kh(f.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)(Ah,{title:`Decisions`,hint:`${f.evals} evals`,children:(0,D.jsx)(jh,{allowed:f.allowed,blocked:f.blocked,asked:f.asked,forced:f.forced})}),(0,D.jsx)(Ah,{title:`Top tools`,hint:`${r.tools.top.length+ +(r.tools.other>0)} buckets`,children:(0,D.jsx)(Mh,{rows:s,emptyMessage:`No tool activity.`})}),(0,D.jsx)(Ah,{title:`Top rules`,hint:`${c.length} rule${c.length===1?``:`s`}`,children:(0,D.jsx)(Mh,{rows:c,emptyMessage:f.evals>0?`No rule matched any of the ${f.evals} tool call${f.evals===1?``:`s`} in this session — all allowed by the default policy.`:`No rule activity recorded for this session.`})}),(0,D.jsx)(Ah,{title:`Latency`,hint:`duration buckets`,children:(0,D.jsx)(Nh,{latency:d})})]}),(0,D.jsx)(`div`,{"data-tutorial":`sd-audit`,className:`flex-1 min-h-[400px]`,children:(0,D.jsx)(Ku,{sessionKey:e,entries:u,loading:i,error:null,playingIndex:-1})})]})}function Fh({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 Ih=100,Lh={"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 Rh(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 zh(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 Bh({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 ${Lh[e]??`bg-white/5 text-[var(--color-fg-3)] border-white/10`}`,children:e})}function Vh({onOpenSession:e}={}){let{activeProject:t}=Ze(),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(0);(0,_.useEffect)(()=>{r(0)},[t]);let{data:c,loading:l,error:u,refetch:d}=U(Qe(`/api/json/sessions/list?limit=${Ih}&offset=${n}`,t),[o,t]),f=Ge([`activity-updated`])[`activity-updated`]??0;(0,_.useEffect)(()=>{f>0&&s(e=>e+1)},[f]);let p=c?.sessions??[],m=c?.total??0,h=(0,_.useMemo)(()=>{if(!i.trim())return p;let e=i.toLowerCase();return p.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))},[p,i]),g=p.filter(e=>e.is_active).length,v=p.reduce((e,t)=>e+Math.max(0,t.evals),0),y=p.reduce((e,t)=>e+Math.max(0,t.blocked),0),b=v>0?Math.round(y/v*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:m.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:g}),` `,`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:v.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:b>0?`text-rose-300 font-semibold`:`text-emerald-300`,children:[b,`%`]}),` `,`blocked`]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{"data-tutorial":`sessions-filter`,type:`search`,value:i,onChange:e=>a(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`,{"data-tutorial":`sessions-refresh`,type:`button`,onClick:()=>d(),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`,{"data-tutorial":`sessions-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:[l&&h.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…`})}),u&&(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: `,u]})}),!l&&!u&&h.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:p.length===0?`No sessions recorded yet.`:`No sessions match "${i}".`})}),h.map(t=>{let n={...t,evals:Math.max(0,t.evals),allowed:Math.max(0,t.allowed),blocked:Math.max(0,t.blocked),asked:Math.max(0,t.asked),forced:Math.max(0,t.forced),duration_s:Math.max(0,t.duration_s)},r=n.evals>0?Math.round(n.blocked/n.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(n.session_key)}`,className:`flex items-center gap-1.5 no-underline`,onClick:t=>{e&&(t.preventDefault(),e(n.session_key,n.agent_id))},children:n.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)(Bh,{client:n.client})}),(0,D.jsx)(`td`,{className:`px-3 py-2`,children:(0,D.jsx)(`a`,{href:`/sessions/${encodeURIComponent(n.session_key)}`,className:`text-[var(--color-fg-1)] hover:text-[var(--color-hig-blue)] hover:underline`,onClick:t=>{e&&(t.preventDefault(),e(n.session_key,n.agent_id))},children:n.agent_id})}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:Rh(n.started_at)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-[var(--color-fg-3)]`,children:zh(n.duration_s)}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right font-semibold`,children:n.evals.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right text-emerald-300`,children:n.allowed.toLocaleString()}),(0,D.jsx)(`td`,{className:`px-3 py-2 text-right`,children:n.blocked>0?(0,D.jsxs)(`span`,{className:`text-rose-300`,children:[n.blocked.toLocaleString(),r>0&&(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-4)] ml-1 text-[10px]`,children:[`(`,r,`%)`]})]}):(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:n.asked>0?n.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:n.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:n.top_rule??(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`—`})})]},n.session_key)})]})]})})}),m>Ih&&(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:[n+1,`–`,Math.min(n+Ih,m),` of`,` `,m.toLocaleString()]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,disabled:n===0,onClick:()=>r(Math.max(0,n-Ih)),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:n+Ih>=m,onClick:()=>r(n+Ih),className:`px-3 py-1 border border-[var(--color-line-1)] rounded-sm disabled:opacity-30 hover:bg-white/5`,children:`Next →`})]})]})]})}function Hh(e){return`ssg:session-subtabs:${e}`}function Uh(e){try{let t=localStorage.getItem(Hh(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.key==`string`&&typeof e.label==`string`):[]}catch{return[]}}function Wh(e){return`shrink-0 rounded-sm border px-2.5 py-1 text-[11px] font-mono transition-colors ${e?`border-[var(--color-hig-blue)]/50 bg-[var(--color-hig-blue)]/15 text-[var(--color-fg-1)]`:`border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:bg-white/5`}`}function Gh(){let{activeProject:e}=Ze(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{n(Uh(e)),i(null)},[e]);let a=(0,_.useCallback)(t=>{try{localStorage.setItem(Hh(e),JSON.stringify(t))}catch{}},[e]),o=(0,_.useCallback)((e,t)=>{n(n=>{let r=n.some(t=>t.key===e)?n:[...n,{key:e,label:t}];return a(r),r}),i(e)},[a]),s=(0,_.useCallback)(e=>{n(t=>{let n=t.findIndex(t=>t.key===e),r=t.filter(t=>t.key!==e);return a(r),i(t=>t===e?r.length===0?null:r[Math.max(0,n-1)].key:t),r})},[a]);return(0,D.jsxs)(`div`,{className:`flex flex-col`,children:[t.length>0&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto border-b border-[var(--color-line-1)] px-4 py-1.5`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:Wh(r===null),children:`Sessions list`}),t.map(e=>(0,D.jsxs)(`span`,{className:`group inline-flex items-center gap-1.5 ${Wh(r===e.key)}`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>i(e.key),className:`max-w-[160px] truncate`,children:e.label}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>s(e.key),"aria-label":`Close ${e.label}`,className:`text-[var(--color-fg-4)] hover:text-rose-300`,children:`×`})]},e.key))]}),r===null?(0,D.jsx)(Vh,{onOpenSession:o}):(0,D.jsx)(Ph,{sessionKey:r})]})}function Kh({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 qh({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 Jh(e){return e===void 0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Yh(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 Xh(e,t){return t&&e.startsWith(`${t}/`)?`~/${e.slice(t.length+1)}`:e===t?`~`:e}function Zh({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)(Kh,{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:Xh(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:Jh(e.size)}),(0,D.jsx)(`span`,{className:`text-[10.5px] text-[var(--color-fg-3)] min-w-[60px] text-right`,children:Yh(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 Qh({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)(Kh,{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 $h({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 eg={"claude-code":`Claude Code`,cursor:`Cursor`,codex:`Codex CLI`,pi:`Pi Agent`,gemini:`Gemini CLI`,antigravity:`Antigravity`,copilot:`GitHub Copilot`};function tg({adapter:e,home:t}){let n=eg[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)(Kh,{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)(Zh,{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 ng(){let{data:e,loading:t,error:n,refetch:r}=U(`/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`,{"data-tutorial":`setup-summary`,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)(Kh,{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:Xh(_,g)})]})]}),(0,D.jsx)(Qh,{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)(Kh,{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)(qh,{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)(Qh,{title:`License & authentication`,status:a.status===`healthy`||a.status===`healthy_free`?`ok`:`warn`,children:[(0,D.jsx)($h,{k:`Tier`,v:a.tier_label}),(0,D.jsx)($h,{k:`Status`,v:a.status}),(0,D.jsx)($h,{k:`Account`,v:a.email??`—`}),(0,D.jsx)($h,{k:`Auth method`,v:a.auth_method??`—`}),(0,D.jsx)($h,{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)(Zh,{file:a.license_file,home:g}),(0,D.jsx)(Zh,{file:a.hosts_file,home:g})]})]}),(0,D.jsxs)(Qh,{title:`Runtime processes`,status:o.alive&&s.alive?`ok`:`warn`,children:[(0,D.jsx)($h,{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)($h,{k:`Daemon socket`,v:o.socket_exists?`present`:`missing`,mono:!0}),(0,D.jsx)($h,{k:`Dashboard (serve)`,v:s.alive?`running — PID ${s.pid}`:`not running`}),(0,D.jsx)($h,{k:`Native engine`,v:c.available?`loaded — sub-ms eval available`:`unavailable — TypeScript fallback`})]}),(0,D.jsxs)(Qh,{title:`Database & MCP`,status:l.status,children:[(0,D.jsx)($h,{k:`Rules in DB`,v:l.rules.toLocaleString()}),(0,D.jsx)($h,{k:`Audit log rows`,v:l.audit_rows.toLocaleString()}),(0,D.jsx)($h,{k:`DB path`,v:Xh(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)($h,{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)($h,{k:`All-time calls`,v:u.total.toLocaleString()})]})]}),(0,D.jsxs)(Qh,{title:`Rules directories`,status:d.local_count>0?`ok`:`warn`,children:[(0,D.jsx)($h,{k:`Local`,v:`${d.local_count} .rules file${d.local_count===1?``:`s`}`}),(0,D.jsx)($h,{k:`Local path`,v:Xh(d.local_dir,g),mono:!0}),(0,D.jsx)($h,{k:`Global`,v:`${d.global_count} .rules file${d.global_count===1?``:`s`}`}),(0,D.jsx)($h,{k:`Global path`,v:Xh(d.global_dir,g),mono:!0})]}),(0,D.jsx)(Qh,{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)(Zh,{file:e,home:g},e.path))})}),(0,D.jsx)(Qh,{title:`Adapters, hooks & MCP files`,hint:e.active_adapter?`Active: ${eg[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)(tg,{adapter:e,home:g},e.id))})}),(0,D.jsxs)(Qh,{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)(Zh,{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)(Kh,{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:Yh(e.installed_at)})]}),(0,D.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--color-fg-2)]`,title:e.path,children:Xh(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 rg=[{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`}],ig=[{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`}}],ag=`ssg.tryit.intro-dismissed.v1`,og=`ssg.tryit.os.v1`,sg={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 cg(){if(typeof window>`u`)return`linux`;try{let e=window.localStorage.getItem(og);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 lg(e){return e===`windows`?`Windows`:e===`macos`?`Mac`:`Linux`}function ug(e){return e===`windows`?`⊞`:e===`macos`?`🍎`:`🐧`}function dg(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 fg({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 pg({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 ${lg(n)}`,children:[ug(n),` `,lg(n)]},n))})}function mg({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)(fg,{n:1,label:`Pick a scenario below`}),(0,D.jsx)(fg,{n:2,label:`Click Run`}),(0,D.jsx)(fg,{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)(pg,{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 hg({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:dg(e,n)})]})}function gg(){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(ag)===`1`}catch{return!1}}),[g,v]=(0,_.useState)(()=>cg()),[y,b]=(0,_.useState)(!1);function x(e){v(e);try{window.localStorage.setItem(og,e)}catch{}}function S(){h(!0);try{window.localStorage.setItem(ag,`1`)}catch{}}function C(){h(!1);try{window.localStorage.removeItem(ag)}catch{}}let w=ig.find(t=>t.id===e),T=(0,_.useMemo)(()=>{let e=new Map;for(let t of ig){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return rg.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&&ig.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`,...W()},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 ee(){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 A=n?sg[n.decision]??sg.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)(mg,{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)(pg,{os:g,setOs:x})]}),(0,D.jsx)(`div`,{"data-tutorial":`try-scenarios`,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)(hg,{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`,{"data-tutorial":`try-detail`,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 · `,lg(g)]}),(0,D.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--color-fg-1)] break-all`,children:dg(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
52
52
  border border-[var(--color-line-1)] bg-[var(--color-surface-1)] text-[var(--color-fg-2)]
53
53
  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
54
54
  bg-[var(--color-brand)] text-white hover:opacity-90
55
55
  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&&A&&(0,D.jsxs)(`div`,{id:`tryit-result`,className:`rounded-xl border p-4 ${A.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 ${A.bg} ${A.color}`,children:A.icon}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-[15px] font-semibold ${A.color}`,children:A.label}),(0,D.jsx)(`p`,{className:`text-[12.5px] mt-0.5 ${A.color} opacity-90`,children:A.headline})]})]}),(0,D.jsx)(`p`,{className:`text-[12.5px] text-[var(--color-fg-1)] leading-relaxed`,children:A.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
56
56
  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`,{"data-tutorial":`try-advanced`,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:ee,disabled:i,className:`px-3 h-8 rounded-full text-[11px] font-medium cursor-pointer transition-colors
57
57
  bg-[var(--color-fg-1)] text-[var(--color-bg)] hover:opacity-90
58
- disabled:opacity-40 disabled:cursor-not-allowed`,children:`Run`})]})]})]})]})}var vg={off:{label:`Off`,blurb:`Don't track or limit spend.`,tone:`var(--color-fg-3)`},monitor:{label:`Just track`,blurb:`Record spend and show it here. Never blocks anything.`,tone:`var(--color-decision-allow)`},warn:{label:`Warn me`,blurb:`Ask for confirmation when an agent crosses a limit.`,tone:`var(--color-decision-ask)`},enforce:{label:`Hard stop`,blurb:`Block agent actions once a limit is hit.`,tone:`var(--color-decision-block)`}},yg=[`off`,`monitor`,`warn`,`enforce`],bg=[{id:`light`,label:`Light`,hint:`$5/day · $25/wk · $75/mo`,daily:5,weekly:25,monthly:75},{id:`standard`,label:`Standard`,hint:`$20/day · $100/wk · $300/mo`,daily:20,weekly:100,monthly:300},{id:`heavy`,label:`Heavy`,hint:`$100/day · $500/wk · $1,500/mo`,daily:100,weekly:500,monthly:1500},{id:`none`,label:`No limit`,hint:`unlimited`,daily:null,weekly:null,monthly:null}],xg={sessionUsd:null,dailyUsd:null,weeklyUsd:null,monthlyUsd:null},Sg=[{key:`sessionUsd`,label:`Per session`},{key:`dailyUsd`,label:`Per day`},{key:`weeklyUsd`,label:`Per 7 days`},{key:`monthlyUsd`,label:`Per month`}],Cg={sessionUsd:`sessionUsd`,dailyUsd:`dailyUsd`,weeklyUsd:`weeklyUsd`,monthlyUsd:`monthlyUsd`};function wg(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Tg(e,t){return t===null||!(t>0)?null:e/t}function Eg(e,t){return e===null?`var(--color-line-2)`:e>=1?`var(--color-decision-block)`:e>=t?`var(--color-decision-ask)`:`var(--color-decision-allow)`}function Dg({label:e,spend:t,cap:n,warnAtPct:r}){let i=Tg(t,n),a=i===null?0:Math.min(100,i*100);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,D.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e}),(0,D.jsxs)(`span`,{className:`font-mono text-[13px] text-[var(--color-fg-0)]`,children:[wg(t),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[` `,`/ `,n===null?`no limit`:wg(n)]})]})]}),(0,D.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full`,style:{background:`var(--color-surface-3)`},children:(0,D.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${a}%`,background:Eg(i,r)}})})]})}function Og({mode:e,onPick:t,busy:n}){return(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:yg.map(r=>{let i=r===e,a=vg[r];return(0,D.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(r),className:`flex flex-col gap-1 rounded-md border p-3 text-left transition-colors disabled:opacity-50`,style:{borderColor:i?a.tone:`var(--color-line-1)`,background:i?`color-mix(in srgb, var(--color-brand) 8%, transparent)`:`transparent`},children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold`,style:{color:i?`var(--color-fg-0)`:`var(--color-fg-1)`},children:a.label}),(0,D.jsx)(`span`,{className:`text-[11px] leading-snug text-[var(--color-fg-3)]`,children:a.blurb})]},r)})})}function kg({value:e,onCommit:t,disabled:n}){let[r,i]=(0,_.useState)(e===null?``:String(e));return(0,_.useEffect)(()=>{i(e===null?``:String(e))},[e]),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`$`}),(0,D.jsx)(`input`,{type:`number`,min:`0`,step:`1`,inputMode:`decimal`,disabled:n,value:r,placeholder:`—`,onChange:e=>i(e.target.value),onBlur:()=>{let e=r.trim();if(e===``){t(null);return}let n=Number(e);t(Number.isFinite(n)&&n>0?n:null)},className:`w-20 rounded border bg-[var(--color-surface-1)] px-1.5 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}})]})}function Ag(){let e=Ge([`budget-changed`,`eval-burst`]),{data:t,loading:n,error:r,refetch:i}=U(`/api/json/budget`,[(e[`budget-changed`]??0)+(e[`eval-burst`]??0)]),[a,o]=(0,_.useState)(`simple`),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),p=t?.config??null;(0,_.useEffect)(()=>{p&&s===null&&c(p)},[p,s]);let m=t?.snapshot??null,h=s??p,g=(0,_.useMemo)(()=>!s||!p?!1:JSON.stringify(s)!==JSON.stringify(p),[s,p]);async function v(e){u(!0),f(null);try{let t=await fetch(`/api/json/budget`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({mode:e.mode,warnAtPct:e.warnAtPct,global:e.global,perClient:e.perClient})});if(!t.ok)throw Error(`HTTP ${t.status}`);c((await t.json()).config),i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}function y(e){if(!h)return;let t=e(jg(h));c(t),v(t)}function b(e){h&&c(e(jg(h)))}if(n&&!t)return(0,D.jsx)(`div`,{className:`p-6 text-[var(--color-fg-3)]`,children:`Loading…`});if(r&&!t)return(0,D.jsxs)(`div`,{className:`p-6 text-[var(--color-decision-block)]`,children:[`Failed to load spend limits: `,r]});if(!h)return null;let x=m?.global.spend.monthlyUsd??0,S=m?.global.spend.dailyUsd??0,C=m?.global.spend.weeklyUsd??0,w=m?[m.global,...m.clients]:[];return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[17px] font-semibold text-[var(--color-fg-0)]`,children:`Token Spending Limits`}),(0,D.jsx)(`p`,{className:`max-w-2xl text-[12px] leading-snug text-[var(--color-fg-3)]`,children:`Cap what your AI agents (Claude Code, Codex, Gemini, and others) can spend per day, week, or month — so a runaway loop or an un-metered seat can't quietly run up a giant bill.`})]}),(0,D.jsxs)(`div`,{className:`flex items-center overflow-hidden rounded-sm border border-[var(--color-line-1)] text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(`simple`),className:`px-2.5 py-1 ${a===`simple`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)]`}`,children:`simple`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(`technical`),className:`border-l border-[var(--color-line-1)] px-2.5 py-1 ${a===`technical`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)]`}`,children:`technical`})]})]}),m===null&&(0,D.jsx)(`div`,{className:`rounded-md border border-l-2 border-l-[var(--color-decision-ask)] border-[var(--color-line-1)] px-3 py-2 text-[12px] text-[var(--color-fg-2)]`,children:`Live spend is unavailable (the eval daemon may be starting). You can still set limits — they apply as soon as the daemon is up.`}),(0,D.jsxs)(q,{children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Enforcement mode`}),l&&(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`saving…`})]}),(0,D.jsxs)(Y,{className:`overflow-visible`,children:[(0,D.jsx)(Og,{mode:h.mode,busy:l,onPick:e=>y(t=>({...t,mode:e}))}),d&&(0,D.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--color-decision-block)]`,children:d})]})]}),a===`simple`?(0,D.jsx)(Mg,{cfg:h,monthlySpend:x,dailySpend:S,weeklySpend:C,agentRows:w,busy:l,onPreset:(e,t,n)=>y(r=>({...r,global:{...r.global,dailyUsd:e,weeklyUsd:t,monthlyUsd:n}})),onWarnAt:e=>y(t=>({...t,warnAtPct:e}))}):(0,D.jsx)(Ng,{cfg:h,snapshot:m,dirty:g,busy:l,onEdit:b,onSave:()=>h&&v(h),onReset:()=>p&&c(p)})]})}function jg(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function Mg({cfg:e,monthlySpend:t,dailySpend:n,weeklySpend:r,agentRows:i,busy:a,onPreset:o,onWarnAt:s}){let c=bg.find(t=>t.daily===e.global.dailyUsd&&t.weekly===e.global.weeklyUsd&&t.monthly===e.global.monthlyUsd);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Where you stand`})}),(0,D.jsxs)(Y,{className:`flex flex-col gap-4 overflow-visible`,children:[(0,D.jsx)(Dg,{label:`Today (all agents)`,spend:n,cap:e.global.dailyUsd,warnAtPct:e.warnAtPct}),(0,D.jsx)(Dg,{label:`This week (all agents)`,spend:r,cap:e.global.weeklyUsd,warnAtPct:e.warnAtPct}),(0,D.jsx)(Dg,{label:`This month (all agents)`,spend:t,cap:e.global.monthlyUsd,warnAtPct:e.warnAtPct})]})]}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Pick a spending limit`})}),(0,D.jsxs)(Y,{className:`overflow-visible`,children:[(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:bg.map(e=>{let t=c?.id===e.id;return(0,D.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>o(e.daily,e.weekly,e.monthly),className:`flex flex-col gap-0.5 rounded-md border p-3 text-left disabled:opacity-50`,style:{borderColor:t?`var(--color-brand)`:`var(--color-line-1)`,background:t?`color-mix(in srgb, var(--color-brand) 8%, transparent)`:`transparent`},children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:e.label}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:e.hint})]},e.id)})}),(0,D.jsxs)(`div`,{className:`mt-4 flex flex-col gap-1`,children:[(0,D.jsxs)(`label`,{htmlFor:`ssg-warn-range`,className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:[`Warn me at `,Math.round(e.warnAtPct*100),`% of a limit`]}),(0,D.jsx)(`input`,{id:`ssg-warn-range`,type:`range`,min:`50`,max:`95`,step:`5`,disabled:a,value:Math.round(e.warnAtPct*100),onChange:e=>s(Number(e.target.value)/100),className:`w-full max-w-sm`})]})]})]}),i.length>1&&(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`This month, by agent`})}),(0,D.jsxs)(Y,{className:`flex flex-col gap-3 overflow-visible`,children:[i.filter(e=>e.scope===`client`).map(t=>(0,D.jsx)(Dg,{label:t.client??`(unknown)`,spend:t.spend.monthlyUsd,cap:t.caps.monthlyUsd??e.global.monthlyUsd,warnAtPct:e.warnAtPct},t.client??`?`)),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Need a tighter cap on one agent? Switch to the technical view.`})]})]})]})}function Ng({cfg:e,snapshot:t,dirty:n,busy:r,onEdit:i,onSave:a,onReset:o}){let[s,c]=(0,_.useState)(``),l=Object.keys(e.perClient),u=e=>t?e===null?t.global.spend:t.clients.find(t=>t.client===e)?.spend??null:null;function d(e,t,n){i(r=>{if(e===null)return{...r,global:{...r.global,[t]:n}};let i=r.perClient[e]??{...xg};return{...r,perClient:{...r.perClient,[e]:{...i,[t]:n}}}})}function f(){let t=s.trim().toLowerCase();!/^[a-z0-9._:-]{1,64}$/.test(t)||e.perClient[t]||(i(e=>({...e,perClient:{...e.perClient,[t]:{...xg}}})),c(``))}function p(e){i(t=>{let n={...t.perClient};return delete n[e],{...t,perClient:n}})}let m=(t,n)=>{let i=t===null?e.global:e.perClient[t]??xg,a=u(t);return(0,D.jsxs)(`tr`,{className:`border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`td`,{className:`py-2 pr-3 align-top`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-[12px] text-[var(--color-fg-0)]`,children:n}),t!==null&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>p(t),className:`text-[11px] text-[var(--color-fg-3)] hover:text-[var(--color-decision-block)]`,children:`remove`})]})}),Sg.map(e=>{let n=a?a[Cg[e.key]]:null;return(0,D.jsxs)(`td`,{className:`py-2 pr-3 align-top`,children:[(0,D.jsx)(kg,{value:i[e.key],disabled:r,onCommit:n=>d(t,e.key,n)}),n!=null&&(0,D.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-[var(--color-fg-3)]`,children:[`now `,wg(n)]})]},e.key)})]},t??`__global`)};return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(q,{children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Caps by agent and window`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,D.jsx)(K,{variant:`ghost`,size:`sm`,disabled:r,onClick:o,children:`Discard`}),(0,D.jsx)(K,{variant:`primary`,size:`sm`,disabled:r||!n,onClick:a,children:r?`Saving…`:`Save limits`})]})]}),(0,D.jsxs)(Y,{className:`overflow-auto`,children:[(0,D.jsxs)(`table`,{className:`w-full text-left text-[12px]`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{className:`pb-2 pr-3 text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:`Scope`}),Sg.map(e=>(0,D.jsx)(`th`,{className:`pb-2 pr-3 text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e.label},e.key))]})}),(0,D.jsxs)(`tbody`,{children:[m(null,`global (all agents)`),l.map(e=>m(e,e))]})]}),(0,D.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`text`,value:s,placeholder:`agent id (e.g. codex)`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f()},className:`w-44 rounded border bg-[var(--color-surface-1)] px-2 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}}),(0,D.jsx)(K,{variant:`secondary`,size:`sm`,onClick:f,children:`Add agent cap`}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Known ids: claude-code · codex · gemini · cursor`})]})]})]}),(0,D.jsxs)(q,{children:[(0,D.jsx)(J,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Warn threshold & policy`})}),(0,D.jsxs)(Y,{className:`flex flex-col gap-3 overflow-visible`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{children:`Warn at`}),(0,D.jsx)(`input`,{type:`number`,min:`1`,max:`100`,step:`1`,disabled:r,value:Math.round(e.warnAtPct*100),onChange:e=>i(t=>({...t,warnAtPct:Math.min(1,Math.max(.01,Number(e.target.value)/100))})),className:`w-16 rounded border bg-[var(--color-surface-1)] px-1.5 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}}),(0,D.jsx)(`span`,{children:`% of any cap.`})]}),(0,D.jsxs)(`p`,{className:`text-[11px] leading-snug text-[var(--color-fg-3)]`,children:[`Enforcement runs at the eval gate after the normal rule pass: over a cap → blocked (enforce) or asked (warn); past the warn threshold → asked. Spend is the directional estimate from`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg cost summary`}),`; the daemon re-reads this policy within ~2s of a save.`]}),(0,D.jsx)(`pre`,{className:`overflow-auto rounded border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-2 font-mono text-[10px] text-[var(--color-fg-2)]`,children:JSON.stringify({mode:e.mode,warnAtPct:e.warnAtPct,global:e.global,perClient:e.perClient},null,2)})]})]})]})}function Pg(e){switch(e){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`linux`:return`Linux`;default:return e??`unknown OS`}}function Fg(e){return e?`${e.app_version?`ssg ${e.app_version}`:`ssg (unknown version)`} · ${`${Pg(e.platform)}${e.arch?` ${e.arch}`:``}`}${e.electrobun_channel&&e.electrobun_channel!==`web`?` · ${e.electrobun_channel}`:``}`:``}var Ig=[{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`}],Lg=[{value:`p4`,label:`P4 — Low`},{value:`p3`,label:`P3 — Normal`},{value:`p2`,label:`P2 — High (4h SLA)`},{value:`p1`,label:`P1 — Critical (1h SLA)`}],Rg=5,zg=8*1024*1024;function Bg(){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,w]=(0,_.useState)(``),T=(0,_.useRef)(null);async function E(e,t){try{await navigator.clipboard.writeText(e),S(t),setTimeout(()=>S(``),1500)}catch{}}(0,_.useEffect)(()=>{fetch(`/api/json/profile`,{headers:W()}).then(e=>e.ok?e.json():null).then(e=>{e?.email&&l(e.email)}).catch(()=>{})},[]),(0,_.useEffect)(()=>{fetch(`/api/support/diagnostics?route=${encodeURIComponent(window.location.pathname)}`).then(e=>e.ok?e.json():null).then(e=>v(e)).catch(()=>{})},[]),(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 O(e){e.preventDefault(),ee(Array.from(e.dataTransfer.files))}function k(e){ee(Array.from(e.target.files??[])),T.current&&(T.current.value=``)}function ee(e){w(``);let t=e.filter(e=>e.type.startsWith(`image/`));t.length<e.length&&w(`Only image files are accepted.`);let n=Rg-u.length,r=t.slice(0,n);r.length<t.length&&w(`Maximum ${Rg} images. Some were dropped.`);let i=r.filter(e=>e.size>zg);if(i.length>0){w(`"${i[0].name}" exceeds 8 MiB.`);return}let a=r.map(e=>({file:e,preview:URL.createObjectURL(e)}));d(e=>[...e,...a])}function A(e){d(t=>(URL.revokeObjectURL(t[e].preview),t.filter((t,n)=>n!==e)))}async function j(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:W(),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)(q,{children:(0,D.jsx)(Y,{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:j,className:`space-y-4`,children:[(0,D.jsx)(q,{children:(0,D.jsxs)(Y,{children:[(0,D.jsx)(`label`,{className:`block overline mb-2`,children:`type`}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Ig.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)(q,{children:(0,D.jsxs)(Y,{children:[(0,D.jsx)(`label`,{className:`block overline mb-2`,children:`severity`}),(0,D.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:Lg.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)(q,{children:(0,D.jsx)(Y,{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`,{"data-tutorial":`support-subject`,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`,{"data-tutorial":`support-desc`,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)(q,{children:(0,D.jsxs)(Y,{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 `,Rg,` images)`]})]}),u.length<Rg&&(0,D.jsxs)(`div`,{"data-tutorial":`support-attach`,onDragOver:e=>e.preventDefault(),onDrop:O,onClick:()=>T.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:T,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:k}),C&&(0,D.jsx)(`p`,{className:`text-xs text-red-400 font-mono mt-2`,children:C}),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:()=>A(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)] bg-[var(--color-surface-0)] px-3 py-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`overline block mb-0.5`,children:`environment`}),(0,D.jsx)(`code`,{className:`block text-[12px] font-mono text-[var(--color-fg-1)] truncate`,children:g?Fg(g):`Detecting…`})]}),(0,D.jsx)(`button`,{type:`button`,disabled:!g,onClick:()=>E(Fg(g),`summary`),title:`Copy your ssg version and OS for a bug report`,className:`shrink-0 text-[11px] font-mono px-2.5 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-0)] transition-colors disabled:opacity-40`,children:x===`summary`?`copied ✓`:`copy`})]}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] font-mono mt-1.5`,children:`attached to your report automatically — copy it to share when asking for help elsewhere`})]}),(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:`full diagnostics that will be attached`}),(0,D.jsx)(`span`,{children:y?`▲`:`▼`})]}),y&&(0,D.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border-t border-[var(--color-line-1)]`,children:[(0,D.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,D.jsx)(`button`,{type:`button`,disabled:!g,onClick:()=>E(JSON.stringify(g,null,2),`json`),className:`text-[11px] font-mono px-2.5 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-0)] transition-colors disabled:opacity-40`,children:x===`json`?`copied ✓`:`copy JSON`})}),(0,D.jsx)(`div`,{className:`px-3 py-2 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)(K,{type:`submit`,variant:`primary`,disabled:f,children:f?`submitting…`:`submit feedback`})]})]})}function Vg(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 Hg={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 Ug(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 Wg({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 Gg(){let{data:e}=U(`/api/json/counters`,[Ge([`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)(Kg,{value:t,label:`evaluated`,tone:`default`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(Kg,{value:n,label:`blocked`,tone:`red`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(Kg,{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 Kg({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 qg({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)(Wg,{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 Jg(){let{data:e}=U(`/api/state/activity?limit=5`,[Ge([`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:Hg[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:Hg[e.decision]??`var(--color-fg-2)`},children:Ug(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:ea(e.tool)}),(0,D.jsx)(`span`,{className:`hig-feed-row-time`,children:Vg(e.timestamp)})]},e.id??t))})}function Yg(){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`,{"data-tutorial":`wh-hero`,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)(Gg,{})})]}),(0,D.jsx)(`section`,{children:(0,D.jsxs)(`div`,{"data-tutorial":`wh-actions`,className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(qg,{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)(qg,{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)(qg,{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`,"data-tutorial":`wh-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)(Jg,{})})]})]})})}var Xg={persistence:(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 3v8`}),(0,D.jsx)(`path`,{d:`M7.5 6.5a7 7 0 109 0`})]}),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`})]}),plugins:(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 3v4a2 2 0 0 1-2 2H3`}),(0,D.jsx)(`path`,{d:`M15 3v4a2 2 0 0 0 2 2h4`}),(0,D.jsx)(`rect`,{x:`3`,y:`9`,width:`18`,height:`12`,rx:`2`}),(0,D.jsx)(`path`,{d:`M7 14h2M12 14h5M7 18h10`})]})},Zg=[{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`},{path:`/spending-limits`,label:`Spending Limits`,icon:`observability`}]},{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:`/plugins`,label:`Plugins`,icon:`plugins`},{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/persistence`,label:`Persistence`,icon:`persistence`},{path:`/backup`,label:`Export & Import`,icon:`setup`},{path:`/debug`,label:`Debug`,icon:`debug`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}],Qg=[{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`},{path:`/spending-limits`,label:`Spending Limits`,icon:`observability`}]},{title:`You`,items:[{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/persistence`,label:`Persistence`,icon:`persistence`},{path:`/backup`,label:`Export & Import`,icon:`setup`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}];function $g(e){return e_(e===`newcomer`?Qg:Zg)}function e_(e){let t=window.__SSG_PLUGINS__;if(!t||t.nav.length===0)return e;let n=e=>{let t=e.toLowerCase();return t===`tools`?`Tools`:t===`activity`?`Activity`:t===`overview`?`Overview`:t===`rules`?`Rules`:e.charAt(0).toUpperCase()+e.slice(1)},r=e.map(e=>({...e,items:[...e.items]})),i=new Map;for(let e of t.nav){let t={path:e.path,label:e.label,icon:`plugins`},a=n(e.section),o=r.find(e=>e.title===a);if(o)o.items.push(t);else{let e=i.get(a)??[];e.push(t),i.set(a,e)}}for(let[e,t]of i)r.push({title:e,items:t});return r}function t_(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 n_(){let{data:e}=U(`/api/json/daemon-status`,[Ge([`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?t_(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(`
59
- `)})]})]})]})}function r_(){let{data:e}=U(`/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 i_(){let{data:e}=U(`/api/json/license`,[Ge([`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 a_(){let{data:e}=U(`/api/json/license`,[Ge([`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 o_(){let{data:e,refetch:t}=U(`/api/json/ask-mode`),[n,r]=(0,_.useState)(!1),i=e?.mode??`native`;async function a(e){if(!(n||e===i)){r(!0);try{await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}let o=i===`dashboard`;return(0,D.jsxs)(`button`,{onClick:()=>a(o?`tty`:`dashboard`),disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:o?`ASK decisions queue on /approvals. Click to route to native prompt.`:`ASK decisions prompt in the native IDE/TTY. Click to route to dashboard.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${o?`bg-[var(--color-hig-purple)]`:`bg-[var(--color-hig-blue)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Ask · `,o?`Dashboard`:`Native`]})]})}function s_(){let{data:e,refetch:t}=U(`/api/json/session-banner`),[n,r]=(0,_.useState)(!1),i=e?.enabled??!0;async function a(){if(!n){r(!0);try{await fetch(`/api/json/session-banner`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({enabled:!i})}),t()}finally{r(!1)}}}return(0,D.jsxs)(`button`,{onClick:a,disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:i?`SessionStart banner is ON — every Claude Code session opens with the active-rule count + dashboard link. Click to hide it.`:`SessionStart banner is OFF. Click to show it at the start of each session.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${i?`bg-[var(--color-hig-green)]`:`bg-[var(--color-fg-3)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Banner · `,i?`On`:`Off`]})]})}function c_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:e?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-hig-green)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2l8 3v6c0 5-3.5 9.5-8 11-4.5-1.5-8-6-8-11V5l8-3z`}),e?(0,D.jsx)(`path`,{d:`M8.5 12.2l2.5 2.5 4.5-5`,stroke:`var(--color-accent-on)`,fill:`none`}):null]})}function l_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-hig-green)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2v10`}),(0,D.jsx)(`path`,{d:`M18.4 6.6a9 9 0 1 1-12.8 0`})]})}function u_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-brand)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`line`,{x1:`4`,y1:`21`,x2:`4`,y2:`14`}),(0,D.jsx)(`line`,{x1:`4`,y1:`10`,x2:`4`,y2:`3`}),(0,D.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`3`}),(0,D.jsx)(`line`,{x1:`20`,y1:`21`,x2:`20`,y2:`16`}),(0,D.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`3`}),(0,D.jsx)(`line`,{x1:`1`,y1:`14`,x2:`7`,y2:`14`}),(0,D.jsx)(`line`,{x1:`9`,y1:`8`,x2:`15`,y2:`8`}),(0,D.jsx)(`line`,{x1:`17`,y1:`16`,x2:`23`,y2:`16`})]})}function d_(){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--color-decision-block)`},"aria-hidden":`true`,children:[(0,D.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,D.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,D.jsx)(`line`,{x1:`10`,y1:`11`,x2:`10`,y2:`17`}),(0,D.jsx)(`line`,{x1:`14`,y1:`11`,x2:`14`,y2:`17`})]})}function f_(){let{enabled:e,saving:t,setEnabled:n}=Dn();return(0,D.jsxs)(`button`,{onClick:()=>n(!e),disabled:t,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:e?`Self-protection is ON — AI agents are blocked from uninstalling SigmaShake (ssg + Desktop). Click to turn off.`:`Self-protection is OFF — an AI agent could uninstall SigmaShake. Click to turn on.`,"aria-pressed":e,children:[(0,D.jsx)(c_,{on:e}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Self-protect · `,e?`On`:`Off`]})]})}function p_(){let{enabled:e,saving:t,setEnabled:n}=Dn();return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta`,"data-on":e?`true`:`false`,disabled:t,"aria-pressed":e,onClick:()=>n(!e),title:e?`AI agents are blocked from uninstalling SigmaShake. Click to turn protection off.`:`AI agents can currently uninstall SigmaShake. Click to turn protection on.`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(c_,{on:e})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`Agent self-protection`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:e?`On · uninstall blocked`:`Off · agent can uninstall`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function m_(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 g_(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`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`,...W()},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 ${m_(e.rearmAt)}`:``,c=`SSG · ${i.toUpperCase()}${s}`;return(0,D.jsxs)(`button`,{"data-tutorial":`app-mode`,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,D.jsx)(`span`,{className:`status-dot ${o}`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:c})]})}function __(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`mode-changed`])[`mode-changed`]]),n=e?.mode??`on`;if(n===`on`)return null;let r=e?.rearmAt===void 0?``:` Auto-restores at ${m_(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`,...W()},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 v_(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`mode-changed`])[`mode-changed`]]),[n,r]=(0,_.useState)(!1),i=e?.mode??`on`,a=i===`on`;async function o(e){if(!n){r(!0);try{await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta`,"data-on":a?`true`:`false`,disabled:n,"aria-pressed":a,onClick:()=>o(a?`off`:`on`),title:a?`SSG is ON — rules enforce normally. Click to switch OFF (kill switch: every tool call is allowed without evaluation).`:`SSG is not fully enforcing. Click to switch it ON (normal rule enforcement).`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(l_,{on:a})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`SSG enforcement`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:i===`on`?`On · rules enforced`:i===`off`?`Off · all calls allowed`:i===`soft`?`Soft · blocks downgraded`:`Audit · log-only`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function y_(){let{mode:e,setMode:t}=Ht(),n=e===`pro`;return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta hig-shield-cta--brand`,"data-on":n?`true`:`false`,"aria-pressed":n,onClick:()=>t(n?`newcomer`:`pro`),title:n?`Advanced view — every page and tool is shown. Click for Simple (guided) view.`:`Simple view — a guided, pared-down set of pages. Click for Advanced (all tools).`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(u_,{on:n})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`Interface mode`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:n?`Advanced · all tools`:`Simple · guided`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function b_(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>t(!1),4e3);return()=>clearTimeout(n)},[e]);async function o(){r(!0);try{await fetch(`/api/json/uninstall-everything`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({keepData:!0})}),a(!0)}finally{r(!1),t(!1)}}return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta hig-shield-cta--danger`,"data-armed":e?`true`:`false`,disabled:n||i,"aria-label":`Uninstall SigmaShake from all AI clients`,onClick:()=>{if(!(i||n)){if(!e){t(!0);return}o()}},title:`Remove SigmaShake everywhere — uninstalls hooks, MCP entries, and the daemon from every detected AI client. Your activity history and license are kept.`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(d_,{})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:i?`Uninstall started`:`Uninstall SigmaShake`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:i?`Removed from detected clients`:n?`Removing…`:e?`Click again to confirm`:`Remove from all AI clients`})]})]})}function x_(){return(0,D.jsxs)(`div`,{className:`hig-sidebar-cta-group`,children:[(0,D.jsx)(p_,{}),(0,D.jsx)(v_,{}),(0,D.jsx)(y_,{}),(0,D.jsx)(b_,{})]})}function S_({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 C_(){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 w_(){let{data:e}=U(`/api/json/mcp-status`,[Ge([`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 T_(){let{data:e}=U(`/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 E_(e,t){if(e===`/`)return t===`newcomer`?(0,D.jsx)(Yg,{}):(0,D.jsx)(hu,{});if(e===`/graph`)return(0,D.jsx)(ff,{});if(e===`/sessions`)return(0,D.jsx)(Kh,{});if(e.startsWith(`/sessions/`)){let t=decodeURIComponent(e.slice(10));if(t)return(0,D.jsx)(Fh,{sessionKey:t})}if(e===`/debug`)return(0,D.jsx)(vu,{});if(e===`/rules`)return(0,D.jsx)(Th,{});if(e===`/spending-limits`)return(0,D.jsx)(Ag,{});if(e===`/audit`)return(0,D.jsx)(wa,{});if(e===`/approvals`)return(0,D.jsx)(Ki,{});if(e===`/profile`)return(0,D.jsx)(Mm,{});if(e===`/backup`)return(0,D.jsx)(Ea,{});if(e===`/agents`)return(0,D.jsx)(Qn,{});if(e===`/notifications`)return(0,D.jsx)(ip,{});if(e===`/setup`)return(0,D.jsx)(rg,{});if(e===`/persistence`)return(0,D.jsx)(Wp,{});if(e===`/try`)return(0,D.jsx)(_g,{});if(e===`/guardrails`)return(0,D.jsx)(bf,{});if(e===`/hub/connect`)return(0,D.jsx)(pf,{});if(e===`/hub/publish`)return(0,D.jsx)(Nf,{});if(e.startsWith(`/hub/`)){let t=e.slice(5);if(t)return(0,D.jsx)(hf,{id:t})}return e===`/hub`?(0,D.jsx)(jf,{}):e===`/monitor`?(0,D.jsx)(np,{}):e===`/observability`?(0,D.jsx)(jp,{}):e===`/plugins`?(0,D.jsx)(vm,{}):e===`/publish-plugin`?(0,D.jsx)(Jp,{}):e===`/support`?(0,D.jsx)(Bg,{}):(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 D_(e,t){return e===`/`?t===`newcomer`?`Home`:`Dashboard`:e===`/graph`?`Graph`:e===`/sessions`?`Sessions`:e.startsWith(`/sessions/`)?`Session Inspector`:e===`/debug`?`Debug`:e===`/rules`?`Rules`:e===`/spending-limits`?`Spending Limits`:e===`/audit`?t===`newcomer`?`Activity`:`Audit`:e===`/approvals`?`Approvals`:e===`/profile`?`Profile`:e===`/backup`?`Export & Import`:e===`/agents`?`Agents`:e===`/notifications`?`Notifications`:e===`/setup`?`Setup Status`:e===`/persistence`?`Persistence`: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===`/plugins`?`Plugins`:e===`/publish-plugin`?`Publish a Plugin`:e===`/support`?`Support & Feedback`:`SigmaShake`}function O_(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function k_({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 A_({onCollapse:e}){let{data:t}=U(`/api/health`),n=t?.version;return(0,D.jsxs)(`div`,{className:`hig-sidebar-footer`,children:[(0,D.jsx)(`span`,{className:`hig-sidebar-version`,title:n?`SigmaShake Governance v${n}`:`daemon version unavailable`,children:n?(0,D.jsxs)(D.Fragment,{children:[`ssg `,(0,D.jsxs)(`b`,{children:[`v`,n]})]}):`ssg`}),(0,D.jsx)(`button`,{type:`button`,className:`hig-sidebar-collapse`,"aria-label":`Collapse sidebar`,title:`Collapse sidebar`,onClick:e,children:(0,D.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M11 7l-5 5 5 5`}),(0,D.jsx)(`path`,{d:`M18 7l-5 5 5 5`})]})})]})}function j_({pathname:e,navSections:t,open:n,onClose:r,onCollapse:i}){let a=t=>t===`/`?e===`/`:e.startsWith(t);return(0,D.jsxs)(`aside`,{className:`hig-sidebar ${n?`open`:``}`,"aria-label":`Primary`,"data-tutorial":`app-sidebar`,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)(`button`,{className:`hig-sidebar-close`,"aria-label":`Close sidebar`,onClick:r,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:`4`,y1:`4`,x2:`14`,y2:`14`}),(0,D.jsx)(`line`,{x1:`14`,y1:`4`,x2:`4`,y2:`14`})]})})]}),(0,D.jsx)(x_,{}),(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":a(e.path)?`true`:`false`,children:[(0,D.jsx)(`span`,{className:`hig-sidebar-icon`,"aria-hidden":`true`,children:Xg[e.icon]}),(0,D.jsx)(`span`,{children:e.label})]},e.path))]},e.title))}),(0,D.jsx)(A_,{onCollapse:i})]})}function M_(){let[e,t]=(0,_.useState)(window.location.pathname),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>{try{return localStorage.getItem(`ssg:sidebar-collapsed`)===`1`}catch{return!1}}),{otherTabCount:c}=Mn(),{mode:l}=Ht(),u=$g(l),d=D_(e,l);return(0,_.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,_.useEffect)(()=>{a(!1)},[]),(0,_.useEffect)(()=>{try{localStorage.setItem(`ssg:sidebar-collapsed`,o?`1`:`0`)}catch{}},[o]),(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/`)||n.startsWith(`/plugins/`)||(e.preventDefault(),O_(n))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]),(0,D.jsxs)(`div`,{className:`hig-app`,"data-sidebar-collapsed":o?`true`:`false`,children:[(0,D.jsx)(j_,{pathname:e,navSections:u,open:i,onClose:()=>a(!1),onCollapse:()=>s(!0)}),i&&(0,D.jsx)(`div`,{className:`hig-sidebar-backdrop`,"aria-hidden":`true`,onClick:()=>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:`hig-sidebar-toggle hig-button hig-button-small`,onClick:()=>{window.matchMedia(`(min-width: 901px)`).matches?s(e=>!e):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:d}),(0,D.jsx)(Pt,{pathname:e,mode:l}),(0,D.jsx)(`div`,{className:`hig-toolbar-spacer`}),(0,D.jsxs)(`button`,{type:`button`,className:`hig-toolbar-search`,"aria-label":`Open command palette (Ctrl/Cmd+K)`,title:`Search pages, actions, rules (⌘K)`,onClick:()=>{window.dispatchEvent(new CustomEvent(`sigmashake:open-palette`,{detail:{query:``}}))},children:[(0,D.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,D.jsx)(`line`,{x1:`10.5`,y1:`10.5`,x2:`13.5`,y2:`13.5`})]}),(0,D.jsx)(`span`,{className:`hig-toolbar-search-text`,children:`Search…`}),(0,D.jsx)(`span`,{className:`hig-toolbar-search-kbd`,children:`⌘K`})]}),(0,D.jsxs)(`div`,{className:`hig-toolbar-controls hidden md:flex`,children:[c>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:`${c} other tab${c===1?``:`s`} open — may cause connection issues`,children:[c+1,` tabs`]}),(0,D.jsx)(Gt,{}),(0,D.jsx)(g_,{}),(0,D.jsx)(T_,{}),(0,D.jsx)(n_,{}),(0,D.jsx)(f_,{}),(0,D.jsx)(o_,{}),(0,D.jsx)(S_,{onRefresh:()=>r(e=>e+1)}),(0,D.jsxs)(`details`,{className:`hig-toolbar-menu`,children:[(0,D.jsx)(`summary`,{className:`chip`,title:`Settings`,"aria-label":`Settings`,children:`⚙`}),(0,D.jsxs)(`div`,{className:`hig-toolbar-menu-panel`,children:[(0,D.jsx)(s_,{}),(0,D.jsx)(w_,{}),(0,D.jsx)(Ut,{}),(0,D.jsx)(vt,{}),(0,D.jsx)(We,{}),(0,D.jsx)(C_,{})]})]})]})]}),(0,D.jsx)(O,{}),(0,D.jsx)(Tn,{}),(0,D.jsx)(Fe,{}),(0,D.jsx)(__,{}),(0,D.jsx)(k_,{count:c}),(0,D.jsx)(a_,{}),(0,D.jsx)(i_,{}),(0,D.jsx)(r_,{}),(e===`/`||e===`/graph`||e===`/sessions`||e.startsWith(`/sessions/`)||e===`/audit`)&&(0,D.jsx)(st,{}),(0,D.jsx)(`main`,{className:`hig-content px-6 py-6`,children:E_(e,l)},n)]})]})}var N_=document.getElementById(`app-root`);if(!N_)throw Error(`Missing #app-root`);v.createRoot(N_).render((0,D.jsx)(_.StrictMode,{children:(0,D.jsx)(M_,{})}));
58
+ disabled:opacity-40 disabled:cursor-not-allowed`,children:`Run`})]})]})]})]})}var _g={off:{label:`Off`,blurb:`Don't track or limit spend.`,tone:`var(--color-fg-3)`},monitor:{label:`Just track`,blurb:`Record spend and show it here. Never blocks anything.`,tone:`var(--color-decision-allow)`},warn:{label:`Warn me`,blurb:`Ask for confirmation when an agent crosses a limit.`,tone:`var(--color-decision-ask)`},enforce:{label:`Hard stop`,blurb:`Block agent actions once a limit is hit.`,tone:`var(--color-decision-block)`}},vg=[`off`,`monitor`,`warn`,`enforce`],yg=[{id:`light`,label:`Light`,hint:`$1/hr · $5/day · $25/wk · $75/mo`,hourly:1,daily:5,weekly:25,monthly:75},{id:`standard`,label:`Standard`,hint:`$4/hr · $20/day · $100/wk · $300/mo`,hourly:4,daily:20,weekly:100,monthly:300},{id:`heavy`,label:`Heavy`,hint:`$20/hr · $100/day · $500/wk · $1,500/mo`,hourly:20,daily:100,weekly:500,monthly:1500},{id:`none`,label:`No limit`,hint:`unlimited`,hourly:null,daily:null,weekly:null,monthly:null}],bg={sessionUsd:null,hourlyUsd:null,dailyUsd:null,weeklyUsd:null,monthlyUsd:null},xg=[{key:`sessionUsd`,label:`Per session`},{key:`hourlyUsd`,label:`Per hour`},{key:`dailyUsd`,label:`Per day`},{key:`weeklyUsd`,label:`Per 7 days`},{key:`monthlyUsd`,label:`Per month`}],Sg={sessionUsd:`sessionUsd`,hourlyUsd:`hourlyUsd`,dailyUsd:`dailyUsd`,weeklyUsd:`weeklyUsd`,monthlyUsd:`monthlyUsd`};function Cg(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function wg(e,t){return t===null||!(t>0)?null:e/t}function Tg(e,t){return e===null?`var(--color-line-2)`:e>=1?`var(--color-decision-block)`:e>=t?`var(--color-decision-ask)`:`var(--color-decision-allow)`}function Eg({label:e,spend:t,cap:n,warnAtPct:r}){let i=wg(t,n),a=i===null?0:Math.min(100,i*100);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,D.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e}),(0,D.jsxs)(`span`,{className:`font-mono text-[13px] text-[var(--color-fg-0)]`,children:[Cg(t),(0,D.jsxs)(`span`,{className:`text-[var(--color-fg-3)]`,children:[` `,`/ `,n===null?`no limit`:Cg(n)]})]})]}),(0,D.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full`,style:{background:`var(--color-surface-3)`},children:(0,D.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${a}%`,background:Tg(i,r)}})})]})}function Dg({mode:e,onPick:t,busy:n}){return(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:vg.map(r=>{let i=r===e,a=_g[r];return(0,D.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(r),className:`flex flex-col gap-1 rounded-md border p-3 text-left transition-colors disabled:opacity-50`,style:{borderColor:i?a.tone:`var(--color-line-1)`,background:i?`color-mix(in srgb, var(--color-brand) 8%, transparent)`:`transparent`},children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold`,style:{color:i?`var(--color-fg-0)`:`var(--color-fg-1)`},children:a.label}),(0,D.jsx)(`span`,{className:`text-[11px] leading-snug text-[var(--color-fg-3)]`,children:a.blurb})]},r)})})}function Og({value:e,onCommit:t,disabled:n}){let[r,i]=(0,_.useState)(e===null?``:String(e));return(0,_.useEffect)(()=>{i(e===null?``:String(e))},[e]),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`span`,{className:`text-[var(--color-fg-3)]`,children:`$`}),(0,D.jsx)(`input`,{type:`number`,min:`0`,step:`1`,inputMode:`decimal`,disabled:n,value:r,placeholder:`—`,onChange:e=>i(e.target.value),onBlur:()=>{let e=r.trim();if(e===``){t(null);return}let n=Number(e);t(Number.isFinite(n)&&n>0?n:null)},className:`w-20 rounded border bg-[var(--color-surface-1)] px-1.5 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}})]})}function kg(){let e=Ge([`budget-changed`,`eval-burst`]),{data:t,loading:n,error:r,refetch:i}=U(`/api/json/budget`,[(e[`budget-changed`]??0)+(e[`eval-burst`]??0)]),[a,o]=(0,_.useState)(`simple`),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),p=t?.config??null;(0,_.useEffect)(()=>{p&&s===null&&c(p)},[p,s]);let m=t?.snapshot??null,h=s??p,g=(0,_.useMemo)(()=>!s||!p?!1:JSON.stringify(s)!==JSON.stringify(p),[s,p]);async function v(e){u(!0),f(null);try{let t=await fetch(`/api/json/budget`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,...W()},body:JSON.stringify({mode:e.mode,warnAtPct:e.warnAtPct,global:e.global,perClient:e.perClient})});if(!t.ok)throw Error(`HTTP ${t.status}`);c((await t.json()).config),i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}function y(e){if(!h)return;let t=e(Ag(h));c(t),v(t)}function b(e){h&&c(e(Ag(h)))}if(n&&!t)return(0,D.jsx)(`div`,{className:`p-6 text-[var(--color-fg-3)]`,children:`Loading…`});if(r&&!t)return(0,D.jsxs)(`div`,{className:`p-6 text-[var(--color-decision-block)]`,children:[`Failed to load spend limits: `,r]});if(!h)return null;let x=m?.global.spend.monthlyUsd??0,S=m?.global.spend.dailyUsd??0,C=m?.global.spend.weeklyUsd??0,w=m?.global.spend.hourlyUsd??0,T=m?[m.global,...m.clients]:[];return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-[17px] font-semibold text-[var(--color-fg-0)]`,children:`Token Spending Limits`}),(0,D.jsx)(`p`,{className:`max-w-2xl text-[12px] leading-snug text-[var(--color-fg-3)]`,children:`Cap what your AI agents (Claude Code, Codex, Gemini, and others) can spend per hour, day, week, or month — so a runaway loop or an un-metered seat can't quietly run up a giant bill.`})]}),(0,D.jsxs)(`div`,{className:`flex items-center overflow-hidden rounded-sm border border-[var(--color-line-1)] text-[10px] font-mono uppercase tracking-wider`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(`simple`),className:`px-2.5 py-1 ${a===`simple`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)]`}`,children:`simple`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>o(`technical`),className:`border-l border-[var(--color-line-1)] px-2.5 py-1 ${a===`technical`?`bg-[var(--color-brand)]/15 text-[var(--color-fg-0)]`:`text-[var(--color-fg-3)]`}`,children:`technical`})]})]}),m===null&&(0,D.jsx)(`div`,{className:`rounded-md border border-l-2 border-l-[var(--color-decision-ask)] border-[var(--color-line-1)] px-3 py-2 text-[12px] text-[var(--color-fg-2)]`,children:`Live spend is unavailable (the eval daemon may be starting). You can still set limits — they apply as soon as the daemon is up.`}),(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Enforcement mode`}),l&&(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`saving…`})]}),(0,D.jsxs)(X,{className:`overflow-visible`,children:[(0,D.jsx)(Dg,{mode:h.mode,busy:l,onPick:e=>y(t=>({...t,mode:e}))}),d&&(0,D.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--color-decision-block)]`,children:d})]})]}),a===`simple`?(0,D.jsx)(jg,{cfg:h,monthlySpend:x,dailySpend:S,weeklySpend:C,hourlySpend:w,agentRows:T,busy:l,onPreset:(e,t,n,r)=>y(i=>({...i,global:{...i.global,hourlyUsd:e,dailyUsd:t,weeklyUsd:n,monthlyUsd:r}})),onWarnAt:e=>y(t=>({...t,warnAtPct:e}))}):(0,D.jsx)(Mg,{cfg:h,snapshot:m,dirty:g,busy:l,onEdit:b,onSave:()=>h&&v(h),onReset:()=>p&&c(p)})]})}function Ag(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function jg({cfg:e,monthlySpend:t,dailySpend:n,weeklySpend:r,hourlySpend:i,agentRows:a,busy:o,onPreset:s,onWarnAt:c}){let l=yg.find(t=>t.hourly===e.global.hourlyUsd&&t.daily===e.global.dailyUsd&&t.weekly===e.global.weeklyUsd&&t.monthly===e.global.monthlyUsd);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Where you stand`})}),(0,D.jsxs)(X,{className:`flex flex-col gap-4 overflow-visible`,children:[(0,D.jsx)(Eg,{label:`This hour (all agents)`,spend:i,cap:e.global.hourlyUsd,warnAtPct:e.warnAtPct}),(0,D.jsx)(Eg,{label:`Today (all agents)`,spend:n,cap:e.global.dailyUsd,warnAtPct:e.warnAtPct}),(0,D.jsx)(Eg,{label:`This week (all agents)`,spend:r,cap:e.global.weeklyUsd,warnAtPct:e.warnAtPct}),(0,D.jsx)(Eg,{label:`This month (all agents)`,spend:t,cap:e.global.monthlyUsd,warnAtPct:e.warnAtPct})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Pick a spending limit`})}),(0,D.jsxs)(X,{className:`overflow-visible`,children:[(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:yg.map(e=>{let t=l?.id===e.id;return(0,D.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>s(e.hourly,e.daily,e.weekly,e.monthly),className:`flex flex-col gap-0.5 rounded-md border p-3 text-left disabled:opacity-50`,style:{borderColor:t?`var(--color-brand)`:`var(--color-line-1)`,background:t?`color-mix(in srgb, var(--color-brand) 8%, transparent)`:`transparent`},children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:e.label}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:e.hint})]},e.id)})}),(0,D.jsxs)(`div`,{className:`mt-4 flex flex-col gap-1`,children:[(0,D.jsxs)(`label`,{htmlFor:`ssg-warn-range`,className:`text-[11px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:[`Warn me at `,Math.round(e.warnAtPct*100),`% of a limit`]}),(0,D.jsx)(`input`,{id:`ssg-warn-range`,type:`range`,min:`50`,max:`95`,step:`5`,disabled:o,value:Math.round(e.warnAtPct*100),onChange:e=>c(Number(e.target.value)/100),className:`w-full max-w-sm`})]})]})]}),a.length>1&&(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`This month, by agent`})}),(0,D.jsxs)(X,{className:`flex flex-col gap-3 overflow-visible`,children:[a.filter(e=>e.scope===`client`).map(t=>(0,D.jsx)(Eg,{label:t.client??`(unknown)`,spend:t.spend.monthlyUsd,cap:t.caps.monthlyUsd??e.global.monthlyUsd,warnAtPct:e.warnAtPct},t.client??`?`)),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Need a tighter cap on one agent? Switch to the technical view.`})]})]})]})}function Mg({cfg:e,snapshot:t,dirty:n,busy:r,onEdit:i,onSave:a,onReset:o}){let[s,c]=(0,_.useState)(``),l=Object.keys(e.perClient),u=e=>t?e===null?t.global.spend:t.clients.find(t=>t.client===e)?.spend??null:null;function d(e,t,n){i(r=>{if(e===null)return{...r,global:{...r.global,[t]:n}};let i=r.perClient[e]??{...bg};return{...r,perClient:{...r.perClient,[e]:{...i,[t]:n}}}})}function f(){let t=s.trim().toLowerCase();!/^[a-z0-9._:-]{1,64}$/.test(t)||e.perClient[t]||(i(e=>({...e,perClient:{...e.perClient,[t]:{...bg}}})),c(``))}function p(e){i(t=>{let n={...t.perClient};return delete n[e],{...t,perClient:n}})}let m=(t,n)=>{let i=t===null?e.global:e.perClient[t]??bg,a=u(t);return(0,D.jsxs)(`tr`,{className:`border-t border-[var(--color-line-0)]`,children:[(0,D.jsx)(`td`,{className:`py-2 pr-3 align-top`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-mono text-[12px] text-[var(--color-fg-0)]`,children:n}),t!==null&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>p(t),className:`text-[11px] text-[var(--color-fg-3)] hover:text-[var(--color-decision-block)]`,children:`remove`})]})}),xg.map(e=>{let n=a?a[Sg[e.key]]:null;return(0,D.jsxs)(`td`,{className:`py-2 pr-3 align-top`,children:[(0,D.jsx)(Og,{value:i[e.key],disabled:r,onCommit:n=>d(t,e.key,n)}),n!=null&&(0,D.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-[var(--color-fg-3)]`,children:[`now `,Cg(n)]})]},e.key)})]},t??`__global`)};return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(J,{children:[(0,D.jsxs)(Y,{children:[(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Caps by agent and window`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,D.jsx)(q,{variant:`ghost`,size:`sm`,disabled:r,onClick:o,children:`Discard`}),(0,D.jsx)(q,{variant:`primary`,size:`sm`,disabled:r||!n,onClick:a,children:r?`Saving…`:`Save limits`})]})]}),(0,D.jsxs)(X,{className:`overflow-auto`,children:[(0,D.jsxs)(`table`,{className:`w-full text-left text-[12px]`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{className:`pb-2 pr-3 text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:`Scope`}),xg.map(e=>(0,D.jsx)(`th`,{className:`pb-2 pr-3 text-[10px] uppercase tracking-wider text-[var(--color-fg-3)]`,children:e.label},e.key))]})}),(0,D.jsxs)(`tbody`,{children:[m(null,`global (all agents)`),l.map(e=>m(e,e))]})]}),(0,D.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,D.jsx)(`input`,{type:`text`,value:s,placeholder:`agent id (e.g. codex)`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f()},className:`w-44 rounded border bg-[var(--color-surface-1)] px-2 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}}),(0,D.jsx)(q,{variant:`secondary`,size:`sm`,onClick:f,children:`Add agent cap`}),(0,D.jsx)(`span`,{className:`text-[11px] text-[var(--color-fg-3)]`,children:`Known ids: claude-code · codex · gemini · cursor`})]})]})]}),(0,D.jsxs)(J,{children:[(0,D.jsx)(Y,{children:(0,D.jsx)(`span`,{className:`text-[13px] font-semibold text-[var(--color-fg-0)]`,children:`Warn threshold & policy`})}),(0,D.jsxs)(X,{className:`flex flex-col gap-3 overflow-visible`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-[var(--color-fg-2)]`,children:[(0,D.jsx)(`span`,{children:`Warn at`}),(0,D.jsx)(`input`,{type:`number`,min:`1`,max:`100`,step:`1`,disabled:r,value:Math.round(e.warnAtPct*100),onChange:e=>i(t=>({...t,warnAtPct:Math.min(1,Math.max(.01,Number(e.target.value)/100))})),className:`w-16 rounded border bg-[var(--color-surface-1)] px-1.5 py-1 font-mono text-[12px] text-[var(--color-fg-0)]`,style:{borderColor:`var(--color-line-1)`}}),(0,D.jsx)(`span`,{children:`% of any cap.`})]}),(0,D.jsxs)(`p`,{className:`text-[11px] leading-snug text-[var(--color-fg-3)]`,children:[`Enforcement runs at the eval gate after the normal rule pass: over a cap → blocked (enforce) or asked (warn); past the warn threshold → asked. Spend is the directional estimate from`,` `,(0,D.jsx)(`code`,{className:`font-mono`,children:`ssg cost summary`}),`; the daemon re-reads this policy within ~2s of a save.`]}),(0,D.jsx)(`pre`,{className:`overflow-auto rounded border border-[var(--color-line-1)] bg-[var(--color-surface-1)] p-2 font-mono text-[10px] text-[var(--color-fg-2)]`,children:JSON.stringify({mode:e.mode,warnAtPct:e.warnAtPct,global:e.global,perClient:e.perClient},null,2)})]})]})]})}function Ng(e){switch(e){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`linux`:return`Linux`;default:return e??`unknown OS`}}function Pg(e){return e?`${e.app_version?`ssg ${e.app_version}`:`ssg (unknown version)`} · ${`${Ng(e.platform)}${e.arch?` ${e.arch}`:``}`}${e.electrobun_channel&&e.electrobun_channel!==`web`?` · ${e.electrobun_channel}`:``}`:``}var Fg=[{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`}],Ig=[{value:`p4`,label:`P4 — Low`},{value:`p3`,label:`P3 — Normal`},{value:`p2`,label:`P2 — High (4h SLA)`},{value:`p1`,label:`P1 — Critical (1h SLA)`}],Lg=5,Rg=8*1024*1024;function zg(){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,w]=(0,_.useState)(``),T=(0,_.useRef)(null);async function E(e,t){try{await navigator.clipboard.writeText(e),S(t),setTimeout(()=>S(``),1500)}catch{}}(0,_.useEffect)(()=>{fetch(`/api/json/profile`,{headers:W()}).then(e=>e.ok?e.json():null).then(e=>{e?.email&&l(e.email)}).catch(()=>{})},[]),(0,_.useEffect)(()=>{fetch(`/api/support/diagnostics?route=${encodeURIComponent(window.location.pathname)}`).then(e=>e.ok?e.json():null).then(e=>v(e)).catch(()=>{})},[]),(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 O(e){e.preventDefault(),ee(Array.from(e.dataTransfer.files))}function k(e){ee(Array.from(e.target.files??[])),T.current&&(T.current.value=``)}function ee(e){w(``);let t=e.filter(e=>e.type.startsWith(`image/`));t.length<e.length&&w(`Only image files are accepted.`);let n=Lg-u.length,r=t.slice(0,n);r.length<t.length&&w(`Maximum ${Lg} images. Some were dropped.`);let i=r.filter(e=>e.size>Rg);if(i.length>0){w(`"${i[0].name}" exceeds 8 MiB.`);return}let a=r.map(e=>({file:e,preview:URL.createObjectURL(e)}));d(e=>[...e,...a])}function A(e){d(t=>(URL.revokeObjectURL(t[e].preview),t.filter((t,n)=>n!==e)))}async function j(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:W(),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:j,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:Fg.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:Ig.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`,{"data-tutorial":`support-subject`,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`,{"data-tutorial":`support-desc`,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 `,Lg,` images)`]})]}),u.length<Lg&&(0,D.jsxs)(`div`,{"data-tutorial":`support-attach`,onDragOver:e=>e.preventDefault(),onDrop:O,onClick:()=>T.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:T,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:k}),C&&(0,D.jsx)(`p`,{className:`text-xs text-red-400 font-mono mt-2`,children:C}),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:()=>A(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)] bg-[var(--color-surface-0)] px-3 py-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`overline block mb-0.5`,children:`environment`}),(0,D.jsx)(`code`,{className:`block text-[12px] font-mono text-[var(--color-fg-1)] truncate`,children:g?Pg(g):`Detecting…`})]}),(0,D.jsx)(`button`,{type:`button`,disabled:!g,onClick:()=>E(Pg(g),`summary`),title:`Copy your ssg version and OS for a bug report`,className:`shrink-0 text-[11px] font-mono px-2.5 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-0)] transition-colors disabled:opacity-40`,children:x===`summary`?`copied ✓`:`copy`})]}),(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-4)] font-mono mt-1.5`,children:`attached to your report automatically — copy it to share when asking for help elsewhere`})]}),(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:`full diagnostics that will be attached`}),(0,D.jsx)(`span`,{children:y?`▲`:`▼`})]}),y&&(0,D.jsxs)(`div`,{className:`bg-[var(--color-surface-0)] border-t border-[var(--color-line-1)]`,children:[(0,D.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,D.jsx)(`button`,{type:`button`,disabled:!g,onClick:()=>E(JSON.stringify(g,null,2),`json`),className:`text-[11px] font-mono px-2.5 py-1 rounded-sm border border-[var(--color-line-1)] text-[var(--color-fg-3)] hover:text-[var(--color-fg-0)] hover:border-[var(--color-line-0)] transition-colors disabled:opacity-40`,children:x===`json`?`copied ✓`:`copy JSON`})}),(0,D.jsx)(`div`,{className:`px-3 py-2 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 Bg(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 Vg={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 Hg(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 Ug({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 Wg(){let{data:e}=U(`/api/json/counters`,[Ge([`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)(Gg,{value:t,label:`evaluated`,tone:`default`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(Gg,{value:n,label:`blocked`,tone:`red`}),(0,D.jsx)(`span`,{className:`text-[var(--color-fg-4)]`,children:`·`}),(0,D.jsx)(Gg,{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 Gg({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 Kg({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)(Ug,{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 qg(){let{data:e}=U(`/api/state/activity?limit=5`,[Ge([`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:Vg[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:Vg[e.decision]??`var(--color-fg-2)`},children:Hg(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:na(e.tool)}),(0,D.jsx)(`span`,{className:`hig-feed-row-time`,children:Bg(e.timestamp)})]},e.id??t))})}function Jg(){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`,{"data-tutorial":`wh-hero`,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)(Wg,{})})]}),(0,D.jsx)(`section`,{children:(0,D.jsxs)(`div`,{"data-tutorial":`wh-actions`,className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(Kg,{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)(Kg,{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)(Kg,{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`,"data-tutorial":`wh-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)(qg,{})})]})]})})}var Yg={persistence:(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 3v8`}),(0,D.jsx)(`path`,{d:`M7.5 6.5a7 7 0 109 0`})]}),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`})]}),plugins:(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 3v4a2 2 0 0 1-2 2H3`}),(0,D.jsx)(`path`,{d:`M15 3v4a2 2 0 0 0 2 2h4`}),(0,D.jsx)(`rect`,{x:`3`,y:`9`,width:`18`,height:`12`,rx:`2`}),(0,D.jsx)(`path`,{d:`M7 14h2M12 14h5M7 18h10`})]})},Xg=[{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`},{path:`/spending-limits`,label:`Spending Limits`,icon:`observability`}]},{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:`/plugins`,label:`Plugins`,icon:`plugins`},{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/persistence`,label:`Persistence`,icon:`persistence`},{path:`/backup`,label:`Export & Import`,icon:`setup`},{path:`/debug`,label:`Debug`,icon:`debug`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}],Zg=[{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`},{path:`/spending-limits`,label:`Spending Limits`,icon:`observability`}]},{title:`You`,items:[{path:`/setup`,label:`Setup`,icon:`setup`},{path:`/persistence`,label:`Persistence`,icon:`persistence`},{path:`/backup`,label:`Export & Import`,icon:`setup`},{path:`/profile`,label:`Profile`,icon:`profile`},{path:`/support`,label:`Support`,icon:`support`}]}];function Qg(e){return $g(e===`newcomer`?Zg:Xg)}function $g(e){let t=window.__SSG_PLUGINS__;if(!t||t.nav.length===0)return e;let n=e=>{let t=e.toLowerCase();return t===`tools`?`Tools`:t===`activity`?`Activity`:t===`overview`?`Overview`:t===`rules`?`Rules`:e.charAt(0).toUpperCase()+e.slice(1)},r=e.map(e=>({...e,items:[...e.items]})),i=new Map;for(let e of t.nav){let t={path:e.path,label:e.label,icon:`plugins`},a=n(e.section),o=r.find(e=>e.title===a);if(o)o.items.push(t);else{let e=i.get(a)??[];e.push(t),i.set(a,e)}}for(let[e,t]of i)r.push({title:e,items:t});return r}function e_(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 t_(){let{data:e}=U(`/api/json/daemon-status`,[Ge([`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?e_(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(`
59
+ `)})]})]})]})}function n_(){let{data:e}=U(`/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 r_(){let{data:e}=U(`/api/json/license`,[Ge([`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 i_(){let{data:e}=U(`/api/json/license`,[Ge([`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 a_(){let{data:e,refetch:t}=U(`/api/json/ask-mode`),[n,r]=(0,_.useState)(!1),i=e?.mode??`native`;async function a(e){if(!(n||e===i)){r(!0);try{await fetch(`/api/json/ask-mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}let o=i===`dashboard`;return(0,D.jsxs)(`button`,{onClick:()=>a(o?`tty`:`dashboard`),disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:o?`ASK decisions queue on /approvals. Click to route to native prompt.`:`ASK decisions prompt in the native IDE/TTY. Click to route to dashboard.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${o?`bg-[var(--color-hig-purple)]`:`bg-[var(--color-hig-blue)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Ask · `,o?`Dashboard`:`Native`]})]})}function o_(){let{data:e,refetch:t}=U(`/api/json/session-banner`),[n,r]=(0,_.useState)(!1),i=e?.enabled??!0;async function a(){if(!n){r(!0);try{await fetch(`/api/json/session-banner`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({enabled:!i})}),t()}finally{r(!1)}}}return(0,D.jsxs)(`button`,{onClick:a,disabled:n,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:i?`SessionStart banner is ON — every Claude Code session opens with the active-rule count + dashboard link. Click to hide it.`:`SessionStart banner is OFF. Click to show it at the start of each session.`,children:[(0,D.jsx)(`span`,{className:`status-dot ${i?`bg-[var(--color-hig-green)]`:`bg-[var(--color-fg-3)]`}`}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Banner · `,i?`On`:`Off`]})]})}function s_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:e?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-hig-green)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2l8 3v6c0 5-3.5 9.5-8 11-4.5-1.5-8-6-8-11V5l8-3z`}),e?(0,D.jsx)(`path`,{d:`M8.5 12.2l2.5 2.5 4.5-5`,stroke:`var(--color-accent-on)`,fill:`none`}):null]})}function c_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-hig-green)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2v10`}),(0,D.jsx)(`path`,{d:`M18.4 6.6a9 9 0 1 1-12.8 0`})]})}function l_({on:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e?`var(--color-brand)`:`var(--color-fg-3)`},"aria-hidden":`true`,children:[(0,D.jsx)(`line`,{x1:`4`,y1:`21`,x2:`4`,y2:`14`}),(0,D.jsx)(`line`,{x1:`4`,y1:`10`,x2:`4`,y2:`3`}),(0,D.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`12`}),(0,D.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`3`}),(0,D.jsx)(`line`,{x1:`20`,y1:`21`,x2:`20`,y2:`16`}),(0,D.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`3`}),(0,D.jsx)(`line`,{x1:`1`,y1:`14`,x2:`7`,y2:`14`}),(0,D.jsx)(`line`,{x1:`9`,y1:`8`,x2:`15`,y2:`8`}),(0,D.jsx)(`line`,{x1:`17`,y1:`16`,x2:`23`,y2:`16`})]})}function u_(){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--color-decision-block)`},"aria-hidden":`true`,children:[(0,D.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,D.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,D.jsx)(`line`,{x1:`10`,y1:`11`,x2:`10`,y2:`17`}),(0,D.jsx)(`line`,{x1:`14`,y1:`11`,x2:`14`,y2:`17`})]})}function d_(){let{enabled:e,saving:t,setEnabled:n}=An();return(0,D.jsxs)(`button`,{onClick:()=>n(!e),disabled:t,className:`chip cursor-pointer hover:bg-[var(--color-fill-2)] transition-colors disabled:opacity-50`,title:e?`Self-protection is ON — AI agents are blocked from uninstalling SigmaShake (ssg + Desktop). Click to turn off.`:`Self-protection is OFF — an AI agent could uninstall SigmaShake. Click to turn on.`,"aria-pressed":e,children:[(0,D.jsx)(s_,{on:e}),(0,D.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Self-protect · `,e?`On`:`Off`]})]})}function f_(){let{enabled:e,saving:t,setEnabled:n}=An();return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta`,"data-on":e?`true`:`false`,disabled:t,"aria-pressed":e,onClick:()=>n(!e),title:e?`AI agents are blocked from uninstalling SigmaShake. Click to turn protection off.`:`AI agents can currently uninstall SigmaShake. Click to turn protection on.`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(s_,{on:e})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`Agent self-protection`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:e?`On · uninstall blocked`:`Off · agent can uninstall`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function p_(e){let t=new Date(e);return`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}`}var m_={on:`soft`,soft:`audit`,audit:`off`,off:`on`};function h_(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`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`,...W()},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 ${p_(e.rearmAt)}`:``,c=`SSG · ${i.toUpperCase()}${s}`;return(0,D.jsxs)(`button`,{"data-tutorial":`app-mode`,onClick:e=>{e.shiftKey?a(i===`off`?`audit`:`on`):a(m_[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 g_(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`mode-changed`])[`mode-changed`]]),n=e?.mode??`on`;if(n===`on`)return null;let r=e?.rearmAt===void 0?``:` Auto-restores at ${p_(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`,...W()},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 __(){let{data:e,refetch:t}=U(`/api/json/mode`,[Ge([`mode-changed`])[`mode-changed`]]),[n,r]=(0,_.useState)(!1),i=e?.mode??`on`,a=i===`on`;async function o(e){if(!n){r(!0);try{await fetch(`/api/json/mode`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({mode:e})}),t()}finally{r(!1)}}}return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta`,"data-on":a?`true`:`false`,disabled:n,"aria-pressed":a,onClick:()=>o(a?`off`:`on`),title:a?`SSG is ON — rules enforce normally. Click to switch OFF (kill switch: every tool call is allowed without evaluation).`:`SSG is not fully enforcing. Click to switch it ON (normal rule enforcement).`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(c_,{on:a})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`SSG enforcement`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:i===`on`?`On · rules enforced`:i===`off`?`Off · all calls allowed`:i===`soft`?`Soft · blocks downgraded`:`Audit · log-only`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function v_(){let{mode:e,setMode:t}=Ht(),n=e===`pro`;return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta hig-shield-cta--brand`,"data-on":n?`true`:`false`,"aria-pressed":n,onClick:()=>t(n?`newcomer`:`pro`),title:n?`Advanced view — every page and tool is shown. Click for Simple (guided) view.`:`Simple view — a guided, pared-down set of pages. Click for Advanced (all tools).`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(l_,{on:n})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`Interface mode`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:n?`Advanced · all tools`:`Simple · guided`})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]})}function y_(){let[e,t]=(0,_.useState)(!1),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>t(!1),4e3);return()=>clearTimeout(n)},[e]);async function o(){r(!0);try{await fetch(`/api/json/uninstall-everything`,{method:`POST`,headers:{"Content-Type":`application/json`,...W()},body:JSON.stringify({keepData:!0})}),a(!0)}finally{r(!1),t(!1)}}return(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta hig-shield-cta--danger`,"data-armed":e?`true`:`false`,disabled:n||i,"aria-label":`Uninstall SigmaShake from all AI clients`,onClick:()=>{if(!(i||n)){if(!e){t(!0);return}o()}},title:`Remove SigmaShake everywhere — uninstalls hooks, MCP entries, and the daemon from every detected AI client. Your activity history and license are kept.`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(u_,{})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:i?`Uninstall started`:`Uninstall SigmaShake`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:i?`Removed from detected clients`:n?`Removing…`:e?`Click again to confirm`:`Remove from all AI clients`})]})]})}function b_({tone:e}){return(0,D.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:e},"aria-hidden":`true`,children:[(0,D.jsx)(`path`,{d:`M12 2v9`}),(0,D.jsx)(`path`,{d:`M6.8 6.2a8 8 0 1 0 10.4 0`})]})}function x_(){let{status:e,saving:t,flow:n,begin:r,confirmNative:i,approveDashboard:a,denyDashboard:o,cancel:s}=On();if(!e||e.mechanism===`unsupported`)return null;let c=e.enabled,l=c?e.health===`degraded`?`var(--color-decision-ask)`:`var(--color-hig-green)`:`var(--color-fg-3)`,u=c?e.health===`degraded`?`On · needs attention`:`On · launches at login`:`Off · manual start`,d=c?`SigmaShake persistence is ON — the governance daemon launches at login and stays running. Click to turn off.`:`SigmaShake persistence is OFF — the daemon does not auto-start. Click to launch on startup and always run.`;return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`button`,{type:`button`,className:`hig-shield-cta`,"data-on":c?`true`:`false`,disabled:t||n.kind!==`idle`,"aria-pressed":c,onClick:()=>r(c?`disable`:`enable`),title:d,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-icon`,"aria-hidden":`true`,children:(0,D.jsx)(b_,{tone:l})}),(0,D.jsxs)(`span`,{className:`hig-shield-cta-body`,children:[(0,D.jsx)(`span`,{className:`hig-shield-cta-title`,children:`Persistence`}),(0,D.jsx)(`span`,{className:`hig-shield-cta-state`,children:u})]}),(0,D.jsx)(`span`,{className:`hig-shield-cta-switch`,"aria-hidden":`true`,children:(0,D.jsx)(`span`,{className:`hig-shield-cta-knob`})})]}),n.kind===`native-confirm`&&(0,D.jsxs)(`div`,{className:`mt-1.5 px-2.5 py-2 rounded-md bg-[var(--color-fill-2)] border border-[var(--color-decision-ask)]`,children:[(0,D.jsx)(`p`,{className:`text-[11px] text-[var(--color-fg-2)] leading-snug mb-2`,children:n.env.prompt}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:i,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Confirm`}),(0,D.jsx)(`button`,{type:`button`,onClick:s,disabled:t,className:`hig-button hig-button-small`,children:`Cancel`})]})]}),n.kind===`dashboard-pending`&&(0,D.jsxs)(`div`,{className:`mt-1.5 px-2.5 py-2 rounded-md bg-[var(--color-fill-2)] border border-[var(--color-hig-purple)]`,children:[(0,D.jsxs)(`p`,{className:`text-[11px] text-[var(--color-fg-2)] leading-snug mb-2`,children:[`Queued for approval — resolve here or on the`,` `,(0,D.jsx)(`a`,{href:`/approvals`,className:`text-[var(--color-hig-blue)] hover:underline`,children:`Approvals`}),` `,`page.`]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`hig-button hig-button-small hig-button-primary`,children:t?`Applying…`:`Approve`}),(0,D.jsx)(`button`,{type:`button`,onClick:o,disabled:t,className:`hig-button hig-button-small`,children:`Deny`})]})]})]})}function S_(){return(0,D.jsxs)(`div`,{className:`hig-sidebar-cta-group`,children:[(0,D.jsx)(f_,{}),(0,D.jsx)(__,{}),(0,D.jsx)(v_,{}),(0,D.jsx)(x_,{}),(0,D.jsx)(y_,{})]})}function C_({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 w_(){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 T_(){let{data:e}=U(`/api/json/mcp-status`,[Ge([`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 E_(){let{data:e}=U(`/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 D_(e,t){if(e===`/`)return t===`newcomer`?(0,D.jsx)(Jg,{}):(0,D.jsx)(gu,{});if(e===`/graph`)return(0,D.jsx)(mf,{});if(e===`/sessions`)return(0,D.jsx)(Gh,{});if(e.startsWith(`/sessions/`)){let t=decodeURIComponent(e.slice(10));if(t)return(0,D.jsx)(Ph,{sessionKey:t})}if(e===`/debug`)return(0,D.jsx)(yu,{});if(e===`/rules`)return(0,D.jsx)(wh,{});if(e===`/spending-limits`)return(0,D.jsx)(kg,{});if(e===`/audit`)return(0,D.jsx)(Ea,{});if(e===`/approvals`)return(0,D.jsx)(Ji,{});if(e===`/profile`)return(0,D.jsx)(jm,{});if(e===`/backup`)return(0,D.jsx)(Oa,{});if(e===`/agents`)return(0,D.jsx)(tr,{});if(e===`/notifications`)return(0,D.jsx)(op,{});if(e===`/setup`)return(0,D.jsx)(ng,{});if(e===`/persistence`)return(0,D.jsx)(Up,{});if(e===`/try`)return(0,D.jsx)(gg,{});if(e===`/guardrails`)return(0,D.jsx)(Sf,{});if(e===`/hub/connect`)return(0,D.jsx)(hf,{});if(e===`/hub/publish`)return(0,D.jsx)(Ff,{});if(e.startsWith(`/hub/`)){let t=e.slice(5);if(t)return(0,D.jsx)(_f,{id:t})}return e===`/hub`?(0,D.jsx)(Nf,{}):e===`/monitor`?(0,D.jsx)(ip,{}):e===`/observability`?(0,D.jsx)(Np,{}):e===`/plugins`?(0,D.jsx)(_m,{}):e===`/publish-plugin`?(0,D.jsx)(qp,{}):e===`/support`?(0,D.jsx)(zg,{}):(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 O_(e,t){return e===`/`?t===`newcomer`?`Home`:`Dashboard`:e===`/graph`?`Graph`:e===`/sessions`?`Sessions`:e.startsWith(`/sessions/`)?`Session Inspector`:e===`/debug`?`Debug`:e===`/rules`?`Rules`:e===`/spending-limits`?`Spending Limits`:e===`/audit`?t===`newcomer`?`Activity`:`Audit`:e===`/approvals`?`Approvals`:e===`/profile`?`Profile`:e===`/backup`?`Export & Import`:e===`/agents`?`Agents`:e===`/notifications`?`Notifications`:e===`/setup`?`Setup Status`:e===`/persistence`?`Persistence`: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===`/plugins`?`Plugins`:e===`/publish-plugin`?`Publish a Plugin`:e===`/support`?`Support & Feedback`:`SigmaShake`}function k_(e){history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function A_({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 j_({onCollapse:e}){let{data:t}=U(`/api/health`),n=t?.version;return(0,D.jsxs)(`div`,{className:`hig-sidebar-footer`,children:[(0,D.jsx)(`span`,{className:`hig-sidebar-version`,title:n?`SigmaShake Governance v${n}`:`daemon version unavailable`,children:n?(0,D.jsxs)(D.Fragment,{children:[`ssg `,(0,D.jsxs)(`b`,{children:[`v`,n]})]}):`ssg`}),(0,D.jsx)(`button`,{type:`button`,className:`hig-sidebar-collapse`,"aria-label":`Collapse sidebar`,title:`Collapse sidebar`,onClick:e,children:(0,D.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M11 7l-5 5 5 5`}),(0,D.jsx)(`path`,{d:`M18 7l-5 5 5 5`})]})})]})}function M_({pathname:e,navSections:t,open:n,onClose:r,onCollapse:i}){let a=t=>t===`/`?e===`/`:e.startsWith(t);return(0,D.jsxs)(`aside`,{className:`hig-sidebar ${n?`open`:``}`,"aria-label":`Primary`,"data-tutorial":`app-sidebar`,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)(`button`,{className:`hig-sidebar-close`,"aria-label":`Close sidebar`,onClick:r,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:`4`,y1:`4`,x2:`14`,y2:`14`}),(0,D.jsx)(`line`,{x1:`14`,y1:`4`,x2:`4`,y2:`14`})]})})]}),(0,D.jsx)(S_,{}),(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":a(e.path)?`true`:`false`,children:[(0,D.jsx)(`span`,{className:`hig-sidebar-icon`,"aria-hidden":`true`,children:Yg[e.icon]}),(0,D.jsx)(`span`,{children:e.label})]},e.path))]},e.title))}),(0,D.jsx)(j_,{onCollapse:i})]})}function N_(){let[e,t]=(0,_.useState)(window.location.pathname),[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>{try{return localStorage.getItem(`ssg:sidebar-collapsed`)===`1`}catch{return!1}}),{otherTabCount:c}=Fn(),{mode:l}=Ht(),u=Qg(l),d=O_(e,l);return(0,_.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,_.useEffect)(()=>{a(!1)},[]),(0,_.useEffect)(()=>{try{localStorage.setItem(`ssg:sidebar-collapsed`,o?`1`:`0`)}catch{}},[o]),(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/`)||n.startsWith(`/plugins/`)||(e.preventDefault(),k_(n))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]),(0,D.jsxs)(`div`,{className:`hig-app`,"data-sidebar-collapsed":o?`true`:`false`,children:[(0,D.jsx)(M_,{pathname:e,navSections:u,open:i,onClose:()=>a(!1),onCollapse:()=>s(!0)}),i&&(0,D.jsx)(`div`,{className:`hig-sidebar-backdrop`,"aria-hidden":`true`,onClick:()=>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:`hig-sidebar-toggle hig-button hig-button-small`,onClick:()=>{window.matchMedia(`(min-width: 901px)`).matches?s(e=>!e):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:d}),(0,D.jsx)(Pt,{pathname:e,mode:l}),(0,D.jsx)(`div`,{className:`hig-toolbar-spacer`}),(0,D.jsxs)(`button`,{type:`button`,className:`hig-toolbar-search`,"aria-label":`Open command palette (Ctrl/Cmd+K)`,title:`Search pages, actions, rules (⌘K)`,onClick:()=>{window.dispatchEvent(new CustomEvent(`sigmashake:open-palette`,{detail:{query:``}}))},children:[(0,D.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,D.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,D.jsx)(`line`,{x1:`10.5`,y1:`10.5`,x2:`13.5`,y2:`13.5`})]}),(0,D.jsx)(`span`,{className:`hig-toolbar-search-text`,children:`Search…`}),(0,D.jsx)(`span`,{className:`hig-toolbar-search-kbd`,children:`⌘K`})]}),(0,D.jsxs)(`div`,{className:`hig-toolbar-controls hidden md:flex`,children:[c>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:`${c} other tab${c===1?``:`s`} open — may cause connection issues`,children:[c+1,` tabs`]}),(0,D.jsx)(Gt,{}),(0,D.jsx)(h_,{}),(0,D.jsx)(E_,{}),(0,D.jsx)(t_,{}),(0,D.jsx)(d_,{}),(0,D.jsx)(a_,{}),(0,D.jsx)(C_,{onRefresh:()=>r(e=>e+1)}),(0,D.jsxs)(`details`,{className:`hig-toolbar-menu`,children:[(0,D.jsx)(`summary`,{className:`chip`,title:`Settings`,"aria-label":`Settings`,children:`⚙`}),(0,D.jsxs)(`div`,{className:`hig-toolbar-menu-panel`,children:[(0,D.jsx)(o_,{}),(0,D.jsx)(T_,{}),(0,D.jsx)(Ut,{}),(0,D.jsx)(vt,{}),(0,D.jsx)(We,{}),(0,D.jsx)(w_,{})]})]})]})]}),(0,D.jsx)(O,{}),(0,D.jsx)(Tn,{}),(0,D.jsx)(Fe,{}),(0,D.jsx)(g_,{}),(0,D.jsx)(A_,{count:c}),(0,D.jsx)(i_,{}),(0,D.jsx)(r_,{}),(0,D.jsx)(n_,{}),(e===`/`||e===`/graph`||e===`/sessions`||e.startsWith(`/sessions/`)||e===`/audit`)&&(0,D.jsx)(st,{}),(0,D.jsx)(`main`,{className:`hig-content px-6 py-6`,children:D_(e,l)},n)]})]})}var P_=document.getElementById(`app-root`);if(!P_)throw Error(`Missing #app-root`);v.createRoot(P_).render((0,D.jsx)(_.StrictMode,{children:(0,D.jsx)(N_,{})}));