vskill 0.5.117 → 0.5.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-B6bbI5Am.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-BoXvLUq1.js","assets/CreateSkillPage-9cOfboMo.js"])))=>i.map(i=>d[i]);
2
- /* empty css */(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function rv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var od={exports:{}},Ts={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-C-4cwFXV.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-BZekSSlW.js","assets/CreateSkillPage-CJCr7_2R.js"])))=>i.map(i=>d[i]);
2
+ /* empty css */(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function lv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var od={exports:{}},Ts={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
5
5
  *
@@ -7,7 +7,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var Cx;function n0(){if(Cx)return Ts;Cx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(o,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:u}}return Ts.Fragment=r,Ts.jsx=s,Ts.jsxs=s,Ts}var Ex;function a0(){return Ex||(Ex=1,od.exports=n0()),od.exports}var a=a0(),cd={exports:{}},Ie={};/**
10
+ */var Cx;function r0(){if(Cx)return Ts;Cx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(o,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:u}}return Ts.Fragment=r,Ts.jsx=s,Ts.jsxs=s,Ts}var Ex;function l0(){return Ex||(Ex=1,od.exports=r0()),od.exports}var a=l0(),cd={exports:{}},Ie={};/**
11
11
  * @license React
12
12
  * react.production.js
13
13
  *
@@ -15,7 +15,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Nx;function r0(){if(Nx)return Ie;Nx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(A){return A===null||typeof A!="object"?null:(A=b&&A[b]||A["@@iterator"],typeof A=="function"?A:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function N(A,Y,W){this.props=A,this.context=Y,this.refs=C,this.updater=W||k}N.prototype.isReactComponent={},N.prototype.setState=function(A,Y){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,Y,"setState")},N.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function R(){}R.prototype=N.prototype;function L(A,Y,W){this.props=A,this.context=Y,this.refs=C,this.updater=W||k}var B=L.prototype=new R;B.constructor=L,w(B,N.prototype),B.isPureReactComponent=!0;var D=Array.isArray;function F(){}var E={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function z(A,Y,W){var te=W.ref;return{$$typeof:t,type:A,key:Y,ref:te!==void 0?te:null,props:W}}function I(A,Y){return z(A.type,Y,A.props)}function U(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function q(A){var Y={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(W){return Y[W]})}var X=/\/+/g;function J(A,Y){return typeof A=="object"&&A!==null&&A.key!=null?q(""+A.key):Y.toString(36)}function $(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(F,F):(A.status="pending",A.then(function(Y){A.status==="pending"&&(A.status="fulfilled",A.value=Y)},function(Y){A.status==="pending"&&(A.status="rejected",A.reason=Y)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function M(A,Y,W,te,fe){var ie=typeof A;(ie==="undefined"||ie==="boolean")&&(A=null);var ye=!1;if(A===null)ye=!0;else switch(ie){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(A.$$typeof){case t:case r:ye=!0;break;case y:return ye=A._init,M(ye(A._payload),Y,W,te,fe)}}if(ye)return fe=fe(A),ye=te===""?"."+J(A,0):te,D(fe)?(W="",ye!=null&&(W=ye.replace(X,"$&/")+"/"),M(fe,Y,W,"",function(Ae){return Ae})):fe!=null&&(U(fe)&&(fe=I(fe,W+(fe.key==null||A&&A.key===fe.key?"":(""+fe.key).replace(X,"$&/")+"/")+ye)),Y.push(fe)),1;ye=0;var de=te===""?".":te+":";if(D(A))for(var Se=0;Se<A.length;Se++)te=A[Se],ie=de+J(te,Se),ye+=M(te,Y,W,ie,fe);else if(Se=S(A),typeof Se=="function")for(A=Se.call(A),Se=0;!(te=A.next()).done;)te=te.value,ie=de+J(te,Se++),ye+=M(te,Y,W,ie,fe);else if(ie==="object"){if(typeof A.then=="function")return M($(A),Y,W,te,fe);throw Y=String(A),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ye}function _(A,Y,W){if(A==null)return A;var te=[],fe=0;return M(A,te,"","",function(ie){return Y.call(W,ie,fe++)}),te}function O(A){if(A._status===-1){var Y=A._result;Y=Y(),Y.then(function(W){(A._status===0||A._status===-1)&&(A._status=1,A._result=W)},function(W){(A._status===0||A._status===-1)&&(A._status=2,A._result=W)}),A._status===-1&&(A._status=0,A._result=Y)}if(A._status===1)return A._result.default;throw A._result}var V=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},se={map:_,forEach:function(A,Y,W){_(A,function(){Y.apply(this,arguments)},W)},count:function(A){var Y=0;return _(A,function(){Y++}),Y},toArray:function(A){return _(A,function(Y){return Y})||[]},only:function(A){if(!U(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};return Ie.Activity=v,Ie.Children=se,Ie.Component=N,Ie.Fragment=s,Ie.Profiler=c,Ie.PureComponent=L,Ie.StrictMode=o,Ie.Suspense=g,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(A){return E.H.useMemoCache(A)}},Ie.cache=function(A){return function(){return A.apply(null,arguments)}},Ie.cacheSignal=function(){return null},Ie.cloneElement=function(A,Y,W){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var te=w({},A.props),fe=A.key;if(Y!=null)for(ie in Y.key!==void 0&&(fe=""+Y.key),Y)!H.call(Y,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&Y.ref===void 0||(te[ie]=Y[ie]);var ie=arguments.length-2;if(ie===1)te.children=W;else if(1<ie){for(var ye=Array(ie),de=0;de<ie;de++)ye[de]=arguments[de+2];te.children=ye}return z(A.type,fe,te)},Ie.createContext=function(A){return A={$$typeof:d,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:u,_context:A},A},Ie.createElement=function(A,Y,W){var te,fe={},ie=null;if(Y!=null)for(te in Y.key!==void 0&&(ie=""+Y.key),Y)H.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=Y[te]);var ye=arguments.length-2;if(ye===1)fe.children=W;else if(1<ye){for(var de=Array(ye),Se=0;Se<ye;Se++)de[Se]=arguments[Se+2];fe.children=de}if(A&&A.defaultProps)for(te in ye=A.defaultProps,ye)fe[te]===void 0&&(fe[te]=ye[te]);return z(A,ie,fe)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(A){return{$$typeof:h,render:A}},Ie.isValidElement=U,Ie.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:O}},Ie.memo=function(A,Y){return{$$typeof:m,type:A,compare:Y===void 0?null:Y}},Ie.startTransition=function(A){var Y=E.T,W={};E.T=W;try{var te=A(),fe=E.S;fe!==null&&fe(W,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(F,V)}catch(ie){V(ie)}finally{Y!==null&&W.types!==null&&(Y.types=W.types),E.T=Y}},Ie.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},Ie.use=function(A){return E.H.use(A)},Ie.useActionState=function(A,Y,W){return E.H.useActionState(A,Y,W)},Ie.useCallback=function(A,Y){return E.H.useCallback(A,Y)},Ie.useContext=function(A){return E.H.useContext(A)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(A,Y){return E.H.useDeferredValue(A,Y)},Ie.useEffect=function(A,Y){return E.H.useEffect(A,Y)},Ie.useEffectEvent=function(A){return E.H.useEffectEvent(A)},Ie.useId=function(){return E.H.useId()},Ie.useImperativeHandle=function(A,Y,W){return E.H.useImperativeHandle(A,Y,W)},Ie.useInsertionEffect=function(A,Y){return E.H.useInsertionEffect(A,Y)},Ie.useLayoutEffect=function(A,Y){return E.H.useLayoutEffect(A,Y)},Ie.useMemo=function(A,Y){return E.H.useMemo(A,Y)},Ie.useOptimistic=function(A,Y){return E.H.useOptimistic(A,Y)},Ie.useReducer=function(A,Y,W){return E.H.useReducer(A,Y,W)},Ie.useRef=function(A){return E.H.useRef(A)},Ie.useState=function(A){return E.H.useState(A)},Ie.useSyncExternalStore=function(A,Y,W){return E.H.useSyncExternalStore(A,Y,W)},Ie.useTransition=function(){return E.H.useTransition()},Ie.version="19.2.4",Ie}var Tx;function df(){return Tx||(Tx=1,cd.exports=r0()),cd.exports}var p=df();const Ne=rv(p);var ud={exports:{}},Rs={},dd={exports:{}},fd={};/**
18
+ */var Nx;function s0(){if(Nx)return Ie;Nx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function N(M,Y,W){this.props=M,this.context=Y,this.refs=C,this.updater=W||k}N.prototype.isReactComponent={},N.prototype.setState=function(M,Y){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,Y,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function T(){}T.prototype=N.prototype;function A(M,Y,W){this.props=M,this.context=Y,this.refs=C,this.updater=W||k}var B=A.prototype=new T;B.constructor=A,E(B,N.prototype),B.isPureReactComponent=!0;var D=Array.isArray;function F(){}var w={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function z(M,Y,W){var te=W.ref;return{$$typeof:t,type:M,key:Y,ref:te!==void 0?te:null,props:W}}function U(M,Y){return z(M.type,Y,M.props)}function H(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function q(M){var Y={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(W){return Y[W]})}var X=/\/+/g;function J(M,Y){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):Y.toString(36)}function $(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(F,F):(M.status="pending",M.then(function(Y){M.status==="pending"&&(M.status="fulfilled",M.value=Y)},function(Y){M.status==="pending"&&(M.status="rejected",M.reason=Y)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,Y,W,te,fe){var ie=typeof M;(ie==="undefined"||ie==="boolean")&&(M=null);var ye=!1;if(M===null)ye=!0;else switch(ie){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(M.$$typeof){case t:case r:ye=!0;break;case y:return ye=M._init,L(ye(M._payload),Y,W,te,fe)}}if(ye)return fe=fe(M),ye=te===""?"."+J(M,0):te,D(fe)?(W="",ye!=null&&(W=ye.replace(X,"$&/")+"/"),L(fe,Y,W,"",function(Ae){return Ae})):fe!=null&&(H(fe)&&(fe=U(fe,W+(fe.key==null||M&&M.key===fe.key?"":(""+fe.key).replace(X,"$&/")+"/")+ye)),Y.push(fe)),1;ye=0;var de=te===""?".":te+":";if(D(M))for(var Se=0;Se<M.length;Se++)te=M[Se],ie=de+J(te,Se),ye+=L(te,Y,W,ie,fe);else if(Se=S(M),typeof Se=="function")for(M=Se.call(M),Se=0;!(te=M.next()).done;)te=te.value,ie=de+J(te,Se++),ye+=L(te,Y,W,ie,fe);else if(ie==="object"){if(typeof M.then=="function")return L($(M),Y,W,te,fe);throw Y=String(M),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ye}function _(M,Y,W){if(M==null)return M;var te=[],fe=0;return L(M,te,"","",function(ie){return Y.call(W,ie,fe++)}),te}function I(M){if(M._status===-1){var Y=M._result;Y=Y(),Y.then(function(W){(M._status===0||M._status===-1)&&(M._status=1,M._result=W)},function(W){(M._status===0||M._status===-1)&&(M._status=2,M._result=W)}),M._status===-1&&(M._status=0,M._result=Y)}if(M._status===1)return M._result.default;throw M._result}var V=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},se={map:_,forEach:function(M,Y,W){_(M,function(){Y.apply(this,arguments)},W)},count:function(M){var Y=0;return _(M,function(){Y++}),Y},toArray:function(M){return _(M,function(Y){return Y})||[]},only:function(M){if(!H(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ie.Activity=v,Ie.Children=se,Ie.Component=N,Ie.Fragment=s,Ie.Profiler=c,Ie.PureComponent=A,Ie.StrictMode=o,Ie.Suspense=g,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(M){return w.H.useMemoCache(M)}},Ie.cache=function(M){return function(){return M.apply(null,arguments)}},Ie.cacheSignal=function(){return null},Ie.cloneElement=function(M,Y,W){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var te=E({},M.props),fe=M.key;if(Y!=null)for(ie in Y.key!==void 0&&(fe=""+Y.key),Y)!O.call(Y,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&Y.ref===void 0||(te[ie]=Y[ie]);var ie=arguments.length-2;if(ie===1)te.children=W;else if(1<ie){for(var ye=Array(ie),de=0;de<ie;de++)ye[de]=arguments[de+2];te.children=ye}return z(M.type,fe,te)},Ie.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Ie.createElement=function(M,Y,W){var te,fe={},ie=null;if(Y!=null)for(te in Y.key!==void 0&&(ie=""+Y.key),Y)O.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=Y[te]);var ye=arguments.length-2;if(ye===1)fe.children=W;else if(1<ye){for(var de=Array(ye),Se=0;Se<ye;Se++)de[Se]=arguments[Se+2];fe.children=de}if(M&&M.defaultProps)for(te in ye=M.defaultProps,ye)fe[te]===void 0&&(fe[te]=ye[te]);return z(M,ie,fe)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(M){return{$$typeof:h,render:M}},Ie.isValidElement=H,Ie.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:I}},Ie.memo=function(M,Y){return{$$typeof:p,type:M,compare:Y===void 0?null:Y}},Ie.startTransition=function(M){var Y=w.T,W={};w.T=W;try{var te=M(),fe=w.S;fe!==null&&fe(W,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(F,V)}catch(ie){V(ie)}finally{Y!==null&&W.types!==null&&(Y.types=W.types),w.T=Y}},Ie.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},Ie.use=function(M){return w.H.use(M)},Ie.useActionState=function(M,Y,W){return w.H.useActionState(M,Y,W)},Ie.useCallback=function(M,Y){return w.H.useCallback(M,Y)},Ie.useContext=function(M){return w.H.useContext(M)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(M,Y){return w.H.useDeferredValue(M,Y)},Ie.useEffect=function(M,Y){return w.H.useEffect(M,Y)},Ie.useEffectEvent=function(M){return w.H.useEffectEvent(M)},Ie.useId=function(){return w.H.useId()},Ie.useImperativeHandle=function(M,Y,W){return w.H.useImperativeHandle(M,Y,W)},Ie.useInsertionEffect=function(M,Y){return w.H.useInsertionEffect(M,Y)},Ie.useLayoutEffect=function(M,Y){return w.H.useLayoutEffect(M,Y)},Ie.useMemo=function(M,Y){return w.H.useMemo(M,Y)},Ie.useOptimistic=function(M,Y){return w.H.useOptimistic(M,Y)},Ie.useReducer=function(M,Y,W){return w.H.useReducer(M,Y,W)},Ie.useRef=function(M){return w.H.useRef(M)},Ie.useState=function(M){return w.H.useState(M)},Ie.useSyncExternalStore=function(M,Y,W){return w.H.useSyncExternalStore(M,Y,W)},Ie.useTransition=function(){return w.H.useTransition()},Ie.version="19.2.4",Ie}var Tx;function df(){return Tx||(Tx=1,cd.exports=s0()),cd.exports}var m=df();const Te=lv(m);var ud={exports:{}},Rs={},dd={exports:{}},fd={};/**
19
19
  * @license React
20
20
  * scheduler.production.js
21
21
  *
@@ -23,7 +23,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
23
23
  *
24
24
  * This source code is licensed under the MIT license found in the
25
25
  * LICENSE file in the root directory of this source tree.
26
- */var Rx;function l0(){return Rx||(Rx=1,(function(t){function r(M,_){var O=M.length;M.push(_);e:for(;0<O;){var V=O-1>>>1,se=M[V];if(0<c(se,_))M[V]=_,M[O]=se,O=V;else break e}}function s(M){return M.length===0?null:M[0]}function o(M){if(M.length===0)return null;var _=M[0],O=M.pop();if(O!==_){M[0]=O;e:for(var V=0,se=M.length,A=se>>>1;V<A;){var Y=2*(V+1)-1,W=M[Y],te=Y+1,fe=M[te];if(0>c(W,O))te<se&&0>c(fe,W)?(M[V]=fe,M[te]=O,V=te):(M[V]=W,M[Y]=O,V=Y);else if(te<se&&0>c(fe,O))M[V]=fe,M[te]=O,V=te;else break e}}return _}function c(M,_){var O=M.sortIndex-_.sortIndex;return O!==0?O:M.id-_.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var g=[],m=[],y=1,v=null,b=3,S=!1,k=!1,w=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function B(M){for(var _=s(m);_!==null;){if(_.callback===null)o(m);else if(_.startTime<=M)o(m),_.sortIndex=_.expirationTime,r(g,_);else break;_=s(m)}}function D(M){if(w=!1,B(M),!k)if(s(g)!==null)k=!0,F||(F=!0,q());else{var _=s(m);_!==null&&$(D,_.startTime-M)}}var F=!1,E=-1,H=5,z=-1;function I(){return C?!0:!(t.unstable_now()-z<H)}function U(){if(C=!1,F){var M=t.unstable_now();z=M;var _=!0;try{e:{k=!1,w&&(w=!1,R(E),E=-1),S=!0;var O=b;try{t:{for(B(M),v=s(g);v!==null&&!(v.expirationTime>M&&I());){var V=v.callback;if(typeof V=="function"){v.callback=null,b=v.priorityLevel;var se=V(v.expirationTime<=M);if(M=t.unstable_now(),typeof se=="function"){v.callback=se,B(M),_=!0;break t}v===s(g)&&o(g),B(M)}else o(g);v=s(g)}if(v!==null)_=!0;else{var A=s(m);A!==null&&$(D,A.startTime-M),_=!1}}break e}finally{v=null,b=O,S=!1}_=void 0}}finally{_?q():F=!1}}}var q;if(typeof L=="function")q=function(){L(U)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=U,q=function(){J.postMessage(null)}}else q=function(){N(U,0)};function $(M,_){E=N(function(){M(t.unstable_now())},_)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(M){M.callback=null},t.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<M?Math.floor(1e3/M):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(M){switch(b){case 1:case 2:case 3:var _=3;break;default:_=b}var O=b;b=_;try{return M()}finally{b=O}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(M,_){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var O=b;b=M;try{return _()}finally{b=O}},t.unstable_scheduleCallback=function(M,_,O){var V=t.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0<O?V+O:V):O=V,M){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=O+se,M={id:y++,callback:_,priorityLevel:M,startTime:O,expirationTime:se,sortIndex:-1},O>V?(M.sortIndex=O,r(m,M),s(g)===null&&M===s(m)&&(w?(R(E),E=-1):w=!0,$(D,O-V))):(M.sortIndex=se,r(g,M),k||S||(k=!0,F||(F=!0,q()))),M},t.unstable_shouldYield=I,t.unstable_wrapCallback=function(M){var _=b;return function(){var O=b;b=_;try{return M.apply(this,arguments)}finally{b=O}}}})(fd)),fd}var Ax;function s0(){return Ax||(Ax=1,dd.exports=l0()),dd.exports}var pd={exports:{}},en={};/**
26
+ */var Rx;function i0(){return Rx||(Rx=1,(function(t){function r(L,_){var I=L.length;L.push(_);e:for(;0<I;){var V=I-1>>>1,se=L[V];if(0<c(se,_))L[V]=_,L[I]=se,I=V;else break e}}function s(L){return L.length===0?null:L[0]}function o(L){if(L.length===0)return null;var _=L[0],I=L.pop();if(I!==_){L[0]=I;e:for(var V=0,se=L.length,M=se>>>1;V<M;){var Y=2*(V+1)-1,W=L[Y],te=Y+1,fe=L[te];if(0>c(W,I))te<se&&0>c(fe,W)?(L[V]=fe,L[te]=I,V=te):(L[V]=W,L[Y]=I,V=Y);else if(te<se&&0>c(fe,I))L[V]=fe,L[te]=I,V=te;else break e}}return _}function c(L,_){var I=L.sortIndex-_.sortIndex;return I!==0?I:L.id-_.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var g=[],p=[],y=1,v=null,b=3,S=!1,k=!1,E=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function B(L){for(var _=s(p);_!==null;){if(_.callback===null)o(p);else if(_.startTime<=L)o(p),_.sortIndex=_.expirationTime,r(g,_);else break;_=s(p)}}function D(L){if(E=!1,B(L),!k)if(s(g)!==null)k=!0,F||(F=!0,q());else{var _=s(p);_!==null&&$(D,_.startTime-L)}}var F=!1,w=-1,O=5,z=-1;function U(){return C?!0:!(t.unstable_now()-z<O)}function H(){if(C=!1,F){var L=t.unstable_now();z=L;var _=!0;try{e:{k=!1,E&&(E=!1,T(w),w=-1),S=!0;var I=b;try{t:{for(B(L),v=s(g);v!==null&&!(v.expirationTime>L&&U());){var V=v.callback;if(typeof V=="function"){v.callback=null,b=v.priorityLevel;var se=V(v.expirationTime<=L);if(L=t.unstable_now(),typeof se=="function"){v.callback=se,B(L),_=!0;break t}v===s(g)&&o(g),B(L)}else o(g);v=s(g)}if(v!==null)_=!0;else{var M=s(p);M!==null&&$(D,M.startTime-L),_=!1}}break e}finally{v=null,b=I,S=!1}_=void 0}}finally{_?q():F=!1}}}var q;if(typeof A=="function")q=function(){A(H)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=H,q=function(){J.postMessage(null)}}else q=function(){N(H,0)};function $(L,_){w=N(function(){L(t.unstable_now())},_)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<L?Math.floor(1e3/L):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(L){switch(b){case 1:case 2:case 3:var _=3;break;default:_=b}var I=b;b=_;try{return L()}finally{b=I}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(L,_){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var I=b;b=L;try{return _()}finally{b=I}},t.unstable_scheduleCallback=function(L,_,I){var V=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?V+I:V):I=V,L){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=I+se,L={id:y++,callback:_,priorityLevel:L,startTime:I,expirationTime:se,sortIndex:-1},I>V?(L.sortIndex=I,r(p,L),s(g)===null&&L===s(p)&&(E?(T(w),w=-1):E=!0,$(D,I-V))):(L.sortIndex=se,r(g,L),k||S||(k=!0,F||(F=!0,q()))),L},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(L){var _=b;return function(){var I=b;b=_;try{return L.apply(this,arguments)}finally{b=I}}}})(fd)),fd}var Ax;function o0(){return Ax||(Ax=1,dd.exports=i0()),dd.exports}var pd={exports:{}},en={};/**
27
27
  * @license React
28
28
  * react-dom.production.js
29
29
  *
@@ -31,7 +31,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
33
  * LICENSE file in the root directory of this source tree.
34
- */var Mx;function i0(){if(Mx)return en;Mx=1;var t=df();function r(g){var m="https://react.dev/errors/"+g;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,m,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:m,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,m){if(g==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return en.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,en.createPortal=function(g,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(r(299));return u(g,m,null,y)},en.flushSync=function(g){var m=d.T,y=o.p;try{if(d.T=null,o.p=2,g)return g()}finally{d.T=m,o.p=y,o.d.f()}},en.preconnect=function(g,m){typeof g=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,o.d.C(g,m))},en.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},en.preinit=function(g,m){if(typeof g=="string"&&m&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?o.d.S(g,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},en.preinitModule=function(g,m){if(typeof g=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&o.d.M(g)},en.preload=function(g,m){if(typeof g=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},en.preloadModule=function(g,m){if(typeof g=="string")if(m){var y=h(m.as,m.crossOrigin);o.d.m(g,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else o.d.m(g)},en.requestFormReset=function(g){o.d.r(g)},en.unstable_batchedUpdates=function(g,m){return g(m)},en.useFormState=function(g,m,y){return d.H.useFormState(g,m,y)},en.useFormStatus=function(){return d.H.useHostTransitionStatus()},en.version="19.2.4",en}var Lx;function lv(){if(Lx)return pd.exports;Lx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),pd.exports=i0(),pd.exports}/**
34
+ */var Mx;function c0(){if(Mx)return en;Mx=1;var t=df();function r(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,p,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:p,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return en.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,en.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(r(299));return u(g,p,null,y)},en.flushSync=function(g){var p=d.T,y=o.p;try{if(d.T=null,o.p=2,g)return g()}finally{d.T=p,o.p=y,o.d.f()}},en.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,o.d.C(g,p))},en.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},en.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin),b=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?o.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},en.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=h(p.as,p.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&o.d.M(g)},en.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},en.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=h(p.as,p.crossOrigin);o.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else o.d.m(g)},en.requestFormReset=function(g){o.d.r(g)},en.unstable_batchedUpdates=function(g,p){return g(p)},en.useFormState=function(g,p,y){return d.H.useFormState(g,p,y)},en.useFormStatus=function(){return d.H.useHostTransitionStatus()},en.version="19.2.4",en}var Lx;function sv(){if(Lx)return pd.exports;Lx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),pd.exports=c0(),pd.exports}/**
35
35
  * @license React
36
36
  * react-dom-client.production.js
37
37
  *
@@ -39,15 +39,15 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
41
  * LICENSE file in the root directory of this source tree.
42
- */var zx;function o0(){if(zx)return Rs;zx=1;var t=s0(),r=df(),s=lv();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var f=l.return;if(f===null)break;var x=f.alternate;if(x===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===x.child){for(x=f.child;x;){if(x===l)return g(f),e;if(x===i)return g(f),n;x=x.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=x;else{for(var j=!1,T=f.child;T;){if(T===l){j=!0,l=f,i=x;break}if(T===i){j=!0,i=f,l=x;break}T=T.sibling}if(!j){for(T=x.child;T;){if(T===l){j=!0,l=x,i=f;break}if(T===i){j=!0,i=x,l=f;break}T=T.sibling}if(!j)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),L=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=U&&e[U]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case L:return e.displayName||"Context";case R:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case E:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var $=Array.isArray,M=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O={pending:!1,data:null,method:null,action:null},V=[],se=-1;function A(e){return{current:e}}function Y(e){0>se||(e.current=V[se],V[se]=null,se--)}function W(e,n){se++,V[se]=e.current,e.current=n}var te=A(null),fe=A(null),ie=A(null),ye=A(null);function de(e,n){switch(W(ie,n),W(fe,e),W(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Yh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Yh(n),e=Kh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(te),W(te,e)}function Se(){Y(te),Y(fe),Y(ie)}function Ae(e){e.memoizedState!==null&&W(ye,e);var n=te.current,l=Kh(n,e.type);n!==l&&(W(fe,e),W(te,l))}function _e(e){fe.current===e&&(Y(te),Y(fe)),ye.current===e&&(Y(ye),ws._currentValue=O)}var re,he;function pe(e){if(re===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);re=n&&n[1]||"",he=-1<l.stack.indexOf(`
42
+ */var zx;function u0(){if(zx)return Rs;zx=1;var t=o0(),r=df(),s=sv();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function p(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var f=l.return;if(f===null)break;var x=f.alternate;if(x===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===x.child){for(x=f.child;x;){if(x===l)return g(f),e;if(x===i)return g(f),n;x=x.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=x;else{for(var j=!1,R=f.child;R;){if(R===l){j=!0,l=f,i=x;break}if(R===i){j=!0,i=f,l=x;break}R=R.sibling}if(!j){for(R=x.child;R;){if(R===l){j=!0,l=x,i=f;break}if(R===i){j=!0,i=x,l=f;break}R=R.sibling}if(!j)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=H&&e[H]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case A:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var $=Array.isArray,L=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},V=[],se=-1;function M(e){return{current:e}}function Y(e){0>se||(e.current=V[se],V[se]=null,se--)}function W(e,n){se++,V[se]=e.current,e.current=n}var te=M(null),fe=M(null),ie=M(null),ye=M(null);function de(e,n){switch(W(ie,n),W(fe,e),W(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Yh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Yh(n),e=Kh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(te),W(te,e)}function Se(){Y(te),Y(fe),Y(ie)}function Ae(e){e.memoizedState!==null&&W(ye,e);var n=te.current,l=Kh(n,e.type);n!==l&&(W(fe,e),W(te,l))}function _e(e){fe.current===e&&(Y(te),Y(fe)),ye.current===e&&(Y(ye),ws._currentValue=I)}var re,he;function pe(e){if(re===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);re=n&&n[1]||"",he=-1<l.stack.indexOf(`
43
43
  at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
44
- `+re+e+he}var xe=!1;function je(e,n){if(!e||xe)return"";xe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(ae){var ee=ae}Reflect.construct(e,[],ue)}else{try{ue.call()}catch(ae){ee=ae}e.call(ue.prototype)}}else{try{throw Error()}catch(ae){ee=ae}(ue=e())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(ae){if(ae&&ee&&typeof ae.stack=="string")return[ae.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),j=x[0],T=x[1];if(j&&T){var P=j.split(`
45
- `),Z=T.split(`
44
+ `+re+e+he}var ge=!1;function je(e,n){if(!e||ge)return"";ge=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(ae){var ee=ae}Reflect.construct(e,[],ue)}else{try{ue.call()}catch(ae){ee=ae}e.call(ue.prototype)}}else{try{throw Error()}catch(ae){ee=ae}(ue=e())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(ae){if(ae&&ee&&typeof ae.stack=="string")return[ae.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),j=x[0],R=x[1];if(j&&R){var P=j.split(`
45
+ `),Z=R.split(`
46
46
  `);for(f=i=0;i<P.length&&!P[i].includes("DetermineComponentFrameRoot");)i++;for(;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;if(i===P.length||f===Z.length)for(i=P.length-1,f=Z.length-1;1<=i&&0<=f&&P[i]!==Z[f];)f--;for(;1<=i&&0<=f;i--,f--)if(P[i]!==Z[f]){if(i!==1||f!==1)do if(i--,f--,0>f||P[i]!==Z[f]){var le=`
47
- `+P[i].replace(" at new "," at ");return e.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",e.displayName)),le}while(1<=i&&0<=f);break}}}finally{xe=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?pe(l):""}function Be(e,n){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==n&&n!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return je(e.type,!1);case 11:return je(e.type.render,!1);case 1:return je(e.type,!0);case 31:return pe("Activity");default:return""}}function Oe(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
47
+ `+P[i].replace(" at new "," at ");return e.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",e.displayName)),le}while(1<=i&&0<=f);break}}}finally{ge=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?pe(l):""}function Be(e,n){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==n&&n!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return je(e.type,!1);case 11:return je(e.type.render,!1);case 1:return je(e.type,!0);case 31:return pe("Activity");default:return""}}function Oe(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
48
48
  Error generating stack: `+i.message+`
49
- `+i.stack}}var rt=Object.prototype.hasOwnProperty,Nt=t.unstable_scheduleCallback,ht=t.unstable_cancelCallback,Dt=t.unstable_shouldYield,Tt=t.unstable_requestPaint,Qe=t.unstable_now,tt=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,pt=t.unstable_UserBlockingPriority,Ct=t.unstable_NormalPriority,Yt=t.unstable_LowPriority,un=t.unstable_IdlePriority,Gt=t.log,an=t.unstable_setDisableYieldValue,Mn=null,Mt=null;function xt(e){if(typeof Gt=="function"&&an(e),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(Mn,e)}catch{}}var gt=Math.clz32?Math.clz32:Wn,da=Math.log,za=Math.LN2;function Wn(e){return e>>>=0,e===0?32:31-(da(e)/za|0)|0}var Et=256,ce=262144,ve=4194304;function Re(e){var n=e&42;if(n!==0)return n;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 dn(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var T=i&134217727;return T!==0?(i=T&~x,i!==0?f=Re(i):(j&=T,j!==0?f=Re(j):l||(l=T&~e,l!==0&&(f=Re(l))))):(T=i&~x,T!==0?f=Re(T):j!==0?f=Re(j):l||(l=i&~e,l!==0&&(f=Re(l)))),f===0?0:n!==0&&n!==f&&(n&x)===0&&(x=f&-f,l=n&-n,x>=l||x===32&&(l&4194048)!==0)?n:f}function fn(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function ai(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 qn(){var e=ve;return ve<<=1,(ve&62914560)===0&&(ve=4194304),e}function Bl(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function fr(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Il(e,n,l,i,f,x){var j=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var T=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var le=31-gt(l),ue=1<<le;T[le]=0,P[le]=-1;var ee=Z[le];if(ee!==null)for(Z[le]=null,le=0;le<ee.length;le++){var ae=ee[le];ae!==null&&(ae.lane&=-536870913)}l&=~ue}i!==0&&ta(e,i,0),x!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=x&~(j&~n))}function ta(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-gt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function pr(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-gt(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function mr(e,n){var l=n&-n;return l=(l&42)!==0?1:Pr(l),(l&(e.suspendedLanes|n))!==0?0:l}function Pr(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 Da(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function it(){var e=_.p;return e!==0?e:(e=window.event,e===void 0?32:vx(e.type))}function hr(e,n){var l=_.p;try{return _.p=e,n()}finally{_.p=l}}var rn=Math.random().toString(36).slice(2),Ut="__reactFiber$"+rn,ot="__reactProps$"+rn,xr="__reactContainer$"+rn,na="__reactEvents$"+rn,Jo="__reactListeners$"+rn,Wy="__reactHandles$"+rn,_f="__reactResources$"+rn,Hl="__reactMarker$"+rn;function ec(e){delete e[Ut],delete e[ot],delete e[na],delete e[Jo],delete e[Wy]}function Fr(e){var n=e[Ut];if(n)return n;for(var l=e.parentNode;l;){if(n=l[xr]||l[Ut]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=nx(e);e!==null;){if(l=e[Ut])return l;e=nx(e)}return n}e=l,l=e.parentNode}return null}function Gr(e){if(e=e[Ut]||e[xr]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Ul(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Wr(e){var n=e[_f];return n||(n=e[_f]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Wt(e){e[Hl]=!0}var Of=new Set,Bf={};function gr(e,n){qr(e,n),qr(e+"Capture",n)}function qr(e,n){for(Bf[e]=n,e=0;e<n.length;e++)Of.add(n[e])}var qy=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]*$"),If={},Hf={};function Yy(e){return rt.call(Hf,e)?!0:rt.call(If,e)?!1:qy.test(e)?Hf[e]=!0:(If[e]=!0,!1)}function ri(e,n,l){if(Yy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function li(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function fa(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Uf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ky(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,x=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,x.call(this,j)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function tc(e){if(!e._valueTracker){var n=Uf(e)?"checked":"value";e._valueTracker=Ky(e,n,""+e[n])}}function $f(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=Uf(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function si(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Xy=/[\n"\\]/g;function zn(e){return e.replace(Xy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function nc(e,n,l,i,f,x,j,T){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?ac(e,j,Ln(n)):l!=null?ac(e,j,Ln(l)):i!=null&&e.removeAttribute("value"),f==null&&x!=null&&(e.defaultChecked=!!x),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.name=""+Ln(T):e.removeAttribute("name")}function Vf(e,n,l,i,f,x,j,T){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),n!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||n!=null)){tc(e);return}l=l!=null?""+Ln(l):"",n=n!=null?""+Ln(n):l,T||n===e.value||(e.value=n),e.defaultValue=n}i=i??f,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=T?e.checked:!!i,e.defaultChecked=!!i,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),tc(e)}function ac(e,n,l){n==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Yr(e,n,l,i){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&i&&(e[l].defaultSelected=!0)}else{for(l=""+Ln(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,i&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Pf(e,n,l){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Ln(l):""}function Ff(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=Ln(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),tc(e)}function Kr(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Qy=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 Gf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||Qy.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function Wf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var f in n)i=n[f],n.hasOwnProperty(f)&&l[f]!==i&&Gf(e,f,i)}else for(var x in n)n.hasOwnProperty(x)&&Gf(e,x,n[x])}function rc(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 Zy=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"]]),Jy=/^[\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 ii(e){return Jy.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function pa(){}var lc=null;function sc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xr=null,Qr=null;function qf(e){var n=Gr(e);if(n&&(e=n.stateNode)){var l=e[ot]||null;e:switch(e=n.stateNode,n.type){case"input":if(nc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+zn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ot]||null;if(!f)throw Error(o(90));nc(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&$f(i)}break e;case"textarea":Pf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Yr(e,!!l.multiple,n,!1)}}}var ic=!1;function Yf(e,n,l){if(ic)return e(n,l);ic=!0;try{var i=e(n);return i}finally{if(ic=!1,(Xr!==null||Qr!==null)&&(Yi(),Xr&&(n=Xr,e=Qr,Qr=Xr=null,qf(n),e)))for(n=0;n<e.length;n++)qf(e[n])}}function $l(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ot]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var ma=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oc=!1;if(ma)try{var Vl={};Object.defineProperty(Vl,"passive",{get:function(){oc=!0}}),window.addEventListener("test",Vl,Vl),window.removeEventListener("test",Vl,Vl)}catch{oc=!1}var _a=null,cc=null,oi=null;function Kf(){if(oi)return oi;var e,n=cc,l=n.length,i,f="value"in _a?_a.value:_a.textContent,x=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(i=1;i<=j&&n[l-i]===f[x-i];i++);return oi=f.slice(e,1<i?1-i:void 0)}function ci(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function ui(){return!0}function Xf(){return!1}function pn(e){function n(l,i,f,x,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=x,this.target=j,this.currentTarget=null;for(var T in e)e.hasOwnProperty(T)&&(l=e[T],this[T]=l?l(x):x[T]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ui:Xf,this.isPropagationStopped=Xf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ui)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ui)},persist:function(){},isPersistent:ui}),n}var vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},di=pn(vr),Pl=v({},vr,{view:0,detail:0}),eb=pn(Pl),uc,dc,Fl,fi=v({},Pl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,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!==Fl&&(Fl&&e.type==="mousemove"?(uc=e.screenX-Fl.screenX,dc=e.screenY-Fl.screenY):dc=uc=0,Fl=e),uc)},movementY:function(e){return"movementY"in e?e.movementY:dc}}),Qf=pn(fi),tb=v({},fi,{dataTransfer:0}),nb=pn(tb),ab=v({},Pl,{relatedTarget:0}),fc=pn(ab),rb=v({},vr,{animationName:0,elapsedTime:0,pseudoElement:0}),lb=pn(rb),sb=v({},vr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ib=pn(sb),ob=v({},vr,{data:0}),Zf=pn(ob),cb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ub={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"},db={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=db[e])?!!n[e]:!1}function pc(){return fb}var pb=v({},Pl,{key:function(e){if(e.key){var n=cb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ci(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ub[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(e){return e.type==="keypress"?ci(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ci(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),mb=pn(pb),hb=v({},fi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jf=pn(hb),xb=v({},Pl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),gb=pn(xb),vb=v({},vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),yb=pn(vb),bb=v({},fi,{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}),jb=pn(bb),Sb=v({},vr,{newState:0,oldState:0}),kb=pn(Sb),wb=[9,13,27,32],mc=ma&&"CompositionEvent"in window,Gl=null;ma&&"documentMode"in document&&(Gl=document.documentMode);var Cb=ma&&"TextEvent"in window&&!Gl,ep=ma&&(!mc||Gl&&8<Gl&&11>=Gl),tp=" ",np=!1;function ap(e,n){switch(e){case"keyup":return wb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zr=!1;function Eb(e,n){switch(e){case"compositionend":return rp(n);case"keypress":return n.which!==32?null:(np=!0,tp);case"textInput":return e=n.data,e===tp&&np?null:e;default:return null}}function Nb(e,n){if(Zr)return e==="compositionend"||!mc&&ap(e,n)?(e=Kf(),oi=cc=_a=null,Zr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return ep&&n.locale!=="ko"?null:n.data;default:return null}}var Tb={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 lp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Tb[e.type]:n==="textarea"}function sp(e,n,l,i){Xr?Qr?Qr.push(i):Qr=[i]:Xr=i,n=to(n,"onChange"),0<n.length&&(l=new di("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Wl=null,ql=null;function Rb(e){Vh(e,0)}function pi(e){var n=Ul(e);if($f(n))return e}function ip(e,n){if(e==="change")return n}var op=!1;if(ma){var hc;if(ma){var xc="oninput"in document;if(!xc){var cp=document.createElement("div");cp.setAttribute("oninput","return;"),xc=typeof cp.oninput=="function"}hc=xc}else hc=!1;op=hc&&(!document.documentMode||9<document.documentMode)}function up(){Wl&&(Wl.detachEvent("onpropertychange",dp),ql=Wl=null)}function dp(e){if(e.propertyName==="value"&&pi(ql)){var n=[];sp(n,ql,e,sc(e)),Yf(Rb,n)}}function Ab(e,n,l){e==="focusin"?(up(),Wl=n,ql=l,Wl.attachEvent("onpropertychange",dp)):e==="focusout"&&up()}function Mb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return pi(ql)}function Lb(e,n){if(e==="click")return pi(n)}function zb(e,n){if(e==="input"||e==="change")return pi(n)}function Db(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Db;function Yl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var f=l[i];if(!rt.call(n,f)||!yn(e[f],n[f]))return!1}return!0}function fp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pp(e,n){var l=fp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=fp(l)}}function mp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?mp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function hp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=si(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=si(e.document)}return n}function gc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var _b=ma&&"documentMode"in document&&11>=document.documentMode,Jr=null,vc=null,Kl=null,yc=!1;function xp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;yc||Jr==null||Jr!==si(i)||(i=Jr,"selectionStart"in i&&gc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Kl&&Yl(Kl,i)||(Kl=i,i=to(vc,"onSelect"),0<i.length&&(n=new di("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=Jr)))}function yr(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var el={animationend:yr("Animation","AnimationEnd"),animationiteration:yr("Animation","AnimationIteration"),animationstart:yr("Animation","AnimationStart"),transitionrun:yr("Transition","TransitionRun"),transitionstart:yr("Transition","TransitionStart"),transitioncancel:yr("Transition","TransitionCancel"),transitionend:yr("Transition","TransitionEnd")},bc={},gp={};ma&&(gp=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function br(e){if(bc[e])return bc[e];if(!el[e])return e;var n=el[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in gp)return bc[e]=n[l];return e}var vp=br("animationend"),yp=br("animationiteration"),bp=br("animationstart"),Ob=br("transitionrun"),Bb=br("transitionstart"),Ib=br("transitioncancel"),jp=br("transitionend"),Sp=new Map,jc="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(" ");jc.push("scrollEnd");function Yn(e,n){Sp.set(e,n),gr(n,[e])}var mi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],tl=0,Sc=0;function hi(){for(var e=tl,n=Sc=tl=0;n<e;){var l=Dn[n];Dn[n++]=null;var i=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var x=Dn[n];if(Dn[n++]=null,i!==null&&f!==null){var j=i.pending;j===null?f.next=f:(f.next=j.next,j.next=f),i.pending=f}x!==0&&kp(l,f,x)}}function xi(e,n,l,i){Dn[tl++]=e,Dn[tl++]=n,Dn[tl++]=l,Dn[tl++]=i,Sc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function kc(e,n,l,i){return xi(e,n,l,i),gi(e)}function jr(e,n){return xi(e,null,null,n),gi(e)}function kp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,x=e.return;x!==null;)x.childLanes|=l,i=x.alternate,i!==null&&(i.childLanes|=l),x.tag===22&&(e=x.stateNode,e===null||e._visibility&1||(f=!0)),e=x,x=x.return;return e.tag===3?(x=e.stateNode,f&&n!==null&&(f=31-gt(l),e=x.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),x):null}function gi(e){if(50<gs)throw gs=0,Lu=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var nl={};function Hb(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,l,i){return new Hb(e,n,l,i)}function wc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ha(e,n){var l=e.alternate;return l===null?(l=bn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function wp(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function vi(e,n,l,i,f,x){var j=0;if(i=e,typeof e=="function")wc(e)&&(j=1);else if(typeof e=="string")j=F1(e,l,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=bn(31,l,n,f),e.elementType=z,e.lanes=x,e;case w:return Sr(l.children,f,x,n);case C:j=8,f|=24;break;case N:return e=bn(12,l,n,f|2),e.elementType=N,e.lanes=x,e;case D:return e=bn(13,l,n,f),e.elementType=D,e.lanes=x,e;case F:return e=bn(19,l,n,f),e.elementType=F,e.lanes=x,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L:j=10;break e;case R:j=9;break e;case B:j=11;break e;case E:j=14;break e;case H:j=16,i=null;break e}j=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=bn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=x,n}function Sr(e,n,l,i){return e=bn(7,e,i,n),e.lanes=l,e}function Cc(e,n,l){return e=bn(6,e,null,n),e.lanes=l,e}function Cp(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Ec(e,n,l){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Ep=new WeakMap;function _n(e,n){if(typeof e=="object"&&e!==null){var l=Ep.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Oe(n)},Ep.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var al=[],rl=0,yi=null,Xl=0,On=[],Bn=0,Oa=null,aa=1,ra="";function xa(e,n){al[rl++]=Xl,al[rl++]=yi,yi=e,Xl=n}function Np(e,n,l){On[Bn++]=aa,On[Bn++]=ra,On[Bn++]=Oa,Oa=e;var i=aa;e=ra;var f=32-gt(i)-1;i&=~(1<<f),l+=1;var x=32-gt(n)+f;if(30<x){var j=f-f%5;x=(i&(1<<j)-1).toString(32),i>>=j,f-=j,aa=1<<32-gt(n)+f|l<<f|i,ra=x+e}else aa=1<<x|l<<f|i,ra=e}function Nc(e){e.return!==null&&(xa(e,1),Np(e,1,0))}function Tc(e){for(;e===yi;)yi=al[--rl],al[rl]=null,Xl=al[--rl],al[rl]=null;for(;e===Oa;)Oa=On[--Bn],On[Bn]=null,ra=On[--Bn],On[Bn]=null,aa=On[--Bn],On[Bn]=null}function Tp(e,n){On[Bn++]=aa,On[Bn++]=ra,On[Bn++]=Oa,aa=n.id,ra=n.overflow,Oa=e}var Kt=null,vt=null,Ke=!1,Ba=null,In=!1,Rc=Error(o(519));function Ia(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ql(_n(n,e)),Rc}function Rp(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[Ut]=e,n[ot]=i,l){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(l=0;l<ys.length;l++)We(ys[l],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Vf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),Ff(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||Wh(n.textContent,l)?(i.popover!=null&&(We("beforetoggle",n),We("toggle",n)),i.onScroll!=null&&We("scroll",n),i.onScrollEnd!=null&&We("scrollend",n),i.onClick!=null&&(n.onclick=pa),n=!0):n=!1,n||Ia(e,!0)}function Ap(e){for(Kt=e.return;Kt;)switch(Kt.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Kt=Kt.return}}function ll(e){if(e!==Kt)return!1;if(!Ke)return Ap(e),Ke=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||qu(e.type,e.memoizedProps)),l=!l),l&&vt&&Ia(e),Ap(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=tx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=tx(e)}else n===27?(n=vt,Za(e.type)?(e=Zu,Zu=null,vt=e):vt=n):vt=Kt?Un(e.stateNode.nextSibling):null;return!0}function kr(){vt=Kt=null,Ke=!1}function Ac(){var e=Ba;return e!==null&&(gn===null?gn=e:gn.push.apply(gn,e),Ba=null),e}function Ql(e){Ba===null?Ba=[e]:Ba.push(e)}var Mc=A(null),wr=null,ga=null;function Ha(e,n,l){W(Mc,n._currentValue),n._currentValue=l}function va(e){e._currentValue=Mc.current,Y(Mc)}function Lc(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function zc(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var x=f.dependencies;if(x!==null){var j=f.child;x=x.firstContext;e:for(;x!==null;){var T=x;x=f;for(var P=0;P<n.length;P++)if(T.context===n[P]){x.lanes|=l,T=x.alternate,T!==null&&(T.lanes|=l),Lc(x.return,l,e),i||(j=null);break e}x=T.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,x=j.alternate,x!==null&&(x.lanes|=l),Lc(j,l,e),j=null}else j=f.child;if(j!==null)j.return=f;else for(j=f;j!==null;){if(j===e){j=null;break}if(f=j.sibling,f!==null){f.return=j.return,j=f;break}j=j.return}f=j}}function sl(e,n,l,i){e=null;for(var f=n,x=!1;f!==null;){if(!x){if((f.flags&524288)!==0)x=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(o(387));if(j=j.memoizedProps,j!==null){var T=f.type;yn(f.pendingProps.value,j.value)||(e!==null?e.push(T):e=[T])}}else if(f===ye.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(ws):e=[ws])}f=f.return}e!==null&&zc(n,e,l,i),n.flags|=262144}function bi(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){wr=e,ga=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xt(e){return Mp(wr,e)}function ji(e,n){return wr===null&&Cr(e),Mp(e,n)}function Mp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},ga===null){if(e===null)throw Error(o(308));ga=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else ga=ga.next=n;return l}var Ub=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},$b=t.unstable_scheduleCallback,Vb=t.unstable_NormalPriority,_t={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Dc(){return{controller:new Ub,data:new Map,refCount:0}}function Zl(e){e.refCount--,e.refCount===0&&$b(Vb,function(){e.controller.abort()})}var Jl=null,_c=0,il=0,ol=null;function Pb(e,n){if(Jl===null){var l=Jl=[];_c=0,il=Iu(),ol={status:"pending",value:void 0,then:function(i){l.push(i)}}}return _c++,n.then(Lp,Lp),n}function Lp(){if(--_c===0&&Jl!==null){ol!==null&&(ol.status="fulfilled");var e=Jl;Jl=null,il=0,ol=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Fb(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(i.status="rejected",i.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),i}var zp=M.S;M.S=function(e,n){xh=Qe(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Pb(e,n),zp!==null&&zp(e,n)};var Er=A(null);function Oc(){var e=Er.current;return e!==null?e:mt.pooledCache}function Si(e,n){n===null?W(Er,Er.current):W(Er,n.pool)}function Dp(){var e=Oc();return e===null?null:{parent:_t._currentValue,pool:e}}var cl=Error(o(460)),Bc=Error(o(474)),ki=Error(o(542)),wi={then:function(){}};function _p(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Op(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(pa,pa),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ip(e),e;default:if(typeof n.status=="string")n.then(pa,pa);else{if(e=mt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=i}},function(i){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ip(e),e}throw Tr=n,cl}}function Nr(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Tr=l,cl):l}}var Tr=null;function Bp(){if(Tr===null)throw Error(o(459));var e=Tr;return Tr=null,e}function Ip(e){if(e===cl||e===ki)throw Error(o(483))}var ul=null,es=0;function Ci(e){var n=es;return es+=1,ul===null&&(ul=[]),Op(ul,e,n)}function ts(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ei(e,n){throw n.$$typeof===b?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Hp(e){function n(K,G){if(e){var Q=K.deletions;Q===null?(K.deletions=[G],K.flags|=16):Q.push(G)}}function l(K,G){if(!e)return null;for(;G!==null;)n(K,G),G=G.sibling;return null}function i(K){for(var G=new Map;K!==null;)K.key!==null?G.set(K.key,K):G.set(K.index,K),K=K.sibling;return G}function f(K,G){return K=ha(K,G),K.index=0,K.sibling=null,K}function x(K,G,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<G?(K.flags|=67108866,G):Q):(K.flags|=67108866,G)):(K.flags|=1048576,G)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function T(K,G,Q,oe){return G===null||G.tag!==6?(G=Cc(Q,K.mode,oe),G.return=K,G):(G=f(G,Q),G.return=K,G)}function P(K,G,Q,oe){var Me=Q.type;return Me===w?le(K,G,Q.props.children,oe,Q.key):G!==null&&(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===H&&Nr(Me)===G.type)?(G=f(G,Q.props),ts(G,Q),G.return=K,G):(G=vi(Q.type,Q.key,Q.props,null,K.mode,oe),ts(G,Q),G.return=K,G)}function Z(K,G,Q,oe){return G===null||G.tag!==4||G.stateNode.containerInfo!==Q.containerInfo||G.stateNode.implementation!==Q.implementation?(G=Ec(Q,K.mode,oe),G.return=K,G):(G=f(G,Q.children||[]),G.return=K,G)}function le(K,G,Q,oe,Me){return G===null||G.tag!==7?(G=Sr(Q,K.mode,oe,Me),G.return=K,G):(G=f(G,Q),G.return=K,G)}function ue(K,G,Q){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Cc(""+G,K.mode,Q),G.return=K,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return Q=vi(G.type,G.key,G.props,null,K.mode,Q),ts(Q,G),Q.return=K,Q;case k:return G=Ec(G,K.mode,Q),G.return=K,G;case H:return G=Nr(G),ue(K,G,Q)}if($(G)||q(G))return G=Sr(G,K.mode,Q,null),G.return=K,G;if(typeof G.then=="function")return ue(K,Ci(G),Q);if(G.$$typeof===L)return ue(K,ji(K,G),Q);Ei(K,G)}return null}function ee(K,G,Q,oe){var Me=G!==null?G.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Me!==null?null:T(K,G,""+Q,oe);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Me?P(K,G,Q,oe):null;case k:return Q.key===Me?Z(K,G,Q,oe):null;case H:return Q=Nr(Q),ee(K,G,Q,oe)}if($(Q)||q(Q))return Me!==null?null:le(K,G,Q,oe,null);if(typeof Q.then=="function")return ee(K,G,Ci(Q),oe);if(Q.$$typeof===L)return ee(K,G,ji(K,Q),oe);Ei(K,Q)}return null}function ae(K,G,Q,oe,Me){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return K=K.get(Q)||null,T(G,K,""+oe,Me);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case S:return K=K.get(oe.key===null?Q:oe.key)||null,P(G,K,oe,Me);case k:return K=K.get(oe.key===null?Q:oe.key)||null,Z(G,K,oe,Me);case H:return oe=Nr(oe),ae(K,G,Q,oe,Me)}if($(oe)||q(oe))return K=K.get(Q)||null,le(G,K,oe,Me,null);if(typeof oe.then=="function")return ae(K,G,Q,Ci(oe),Me);if(oe.$$typeof===L)return ae(K,G,Q,ji(G,oe),Me);Ei(G,oe)}return null}function we(K,G,Q,oe){for(var Me=null,Ze=null,Ee=G,Ve=G=0,Ye=null;Ee!==null&&Ve<Q.length;Ve++){Ee.index>Ve?(Ye=Ee,Ee=null):Ye=Ee.sibling;var Je=ee(K,Ee,Q[Ve],oe);if(Je===null){Ee===null&&(Ee=Ye);break}e&&Ee&&Je.alternate===null&&n(K,Ee),G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je,Ee=Ye}if(Ve===Q.length)return l(K,Ee),Ke&&xa(K,Ve),Me;if(Ee===null){for(;Ve<Q.length;Ve++)Ee=ue(K,Q[Ve],oe),Ee!==null&&(G=x(Ee,G,Ve),Ze===null?Me=Ee:Ze.sibling=Ee,Ze=Ee);return Ke&&xa(K,Ve),Me}for(Ee=i(Ee);Ve<Q.length;Ve++)Ye=ae(Ee,K,Ve,Q[Ve],oe),Ye!==null&&(e&&Ye.alternate!==null&&Ee.delete(Ye.key===null?Ve:Ye.key),G=x(Ye,G,Ve),Ze===null?Me=Ye:Ze.sibling=Ye,Ze=Ye);return e&&Ee.forEach(function(ar){return n(K,ar)}),Ke&&xa(K,Ve),Me}function Le(K,G,Q,oe){if(Q==null)throw Error(o(151));for(var Me=null,Ze=null,Ee=G,Ve=G=0,Ye=null,Je=Q.next();Ee!==null&&!Je.done;Ve++,Je=Q.next()){Ee.index>Ve?(Ye=Ee,Ee=null):Ye=Ee.sibling;var ar=ee(K,Ee,Je.value,oe);if(ar===null){Ee===null&&(Ee=Ye);break}e&&Ee&&ar.alternate===null&&n(K,Ee),G=x(ar,G,Ve),Ze===null?Me=ar:Ze.sibling=ar,Ze=ar,Ee=Ye}if(Je.done)return l(K,Ee),Ke&&xa(K,Ve),Me;if(Ee===null){for(;!Je.done;Ve++,Je=Q.next())Je=ue(K,Je.value,oe),Je!==null&&(G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return Ke&&xa(K,Ve),Me}for(Ee=i(Ee);!Je.done;Ve++,Je=Q.next())Je=ae(Ee,K,Ve,Je.value,oe),Je!==null&&(e&&Je.alternate!==null&&Ee.delete(Je.key===null?Ve:Je.key),G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return e&&Ee.forEach(function(t0){return n(K,t0)}),Ke&&xa(K,Ve),Me}function dt(K,G,Q,oe){if(typeof Q=="object"&&Q!==null&&Q.type===w&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Me=Q.key;G!==null;){if(G.key===Me){if(Me=Q.type,Me===w){if(G.tag===7){l(K,G.sibling),oe=f(G,Q.props.children),oe.return=K,K=oe;break e}}else if(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===H&&Nr(Me)===G.type){l(K,G.sibling),oe=f(G,Q.props),ts(oe,Q),oe.return=K,K=oe;break e}l(K,G);break}else n(K,G);G=G.sibling}Q.type===w?(oe=Sr(Q.props.children,K.mode,oe,Q.key),oe.return=K,K=oe):(oe=vi(Q.type,Q.key,Q.props,null,K.mode,oe),ts(oe,Q),oe.return=K,K=oe)}return j(K);case k:e:{for(Me=Q.key;G!==null;){if(G.key===Me)if(G.tag===4&&G.stateNode.containerInfo===Q.containerInfo&&G.stateNode.implementation===Q.implementation){l(K,G.sibling),oe=f(G,Q.children||[]),oe.return=K,K=oe;break e}else{l(K,G);break}else n(K,G);G=G.sibling}oe=Ec(Q,K.mode,oe),oe.return=K,K=oe}return j(K);case H:return Q=Nr(Q),dt(K,G,Q,oe)}if($(Q))return we(K,G,Q,oe);if(q(Q)){if(Me=q(Q),typeof Me!="function")throw Error(o(150));return Q=Me.call(Q),Le(K,G,Q,oe)}if(typeof Q.then=="function")return dt(K,G,Ci(Q),oe);if(Q.$$typeof===L)return dt(K,G,ji(K,Q),oe);Ei(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,G!==null&&G.tag===6?(l(K,G.sibling),oe=f(G,Q),oe.return=K,K=oe):(l(K,G),oe=Cc(Q,K.mode,oe),oe.return=K,K=oe),j(K)):l(K,G)}return function(K,G,Q,oe){try{es=0;var Me=dt(K,G,Q,oe);return ul=null,Me}catch(Ee){if(Ee===cl||Ee===ki)throw Ee;var Ze=bn(29,Ee,null,K.mode);return Ze.lanes=oe,Ze.return=K,Ze}finally{}}}var Rr=Hp(!0),Up=Hp(!1),Ua=!1;function Ic(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $a(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(nt&2)!==0){var f=i.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),i.pending=n,n=gi(e),kp(e,null,l),n}return xi(e,i,n,l),gi(e)}function ns(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pr(e,l)}}function Uc(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?f=x=j:x=x.next=j,l=l.next}while(l!==null);x===null?f=x=n:x=x.next=n}else f=x=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var $c=!1;function as(){if($c){var e=ol;if(e!==null)throw e}}function rs(e,n,l,i){$c=!1;var f=e.updateQueue;Ua=!1;var x=f.firstBaseUpdate,j=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var P=T,Z=P.next;P.next=null,j===null?x=Z:j.next=Z,j=P;var le=e.alternate;le!==null&&(le=le.updateQueue,T=le.lastBaseUpdate,T!==j&&(T===null?le.firstBaseUpdate=Z:T.next=Z,le.lastBaseUpdate=P))}if(x!==null){var ue=f.baseState;j=0,le=Z=P=null,T=x;do{var ee=T.lane&-536870913,ae=ee!==T.lane;if(ae?(qe&ee)===ee:(i&ee)===ee){ee!==0&&ee===il&&($c=!0),le!==null&&(le=le.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var we=e,Le=T;ee=n;var dt=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){ue=we.call(dt,ue,ee);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,ee=typeof we=="function"?we.call(dt,ue,ee):we,ee==null)break e;ue=v({},ue,ee);break e;case 2:Ua=!0}}ee=T.callback,ee!==null&&(e.flags|=64,ae&&(e.flags|=8192),ae=f.callbacks,ae===null?f.callbacks=[ee]:ae.push(ee))}else ae={lane:ee,tag:T.tag,payload:T.payload,callback:T.callback,next:null},le===null?(Z=le=ae,P=ue):le=le.next=ae,j|=ee;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;ae=T,T=ae.next,ae.next=null,f.lastBaseUpdate=ae,f.shared.pending=null}}while(!0);le===null&&(P=ue),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=le,x===null&&(f.shared.lanes=0),qa|=j,e.lanes=j,e.memoizedState=ue}}function $p(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Vp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)$p(l[e],n)}var dl=A(null),Ni=A(0);function Pp(e,n){e=Na,W(Ni,e),W(dl,n),Na=e|n.baseLanes}function Vc(){W(Ni,Na),W(dl,dl.current)}function Pc(){Na=Ni.current,Y(dl),Y(Ni)}var jn=A(null),Hn=null;function Pa(e){var n=e.alternate;W(Lt,Lt.current&1),W(jn,e),Hn===null&&(n===null||dl.current!==null||n.memoizedState!==null)&&(Hn=e)}function Fc(e){W(Lt,Lt.current),W(jn,e),Hn===null&&(Hn=e)}function Fp(e){e.tag===22?(W(Lt,Lt.current),W(jn,e),Hn===null&&(Hn=e)):Fa()}function Fa(){W(Lt,Lt.current),W(jn,jn.current)}function Sn(e){Y(jn),Hn===e&&(Hn=null),Y(Lt)}var Lt=A(0);function Ti(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Xu(l)||Qu(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var ya=0,Ue=null,ct=null,Ot=null,Ri=!1,fl=!1,Ar=!1,Ai=0,ls=0,pl=null,Gb=0;function Rt(){throw Error(o(321))}function Gc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!yn(e[l],n[l]))return!1;return!0}function Wc(e,n,l,i,f,x){return ya=x,Ue=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,M.H=e===null||e.memoizedState===null?Nm:iu,Ar=!1,x=l(i,f),Ar=!1,fl&&(x=Wp(n,l,i,f)),Gp(e),x}function Gp(e){M.H=os;var n=ct!==null&&ct.next!==null;if(ya=0,Ot=ct=Ue=null,Ri=!1,ls=0,pl=null,n)throw Error(o(300));e===null||Bt||(e=e.dependencies,e!==null&&bi(e)&&(Bt=!0))}function Wp(e,n,l,i){Ue=e;var f=0;do{if(fl&&(pl=null),ls=0,fl=!1,25<=f)throw Error(o(301));if(f+=1,Ot=ct=null,e.updateQueue!=null){var x=e.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}M.H=Tm,x=n(l,i)}while(fl);return x}function Wb(){var e=M.H,n=e.useState()[0];return n=typeof n.then=="function"?ss(n):n,e=e.useState()[0],(ct!==null?ct.memoizedState:null)!==e&&(Ue.flags|=1024),n}function qc(){var e=Ai!==0;return Ai=0,e}function Yc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Kc(e){if(Ri){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ri=!1}ya=0,Ot=ct=Ue=null,fl=!1,ls=Ai=0,pl=null}function ln(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?Ue.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function zt(){if(ct===null){var e=Ue.alternate;e=e!==null?e.memoizedState:null}else e=ct.next;var n=Ot===null?Ue.memoizedState:Ot.next;if(n!==null)Ot=n,ct=e;else{if(e===null)throw Ue.alternate===null?Error(o(467)):Error(o(310));ct=e,e={memoizedState:ct.memoizedState,baseState:ct.baseState,baseQueue:ct.baseQueue,queue:ct.queue,next:null},Ot===null?Ue.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function Mi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ss(e){var n=ls;return ls+=1,pl===null&&(pl=[]),e=Op(pl,e,n),n=Ue,(Ot===null?n.memoizedState:Ot.next)===null&&(n=n.alternate,M.H=n===null||n.memoizedState===null?Nm:iu),e}function Li(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ss(e);if(e.$$typeof===L)return Xt(e)}throw Error(o(438,String(e)))}function Xc(e){var n=null,l=Ue.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=Ue.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Mi(),Ue.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=I;return n.index++,l}function ba(e,n){return typeof n=="function"?n(e):n}function zi(e){var n=zt();return Qc(n,ct,e)}function Qc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,x=i.pending;if(x!==null){if(f!==null){var j=f.next;f.next=x.next,x.next=j}n.baseQueue=f=x,i.pending=null}if(x=e.baseState,f===null)e.memoizedState=x;else{n=f.next;var T=j=null,P=null,Z=n,le=!1;do{var ue=Z.lane&-536870913;if(ue!==Z.lane?(qe&ue)===ue:(ya&ue)===ue){var ee=Z.revertLane;if(ee===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ue===il&&(le=!0);else if((ya&ee)===ee){Z=Z.next,ee===il&&(le=!0);continue}else ue={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(T=P=ue,j=x):P=P.next=ue,Ue.lanes|=ee,qa|=ee;ue=Z.action,Ar&&l(x,ue),x=Z.hasEagerState?Z.eagerState:l(x,ue)}else ee={lane:ue,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(T=P=ee,j=x):P=P.next=ee,Ue.lanes|=ue,qa|=ue;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=x:P.next=T,!yn(x,e.memoizedState)&&(Bt=!0,le&&(l=ol,l!==null)))throw l;e.memoizedState=x,e.baseState=j,e.baseQueue=P,i.lastRenderedState=x}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Zc(e){var n=zt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,x=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do x=e(x,j.action),j=j.next;while(j!==f);yn(x,n.memoizedState)||(Bt=!0),n.memoizedState=x,n.baseQueue===null&&(n.baseState=x),l.lastRenderedState=x}return[x,i]}function qp(e,n,l){var i=Ue,f=zt(),x=Ke;if(x){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!yn((ct||f).memoizedState,l);if(j&&(f.memoizedState=l,Bt=!0),f=f.queue,tu(Xp.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||Ot!==null&&Ot.memoizedState.tag&1){if(i.flags|=2048,ml(9,{destroy:void 0},Kp.bind(null,i,f,l,n),null),mt===null)throw Error(o(349));x||(ya&127)!==0||Yp(i,n,l)}return l}function Yp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Ue.updateQueue,n===null?(n=Mi(),Ue.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Kp(e,n,l,i){n.value=l,n.getSnapshot=i,Qp(n)&&Zp(e)}function Xp(e,n,l){return l(function(){Qp(n)&&Zp(e)})}function Qp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!yn(e,l)}catch{return!0}}function Zp(e){var n=jr(e,2);n!==null&&vn(n,e,2)}function Jc(e){var n=ln();if(typeof e=="function"){var l=e;if(e=l(),Ar){xt(!0);try{l()}finally{xt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:e},n}function Jp(e,n,l,i){return e.baseState=l,Qc(e,ct,typeof i=="function"?i:ba)}function qb(e,n,l,i,f){if(Oi(e))throw Error(o(485));if(e=n.action,e!==null){var x={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){x.listeners.push(j)}};M.T!==null?l(!0):x.isTransition=!1,i(x),l=n.pending,l===null?(x.next=n.pending=x,em(n,x)):(x.next=l.next,n.pending=l.next=x)}}function em(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var x=M.T,j={};M.T=j;try{var T=l(f,i),P=M.S;P!==null&&P(j,T),tm(e,n,T)}catch(Z){eu(e,n,Z)}finally{x!==null&&j.types!==null&&(x.types=j.types),M.T=x}}else try{x=l(f,i),tm(e,n,x)}catch(Z){eu(e,n,Z)}}function tm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){nm(e,n,i)},function(i){return eu(e,n,i)}):nm(e,n,l)}function nm(e,n,l){n.status="fulfilled",n.value=l,am(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,em(e,l)))}function eu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,am(n),n=n.next;while(n!==i)}e.action=null}function am(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function rm(e,n){return n}function lm(e,n){if(Ke){var l=mt.formState;if(l!==null){e:{var i=Ue;if(Ke){if(vt){t:{for(var f=vt,x=In;f.nodeType!==8;){if(!x){f=null;break t}if(f=Un(f.nextSibling),f===null){f=null;break t}}x=f.data,f=x==="F!"||x==="F"?f:null}if(f){vt=Un(f.nextSibling),i=f.data==="F!";break e}}Ia(i)}i=!1}i&&(n=l[0])}}return l=ln(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:rm,lastRenderedState:n},l.queue=i,l=wm.bind(null,Ue,i),i.dispatch=l,i=Jc(!1),x=su.bind(null,Ue,!1,i.queue),i=ln(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=qb.bind(null,Ue,f,x,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function sm(e){var n=zt();return im(n,ct,e)}function im(e,n,l){if(n=Qc(e,n,rm)[0],e=zi(ba)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=ss(n)}catch(j){throw j===cl?ki:j}else i=n;n=zt();var f=n.queue,x=f.dispatch;return l!==n.memoizedState&&(Ue.flags|=2048,ml(9,{destroy:void 0},Yb.bind(null,f,l),null)),[i,x,e]}function Yb(e,n){e.action=n}function om(e){var n=zt(),l=ct;if(l!==null)return im(n,l,e);zt(),n=n.memoizedState,l=zt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function ml(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=Ue.updateQueue,n===null&&(n=Mi(),Ue.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function cm(){return zt().memoizedState}function Di(e,n,l,i){var f=ln();Ue.flags|=e,f.memoizedState=ml(1|n,{destroy:void 0},l,i===void 0?null:i)}function _i(e,n,l,i){var f=zt();i=i===void 0?null:i;var x=f.memoizedState.inst;ct!==null&&i!==null&&Gc(i,ct.memoizedState.deps)?f.memoizedState=ml(n,x,l,i):(Ue.flags|=e,f.memoizedState=ml(1|n,x,l,i))}function um(e,n){Di(8390656,8,e,n)}function tu(e,n){_i(2048,8,e,n)}function Kb(e){Ue.flags|=4;var n=Ue.updateQueue;if(n===null)n=Mi(),Ue.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function dm(e){var n=zt().memoizedState;return Kb({ref:n,nextImpl:e}),function(){if((nt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function fm(e,n){return _i(4,2,e,n)}function pm(e,n){return _i(4,4,e,n)}function mm(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function hm(e,n,l){l=l!=null?l.concat([e]):null,_i(4,4,mm.bind(null,n,e),l)}function nu(){}function xm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&Gc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function gm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&Gc(n,i[1]))return i[0];if(i=e(),Ar){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i}function au(e,n,l){return l===void 0||(ya&1073741824)!==0&&(qe&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=vh(),Ue.lanes|=e,qa|=e,l)}function vm(e,n,l,i){return yn(l,n)?l:dl.current!==null?(e=au(e,l,i),yn(e,n)||(Bt=!0),e):(ya&42)===0||(ya&1073741824)!==0&&(qe&261930)===0?(Bt=!0,e.memoizedState=l):(e=vh(),Ue.lanes|=e,qa|=e,n)}function ym(e,n,l,i,f){var x=_.p;_.p=x!==0&&8>x?x:8;var j=M.T,T={};M.T=T,su(e,!1,n,l);try{var P=f(),Z=M.S;if(Z!==null&&Z(T,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var le=Fb(P,i);is(e,n,le,Cn(e))}else is(e,n,i,Cn(e))}catch(ue){is(e,n,{then:function(){},status:"rejected",reason:ue},Cn())}finally{_.p=x,j!==null&&T.types!==null&&(j.types=T.types),M.T=j}}function Xb(){}function ru(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=bm(e).queue;ym(e,f,n,O,l===null?Xb:function(){return jm(e),l(i)})}function bm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:O,baseState:O,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:O},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function jm(e){var n=bm(e);n.next===null&&(n=e.alternate.memoizedState),is(e,n.next.queue,{},Cn())}function lu(){return Xt(ws)}function Sm(){return zt().memoizedState}function km(){return zt().memoizedState}function Qb(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Cn();e=$a(l);var i=Va(n,e,l);i!==null&&(vn(i,n,l),ns(i,n,l)),n={cache:Dc()},e.payload=n;return}n=n.return}}function Zb(e,n,l){var i=Cn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Oi(e)?Cm(n,l):(l=kc(e,n,l,i),l!==null&&(vn(l,e,i),Em(l,n,i)))}function wm(e,n,l){var i=Cn();is(e,n,l,i)}function is(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Oi(e))Cm(n,f);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=n.lastRenderedReducer,x!==null))try{var j=n.lastRenderedState,T=x(j,l);if(f.hasEagerState=!0,f.eagerState=T,yn(T,j))return xi(e,n,f,0),mt===null&&hi(),!1}catch{}finally{}if(l=kc(e,n,f,i),l!==null)return vn(l,e,i),Em(l,n,i),!0}return!1}function su(e,n,l,i){if(i={lane:2,revertLane:Iu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Oi(e)){if(n)throw Error(o(479))}else n=kc(e,l,i,2),n!==null&&vn(n,e,2)}function Oi(e){var n=e.alternate;return e===Ue||n!==null&&n===Ue}function Cm(e,n){fl=Ri=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Em(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pr(e,l)}}var os={readContext:Xt,use:Li,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};os.useEffectEvent=Rt;var Nm={readContext:Xt,use:Li,useCallback:function(e,n){return ln().memoizedState=[e,n===void 0?null:n],e},useContext:Xt,useEffect:um,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Di(4194308,4,mm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Di(4194308,4,e,n)},useInsertionEffect:function(e,n){Di(4,2,e,n)},useMemo:function(e,n){var l=ln();n=n===void 0?null:n;var i=e();if(Ar){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=ln();if(l!==void 0){var f=l(n);if(Ar){xt(!0);try{l(n)}finally{xt(!1)}}}else f=n;return i.memoizedState=i.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},i.queue=e,e=e.dispatch=Zb.bind(null,Ue,e),[i.memoizedState,e]},useRef:function(e){var n=ln();return e={current:e},n.memoizedState=e},useState:function(e){e=Jc(e);var n=e.queue,l=wm.bind(null,Ue,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:nu,useDeferredValue:function(e,n){var l=ln();return au(l,e,n)},useTransition:function(){var e=Jc(!1);return e=ym.bind(null,Ue,e.queue,!0,!1),ln().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=Ue,f=ln();if(Ke){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),mt===null)throw Error(o(349));(qe&127)!==0||Yp(i,n,l)}f.memoizedState=l;var x={value:l,getSnapshot:n};return f.queue=x,um(Xp.bind(null,i,x,e),[e]),i.flags|=2048,ml(9,{destroy:void 0},Kp.bind(null,i,x,l,n),null),l},useId:function(){var e=ln(),n=mt.identifierPrefix;if(Ke){var l=ra,i=aa;l=(i&~(1<<32-gt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Ai++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=Gb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:lu,useFormState:lm,useActionState:lm,useOptimistic:function(e){var n=ln();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=su.bind(null,Ue,!0,l),l.dispatch=n,[e,n]},useMemoCache:Xc,useCacheRefresh:function(){return ln().memoizedState=Qb.bind(null,Ue)},useEffectEvent:function(e){var n=ln(),l={impl:e};return n.memoizedState=l,function(){if((nt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},iu={readContext:Xt,use:Li,useCallback:xm,useContext:Xt,useEffect:tu,useImperativeHandle:hm,useInsertionEffect:fm,useLayoutEffect:pm,useMemo:gm,useReducer:zi,useRef:cm,useState:function(){return zi(ba)},useDebugValue:nu,useDeferredValue:function(e,n){var l=zt();return vm(l,ct.memoizedState,e,n)},useTransition:function(){var e=zi(ba)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:qp,useId:Sm,useHostTransitionStatus:lu,useFormState:sm,useActionState:sm,useOptimistic:function(e,n){var l=zt();return Jp(l,ct,e,n)},useMemoCache:Xc,useCacheRefresh:km};iu.useEffectEvent=dm;var Tm={readContext:Xt,use:Li,useCallback:xm,useContext:Xt,useEffect:tu,useImperativeHandle:hm,useInsertionEffect:fm,useLayoutEffect:pm,useMemo:gm,useReducer:Zc,useRef:cm,useState:function(){return Zc(ba)},useDebugValue:nu,useDeferredValue:function(e,n){var l=zt();return ct===null?au(l,e,n):vm(l,ct.memoizedState,e,n)},useTransition:function(){var e=Zc(ba)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:qp,useId:Sm,useHostTransitionStatus:lu,useFormState:om,useActionState:om,useOptimistic:function(e,n){var l=zt();return ct!==null?Jp(l,ct,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Xc,useCacheRefresh:km};Tm.useEffectEvent=dm;function ou(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var cu={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$a(i);f.payload=n,l!=null&&(f.callback=l),n=Va(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$a(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Va(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Cn(),i=$a(l);i.tag=2,n!=null&&(i.callback=n),n=Va(e,i,l),n!==null&&(vn(n,e,l),ns(n,e,l))}};function Rm(e,n,l,i,f,x,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,x,j):n.prototype&&n.prototype.isPureReactComponent?!Yl(l,i)||!Yl(f,x):!0}function Am(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&cu.enqueueReplaceState(n,n.state,null)}function Mr(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Mm(e){mi(e)}function Lm(e){console.error(e)}function zm(e){mi(e)}function Bi(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function Dm(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function uu(e,n,l){return l=$a(l),l.tag=3,l.payload={element:null},l.callback=function(){Bi(e,n)},l}function _m(e){return e=$a(e),e.tag=3,e}function Om(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var x=i.value;e.payload=function(){return f(x)},e.callback=function(){Dm(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){Dm(n,l,i),typeof f!="function"&&(Ya===null?Ya=new Set([this]):Ya.add(this));var T=i.stack;this.componentDidCatch(i.value,{componentStack:T!==null?T:""})})}function Jb(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&sl(n,l,f,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Hn===null?Ki():l.alternate===null&&At===0&&(At=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===wi?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),_u(e,i,f)),!1;case 22:return l.flags|=65536,i===wi?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),_u(e,i,f)),!1}throw Error(o(435,l.tag))}return _u(e,i,f),Ki(),!1}if(Ke)return n=jn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Rc&&(e=Error(o(422),{cause:i}),Ql(_n(e,l)))):(i!==Rc&&(n=Error(o(423),{cause:i}),Ql(_n(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=_n(i,l),f=uu(e.stateNode,i,f),Uc(e,f),At!==4&&(At=2)),!1;var x=Error(o(520),{cause:i});if(x=_n(x,l),xs===null?xs=[x]:xs.push(x),At!==4&&(At=2),n===null)return!0;i=_n(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=uu(l.stateNode,i,e),Uc(l,e),!1;case 1:if(n=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Ya===null||!Ya.has(x))))return l.flags|=65536,f&=-f,l.lanes|=f,f=_m(f),Om(f,e,l,i),Uc(l,f),!1}l=l.return}while(l!==null);return!1}var du=Error(o(461)),Bt=!1;function Qt(e,n,l,i){n.child=e===null?Up(n,null,l,i):Rr(n,e.child,l,i)}function Bm(e,n,l,i,f){l=l.render;var x=n.ref;if("ref"in i){var j={};for(var T in i)T!=="ref"&&(j[T]=i[T])}else j=i;return Cr(n),i=Wc(e,n,l,j,x,f),T=qc(),e!==null&&!Bt?(Yc(e,n,f),ja(e,n,f)):(Ke&&T&&Nc(n),n.flags|=1,Qt(e,n,i,f),n.child)}function Im(e,n,l,i,f){if(e===null){var x=l.type;return typeof x=="function"&&!wc(x)&&x.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=x,Hm(e,n,x,i,f)):(e=vi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(x=e.child,!yu(e,f)){var j=x.memoizedProps;if(l=l.compare,l=l!==null?l:Yl,l(j,i)&&e.ref===n.ref)return ja(e,n,f)}return n.flags|=1,e=ha(x,i),e.ref=n.ref,e.return=n,n.child=e}function Hm(e,n,l,i,f){if(e!==null){var x=e.memoizedProps;if(Yl(x,i)&&e.ref===n.ref)if(Bt=!1,n.pendingProps=i=x,yu(e,f))(e.flags&131072)!==0&&(Bt=!0);else return n.lanes=e.lanes,ja(e,n,f)}return fu(e,n,l,i,f)}function Um(e,n,l,i){var f=i.children,x=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(x=x!==null?x.baseLanes|l:l,e!==null){for(i=n.child=e.child,f=0;i!==null;)f=f|i.lanes|i.childLanes,i=i.sibling;i=f&~x}else i=0,n.child=null;return $m(e,n,x,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Si(n,x!==null?x.cachePool:null),x!==null?Pp(n,x):Vc(),Fp(n);else return i=n.lanes=536870912,$m(e,n,x!==null?x.baseLanes|l:l,l,i)}else x!==null?(Si(n,x.cachePool),Pp(n,x),Fa(),n.memoizedState=null):(e!==null&&Si(n,null),Vc(),Fa());return Qt(e,n,f,l),n.child}function cs(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function $m(e,n,l,i,f){var x=Oc();return x=x===null?null:{parent:_t._currentValue,pool:x},n.memoizedState={baseLanes:l,cachePool:x},e!==null&&Si(n,null),Vc(),Fp(n),e!==null&&sl(e,n,i,!0),n.childLanes=f,null}function Ii(e,n){return n=Ui({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Vm(e,n,l){return Rr(n,e.child,null,l),e=Ii(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function e1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ke){if(i.mode==="hidden")return e=Ii(n,i),n.lanes=536870912,cs(null,e);if(Fc(n),(e=vt)?(e=ex(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Oa!==null?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},l=Cp(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ia(n);return n.lanes=536870912,null}return Ii(n,i)}var x=e.memoizedState;if(x!==null){var j=x.dehydrated;if(Fc(n),f)if(n.flags&256)n.flags&=-257,n=Vm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(Bt||sl(e,n,l,!1),f=(l&e.childLanes)!==0,Bt||f){if(i=mt,i!==null&&(j=mr(i,l),j!==0&&j!==x.retryLane))throw x.retryLane=j,jr(e,j),vn(i,e,j),du;Ki(),n=Vm(e,n,l)}else e=x.treeContext,vt=Un(j.nextSibling),Kt=n,Ke=!0,Ba=null,In=!1,e!==null&&Tp(n,e),n=Ii(n,i),n.flags|=4096;return n}return e=ha(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Hi(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function fu(e,n,l,i,f){return Cr(n),l=Wc(e,n,l,i,void 0,f),i=qc(),e!==null&&!Bt?(Yc(e,n,f),ja(e,n,f)):(Ke&&i&&Nc(n),n.flags|=1,Qt(e,n,l,f),n.child)}function Pm(e,n,l,i,f,x){return Cr(n),n.updateQueue=null,l=Wp(n,i,l,f),Gp(e),i=qc(),e!==null&&!Bt?(Yc(e,n,x),ja(e,n,x)):(Ke&&i&&Nc(n),n.flags|=1,Qt(e,n,l,x),n.child)}function Fm(e,n,l,i,f){if(Cr(n),n.stateNode===null){var x=nl,j=l.contextType;typeof j=="object"&&j!==null&&(x=Xt(j)),x=new l(i,x),n.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=cu,n.stateNode=x,x._reactInternals=n,x=n.stateNode,x.props=i,x.state=n.memoizedState,x.refs={},Ic(n),j=l.contextType,x.context=typeof j=="object"&&j!==null?Xt(j):nl,x.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(ou(n,l,j,i),x.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(j=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),j!==x.state&&cu.enqueueReplaceState(x,x.state,null),rs(n,i,x,f),as(),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){x=n.stateNode;var T=n.memoizedProps,P=Mr(l,T);x.props=P;var Z=x.context,le=l.contextType;j=nl,typeof le=="object"&&le!==null&&(j=Xt(le));var ue=l.getDerivedStateFromProps;le=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function",T=n.pendingProps!==T,le||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T||Z!==j)&&Am(n,x,i,j),Ua=!1;var ee=n.memoizedState;x.state=ee,rs(n,i,x,f),as(),Z=n.memoizedState,T||ee!==Z||Ua?(typeof ue=="function"&&(ou(n,l,ue,i),Z=n.memoizedState),(P=Ua||Rm(n,l,P,i,ee,Z,j))?(le||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),x.props=i,x.state=Z,x.context=j,i=P):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{x=n.stateNode,Hc(e,n),j=n.memoizedProps,le=Mr(l,j),x.props=le,ue=n.pendingProps,ee=x.context,Z=l.contextType,P=nl,typeof Z=="object"&&Z!==null&&(P=Xt(Z)),T=l.getDerivedStateFromProps,(Z=typeof T=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(j!==ue||ee!==P)&&Am(n,x,i,P),Ua=!1,ee=n.memoizedState,x.state=ee,rs(n,i,x,f),as();var ae=n.memoizedState;j!==ue||ee!==ae||Ua||e!==null&&e.dependencies!==null&&bi(e.dependencies)?(typeof T=="function"&&(ou(n,l,T,i),ae=n.memoizedState),(le=Ua||Rm(n,l,le,i,ee,ae,P)||e!==null&&e.dependencies!==null&&bi(e.dependencies))?(Z||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,ae,P),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,ae,P)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=ae),x.props=i,x.state=ae,x.context=P,i=le):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return x=i,Hi(e,n),i=(n.flags&128)!==0,x||i?(x=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:x.render(),n.flags|=1,e!==null&&i?(n.child=Rr(n,e.child,null,f),n.child=Rr(n,null,l,f)):Qt(e,n,l,f),n.memoizedState=x.state,e=n.child):e=ja(e,n,f),e}function Gm(e,n,l,i){return kr(),n.flags|=256,Qt(e,n,l,i),n.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mu(e){return{baseLanes:e,cachePool:Dp()}}function hu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=wn),e}function Wm(e,n,l){var i=n.pendingProps,f=!1,x=(n.flags&128)!==0,j;if((j=x)||(j=e!==null&&e.memoizedState===null?!1:(Lt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ke){if(f?Pa(n):Fa(),(e=vt)?(e=ex(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Oa!==null?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},l=Cp(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ia(n);return Qu(e)?n.lanes=32:n.lanes=536870912,null}var T=i.children;return i=i.fallback,f?(Fa(),f=n.mode,T=Ui({mode:"hidden",children:T},f),i=Sr(i,f,l,null),T.return=n,i.return=n,T.sibling=i,n.child=T,i=n.child,i.memoizedState=mu(l),i.childLanes=hu(e,j,l),n.memoizedState=pu,cs(null,i)):(Pa(n),xu(n,T))}var P=e.memoizedState;if(P!==null&&(T=P.dehydrated,T!==null)){if(x)n.flags&256?(Pa(n),n.flags&=-257,n=gu(e,n,l)):n.memoizedState!==null?(Fa(),n.child=e.child,n.flags|=128,n=null):(Fa(),T=i.fallback,f=n.mode,i=Ui({mode:"visible",children:i.children},f),T=Sr(T,f,l,null),T.flags|=2,i.return=n,T.return=n,i.sibling=T,n.child=i,Rr(n,e.child,null,l),i=n.child,i.memoizedState=mu(l),i.childLanes=hu(e,j,l),n.memoizedState=pu,n=cs(null,i));else if(Pa(n),Qu(T)){if(j=T.nextSibling&&T.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Ql({value:i,source:null,stack:null}),n=gu(e,n,l)}else if(Bt||sl(e,n,l,!1),j=(l&e.childLanes)!==0,Bt||j){if(j=mt,j!==null&&(i=mr(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,jr(e,i),vn(j,e,i),du;Xu(T)||Ki(),n=gu(e,n,l)}else Xu(T)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,vt=Un(T.nextSibling),Kt=n,Ke=!0,Ba=null,In=!1,e!==null&&Tp(n,e),n=xu(n,i.children),n.flags|=4096);return n}return f?(Fa(),T=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=ha(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?T=ha(Z,T):(T=Sr(T,f,l,null),T.flags|=2),T.return=n,i.return=n,i.sibling=T,n.child=i,cs(null,i),i=n.child,T=e.child.memoizedState,T===null?T=mu(l):(f=T.cachePool,f!==null?(P=_t._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=Dp(),T={baseLanes:T.baseLanes|l,cachePool:f}),i.memoizedState=T,i.childLanes=hu(e,j,l),n.memoizedState=pu,cs(e.child,i)):(Pa(n),l=e.child,e=l.sibling,l=ha(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(j=n.deletions,j===null?(n.deletions=[e],n.flags|=16):j.push(e)),n.child=l,n.memoizedState=null,l)}function xu(e,n){return n=Ui({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Ui(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function gu(e,n,l){return Rr(n,e.child,null,l),e=xu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function qm(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),Lc(e.return,n,l)}function vu(e,n,l,i,f,x){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:x}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=x)}function Ym(e,n,l){var i=n.pendingProps,f=i.revealOrder,x=i.tail;i=i.children;var j=Lt.current,T=(j&2)!==0;if(T?(j=j&1|2,n.flags|=128):j&=1,W(Lt,j),Qt(e,n,i,l),i=Ke?Xl:0,!T&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&qm(e,l,n);else if(e.tag===19)qm(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&Ti(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),vu(n,!1,f,l,x,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ti(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}vu(n,!0,l,null,x,i);break;case"together":vu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function ja(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),qa|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(sl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=ha(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=ha(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function yu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&bi(e)))}function t1(e,n,l){switch(n.tag){case 3:de(n,n.stateNode.containerInfo),Ha(n,_t,e.memoizedState.cache),kr();break;case 27:case 5:Ae(n);break;case 4:de(n,n.stateNode.containerInfo);break;case 10:Ha(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Fc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Pa(n),n.flags|=128,null):(l&n.child.childLanes)!==0?Wm(e,n,l):(Pa(n),e=ja(e,n,l),e!==null?e.sibling:null);Pa(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(sl(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Ym(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),W(Lt,Lt.current),i)break;return null;case 22:return n.lanes=0,Um(e,n,l,n.pendingProps);case 24:Ha(n,_t,e.memoizedState.cache)}return ja(e,n,l)}function Km(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Bt=!0;else{if(!yu(e,l)&&(n.flags&128)===0)return Bt=!1,t1(e,n,l);Bt=(e.flags&131072)!==0}else Bt=!1,Ke&&(n.flags&1048576)!==0&&Np(n,Xl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Nr(n.elementType),n.type=e,typeof e=="function")wc(e)?(i=Mr(e,i),n.tag=1,n=Fm(null,n,e,i,l)):(n.tag=0,n=fu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===B){n.tag=11,n=Bm(null,n,e,i,l);break e}else if(f===E){n.tag=14,n=Im(null,n,e,i,l);break e}}throw n=J(e)||e,Error(o(306,n,""))}}return n;case 0:return fu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Mr(i,n.pendingProps),Fm(e,n,i,f,l);case 3:e:{if(de(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var x=n.memoizedState;f=x.element,Hc(e,n),rs(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Ha(n,_t,i),i!==x.cache&&zc(n,[_t],l,!0),as(),i=j.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=x,n.memoizedState=x,n.flags&256){n=Gm(e,n,i,l);break e}else if(i!==f){f=_n(Error(o(424)),n),Ql(f),n=Gm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(vt=Un(e.firstChild),Kt=n,Ke=!0,Ba=null,In=!0,l=Up(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(kr(),i===f){n=ja(e,n,l);break e}Qt(e,n,i,l)}n=n.child}return n;case 26:return Hi(e,n),e===null?(l=sx(n.type,null,n.pendingProps,null))?n.memoizedState=l:Ke||(l=n.type,e=n.pendingProps,i=no(ie.current).createElement(l),i[Ut]=n,i[ot]=e,Zt(i,l,e),Wt(i),n.stateNode=i):n.memoizedState=sx(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Ae(n),e===null&&Ke&&(i=n.stateNode=ax(n.type,n.pendingProps,ie.current),Kt=n,In=!0,f=vt,Za(n.type)?(Zu=f,vt=Un(i.firstChild)):vt=f),Qt(e,n,n.pendingProps.children,l),Hi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ke&&((f=i=vt)&&(i=M1(i,n.type,n.pendingProps,In),i!==null?(n.stateNode=i,Kt=n,vt=Un(i.firstChild),In=!1,f=!0):f=!1),f||Ia(n)),Ae(n),f=n.type,x=n.pendingProps,j=e!==null?e.memoizedProps:null,i=x.children,qu(f,x)?i=null:j!==null&&qu(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=Wc(e,n,Wb,null,null,l),ws._currentValue=f),Hi(e,n),Qt(e,n,i,l),n.child;case 6:return e===null&&Ke&&((e=l=vt)&&(l=L1(l,n.pendingProps,In),l!==null?(n.stateNode=l,Kt=n,vt=null,e=!0):e=!1),e||Ia(n)),null;case 13:return Wm(e,n,l);case 4:return de(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=Rr(n,null,i,l):Qt(e,n,i,l),n.child;case 11:return Bm(e,n,n.type,n.pendingProps,l);case 7:return Qt(e,n,n.pendingProps,l),n.child;case 8:return Qt(e,n,n.pendingProps.children,l),n.child;case 12:return Qt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ha(n,n.type,i.value),Qt(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Cr(n),f=Xt(f),i=i(f),n.flags|=1,Qt(e,n,i,l),n.child;case 14:return Im(e,n,n.type,n.pendingProps,l);case 15:return Hm(e,n,n.type,n.pendingProps,l);case 19:return Ym(e,n,l);case 31:return e1(e,n,l);case 22:return Um(e,n,l,n.pendingProps);case 24:return Cr(n),i=Xt(_t),e===null?(f=Oc(),f===null&&(f=mt,x=Dc(),f.pooledCache=x,x.refCount++,x!==null&&(f.pooledCacheLanes|=l),f=x),n.memoizedState={parent:i,cache:f},Ic(n),Ha(n,_t,f)):((e.lanes&l)!==0&&(Hc(e,n),rs(n,null,null,l),as()),f=e.memoizedState,x=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ha(n,_t,i)):(i=x.cache,Ha(n,_t,i),i!==f.cache&&zc(n,[_t],l,!0))),Qt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Sa(e){e.flags|=4}function bu(e,n,l,i,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Sh())e.flags|=8192;else throw Tr=wi,Bc}else e.flags&=-16777217}function Xm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!dx(n))if(Sh())e.flags|=8192;else throw Tr=wi,Bc}function $i(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?qn():536870912,e.lanes|=n,vl|=n)}function us(e,n){if(!Ke)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags&65011712,i|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags,i|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function n1(e,n,l){var i=n.pendingProps;switch(Tc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return yt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),va(_t),Se(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(ll(n)?Sa(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Ac())),yt(n),null;case 26:var f=n.type,x=n.memoizedState;return e===null?(Sa(n),x!==null?(yt(n),Xm(n,x)):(yt(n),bu(n,f,null,i,l))):x?x!==e.memoizedState?(Sa(n),yt(n),Xm(n,x)):(yt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Sa(n),yt(n),bu(n,f,e,i,l)),null;case 27:if(_e(n),l=ie.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}e=te.current,ll(n)?Rp(n):(e=ax(f,i,l),n.stateNode=e,Sa(n))}return yt(n),null;case 5:if(_e(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}if(x=te.current,ll(n))Rp(n);else{var j=no(ie.current);switch(x){case 1:x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":x=j.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}x[Ut]=n,x[ot]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===n)break e;for(;j.sibling===null;){if(j.return===null||j.return===n)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}n.stateNode=x;e:switch(Zt(x,f,i),f){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Sa(n)}}return yt(n),bu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=ie.current,ll(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Kt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[Ut]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Wh(e.nodeValue,l)),e||Ia(n,!0)}else e=no(e).createTextNode(i),e[Ut]=n,n.stateNode=e}return yt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=ll(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Ut]=n}else kr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),e=!1}else l=Ac(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return yt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=ll(n),i!==null&&i.dehydrated!==null){if(e===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[Ut]=n}else kr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),f=!1}else f=Ac(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,f=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(f=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),$i(n,n.updateQueue),yt(n),null);case 4:return Se(),e===null&&Vu(n.stateNode.containerInfo),yt(n),null;case 10:return va(n.type),yt(n),null;case 19:if(Y(Lt),i=n.memoizedState,i===null)return yt(n),null;if(f=(n.flags&128)!==0,x=i.rendering,x===null)if(f)us(i,!1);else{if(At!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=Ti(e),x!==null){for(n.flags|=128,us(i,!1),e=x.updateQueue,n.updateQueue=e,$i(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)wp(l,e),l=l.sibling;return W(Lt,Lt.current&1|2),Ke&&xa(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Qe()>Wi&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ti(x),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,$i(n,e),us(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Ke)return yt(n),null}else 2*Qe()-i.renderingStartTime>Wi&&l!==536870912&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304);i.isBackwards?(x.sibling=n.child,n.child=x):(e=i.last,e!==null?e.sibling=x:n.child=x,i.last=x)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Qe(),e.sibling=null,l=Lt.current,W(Lt,f?l&1|2:l&1),Ke&&xa(n,i.treeForkCount),e):(yt(n),null);case 22:case 23:return Sn(n),Pc(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),l=n.updateQueue,l!==null&&$i(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&Y(Er),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),va(_t),yt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function a1(e,n){switch(Tc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return va(_t),Se(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(o(340));kr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));kr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Y(Lt),null;case 4:return Se(),null;case 10:return va(n.type),null;case 22:case 23:return Sn(n),Pc(),e!==null&&Y(Er),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return va(_t),null;case 25:return null;default:return null}}function Qm(e,n){switch(Tc(n),n.tag){case 3:va(_t),Se();break;case 26:case 27:case 5:_e(n);break;case 4:Se();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:Y(Lt);break;case 10:va(n.type);break;case 22:case 23:Sn(n),Pc(),e!==null&&Y(Er);break;case 24:va(_t)}}function ds(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var f=i.next;l=f;do{if((l.tag&e)===e){i=void 0;var x=l.create,j=l.inst;i=x(),j.destroy=i}l=l.next}while(l!==f)}}catch(T){st(n,n.return,T)}}function Ga(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var x=f.next;i=x;do{if((i.tag&e)===e){var j=i.inst,T=j.destroy;if(T!==void 0){j.destroy=void 0,f=n;var P=l,Z=T;try{Z()}catch(le){st(f,P,le)}}}i=i.next}while(i!==x)}}catch(le){st(n,n.return,le)}}function Zm(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Vp(n,l)}catch(i){st(e,e.return,i)}}}function Jm(e,n,l){l.props=Mr(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){st(e,n,i)}}function fs(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(f){st(e,n,f)}}function la(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){st(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){st(e,n,f)}else l.current=null}function eh(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(f){st(e,e.return,f)}}function ju(e,n,l){try{var i=e.stateNode;C1(i,e.type,l,n),i[ot]=n}catch(f){st(e,e.return,f)}}function th(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Za(e.type)||e.tag===4}function Su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||th(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&&Za(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ku(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=pa));else if(i!==4&&(i===27&&Za(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(ku(e,n,l),e=e.sibling;e!==null;)ku(e,n,l),e=e.sibling}function Vi(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Za(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Vi(e,n,l),e=e.sibling;e!==null;)Vi(e,n,l),e=e.sibling}function nh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);Zt(n,i,l),n[Ut]=e,n[ot]=l}catch(x){st(e,e.return,x)}}var ka=!1,It=!1,wu=!1,ah=typeof WeakSet=="function"?WeakSet:Set,qt=null;function r1(e,n){if(e=e.containerInfo,Gu=co,e=hp(e),gc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var f=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var j=0,T=-1,P=-1,Z=0,le=0,ue=e,ee=null;t:for(;;){for(var ae;ue!==l||f!==0&&ue.nodeType!==3||(T=j+f),ue!==x||i!==0&&ue.nodeType!==3||(P=j+i),ue.nodeType===3&&(j+=ue.nodeValue.length),(ae=ue.firstChild)!==null;)ee=ue,ue=ae;for(;;){if(ue===e)break t;if(ee===l&&++Z===f&&(T=j),ee===x&&++le===i&&(P=j),(ae=ue.nextSibling)!==null)break;ue=ee,ee=ue.parentNode}ue=ae}l=T===-1||P===-1?null:{start:T,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(Wu={focusedElem:e,selectionRange:l},co=!1,qt=n;qt!==null;)if(n=qt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,qt=e;else for(;qt!==null;){switch(n=qt,x=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&x!==null){e=void 0,l=n,f=x.memoizedProps,x=x.memoizedState,i=l.stateNode;try{var we=Mr(l.type,f);e=i.getSnapshotBeforeUpdate(we,x),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){st(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Ku(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ku(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,qt=e;break}qt=n.return}}function rh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Ca(e,l),i&4&&ds(5,l);break;case 1:if(Ca(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){st(l,l.return,j)}else{var f=Mr(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){st(l,l.return,j)}}i&64&&Zm(l),i&512&&fs(l,l.return);break;case 3:if(Ca(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Vp(e,n)}catch(j){st(l,l.return,j)}}break;case 27:n===null&&i&4&&nh(l);case 26:case 5:Ca(e,l),n===null&&i&4&&eh(l),i&512&&fs(l,l.return);break;case 12:Ca(e,l);break;case 31:Ca(e,l),i&4&&ih(e,l);break;case 13:Ca(e,l),i&4&&oh(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=p1.bind(null,l),z1(e,l))));break;case 22:if(i=l.memoizedState!==null||ka,!i){n=n!==null&&n.memoizedState!==null||It,f=ka;var x=It;ka=i,(It=n)&&!x?Ea(e,l,(l.subtreeFlags&8772)!==0):Ca(e,l),ka=f,It=x}break;case 30:break;default:Ca(e,l)}}function lh(e){var n=e.alternate;n!==null&&(e.alternate=null,lh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&ec(n)),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 St=null,mn=!1;function wa(e,n,l){for(l=l.child;l!==null;)sh(e,n,l),l=l.sibling}function sh(e,n,l){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Mn,l)}catch{}switch(l.tag){case 26:It||la(l,n),wa(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:It||la(l,n);var i=St,f=mn;Za(l.type)&&(St=l.stateNode,mn=!1),wa(e,n,l),js(l.stateNode),St=i,mn=f;break;case 5:It||la(l,n);case 6:if(i=St,f=mn,St=null,wa(e,n,l),St=i,mn=f,St!==null)if(mn)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(l.stateNode)}catch(x){st(l,n,x)}else try{St.removeChild(l.stateNode)}catch(x){st(l,n,x)}break;case 18:St!==null&&(mn?(e=St,Zh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),El(e)):Zh(St,l.stateNode));break;case 4:i=St,f=mn,St=l.stateNode.containerInfo,mn=!0,wa(e,n,l),St=i,mn=f;break;case 0:case 11:case 14:case 15:Ga(2,l,n),It||Ga(4,l,n),wa(e,n,l);break;case 1:It||(la(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&Jm(l,n,i)),wa(e,n,l);break;case 21:wa(e,n,l);break;case 22:It=(i=It)||l.memoizedState!==null,wa(e,n,l),It=i;break;default:wa(e,n,l)}}function ih(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{El(e)}catch(l){st(n,n.return,l)}}}function oh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{El(e)}catch(l){st(n,n.return,l)}}function l1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ah),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ah),n;default:throw Error(o(435,e.tag))}}function Pi(e,n){var l=l1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=m1.bind(null,e,i);i.then(f,f)}})}function hn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],x=e,j=n,T=j;e:for(;T!==null;){switch(T.tag){case 27:if(Za(T.type)){St=T.stateNode,mn=!1;break e}break;case 5:St=T.stateNode,mn=!1;break e;case 3:case 4:St=T.stateNode.containerInfo,mn=!0;break e}T=T.return}if(St===null)throw Error(o(160));sh(x,j,f),St=null,mn=!1,x=f.alternate,x!==null&&(x.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)ch(n,e),n=n.sibling}var Kn=null;function ch(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),xn(e),i&4&&(Ga(3,e,e.return),ds(3,e),Ga(5,e,e.return));break;case 1:hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),i&64&&ka&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var f=Kn;if(hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),i&4){var x=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(i){case"title":x=f.getElementsByTagName("title")[0],(!x||x[Hl]||x[Ut]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=f.createElement(i),f.head.insertBefore(x,f.querySelector("head > title"))),Zt(x,i,l),x[Ut]=e,Wt(x),i=x;break e;case"link":var j=cx("link","href",f).get(i+(l.href||""));if(j){for(var T=0;T<j.length;T++)if(x=j[T],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(T,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;case"meta":if(j=cx("meta","content",f).get(i+(l.content||""))){for(T=0;T<j.length;T++)if(x=j[T],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(T,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;default:throw Error(o(468,i))}x[Ut]=e,Wt(x),i=x}e.stateNode=i}else ux(f,e.type,e.stateNode);else e.stateNode=ox(f,i,e.memoizedProps);else x!==i?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,i===null?ux(f,e.type,e.stateNode):ox(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&ju(e,e.memoizedProps,l.memoizedProps)}break;case 27:hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),l!==null&&i&4&&ju(e,e.memoizedProps,l.memoizedProps);break;case 5:if(hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),e.flags&32){f=e.stateNode;try{Kr(f,"")}catch(we){st(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,ju(e,f,l!==null?l.memoizedProps:f)),i&1024&&(wu=!0);break;case 6:if(hn(n,e),xn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){st(e,e.return,we)}}break;case 3:if(lo=null,f=Kn,Kn=ao(n.containerInfo),hn(n,e),Kn=f,xn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{El(n.containerInfo)}catch(we){st(e,e.return,we)}wu&&(wu=!1,uh(e));break;case 4:i=Kn,Kn=ao(e.stateNode.containerInfo),hn(n,e),xn(e),Kn=i;break;case 12:hn(n,e),xn(e);break;case 31:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 13:hn(n,e),xn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Gi=Qe()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=ka,le=It;if(ka=Z||f,It=le||P,hn(n,e),It=le,ka=Z,xn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||ka||It||Lr(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(x=P.stateNode,f)j=x.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{T=P.stateNode;var ue=P.memoizedProps.style,ee=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;T.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(we){st(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){st(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var ae=P.stateNode;f?Jh(ae,!0):Jh(P.stateNode,!1)}catch(we){st(P,P.return,we)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Pi(e,l))));break;case 19:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 30:break;case 21:break;default:hn(n,e),xn(e)}}function xn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(th(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,x=Su(e);Vi(e,x,f);break;case 5:var j=l.stateNode;l.flags&32&&(Kr(j,""),l.flags&=-33);var T=Su(e);Vi(e,T,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=Su(e);ku(e,Z,P);break;default:throw Error(o(161))}}catch(le){st(e,e.return,le)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function uh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;uh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Ca(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)rh(e,n.alternate,n),n=n.sibling}function Lr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ga(4,n,n.return),Lr(n);break;case 1:la(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&Jm(n,n.return,l),Lr(n);break;case 27:js(n.stateNode);case 26:case 5:la(n,n.return),Lr(n);break;case 22:n.memoizedState===null&&Lr(n);break;case 30:Lr(n);break;default:Lr(n)}e=e.sibling}}function Ea(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,x=n,j=x.flags;switch(x.tag){case 0:case 11:case 15:Ea(f,x,l),ds(4,x);break;case 1:if(Ea(f,x,l),i=x,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){st(i,i.return,Z)}if(i=x,f=i.updateQueue,f!==null){var T=i.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)$p(P[f],T)}catch(Z){st(i,i.return,Z)}}l&&j&64&&Zm(x),fs(x,x.return);break;case 27:nh(x);case 26:case 5:Ea(f,x,l),l&&i===null&&j&4&&eh(x),fs(x,x.return);break;case 12:Ea(f,x,l);break;case 31:Ea(f,x,l),l&&j&4&&ih(f,x);break;case 13:Ea(f,x,l),l&&j&4&&oh(f,x);break;case 22:x.memoizedState===null&&Ea(f,x,l),fs(x,x.return);break;case 30:break;default:Ea(f,x,l)}n=n.sibling}}function Cu(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&Zl(l))}function Eu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e))}function Xn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)dh(e,n,l,i),n=n.sibling}function dh(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Xn(e,n,l,i),f&2048&&ds(9,n);break;case 1:Xn(e,n,l,i);break;case 3:Xn(e,n,l,i),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e)));break;case 12:if(f&2048){Xn(e,n,l,i),e=n.stateNode;try{var x=n.memoizedProps,j=x.id,T=x.onPostCommit;typeof T=="function"&&T(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){st(n,n.return,P)}}else Xn(e,n,l,i);break;case 31:Xn(e,n,l,i);break;case 13:Xn(e,n,l,i);break;case 23:break;case 22:x=n.stateNode,j=n.alternate,n.memoizedState!==null?x._visibility&2?Xn(e,n,l,i):ps(e,n):x._visibility&2?Xn(e,n,l,i):(x._visibility|=2,hl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Cu(j,n);break;case 24:Xn(e,n,l,i),f&2048&&Eu(n.alternate,n);break;default:Xn(e,n,l,i)}}function hl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var x=e,j=n,T=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:hl(x,j,T,P,f),ds(8,j);break;case 23:break;case 22:var le=j.stateNode;j.memoizedState!==null?le._visibility&2?hl(x,j,T,P,f):ps(x,j):(le._visibility|=2,hl(x,j,T,P,f)),f&&Z&2048&&Cu(j.alternate,j);break;case 24:hl(x,j,T,P,f),f&&Z&2048&&Eu(j.alternate,j);break;default:hl(x,j,T,P,f)}n=n.sibling}}function ps(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,f=i.flags;switch(i.tag){case 22:ps(l,i),f&2048&&Cu(i.alternate,i);break;case 24:ps(l,i),f&2048&&Eu(i.alternate,i);break;default:ps(l,i)}n=n.sibling}}var ms=8192;function xl(e,n,l){if(e.subtreeFlags&ms)for(e=e.child;e!==null;)fh(e,n,l),e=e.sibling}function fh(e,n,l){switch(e.tag){case 26:xl(e,n,l),e.flags&ms&&e.memoizedState!==null&&G1(l,Kn,e.memoizedState,e.memoizedProps);break;case 5:xl(e,n,l);break;case 3:case 4:var i=Kn;Kn=ao(e.stateNode.containerInfo),xl(e,n,l),Kn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=ms,ms=16777216,xl(e,n,l),ms=i):xl(e,n,l));break;default:xl(e,n,l)}}function ph(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function hs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,hh(i,e)}ph(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)mh(e),e=e.sibling}function mh(e){switch(e.tag){case 0:case 11:case 15:hs(e),e.flags&2048&&Ga(9,e,e.return);break;case 3:hs(e);break;case 12:hs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Fi(e)):hs(e);break;default:hs(e)}}function Fi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,hh(i,e)}ph(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ga(8,n,n.return),Fi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Fi(n));break;default:Fi(n)}e=e.sibling}}function hh(e,n){for(;qt!==null;){var l=qt;switch(l.tag){case 0:case 11:case 15:Ga(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Zl(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,qt=i;else e:for(l=e;qt!==null;){i=qt;var f=i.sibling,x=i.return;if(lh(i),i===l){qt=null;break e}if(f!==null){f.return=x,qt=f;break e}qt=x}}}var s1={getCacheForType:function(e){var n=Xt(_t),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Xt(_t).controller.signal}},i1=typeof WeakMap=="function"?WeakMap:Map,nt=0,mt=null,Ge=null,qe=0,lt=0,kn=null,Wa=!1,gl=!1,Nu=!1,Na=0,At=0,qa=0,zr=0,Tu=0,wn=0,vl=0,xs=null,gn=null,Ru=!1,Gi=0,xh=0,Wi=1/0,qi=null,Ya=null,$t=0,Ka=null,yl=null,Ta=0,Au=0,Mu=null,gh=null,gs=0,Lu=null;function Cn(){return(nt&2)!==0&&qe!==0?qe&-qe:M.T!==null?Iu():it()}function vh(){if(wn===0)if((qe&536870912)===0||Ke){var e=ce;ce<<=1,(ce&3932160)===0&&(ce=262144),wn=e}else wn=536870912;return e=jn.current,e!==null&&(e.flags|=32),wn}function vn(e,n,l){(e===mt&&(lt===2||lt===9)||e.cancelPendingCommit!==null)&&(bl(e,0),Xa(e,qe,wn,!1)),fr(e,l),((nt&2)===0||e!==mt)&&(e===mt&&((nt&2)===0&&(zr|=l),At===4&&Xa(e,qe,wn,!1)),sa(e))}function yh(e,n,l){if((nt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||fn(e,n),f=i?u1(e,n):Du(e,n,!0),x=i;do{if(f===0){gl&&!i&&Xa(e,n,0,!1);break}else{if(l=e.current.alternate,x&&!o1(l)){f=Du(e,n,!1),x=!1;continue}if(f===2){if(x=n,e.errorRecoveryDisabledLanes&x)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var T=e;f=xs;var P=T.current.memoizedState.isDehydrated;if(P&&(bl(T,j).flags|=256),j=Du(T,j,!1),j!==2){if(Nu&&!P){T.errorRecoveryDisabledLanes|=x,zr|=x,f=4;break e}x=gn,gn=f,x!==null&&(gn===null?gn=x:gn.push.apply(gn,x))}f=j}if(x=!1,f!==2)continue}}if(f===1){bl(e,0),Xa(e,n,0,!0);break}e:{switch(i=e,x=f,x){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Xa(i,n,wn,!Wa);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Gi+300-Qe(),10<f)){if(Xa(i,n,wn,!Wa),dn(i,0,!0)!==0)break e;Ta=n,i.timeoutHandle=Xh(bh.bind(null,i,l,gn,qi,Ru,n,wn,zr,vl,Wa,x,"Throttled",-0,0),f);break e}bh(i,l,gn,qi,Ru,n,wn,zr,vl,Wa,x,null,-0,0)}}break}while(!0);sa(e)}function bh(e,n,l,i,f,x,j,T,P,Z,le,ue,ee,ae){if(e.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pa},fh(n,x,ue);var we=(x&62914560)===x?Gi-Qe():(x&4194048)===x?xh-Qe():0;if(we=W1(ue,we),we!==null){Ta=x,e.cancelPendingCommit=we(Th.bind(null,e,n,x,l,i,f,j,T,P,le,ue,null,ee,ae)),Xa(e,x,j,!Z);return}}Th(e,n,x,l,i,f,j,T,P)}function o1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var f=l[i],x=f.getSnapshot;f=f.value;try{if(!yn(x(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Xa(e,n,l,i){n&=~Tu,n&=~zr,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var x=31-gt(f),j=1<<x;i[x]=-1,f&=~j}l!==0&&ta(e,l,n)}function Yi(){return(nt&6)===0?(vs(0),!1):!0}function zu(){if(Ge!==null){if(lt===0)var e=Ge.return;else e=Ge,ga=wr=null,Kc(e),ul=null,es=0,e=Ge;for(;e!==null;)Qm(e.alternate,e),e=e.return;Ge=null}}function bl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,T1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Ta=0,zu(),mt=e,Ge=l=ha(e.current,null),qe=n,lt=0,kn=null,Wa=!1,gl=fn(e,n),Nu=!1,vl=wn=Tu=zr=qa=At=0,gn=xs=null,Ru=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var f=31-gt(i),x=1<<f;n|=e[f],i&=~x}return Na=n,hi(),l}function jh(e,n){Ue=null,M.H=os,n===cl||n===ki?(n=Bp(),lt=3):n===Bc?(n=Bp(),lt=4):lt=n===du?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,Ge===null&&(At=1,Bi(e,_n(n,e.current)))}function Sh(){var e=jn.current;return e===null?!0:(qe&4194048)===qe?Hn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===Hn:!1}function kh(){var e=M.H;return M.H=os,e===null?os:e}function wh(){var e=M.A;return M.A=s1,e}function Ki(){At=4,Wa||(qe&4194048)!==qe&&jn.current!==null||(gl=!0),(qa&134217727)===0&&(zr&134217727)===0||mt===null||Xa(mt,qe,wn,!1)}function Du(e,n,l){var i=nt;nt|=2;var f=kh(),x=wh();(mt!==e||qe!==n)&&(qi=null,bl(e,n)),n=!1;var j=At;e:do try{if(lt!==0&&Ge!==null){var T=Ge,P=kn;switch(lt){case 8:zu(),j=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(n=!0);var Z=lt;if(lt=0,kn=null,jl(e,T,P,Z),l&&gl){j=0;break e}break;default:Z=lt,lt=0,kn=null,jl(e,T,P,Z)}}c1(),j=At;break}catch(le){jh(e,le)}while(!0);return n&&e.shellSuspendCounter++,ga=wr=null,nt=i,M.H=f,M.A=x,Ge===null&&(mt=null,qe=0,hi()),j}function c1(){for(;Ge!==null;)Ch(Ge)}function u1(e,n){var l=nt;nt|=2;var i=kh(),f=wh();mt!==e||qe!==n?(qi=null,Wi=Qe()+500,bl(e,n)):gl=fn(e,n);e:do try{if(lt!==0&&Ge!==null){n=Ge;var x=kn;t:switch(lt){case 1:lt=0,kn=null,jl(e,n,x,1);break;case 2:case 9:if(_p(x)){lt=0,kn=null,Eh(n);break}n=function(){lt!==2&&lt!==9||mt!==e||(lt=7),sa(e)},x.then(n,n);break e;case 3:lt=7;break e;case 4:lt=5;break e;case 7:_p(x)?(lt=0,kn=null,Eh(n)):(lt=0,kn=null,jl(e,n,x,7));break;case 5:var j=null;switch(Ge.tag){case 26:j=Ge.memoizedState;case 5:case 27:var T=Ge;if(j?dx(j):T.stateNode.complete){lt=0,kn=null;var P=T.sibling;if(P!==null)Ge=P;else{var Z=T.return;Z!==null?(Ge=Z,Xi(Z)):Ge=null}break t}}lt=0,kn=null,jl(e,n,x,5);break;case 6:lt=0,kn=null,jl(e,n,x,6);break;case 8:zu(),At=6;break e;default:throw Error(o(462))}}d1();break}catch(le){jh(e,le)}while(!0);return ga=wr=null,M.H=i,M.A=f,nt=l,Ge!==null?0:(mt=null,qe=0,hi(),At)}function d1(){for(;Ge!==null&&!Dt();)Ch(Ge)}function Ch(e){var n=Km(e.alternate,e,Na);e.memoizedProps=e.pendingProps,n===null?Xi(e):Ge=n}function Eh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Pm(l,n,n.pendingProps,n.type,void 0,qe);break;case 11:n=Pm(l,n,n.pendingProps,n.type.render,n.ref,qe);break;case 5:Kc(n);default:Qm(l,n),n=Ge=wp(n,Na),n=Km(l,n,Na)}e.memoizedProps=e.pendingProps,n===null?Xi(e):Ge=n}function jl(e,n,l,i){ga=wr=null,Kc(n),ul=null,es=0;var f=n.return;try{if(Jb(e,f,n,l,qe)){At=1,Bi(e,_n(l,e.current)),Ge=null;return}}catch(x){if(f!==null)throw Ge=f,x;At=1,Bi(e,_n(l,e.current)),Ge=null;return}n.flags&32768?(Ke||i===1?e=!0:gl||(qe&536870912)!==0?e=!1:(Wa=e=!0,(i===2||i===9||i===3||i===6)&&(i=jn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Nh(n,e)):Xi(n)}function Xi(e){var n=e;do{if((n.flags&32768)!==0){Nh(n,Wa);return}e=n.return;var l=n1(n.alternate,n,Na);if(l!==null){Ge=l;return}if(n=n.sibling,n!==null){Ge=n;return}Ge=n=e}while(n!==null);At===0&&(At=5)}function Nh(e,n){do{var l=a1(e.alternate,e);if(l!==null){l.flags&=32767,Ge=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ge=e;return}Ge=e=l}while(e!==null);At=6,Ge=null}function Th(e,n,l,i,f,x,j,T,P){e.cancelPendingCommit=null;do Qi();while($t!==0);if((nt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(x=n.lanes|n.childLanes,x|=Sc,Il(e,l,x,j,T,P),e===mt&&(Ge=mt=null,qe=0),yl=n,Ka=e,Ta=l,Au=x,Mu=f,gh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,h1(Ct,function(){return zh(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=M.T,M.T=null,f=_.p,_.p=2,j=nt,nt|=4;try{r1(e,n,l)}finally{nt=j,_.p=f,M.T=i}}$t=1,Rh(),Ah(),Mh()}}function Rh(){if($t===1){$t=0;var e=Ka,n=yl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=M.T,M.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{ch(n,e);var x=Wu,j=hp(e.containerInfo),T=x.focusedElem,P=x.selectionRange;if(j!==T&&T&&T.ownerDocument&&mp(T.ownerDocument.documentElement,T)){if(P!==null&&gc(T)){var Z=P.start,le=P.end;if(le===void 0&&(le=Z),"selectionStart"in T)T.selectionStart=Z,T.selectionEnd=Math.min(le,T.value.length);else{var ue=T.ownerDocument||document,ee=ue&&ue.defaultView||window;if(ee.getSelection){var ae=ee.getSelection(),we=T.textContent.length,Le=Math.min(P.start,we),dt=P.end===void 0?Le:Math.min(P.end,we);!ae.extend&&Le>dt&&(j=dt,dt=Le,Le=j);var K=pp(T,Le),G=pp(T,dt);if(K&&G&&(ae.rangeCount!==1||ae.anchorNode!==K.node||ae.anchorOffset!==K.offset||ae.focusNode!==G.node||ae.focusOffset!==G.offset)){var Q=ue.createRange();Q.setStart(K.node,K.offset),ae.removeAllRanges(),Le>dt?(ae.addRange(Q),ae.extend(G.node,G.offset)):(Q.setEnd(G.node,G.offset),ae.addRange(Q))}}}}for(ue=[],ae=T;ae=ae.parentNode;)ae.nodeType===1&&ue.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<ue.length;T++){var oe=ue[T];oe.element.scrollLeft=oe.left,oe.element.scrollTop=oe.top}}co=!!Gu,Wu=Gu=null}finally{nt=f,_.p=i,M.T=l}}e.current=n,$t=2}}function Ah(){if($t===2){$t=0;var e=Ka,n=yl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=M.T,M.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{rh(e,n.alternate,n)}finally{nt=f,_.p=i,M.T=l}}$t=3}}function Mh(){if($t===4||$t===3){$t=0,Tt();var e=Ka,n=yl,l=Ta,i=gh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?$t=5:($t=0,yl=Ka=null,Lh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Ya=null),Da(l),n=n.stateNode,Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Mn,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=M.T,f=_.p,_.p=2,M.T=null;try{for(var x=e.onRecoverableError,j=0;j<i.length;j++){var T=i[j];x(T.value,{componentStack:T.stack})}}finally{M.T=n,_.p=f}}(Ta&3)!==0&&Qi(),sa(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Lu?gs++:(gs=0,Lu=e):gs=0,vs(0)}}function Lh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Zl(n)))}function Qi(){return Rh(),Ah(),Mh(),zh()}function zh(){if($t!==5)return!1;var e=Ka,n=Au;Au=0;var l=Da(Ta),i=M.T,f=_.p;try{_.p=32>l?32:l,M.T=null,l=Mu,Mu=null;var x=Ka,j=Ta;if($t=0,yl=Ka=null,Ta=0,(nt&6)!==0)throw Error(o(331));var T=nt;if(nt|=4,mh(x.current),dh(x,x.current,j,l),nt=T,vs(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Mn,x)}catch{}return!0}finally{_.p=f,M.T=i,Lh(e,n)}}function Dh(e,n,l){n=_n(l,n),n=uu(e.stateNode,n,2),e=Va(e,n,2),e!==null&&(fr(e,2),sa(e))}function st(e,n,l){if(e.tag===3)Dh(e,e,l);else for(;n!==null;){if(n.tag===3){Dh(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Ya===null||!Ya.has(i))){e=_n(l,e),l=_m(2),i=Va(n,l,2),i!==null&&(Om(l,i,n,e),fr(i,2),sa(i));break}}n=n.return}}function _u(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new i1;var f=new Set;i.set(n,f)}else f=i.get(n),f===void 0&&(f=new Set,i.set(n,f));f.has(l)||(Nu=!0,f.add(l),e=f1.bind(null,e,n,l),n.then(e,e))}function f1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,mt===e&&(qe&l)===l&&(At===4||At===3&&(qe&62914560)===qe&&300>Qe()-Gi?(nt&2)===0&&bl(e,0):Tu|=l,vl===qe&&(vl=0)),sa(e)}function _h(e,n){n===0&&(n=qn()),e=jr(e,n),e!==null&&(fr(e,n),sa(e))}function p1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),_h(e,l)}function m1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),_h(e,l)}function h1(e,n){return Nt(e,n)}var Zi=null,Sl=null,Ou=!1,Ji=!1,Bu=!1,Qa=0;function sa(e){e!==Sl&&e.next===null&&(Sl===null?Zi=Sl=e:Sl=Sl.next=e),Ji=!0,Ou||(Ou=!0,g1())}function vs(e,n){if(!Bu&&Ji){Bu=!0;do for(var l=!1,i=Zi;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var x=0;else{var j=i.suspendedLanes,T=i.pingedLanes;x=(1<<31-gt(42|e)+1)-1,x&=f&~(j&~T),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,Hh(i,x))}else x=qe,x=dn(i,i===mt?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||fn(i,x)||(l=!0,Hh(i,x));i=i.next}while(l);Bu=!1}}function x1(){Oh()}function Oh(){Ji=Ou=!1;var e=0;Qa!==0&&N1()&&(e=Qa);for(var n=Qe(),l=null,i=Zi;i!==null;){var f=i.next,x=Bh(i,n);x===0?(i.next=null,l===null?Zi=f:l.next=f,f===null&&(Sl=l)):(l=i,(e!==0||(x&3)!==0)&&(Ji=!0)),i=f}$t!==0&&$t!==5||vs(e),Qa!==0&&(Qa=0)}function Bh(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,x=e.pendingLanes&-62914561;0<x;){var j=31-gt(x),T=1<<j,P=f[j];P===-1?((T&l)===0||(T&i)!==0)&&(f[j]=ai(T,n)):P<=n&&(e.expiredLanes|=T),x&=~T}if(n=mt,l=qe,l=dn(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(lt===2||lt===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&ht(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||fn(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&ht(i),Da(l)){case 2:case 8:l=pt;break;case 32:l=Ct;break;case 268435456:l=un;break;default:l=Ct}return i=Ih.bind(null,e),l=Nt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&ht(i),e.callbackPriority=2,e.callbackNode=null,2}function Ih(e,n){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Qi()&&e.callbackNode!==l)return null;var i=qe;return i=dn(e,e===mt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(yh(e,i,n),Bh(e,Qe()),e.callbackNode!=null&&e.callbackNode===l?Ih.bind(null,e):null)}function Hh(e,n){if(Qi())return null;yh(e,n,!0)}function g1(){R1(function(){(nt&6)!==0?Nt(be,x1):Oh()})}function Iu(){if(Qa===0){var e=il;e===0&&(e=Et,Et<<=1,(Et&261888)===0&&(Et=256)),Qa=e}return Qa}function Uh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ii(""+e)}function $h(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function v1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var x=Uh((f[ot]||null).action),j=i.submitter;j&&(n=(n=j[ot]||null)?Uh(n.formAction):j.getAttribute("formAction"),n!==null&&(x=n,j=null));var T=new di("action","action",null,i,f);e.push({event:T,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Qa!==0){var P=j?$h(f,j):new FormData(f);ru(l,{pending:!0,data:P,method:f.method,action:x},null,P)}}else typeof x=="function"&&(T.preventDefault(),P=j?$h(f,j):new FormData(f),ru(l,{pending:!0,data:P,method:f.method,action:x},x,P))},currentTarget:f}]})}}for(var Hu=0;Hu<jc.length;Hu++){var Uu=jc[Hu],y1=Uu.toLowerCase(),b1=Uu[0].toUpperCase()+Uu.slice(1);Yn(y1,"on"+b1)}Yn(vp,"onAnimationEnd"),Yn(yp,"onAnimationIteration"),Yn(bp,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(Ob,"onTransitionRun"),Yn(Bb,"onTransitionStart"),Yn(Ib,"onTransitionCancel"),Yn(jp,"onTransitionEnd"),qr("onMouseEnter",["mouseout","mouseover"]),qr("onMouseLeave",["mouseout","mouseover"]),qr("onPointerEnter",["pointerout","pointerover"]),qr("onPointerLeave",["pointerout","pointerover"]),gr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),gr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),gr("onBeforeInput",["compositionend","keypress","textInput","paste"]),gr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),gr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),gr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ys="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(" "),j1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ys));function Vh(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],f=i.event;i=i.listeners;e:{var x=void 0;if(n)for(var j=i.length-1;0<=j;j--){var T=i[j],P=T.instance,Z=T.currentTarget;if(T=T.listener,P!==x&&f.isPropagationStopped())break e;x=T,f.currentTarget=Z;try{x(f)}catch(le){mi(le)}f.currentTarget=null,x=P}else for(j=0;j<i.length;j++){if(T=i[j],P=T.instance,Z=T.currentTarget,T=T.listener,P!==x&&f.isPropagationStopped())break e;x=T,f.currentTarget=Z;try{x(f)}catch(le){mi(le)}f.currentTarget=null,x=P}}}}function We(e,n){var l=n[na];l===void 0&&(l=n[na]=new Set);var i=e+"__bubble";l.has(i)||(Ph(n,e,2,!1),l.add(i))}function $u(e,n,l){var i=0;n&&(i|=4),Ph(l,e,i,n)}var eo="_reactListening"+Math.random().toString(36).slice(2);function Vu(e){if(!e[eo]){e[eo]=!0,Of.forEach(function(l){l!=="selectionchange"&&(j1.has(l)||$u(l,!1,e),$u(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[eo]||(n[eo]=!0,$u("selectionchange",!1,n))}}function Ph(e,n,l,i){switch(vx(n)){case 2:var f=K1;break;case 8:f=X1;break;default:f=ad}l=f.bind(null,n,l,e),f=void 0,!oc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),i?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Pu(e,n,l,i,f){var x=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var j=i.tag;if(j===3||j===4){var T=i.stateNode.containerInfo;if(T===f)break;if(j===4)for(j=i.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;T!==null;){if(j=Fr(T),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=x=j;continue e}T=T.parentNode}}i=i.return}Yf(function(){var Z=x,le=sc(l),ue=[];e:{var ee=Sp.get(e);if(ee!==void 0){var ae=di,we=e;switch(e){case"keypress":if(ci(l)===0)break e;case"keydown":case"keyup":ae=mb;break;case"focusin":we="focus",ae=fc;break;case"focusout":we="blur",ae=fc;break;case"beforeblur":case"afterblur":ae=fc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=Qf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=nb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=gb;break;case vp:case yp:case bp:ae=lb;break;case jp:ae=yb;break;case"scroll":case"scrollend":ae=eb;break;case"wheel":ae=jb;break;case"copy":case"cut":case"paste":ae=ib;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Jf;break;case"toggle":case"beforetoggle":ae=kb}var Le=(n&4)!==0,dt=!Le&&(e==="scroll"||e==="scrollend"),K=Le?ee!==null?ee+"Capture":null:ee;Le=[];for(var G=Z,Q;G!==null;){var oe=G;if(Q=oe.stateNode,oe=oe.tag,oe!==5&&oe!==26&&oe!==27||Q===null||K===null||(oe=$l(G,K),oe!=null&&Le.push(bs(G,oe,Q))),dt)break;G=G.return}0<Le.length&&(ee=new ae(ee,we,null,l,le),ue.push({event:ee,listeners:Le}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",ae=e==="mouseout"||e==="pointerout",ee&&l!==lc&&(we=l.relatedTarget||l.fromElement)&&(Fr(we)||we[xr]))break e;if((ae||ee)&&(ee=le.window===le?le:(ee=le.ownerDocument)?ee.defaultView||ee.parentWindow:window,ae?(we=l.relatedTarget||l.toElement,ae=Z,we=we?Fr(we):null,we!==null&&(dt=u(we),Le=we.tag,we!==dt||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(ae=null,we=Z),ae!==we)){if(Le=Qf,oe="onMouseLeave",K="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Le=Jf,oe="onPointerLeave",K="onPointerEnter",G="pointer"),dt=ae==null?ee:Ul(ae),Q=we==null?ee:Ul(we),ee=new Le(oe,G+"leave",ae,l,le),ee.target=dt,ee.relatedTarget=Q,oe=null,Fr(le)===Z&&(Le=new Le(K,G+"enter",we,l,le),Le.target=Q,Le.relatedTarget=dt,oe=Le),dt=oe,ae&&we)t:{for(Le=S1,K=ae,G=we,Q=0,oe=K;oe;oe=Le(oe))Q++;oe=0;for(var Me=G;Me;Me=Le(Me))oe++;for(;0<Q-oe;)K=Le(K),Q--;for(;0<oe-Q;)G=Le(G),oe--;for(;Q--;){if(K===G||G!==null&&K===G.alternate){Le=K;break t}K=Le(K),G=Le(G)}Le=null}else Le=null;ae!==null&&Fh(ue,ee,ae,Le,!1),we!==null&&dt!==null&&Fh(ue,dt,we,Le,!0)}}e:{if(ee=Z?Ul(Z):window,ae=ee.nodeName&&ee.nodeName.toLowerCase(),ae==="select"||ae==="input"&&ee.type==="file")var Ze=ip;else if(lp(ee))if(op)Ze=zb;else{Ze=Mb;var Ee=Ab}else ae=ee.nodeName,!ae||ae.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&rc(Z.elementType)&&(Ze=ip):Ze=Lb;if(Ze&&(Ze=Ze(e,Z))){sp(ue,Ze,l,le);break e}Ee&&Ee(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&ac(ee,"number",ee.value)}switch(Ee=Z?Ul(Z):window,e){case"focusin":(lp(Ee)||Ee.contentEditable==="true")&&(Jr=Ee,vc=Z,Kl=null);break;case"focusout":Kl=vc=Jr=null;break;case"mousedown":yc=!0;break;case"contextmenu":case"mouseup":case"dragend":yc=!1,xp(ue,l,le);break;case"selectionchange":if(_b)break;case"keydown":case"keyup":xp(ue,l,le)}var Ve;if(mc)e:{switch(e){case"compositionstart":var Ye="onCompositionStart";break e;case"compositionend":Ye="onCompositionEnd";break e;case"compositionupdate":Ye="onCompositionUpdate";break e}Ye=void 0}else Zr?ap(e,l)&&(Ye="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ye="onCompositionStart");Ye&&(ep&&l.locale!=="ko"&&(Zr||Ye!=="onCompositionStart"?Ye==="onCompositionEnd"&&Zr&&(Ve=Kf()):(_a=le,cc="value"in _a?_a.value:_a.textContent,Zr=!0)),Ee=to(Z,Ye),0<Ee.length&&(Ye=new Zf(Ye,e,null,l,le),ue.push({event:Ye,listeners:Ee}),Ve?Ye.data=Ve:(Ve=rp(l),Ve!==null&&(Ye.data=Ve)))),(Ve=Cb?Eb(e,l):Nb(e,l))&&(Ye=to(Z,"onBeforeInput"),0<Ye.length&&(Ee=new Zf("onBeforeInput","beforeinput",null,l,le),ue.push({event:Ee,listeners:Ye}),Ee.data=Ve)),v1(ue,e,Z,l,le)}Vh(ue,n)})}function bs(e,n,l){return{instance:e,listener:n,currentTarget:l}}function to(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,x=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||x===null||(f=$l(e,l),f!=null&&i.unshift(bs(e,f,x)),f=$l(e,n),f!=null&&i.push(bs(e,f,x))),e.tag===3)return i;e=e.return}return[]}function S1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Fh(e,n,l,i,f){for(var x=n._reactName,j=[];l!==null&&l!==i;){var T=l,P=T.alternate,Z=T.stateNode;if(T=T.tag,P!==null&&P===i)break;T!==5&&T!==26&&T!==27||Z===null||(P=Z,f?(Z=$l(l,x),Z!=null&&j.unshift(bs(l,Z,P))):f||(Z=$l(l,x),Z!=null&&j.push(bs(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var k1=/\r\n?/g,w1=/\u0000|\uFFFD/g;function Gh(e){return(typeof e=="string"?e:""+e).replace(k1,`
50
- `).replace(w1,"")}function Wh(e,n){return n=Gh(n),Gh(e)===n}function ut(e,n,l,i,f,x){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Kr(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Kr(e,""+i);break;case"className":li(e,"class",i);break;case"tabIndex":li(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":li(e,l,i);break;case"style":Wf(e,i,x);break;case"data":if(n!=="object"){li(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ii(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"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 x=="function"&&(l==="formAction"?(n!=="input"&&ut(e,n,"name",f.name,f,null),ut(e,n,"formEncType",f.formEncType,f,null),ut(e,n,"formMethod",f.formMethod,f,null),ut(e,n,"formTarget",f.formTarget,f,null)):(ut(e,n,"encType",f.encType,f,null),ut(e,n,"method",f.method,f,null),ut(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ii(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=pa);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=ii(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);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":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":We("beforetoggle",e),We("toggle",e),ri(e,"popover",i);break;case"xlinkActuate":fa(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":fa(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":fa(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":fa(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":fa(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":fa(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":fa(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":fa(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":fa(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":ri(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Zy.get(l)||l,ri(e,l,i))}}function Fu(e,n,l,i,f,x){switch(l){case"style":Wf(e,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Kr(e,i):(typeof i=="number"||typeof i=="bigint")&&Kr(e,""+i);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"onClick":i!=null&&(e.onclick=pa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),x=e[ot]||null,x=x!=null?x[l]:null,typeof x=="function"&&e.removeEventListener(n,x,f),typeof i=="function")){typeof x!="function"&&x!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,f);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):ri(e,l,i)}}}function Zt(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var i=!1,f=!1,x;for(x in l)if(l.hasOwnProperty(x)){var j=l[x];if(j!=null)switch(x){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,x,j,l,null)}}f&&ut(e,n,"srcSet",l.srcSet,l,null),i&&ut(e,n,"src",l.src,l,null);return;case"input":We("invalid",e);var T=x=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var le=l[i];if(le!=null)switch(i){case"name":f=le;break;case"type":j=le;break;case"checked":P=le;break;case"defaultChecked":Z=le;break;case"value":x=le;break;case"defaultValue":T=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(o(137,n));break;default:ut(e,n,i,le,l,null)}}Vf(e,x,T,P,Z,j,f,!1);return;case"select":We("invalid",e),i=j=x=null;for(f in l)if(l.hasOwnProperty(f)&&(T=l[f],T!=null))switch(f){case"value":x=T;break;case"defaultValue":j=T;break;case"multiple":i=T;default:ut(e,n,f,T,l,null)}n=x,l=j,e.multiple=!!i,n!=null?Yr(e,!!i,n,!1):l!=null&&Yr(e,!!i,l,!0);return;case"textarea":We("invalid",e),x=f=i=null;for(j in l)if(l.hasOwnProperty(j)&&(T=l[j],T!=null))switch(j){case"value":i=T;break;case"defaultValue":f=T;break;case"children":x=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(o(91));break;default:ut(e,n,j,T,l,null)}Ff(e,i,f,x);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(i=l[P],i!=null))switch(P){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:ut(e,n,P,i,l,null)}return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(i=0;i<ys.length;i++)We(ys[i],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("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(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,Z,i,l,null)}return;default:if(rc(n)){for(le in l)l.hasOwnProperty(le)&&(i=l[le],i!==void 0&&Fu(e,n,le,i,l,void 0));return}}for(T in l)l.hasOwnProperty(T)&&(i=l[T],i!=null&&ut(e,n,T,i,l,null))}function C1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,x=null,j=null,T=null,P=null,Z=null,le=null;for(ae in l){var ue=l[ae];if(l.hasOwnProperty(ae)&&ue!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":P=ue;default:i.hasOwnProperty(ae)||ut(e,n,ae,null,i,ue)}}for(var ee in i){var ae=i[ee];if(ue=l[ee],i.hasOwnProperty(ee)&&(ae!=null||ue!=null))switch(ee){case"type":x=ae;break;case"name":f=ae;break;case"checked":Z=ae;break;case"defaultChecked":le=ae;break;case"value":j=ae;break;case"defaultValue":T=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(o(137,n));break;default:ae!==ue&&ut(e,n,ee,ae,i,ue)}}nc(e,j,T,P,Z,le,x,f);return;case"select":ae=j=T=ee=null;for(x in l)if(P=l[x],l.hasOwnProperty(x)&&P!=null)switch(x){case"value":break;case"multiple":ae=P;default:i.hasOwnProperty(x)||ut(e,n,x,null,i,P)}for(f in i)if(x=i[f],P=l[f],i.hasOwnProperty(f)&&(x!=null||P!=null))switch(f){case"value":ee=x;break;case"defaultValue":T=x;break;case"multiple":j=x;default:x!==P&&ut(e,n,f,x,i,P)}n=T,l=j,i=ae,ee!=null?Yr(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Yr(e,!!l,n,!0):Yr(e,!!l,l?[]:"",!1));return;case"textarea":ae=ee=null;for(T in l)if(f=l[T],l.hasOwnProperty(T)&&f!=null&&!i.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:ut(e,n,T,null,i,f)}for(j in i)if(f=i[j],x=l[j],i.hasOwnProperty(j)&&(f!=null||x!=null))switch(j){case"value":ee=f;break;case"defaultValue":ae=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==x&&ut(e,n,j,f,i,x)}Pf(e,ee,ae);return;case"option":for(var we in l)if(ee=l[we],l.hasOwnProperty(we)&&ee!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:ut(e,n,we,null,i,ee)}for(P in i)if(ee=i[P],ae=l[P],i.hasOwnProperty(P)&&ee!==ae&&(ee!=null||ae!=null))switch(P){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:ut(e,n,P,ee,i,ae)}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 Le in l)ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!i.hasOwnProperty(Le)&&ut(e,n,Le,null,i,ee);for(Z in i)if(ee=i[Z],ae=l[Z],i.hasOwnProperty(Z)&&ee!==ae&&(ee!=null||ae!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:ut(e,n,Z,ee,i,ae)}return;default:if(rc(n)){for(var dt in l)ee=l[dt],l.hasOwnProperty(dt)&&ee!==void 0&&!i.hasOwnProperty(dt)&&Fu(e,n,dt,void 0,i,ee);for(le in i)ee=i[le],ae=l[le],!i.hasOwnProperty(le)||ee===ae||ee===void 0&&ae===void 0||Fu(e,n,le,ee,i,ae);return}}for(var K in l)ee=l[K],l.hasOwnProperty(K)&&ee!=null&&!i.hasOwnProperty(K)&&ut(e,n,K,null,i,ee);for(ue in i)ee=i[ue],ae=l[ue],!i.hasOwnProperty(ue)||ee===ae||ee==null&&ae==null||ut(e,n,ue,ee,i,ae)}function qh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function E1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var f=l[i],x=f.transferSize,j=f.initiatorType,T=f.duration;if(x&&T&&qh(j)){for(j=0,T=f.responseEnd,i+=1;i<l.length;i++){var P=l[i],Z=P.startTime;if(Z>T)break;var le=P.transferSize,ue=P.initiatorType;le&&qh(ue)&&(P=P.responseEnd,j+=le*(P<T?1:(T-Z)/(P-Z)))}if(--i,n+=8*(x+j)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Gu=null,Wu=null;function no(e){return e.nodeType===9?e:e.ownerDocument}function Yh(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 Kh(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function qu(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Yu=null;function N1(){var e=window.event;return e&&e.type==="popstate"?e===Yu?!1:(Yu=e,!0):(Yu=null,!1)}var Xh=typeof setTimeout=="function"?setTimeout:void 0,T1=typeof clearTimeout=="function"?clearTimeout:void 0,Qh=typeof Promise=="function"?Promise:void 0,R1=typeof queueMicrotask=="function"?queueMicrotask:typeof Qh<"u"?function(e){return Qh.resolve(null).then(e).catch(A1)}:Xh;function A1(e){setTimeout(function(){throw e})}function Za(e){return e==="head"}function Zh(e,n){var l=n,i=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(f),El(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")js(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,js(l);for(var x=l.firstChild;x;){var j=x.nextSibling,T=x.nodeName;x[Hl]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=j}}else l==="body"&&js(e.ownerDocument.body);l=f}while(l);El(n)}function Jh(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Ku(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ku(l),ec(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function M1(e,n,l,i){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[Hl])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(x=e.getAttribute("rel"),x==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(x!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(x=e.getAttribute("src"),(x!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&x&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var x=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===x)return e}else return e;if(e=Un(e.nextSibling),e===null)break}return null}function L1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Un(e.nextSibling),e===null))return null;return e}function ex(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Un(e.nextSibling),e===null))return null;return e}function Xu(e){return e.data==="$?"||e.data==="$~"}function Qu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function z1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function Un(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Zu=null;function tx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Un(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function nx(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function ax(e,n,l){switch(n=no(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function js(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);ec(e)}var $n=new Map,rx=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ra=_.d;_.d={f:D1,r:_1,D:O1,C:B1,L:I1,m:H1,X:$1,S:U1,M:V1};function D1(){var e=Ra.f(),n=Yi();return e||n}function _1(e){var n=Gr(e);n!==null&&n.tag===5&&n.type==="form"?jm(n):Ra.r(e)}var kl=typeof document>"u"?null:document;function lx(e,n,l){var i=kl;if(i&&typeof n=="string"&&n){var f=zn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),rx.has(f)||(rx.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function O1(e){Ra.D(e),lx("dns-prefetch",e,null)}function B1(e,n){Ra.C(e,n),lx("preconnect",e,n)}function I1(e,n,l){Ra.L(e,n,l);var i=kl;if(i&&e&&n){var f='link[rel="preload"][as="'+zn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+zn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+zn(l.imageSizes)+'"]')):f+='[href="'+zn(e)+'"]';var x=f;switch(n){case"style":x=wl(e);break;case"script":x=Cl(e)}$n.has(x)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),$n.set(x,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(Ss(x))||n==="script"&&i.querySelector(ks(x))||(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function H1(e,n){Ra.m(e,n);var l=kl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+zn(i)+'"][href="'+zn(e)+'"]',x=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Cl(e)}if(!$n.has(x)&&(e=v({rel:"modulepreload",href:e},n),$n.set(x,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ks(x)))return}i=l.createElement("link"),Zt(i,"link",e),Wt(i),l.head.appendChild(i)}}}function U1(e,n,l){Ra.S(e,n,l);var i=kl;if(i&&e){var f=Wr(i).hoistableStyles,x=wl(e);n=n||"default";var j=f.get(x);if(!j){var T={loading:0,preload:null};if(j=i.querySelector(Ss(x)))T.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=$n.get(x))&&Ju(e,l);var P=j=i.createElement("link");Wt(P),Zt(P,"link",e),P._p=new Promise(function(Z,le){P.onload=Z,P.onerror=le}),P.addEventListener("load",function(){T.loading|=1}),P.addEventListener("error",function(){T.loading|=2}),T.loading|=4,ro(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:T},f.set(x,j)}}}function $1(e,n){Ra.X(e,n);var l=kl;if(l&&e){var i=Wr(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0},n),(n=$n.get(f))&&ed(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function V1(e,n){Ra.M(e,n);var l=kl;if(l&&e){var i=Wr(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0,type:"module"},n),(n=$n.get(f))&&ed(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function sx(e,n,l,i){var f=(f=ie.current)?ao(f):null;if(!f)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=wl(l.href),l=Wr(f).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=wl(l.href);var x=Wr(f).hoistableStyles,j=x.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=f.querySelector(Ss(e)))&&!x._p&&(j.instance=x,j.state.loading=5),$n.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},$n.set(e,l),x||P1(f,e,l,j.state))),n&&i===null)throw Error(o(528,""));return j}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Cl(l),l=Wr(f).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function wl(e){return'href="'+zn(e)+'"'}function Ss(e){return'link[rel="stylesheet"]['+e+"]"}function ix(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function P1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),Zt(n,"link",l),Wt(n),e.head.appendChild(n))}function Cl(e){return'[src="'+zn(e)+'"]'}function ks(e){return"script[async]"+e}function ox(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+zn(l.href)+'"]');if(i)return n.instance=i,Wt(i),i;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Wt(i),Zt(i,"style",f),ro(i,l.precedence,e),n.instance=i;case"stylesheet":f=wl(l.href);var x=e.querySelector(Ss(f));if(x)return n.state.loading|=4,n.instance=x,Wt(x),x;i=ix(l),(f=$n.get(f))&&Ju(i,f),x=(e.ownerDocument||e).createElement("link"),Wt(x);var j=x;return j._p=new Promise(function(T,P){j.onload=T,j.onerror=P}),Zt(x,"link",i),n.state.loading|=4,ro(x,l.precedence,e),n.instance=x;case"script":return x=Cl(l.src),(f=e.querySelector(ks(x)))?(n.instance=f,Wt(f),f):(i=l,(f=$n.get(x))&&(i=v({},l),ed(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Wt(f),Zt(f,"link",i),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,ro(i,l.precedence,e));return n.instance}function ro(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,x=f,j=0;j<i.length;j++){var T=i[j];if(T.dataset.precedence===n)x=T;else if(x!==f)break}x?x.parentNode.insertBefore(e,x.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function Ju(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function ed(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var lo=null;function cx(e,n,l){if(lo===null){var i=new Map,f=lo=new Map;f.set(l,i)}else f=lo,i=f.get(l),i||(i=new Map,f.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var x=l[f];if(!(x[Hl]||x[Ut]||e==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var j=x.getAttribute(n)||"";j=e+j;var T=i.get(j);T?T.push(x):i.set(j,[x])}}return i}function ux(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function F1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function dx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function G1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=wl(i.href),x=n.querySelector(Ss(f));if(x){n=x._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=so.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=x,Wt(x);return}x=n.ownerDocument||n,i=ix(i),(f=$n.get(f))&&Ju(i,f),x=x.createElement("link"),Wt(x);var j=x;j._p=new Promise(function(T,P){j.onload=T,j.onerror=P}),Zt(x,"link",i),l.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=so.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var td=0;function W1(e,n){return e.stylesheets&&e.count===0&&oo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&oo(e,e.stylesheets),e.unsuspend){var x=e.unsuspend;e.unsuspend=null,x()}},6e4+n);0<e.imgBytes&&td===0&&(td=62500*E1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oo(e,e.stylesheets),e.unsuspend)){var x=e.unsuspend;e.unsuspend=null,x()}},(e.imgBytes>td?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function so(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)oo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var io=null;function oo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,io=new Map,n.forEach(q1,e),io=null,so.call(e))}function q1(e,n){if(!(n.state.loading&4)){var l=io.get(e);if(l)var i=l.get(null);else{l=new Map,io.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<f.length;x++){var j=f[x];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),i=j)}i&&l.set(null,i)}f=n.instance,j=f.getAttribute("data-precedence"),x=l.get(j)||i,x===i&&l.set(null,f),l.set(j,f),this.count++,i=so.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),x?x.parentNode.insertBefore(f,x.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var ws={$$typeof:L,Provider:null,Consumer:null,_currentValue:O,_currentValue2:O,_threadCount:0};function Y1(e,n,l,i,f,x,j,T,P){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=Bl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bl(0),this.hiddenUpdates=Bl(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=x,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function fx(e,n,l,i,f,x,j,T,P,Z,le,ue){return e=new Y1(e,n,l,j,P,Z,le,ue,T),n=1,x===!0&&(n|=24),x=bn(3,null,null,n),e.current=x,x.stateNode=e,n=Dc(),n.refCount++,e.pooledCache=n,n.refCount++,x.memoizedState={element:i,isDehydrated:l,cache:n},Ic(x),e}function px(e){return e?(e=nl,e):nl}function mx(e,n,l,i,f,x){f=px(f),i.context===null?i.context=f:i.pendingContext=f,i=$a(n),i.payload={element:l},x=x===void 0?null:x,x!==null&&(i.callback=x),l=Va(e,i,n),l!==null&&(vn(l,e,n),ns(l,e,n))}function hx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function nd(e,n){hx(e,n),(e=e.alternate)&&hx(e,n)}function xx(e){if(e.tag===13||e.tag===31){var n=jr(e,67108864);n!==null&&vn(n,e,67108864),nd(e,67108864)}}function gx(e){if(e.tag===13||e.tag===31){var n=Cn();n=Pr(n);var l=jr(e,n);l!==null&&vn(l,e,n),nd(e,n)}}var co=!0;function K1(e,n,l,i){var f=M.T;M.T=null;var x=_.p;try{_.p=2,ad(e,n,l,i)}finally{_.p=x,M.T=f}}function X1(e,n,l,i){var f=M.T;M.T=null;var x=_.p;try{_.p=8,ad(e,n,l,i)}finally{_.p=x,M.T=f}}function ad(e,n,l,i){if(co){var f=rd(i);if(f===null)Pu(e,n,i,uo,l),yx(e,i);else if(Z1(f,e,n,l,i))i.stopPropagation();else if(yx(e,i),n&4&&-1<Q1.indexOf(e)){for(;f!==null;){var x=Gr(f);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var j=Re(x.pendingLanes);if(j!==0){var T=x;for(T.pendingLanes|=2,T.entangledLanes|=2;j;){var P=1<<31-gt(j);T.entanglements[1]|=P,j&=~P}sa(x),(nt&6)===0&&(Wi=Qe()+500,vs(0))}}break;case 31:case 13:T=jr(x,2),T!==null&&vn(T,x,2),Yi(),nd(x,2)}if(x=rd(i),x===null&&Pu(e,n,i,uo,l),x===f)break;f=x}f!==null&&i.stopPropagation()}else Pu(e,n,i,null,l)}}function rd(e){return e=sc(e),ld(e)}var uo=null;function ld(e){if(uo=null,e=Fr(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return uo=e,null}function vx(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(tt()){case be:return 2;case pt:return 8;case Ct:case Yt:return 32;case un:return 268435456;default:return 32}default:return 32}}var sd=!1,Ja=null,er=null,tr=null,Cs=new Map,Es=new Map,nr=[],Q1="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 yx(e,n){switch(e){case"focusin":case"focusout":Ja=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":Cs.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Es.delete(n.pointerId)}}function Ns(e,n,l,i,f,x){return e===null||e.nativeEvent!==x?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:x,targetContainers:[f]},n!==null&&(n=Gr(n),n!==null&&xx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function Z1(e,n,l,i,f){switch(n){case"focusin":return Ja=Ns(Ja,e,n,l,i,f),!0;case"dragenter":return er=Ns(er,e,n,l,i,f),!0;case"mouseover":return tr=Ns(tr,e,n,l,i,f),!0;case"pointerover":var x=f.pointerId;return Cs.set(x,Ns(Cs.get(x)||null,e,n,l,i,f)),!0;case"gotpointercapture":return x=f.pointerId,Es.set(x,Ns(Es.get(x)||null,e,n,l,i,f)),!0}return!1}function bx(e){var n=Fr(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,hr(e.priority,function(){gx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,hr(e.priority,function(){gx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function fo(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=rd(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);lc=i,l.target.dispatchEvent(i),lc=null}else return n=Gr(l),n!==null&&xx(n),e.blockedOn=l,!1;n.shift()}return!0}function jx(e,n,l){fo(e)&&l.delete(n)}function J1(){sd=!1,Ja!==null&&fo(Ja)&&(Ja=null),er!==null&&fo(er)&&(er=null),tr!==null&&fo(tr)&&(tr=null),Cs.forEach(jx),Es.forEach(jx)}function po(e,n){e.blockedOn===n&&(e.blockedOn=null,sd||(sd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,J1)))}var mo=null;function Sx(e){mo!==e&&(mo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){mo===e&&(mo=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],f=e[n+2];if(typeof i!="function"){if(ld(i||l)===null)continue;break}var x=Gr(l);x!==null&&(e.splice(n,3),n-=3,ru(x,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function El(e){function n(P){return po(P,e)}Ja!==null&&po(Ja,e),er!==null&&po(er,e),tr!==null&&po(tr,e),Cs.forEach(n),Es.forEach(n);for(var l=0;l<nr.length;l++){var i=nr[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<nr.length&&(l=nr[0],l.blockedOn===null);)bx(l),l.blockedOn===null&&nr.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],x=l[i+1],j=f[ot]||null;if(typeof x=="function")j||Sx(l);else if(j){var T=null;if(x&&x.hasAttribute("formAction")){if(f=x,j=x[ot]||null)T=j.formAction;else if(ld(f)!==null)continue}else T=j.action;typeof T=="function"?l[i+1]=T:(l.splice(i,3),i-=3),Sx(l)}}}function kx(){function e(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function id(e){this._internalRoot=e}ho.prototype.render=id.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Cn();mx(l,i,e,n,null,null)},ho.prototype.unmount=id.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;mx(e.current,2,null,e,null,null),Yi(),n[xr]=null}};function ho(e){this._internalRoot=e}ho.prototype.unstable_scheduleHydration=function(e){if(e){var n=it();e={blockedOn:null,target:e,priority:n};for(var l=0;l<nr.length&&n!==0&&n<nr[l].priority;l++);nr.splice(l,0,e),l===0&&bx(e)}};var wx=r.version;if(wx!=="19.2.4")throw Error(o(527,wx,"19.2.4"));_.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var e0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xo.isDisabled&&xo.supportsFiber)try{Mn=xo.inject(e0),Mt=xo}catch{}}return Rs.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=Mm,x=Lm,j=zm;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(x=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=fx(e,1,!1,null,null,l,i,null,f,x,j,kx),e[xr]=n.current,Vu(e),new id(n)},Rs.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",x=Mm,j=Lm,T=zm,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(T=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=fx(e,1,!0,n,l??null,i,f,P,x,j,T,kx),n.context=px(null),l=n.current,i=Cn(),i=Pr(i),f=$a(i),f.callback=null,Va(l,f,i),l=i,n.current.lanes=l,fr(n,l),sa(n),e[xr]=n.current,Vu(e),new ho(n)},Rs.version="19.2.4",Rs}var Dx;function c0(){if(Dx)return ud.exports;Dx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),ud.exports=o0(),ud.exports}var u0=c0();/**
49
+ `+i.stack}}var rt=Object.prototype.hasOwnProperty,Nt=t.unstable_scheduleCallback,ht=t.unstable_cancelCallback,Dt=t.unstable_shouldYield,Tt=t.unstable_requestPaint,Qe=t.unstable_now,tt=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,pt=t.unstable_UserBlockingPriority,Ct=t.unstable_NormalPriority,Yt=t.unstable_LowPriority,un=t.unstable_IdlePriority,Gt=t.log,an=t.unstable_setDisableYieldValue,Mn=null,Mt=null;function xt(e){if(typeof Gt=="function"&&an(e),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(Mn,e)}catch{}}var gt=Math.clz32?Math.clz32:Wn,da=Math.log,za=Math.LN2;function Wn(e){return e>>>=0,e===0?32:31-(da(e)/za|0)|0}var Et=256,oe=262144,xe=4194304;function Ee(e){var n=e&42;if(n!==0)return n;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 dn(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~x,i!==0?f=Ee(i):(j&=R,j!==0?f=Ee(j):l||(l=R&~e,l!==0&&(f=Ee(l))))):(R=i&~x,R!==0?f=Ee(R):j!==0?f=Ee(j):l||(l=i&~e,l!==0&&(f=Ee(l)))),f===0?0:n!==0&&n!==f&&(n&x)===0&&(x=f&-f,l=n&-n,x>=l||x===32&&(l&4194048)!==0)?n:f}function fn(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function ai(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 qn(){var e=xe;return xe<<=1,(xe&62914560)===0&&(xe=4194304),e}function Bl(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function fr(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Il(e,n,l,i,f,x){var j=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var R=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var le=31-gt(l),ue=1<<le;R[le]=0,P[le]=-1;var ee=Z[le];if(ee!==null)for(Z[le]=null,le=0;le<ee.length;le++){var ae=ee[le];ae!==null&&(ae.lane&=-536870913)}l&=~ue}i!==0&&ta(e,i,0),x!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=x&~(j&~n))}function ta(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-gt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function pr(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-gt(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function mr(e,n){var l=n&-n;return l=(l&42)!==0?1:Pr(l),(l&(e.suspendedLanes|n))!==0?0:l}function Pr(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 Da(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function it(){var e=_.p;return e!==0?e:(e=window.event,e===void 0?32:vx(e.type))}function hr(e,n){var l=_.p;try{return _.p=e,n()}finally{_.p=l}}var rn=Math.random().toString(36).slice(2),Ht="__reactFiber$"+rn,ot="__reactProps$"+rn,xr="__reactContainer$"+rn,na="__reactEvents$"+rn,Jo="__reactListeners$"+rn,Yy="__reactHandles$"+rn,_f="__reactResources$"+rn,Ul="__reactMarker$"+rn;function ec(e){delete e[Ht],delete e[ot],delete e[na],delete e[Jo],delete e[Yy]}function Fr(e){var n=e[Ht];if(n)return n;for(var l=e.parentNode;l;){if(n=l[xr]||l[Ht]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=nx(e);e!==null;){if(l=e[Ht])return l;e=nx(e)}return n}e=l,l=e.parentNode}return null}function Gr(e){if(e=e[Ht]||e[xr]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Hl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Wr(e){var n=e[_f];return n||(n=e[_f]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Wt(e){e[Ul]=!0}var Of=new Set,Bf={};function gr(e,n){qr(e,n),qr(e+"Capture",n)}function qr(e,n){for(Bf[e]=n,e=0;e<n.length;e++)Of.add(n[e])}var Ky=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]*$"),If={},Uf={};function Xy(e){return rt.call(Uf,e)?!0:rt.call(If,e)?!1:Ky.test(e)?Uf[e]=!0:(If[e]=!0,!1)}function ri(e,n,l){if(Xy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function li(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function fa(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Hf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Qy(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,x=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,x.call(this,j)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function tc(e){if(!e._valueTracker){var n=Hf(e)?"checked":"value";e._valueTracker=Qy(e,n,""+e[n])}}function $f(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=Hf(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function si(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Zy=/[\n"\\]/g;function zn(e){return e.replace(Zy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function nc(e,n,l,i,f,x,j,R){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?ac(e,j,Ln(n)):l!=null?ac(e,j,Ln(l)):i!=null&&e.removeAttribute("value"),f==null&&x!=null&&(e.defaultChecked=!!x),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Ln(R):e.removeAttribute("name")}function Vf(e,n,l,i,f,x,j,R){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),n!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||n!=null)){tc(e);return}l=l!=null?""+Ln(l):"",n=n!=null?""+Ln(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}i=i??f,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=R?e.checked:!!i,e.defaultChecked=!!i,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),tc(e)}function ac(e,n,l){n==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Yr(e,n,l,i){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&i&&(e[l].defaultSelected=!0)}else{for(l=""+Ln(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,i&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Pf(e,n,l){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Ln(l):""}function Ff(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=Ln(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),tc(e)}function Kr(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Jy=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 Gf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||Jy.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function Wf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var f in n)i=n[f],n.hasOwnProperty(f)&&l[f]!==i&&Gf(e,f,i)}else for(var x in n)n.hasOwnProperty(x)&&Gf(e,x,n[x])}function rc(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 eb=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"]]),tb=/^[\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 ii(e){return tb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function pa(){}var lc=null;function sc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xr=null,Qr=null;function qf(e){var n=Gr(e);if(n&&(e=n.stateNode)){var l=e[ot]||null;e:switch(e=n.stateNode,n.type){case"input":if(nc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+zn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ot]||null;if(!f)throw Error(o(90));nc(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&$f(i)}break e;case"textarea":Pf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Yr(e,!!l.multiple,n,!1)}}}var ic=!1;function Yf(e,n,l){if(ic)return e(n,l);ic=!0;try{var i=e(n);return i}finally{if(ic=!1,(Xr!==null||Qr!==null)&&(Yi(),Xr&&(n=Xr,e=Qr,Qr=Xr=null,qf(n),e)))for(n=0;n<e.length;n++)qf(e[n])}}function $l(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ot]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var ma=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oc=!1;if(ma)try{var Vl={};Object.defineProperty(Vl,"passive",{get:function(){oc=!0}}),window.addEventListener("test",Vl,Vl),window.removeEventListener("test",Vl,Vl)}catch{oc=!1}var _a=null,cc=null,oi=null;function Kf(){if(oi)return oi;var e,n=cc,l=n.length,i,f="value"in _a?_a.value:_a.textContent,x=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(i=1;i<=j&&n[l-i]===f[x-i];i++);return oi=f.slice(e,1<i?1-i:void 0)}function ci(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function ui(){return!0}function Xf(){return!1}function pn(e){function n(l,i,f,x,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=x,this.target=j,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(x):x[R]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ui:Xf,this.isPropagationStopped=Xf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ui)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ui)},persist:function(){},isPersistent:ui}),n}var vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},di=pn(vr),Pl=v({},vr,{view:0,detail:0}),nb=pn(Pl),uc,dc,Fl,fi=v({},Pl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,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!==Fl&&(Fl&&e.type==="mousemove"?(uc=e.screenX-Fl.screenX,dc=e.screenY-Fl.screenY):dc=uc=0,Fl=e),uc)},movementY:function(e){return"movementY"in e?e.movementY:dc}}),Qf=pn(fi),ab=v({},fi,{dataTransfer:0}),rb=pn(ab),lb=v({},Pl,{relatedTarget:0}),fc=pn(lb),sb=v({},vr,{animationName:0,elapsedTime:0,pseudoElement:0}),ib=pn(sb),ob=v({},vr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),cb=pn(ob),ub=v({},vr,{data:0}),Zf=pn(ub),db={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fb={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"},pb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=pb[e])?!!n[e]:!1}function pc(){return mb}var hb=v({},Pl,{key:function(e){if(e.key){var n=db[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ci(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?fb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(e){return e.type==="keypress"?ci(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ci(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),xb=pn(hb),gb=v({},fi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jf=pn(gb),vb=v({},Pl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),yb=pn(vb),bb=v({},vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),jb=pn(bb),Sb=v({},fi,{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}),kb=pn(Sb),wb=v({},vr,{newState:0,oldState:0}),Cb=pn(wb),Eb=[9,13,27,32],mc=ma&&"CompositionEvent"in window,Gl=null;ma&&"documentMode"in document&&(Gl=document.documentMode);var Nb=ma&&"TextEvent"in window&&!Gl,ep=ma&&(!mc||Gl&&8<Gl&&11>=Gl),tp=" ",np=!1;function ap(e,n){switch(e){case"keyup":return Eb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zr=!1;function Tb(e,n){switch(e){case"compositionend":return rp(n);case"keypress":return n.which!==32?null:(np=!0,tp);case"textInput":return e=n.data,e===tp&&np?null:e;default:return null}}function Rb(e,n){if(Zr)return e==="compositionend"||!mc&&ap(e,n)?(e=Kf(),oi=cc=_a=null,Zr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return ep&&n.locale!=="ko"?null:n.data;default:return null}}var Ab={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 lp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Ab[e.type]:n==="textarea"}function sp(e,n,l,i){Xr?Qr?Qr.push(i):Qr=[i]:Xr=i,n=to(n,"onChange"),0<n.length&&(l=new di("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Wl=null,ql=null;function Mb(e){Vh(e,0)}function pi(e){var n=Hl(e);if($f(n))return e}function ip(e,n){if(e==="change")return n}var op=!1;if(ma){var hc;if(ma){var xc="oninput"in document;if(!xc){var cp=document.createElement("div");cp.setAttribute("oninput","return;"),xc=typeof cp.oninput=="function"}hc=xc}else hc=!1;op=hc&&(!document.documentMode||9<document.documentMode)}function up(){Wl&&(Wl.detachEvent("onpropertychange",dp),ql=Wl=null)}function dp(e){if(e.propertyName==="value"&&pi(ql)){var n=[];sp(n,ql,e,sc(e)),Yf(Mb,n)}}function Lb(e,n,l){e==="focusin"?(up(),Wl=n,ql=l,Wl.attachEvent("onpropertychange",dp)):e==="focusout"&&up()}function zb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return pi(ql)}function Db(e,n){if(e==="click")return pi(n)}function _b(e,n){if(e==="input"||e==="change")return pi(n)}function Ob(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Ob;function Yl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var f=l[i];if(!rt.call(n,f)||!yn(e[f],n[f]))return!1}return!0}function fp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pp(e,n){var l=fp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=fp(l)}}function mp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?mp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function hp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=si(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=si(e.document)}return n}function gc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Bb=ma&&"documentMode"in document&&11>=document.documentMode,Jr=null,vc=null,Kl=null,yc=!1;function xp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;yc||Jr==null||Jr!==si(i)||(i=Jr,"selectionStart"in i&&gc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Kl&&Yl(Kl,i)||(Kl=i,i=to(vc,"onSelect"),0<i.length&&(n=new di("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=Jr)))}function yr(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var el={animationend:yr("Animation","AnimationEnd"),animationiteration:yr("Animation","AnimationIteration"),animationstart:yr("Animation","AnimationStart"),transitionrun:yr("Transition","TransitionRun"),transitionstart:yr("Transition","TransitionStart"),transitioncancel:yr("Transition","TransitionCancel"),transitionend:yr("Transition","TransitionEnd")},bc={},gp={};ma&&(gp=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function br(e){if(bc[e])return bc[e];if(!el[e])return e;var n=el[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in gp)return bc[e]=n[l];return e}var vp=br("animationend"),yp=br("animationiteration"),bp=br("animationstart"),Ib=br("transitionrun"),Ub=br("transitionstart"),Hb=br("transitioncancel"),jp=br("transitionend"),Sp=new Map,jc="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(" ");jc.push("scrollEnd");function Yn(e,n){Sp.set(e,n),gr(n,[e])}var mi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],tl=0,Sc=0;function hi(){for(var e=tl,n=Sc=tl=0;n<e;){var l=Dn[n];Dn[n++]=null;var i=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var x=Dn[n];if(Dn[n++]=null,i!==null&&f!==null){var j=i.pending;j===null?f.next=f:(f.next=j.next,j.next=f),i.pending=f}x!==0&&kp(l,f,x)}}function xi(e,n,l,i){Dn[tl++]=e,Dn[tl++]=n,Dn[tl++]=l,Dn[tl++]=i,Sc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function kc(e,n,l,i){return xi(e,n,l,i),gi(e)}function jr(e,n){return xi(e,null,null,n),gi(e)}function kp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,x=e.return;x!==null;)x.childLanes|=l,i=x.alternate,i!==null&&(i.childLanes|=l),x.tag===22&&(e=x.stateNode,e===null||e._visibility&1||(f=!0)),e=x,x=x.return;return e.tag===3?(x=e.stateNode,f&&n!==null&&(f=31-gt(l),e=x.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),x):null}function gi(e){if(50<gs)throw gs=0,Lu=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var nl={};function $b(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,l,i){return new $b(e,n,l,i)}function wc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ha(e,n){var l=e.alternate;return l===null?(l=bn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function wp(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function vi(e,n,l,i,f,x){var j=0;if(i=e,typeof e=="function")wc(e)&&(j=1);else if(typeof e=="string")j=W1(e,l,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=bn(31,l,n,f),e.elementType=z,e.lanes=x,e;case E:return Sr(l.children,f,x,n);case C:j=8,f|=24;break;case N:return e=bn(12,l,n,f|2),e.elementType=N,e.lanes=x,e;case D:return e=bn(13,l,n,f),e.elementType=D,e.lanes=x,e;case F:return e=bn(19,l,n,f),e.elementType=F,e.lanes=x,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case A:j=10;break e;case T:j=9;break e;case B:j=11;break e;case w:j=14;break e;case O:j=16,i=null;break e}j=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=bn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=x,n}function Sr(e,n,l,i){return e=bn(7,e,i,n),e.lanes=l,e}function Cc(e,n,l){return e=bn(6,e,null,n),e.lanes=l,e}function Cp(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Ec(e,n,l){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Ep=new WeakMap;function _n(e,n){if(typeof e=="object"&&e!==null){var l=Ep.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Oe(n)},Ep.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var al=[],rl=0,yi=null,Xl=0,On=[],Bn=0,Oa=null,aa=1,ra="";function xa(e,n){al[rl++]=Xl,al[rl++]=yi,yi=e,Xl=n}function Np(e,n,l){On[Bn++]=aa,On[Bn++]=ra,On[Bn++]=Oa,Oa=e;var i=aa;e=ra;var f=32-gt(i)-1;i&=~(1<<f),l+=1;var x=32-gt(n)+f;if(30<x){var j=f-f%5;x=(i&(1<<j)-1).toString(32),i>>=j,f-=j,aa=1<<32-gt(n)+f|l<<f|i,ra=x+e}else aa=1<<x|l<<f|i,ra=e}function Nc(e){e.return!==null&&(xa(e,1),Np(e,1,0))}function Tc(e){for(;e===yi;)yi=al[--rl],al[rl]=null,Xl=al[--rl],al[rl]=null;for(;e===Oa;)Oa=On[--Bn],On[Bn]=null,ra=On[--Bn],On[Bn]=null,aa=On[--Bn],On[Bn]=null}function Tp(e,n){On[Bn++]=aa,On[Bn++]=ra,On[Bn++]=Oa,aa=n.id,ra=n.overflow,Oa=e}var Kt=null,vt=null,Ke=!1,Ba=null,In=!1,Rc=Error(o(519));function Ia(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ql(_n(n,e)),Rc}function Rp(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[Ht]=e,n[ot]=i,l){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(l=0;l<ys.length;l++)We(ys[l],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Vf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),Ff(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||Wh(n.textContent,l)?(i.popover!=null&&(We("beforetoggle",n),We("toggle",n)),i.onScroll!=null&&We("scroll",n),i.onScrollEnd!=null&&We("scrollend",n),i.onClick!=null&&(n.onclick=pa),n=!0):n=!1,n||Ia(e,!0)}function Ap(e){for(Kt=e.return;Kt;)switch(Kt.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Kt=Kt.return}}function ll(e){if(e!==Kt)return!1;if(!Ke)return Ap(e),Ke=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||qu(e.type,e.memoizedProps)),l=!l),l&&vt&&Ia(e),Ap(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=tx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=tx(e)}else n===27?(n=vt,Za(e.type)?(e=Zu,Zu=null,vt=e):vt=n):vt=Kt?Hn(e.stateNode.nextSibling):null;return!0}function kr(){vt=Kt=null,Ke=!1}function Ac(){var e=Ba;return e!==null&&(gn===null?gn=e:gn.push.apply(gn,e),Ba=null),e}function Ql(e){Ba===null?Ba=[e]:Ba.push(e)}var Mc=M(null),wr=null,ga=null;function Ua(e,n,l){W(Mc,n._currentValue),n._currentValue=l}function va(e){e._currentValue=Mc.current,Y(Mc)}function Lc(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function zc(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var x=f.dependencies;if(x!==null){var j=f.child;x=x.firstContext;e:for(;x!==null;){var R=x;x=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){x.lanes|=l,R=x.alternate,R!==null&&(R.lanes|=l),Lc(x.return,l,e),i||(j=null);break e}x=R.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,x=j.alternate,x!==null&&(x.lanes|=l),Lc(j,l,e),j=null}else j=f.child;if(j!==null)j.return=f;else for(j=f;j!==null;){if(j===e){j=null;break}if(f=j.sibling,f!==null){f.return=j.return,j=f;break}j=j.return}f=j}}function sl(e,n,l,i){e=null;for(var f=n,x=!1;f!==null;){if(!x){if((f.flags&524288)!==0)x=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(o(387));if(j=j.memoizedProps,j!==null){var R=f.type;yn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===ye.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(ws):e=[ws])}f=f.return}e!==null&&zc(n,e,l,i),n.flags|=262144}function bi(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){wr=e,ga=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xt(e){return Mp(wr,e)}function ji(e,n){return wr===null&&Cr(e),Mp(e,n)}function Mp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},ga===null){if(e===null)throw Error(o(308));ga=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else ga=ga.next=n;return l}var Vb=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},Pb=t.unstable_scheduleCallback,Fb=t.unstable_NormalPriority,_t={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Dc(){return{controller:new Vb,data:new Map,refCount:0}}function Zl(e){e.refCount--,e.refCount===0&&Pb(Fb,function(){e.controller.abort()})}var Jl=null,_c=0,il=0,ol=null;function Gb(e,n){if(Jl===null){var l=Jl=[];_c=0,il=Iu(),ol={status:"pending",value:void 0,then:function(i){l.push(i)}}}return _c++,n.then(Lp,Lp),n}function Lp(){if(--_c===0&&Jl!==null){ol!==null&&(ol.status="fulfilled");var e=Jl;Jl=null,il=0,ol=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Wb(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(i.status="rejected",i.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),i}var zp=L.S;L.S=function(e,n){xh=Qe(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Gb(e,n),zp!==null&&zp(e,n)};var Er=M(null);function Oc(){var e=Er.current;return e!==null?e:mt.pooledCache}function Si(e,n){n===null?W(Er,Er.current):W(Er,n.pool)}function Dp(){var e=Oc();return e===null?null:{parent:_t._currentValue,pool:e}}var cl=Error(o(460)),Bc=Error(o(474)),ki=Error(o(542)),wi={then:function(){}};function _p(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Op(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(pa,pa),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ip(e),e;default:if(typeof n.status=="string")n.then(pa,pa);else{if(e=mt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=i}},function(i){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ip(e),e}throw Tr=n,cl}}function Nr(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Tr=l,cl):l}}var Tr=null;function Bp(){if(Tr===null)throw Error(o(459));var e=Tr;return Tr=null,e}function Ip(e){if(e===cl||e===ki)throw Error(o(483))}var ul=null,es=0;function Ci(e){var n=es;return es+=1,ul===null&&(ul=[]),Op(ul,e,n)}function ts(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ei(e,n){throw n.$$typeof===b?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Up(e){function n(K,G){if(e){var Q=K.deletions;Q===null?(K.deletions=[G],K.flags|=16):Q.push(G)}}function l(K,G){if(!e)return null;for(;G!==null;)n(K,G),G=G.sibling;return null}function i(K){for(var G=new Map;K!==null;)K.key!==null?G.set(K.key,K):G.set(K.index,K),K=K.sibling;return G}function f(K,G){return K=ha(K,G),K.index=0,K.sibling=null,K}function x(K,G,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<G?(K.flags|=67108866,G):Q):(K.flags|=67108866,G)):(K.flags|=1048576,G)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function R(K,G,Q,ce){return G===null||G.tag!==6?(G=Cc(Q,K.mode,ce),G.return=K,G):(G=f(G,Q),G.return=K,G)}function P(K,G,Q,ce){var Me=Q.type;return Me===E?le(K,G,Q.props.children,ce,Q.key):G!==null&&(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Nr(Me)===G.type)?(G=f(G,Q.props),ts(G,Q),G.return=K,G):(G=vi(Q.type,Q.key,Q.props,null,K.mode,ce),ts(G,Q),G.return=K,G)}function Z(K,G,Q,ce){return G===null||G.tag!==4||G.stateNode.containerInfo!==Q.containerInfo||G.stateNode.implementation!==Q.implementation?(G=Ec(Q,K.mode,ce),G.return=K,G):(G=f(G,Q.children||[]),G.return=K,G)}function le(K,G,Q,ce,Me){return G===null||G.tag!==7?(G=Sr(Q,K.mode,ce,Me),G.return=K,G):(G=f(G,Q),G.return=K,G)}function ue(K,G,Q){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Cc(""+G,K.mode,Q),G.return=K,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return Q=vi(G.type,G.key,G.props,null,K.mode,Q),ts(Q,G),Q.return=K,Q;case k:return G=Ec(G,K.mode,Q),G.return=K,G;case O:return G=Nr(G),ue(K,G,Q)}if($(G)||q(G))return G=Sr(G,K.mode,Q,null),G.return=K,G;if(typeof G.then=="function")return ue(K,Ci(G),Q);if(G.$$typeof===A)return ue(K,ji(K,G),Q);Ei(K,G)}return null}function ee(K,G,Q,ce){var Me=G!==null?G.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Me!==null?null:R(K,G,""+Q,ce);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Me?P(K,G,Q,ce):null;case k:return Q.key===Me?Z(K,G,Q,ce):null;case O:return Q=Nr(Q),ee(K,G,Q,ce)}if($(Q)||q(Q))return Me!==null?null:le(K,G,Q,ce,null);if(typeof Q.then=="function")return ee(K,G,Ci(Q),ce);if(Q.$$typeof===A)return ee(K,G,ji(K,Q),ce);Ei(K,Q)}return null}function ae(K,G,Q,ce,Me){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return K=K.get(Q)||null,R(G,K,""+ce,Me);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case S:return K=K.get(ce.key===null?Q:ce.key)||null,P(G,K,ce,Me);case k:return K=K.get(ce.key===null?Q:ce.key)||null,Z(G,K,ce,Me);case O:return ce=Nr(ce),ae(K,G,Q,ce,Me)}if($(ce)||q(ce))return K=K.get(Q)||null,le(G,K,ce,Me,null);if(typeof ce.then=="function")return ae(K,G,Q,Ci(ce),Me);if(ce.$$typeof===A)return ae(K,G,Q,ji(G,ce),Me);Ei(G,ce)}return null}function we(K,G,Q,ce){for(var Me=null,Ze=null,Ne=G,Ve=G=0,Ye=null;Ne!==null&&Ve<Q.length;Ve++){Ne.index>Ve?(Ye=Ne,Ne=null):Ye=Ne.sibling;var Je=ee(K,Ne,Q[Ve],ce);if(Je===null){Ne===null&&(Ne=Ye);break}e&&Ne&&Je.alternate===null&&n(K,Ne),G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je,Ne=Ye}if(Ve===Q.length)return l(K,Ne),Ke&&xa(K,Ve),Me;if(Ne===null){for(;Ve<Q.length;Ve++)Ne=ue(K,Q[Ve],ce),Ne!==null&&(G=x(Ne,G,Ve),Ze===null?Me=Ne:Ze.sibling=Ne,Ze=Ne);return Ke&&xa(K,Ve),Me}for(Ne=i(Ne);Ve<Q.length;Ve++)Ye=ae(Ne,K,Ve,Q[Ve],ce),Ye!==null&&(e&&Ye.alternate!==null&&Ne.delete(Ye.key===null?Ve:Ye.key),G=x(Ye,G,Ve),Ze===null?Me=Ye:Ze.sibling=Ye,Ze=Ye);return e&&Ne.forEach(function(ar){return n(K,ar)}),Ke&&xa(K,Ve),Me}function Le(K,G,Q,ce){if(Q==null)throw Error(o(151));for(var Me=null,Ze=null,Ne=G,Ve=G=0,Ye=null,Je=Q.next();Ne!==null&&!Je.done;Ve++,Je=Q.next()){Ne.index>Ve?(Ye=Ne,Ne=null):Ye=Ne.sibling;var ar=ee(K,Ne,Je.value,ce);if(ar===null){Ne===null&&(Ne=Ye);break}e&&Ne&&ar.alternate===null&&n(K,Ne),G=x(ar,G,Ve),Ze===null?Me=ar:Ze.sibling=ar,Ze=ar,Ne=Ye}if(Je.done)return l(K,Ne),Ke&&xa(K,Ve),Me;if(Ne===null){for(;!Je.done;Ve++,Je=Q.next())Je=ue(K,Je.value,ce),Je!==null&&(G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return Ke&&xa(K,Ve),Me}for(Ne=i(Ne);!Je.done;Ve++,Je=Q.next())Je=ae(Ne,K,Ve,Je.value,ce),Je!==null&&(e&&Je.alternate!==null&&Ne.delete(Je.key===null?Ve:Je.key),G=x(Je,G,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return e&&Ne.forEach(function(a0){return n(K,a0)}),Ke&&xa(K,Ve),Me}function dt(K,G,Q,ce){if(typeof Q=="object"&&Q!==null&&Q.type===E&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Me=Q.key;G!==null;){if(G.key===Me){if(Me=Q.type,Me===E){if(G.tag===7){l(K,G.sibling),ce=f(G,Q.props.children),ce.return=K,K=ce;break e}}else if(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Nr(Me)===G.type){l(K,G.sibling),ce=f(G,Q.props),ts(ce,Q),ce.return=K,K=ce;break e}l(K,G);break}else n(K,G);G=G.sibling}Q.type===E?(ce=Sr(Q.props.children,K.mode,ce,Q.key),ce.return=K,K=ce):(ce=vi(Q.type,Q.key,Q.props,null,K.mode,ce),ts(ce,Q),ce.return=K,K=ce)}return j(K);case k:e:{for(Me=Q.key;G!==null;){if(G.key===Me)if(G.tag===4&&G.stateNode.containerInfo===Q.containerInfo&&G.stateNode.implementation===Q.implementation){l(K,G.sibling),ce=f(G,Q.children||[]),ce.return=K,K=ce;break e}else{l(K,G);break}else n(K,G);G=G.sibling}ce=Ec(Q,K.mode,ce),ce.return=K,K=ce}return j(K);case O:return Q=Nr(Q),dt(K,G,Q,ce)}if($(Q))return we(K,G,Q,ce);if(q(Q)){if(Me=q(Q),typeof Me!="function")throw Error(o(150));return Q=Me.call(Q),Le(K,G,Q,ce)}if(typeof Q.then=="function")return dt(K,G,Ci(Q),ce);if(Q.$$typeof===A)return dt(K,G,ji(K,Q),ce);Ei(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,G!==null&&G.tag===6?(l(K,G.sibling),ce=f(G,Q),ce.return=K,K=ce):(l(K,G),ce=Cc(Q,K.mode,ce),ce.return=K,K=ce),j(K)):l(K,G)}return function(K,G,Q,ce){try{es=0;var Me=dt(K,G,Q,ce);return ul=null,Me}catch(Ne){if(Ne===cl||Ne===ki)throw Ne;var Ze=bn(29,Ne,null,K.mode);return Ze.lanes=ce,Ze.return=K,Ze}finally{}}}var Rr=Up(!0),Hp=Up(!1),Ha=!1;function Ic(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Uc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $a(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(nt&2)!==0){var f=i.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),i.pending=n,n=gi(e),kp(e,null,l),n}return xi(e,i,n,l),gi(e)}function ns(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pr(e,l)}}function Hc(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?f=x=j:x=x.next=j,l=l.next}while(l!==null);x===null?f=x=n:x=x.next=n}else f=x=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var $c=!1;function as(){if($c){var e=ol;if(e!==null)throw e}}function rs(e,n,l,i){$c=!1;var f=e.updateQueue;Ha=!1;var x=f.firstBaseUpdate,j=f.lastBaseUpdate,R=f.shared.pending;if(R!==null){f.shared.pending=null;var P=R,Z=P.next;P.next=null,j===null?x=Z:j.next=Z,j=P;var le=e.alternate;le!==null&&(le=le.updateQueue,R=le.lastBaseUpdate,R!==j&&(R===null?le.firstBaseUpdate=Z:R.next=Z,le.lastBaseUpdate=P))}if(x!==null){var ue=f.baseState;j=0,le=Z=P=null,R=x;do{var ee=R.lane&-536870913,ae=ee!==R.lane;if(ae?(qe&ee)===ee:(i&ee)===ee){ee!==0&&ee===il&&($c=!0),le!==null&&(le=le.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=e,Le=R;ee=n;var dt=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){ue=we.call(dt,ue,ee);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,ee=typeof we=="function"?we.call(dt,ue,ee):we,ee==null)break e;ue=v({},ue,ee);break e;case 2:Ha=!0}}ee=R.callback,ee!==null&&(e.flags|=64,ae&&(e.flags|=8192),ae=f.callbacks,ae===null?f.callbacks=[ee]:ae.push(ee))}else ae={lane:ee,tag:R.tag,payload:R.payload,callback:R.callback,next:null},le===null?(Z=le=ae,P=ue):le=le.next=ae,j|=ee;if(R=R.next,R===null){if(R=f.shared.pending,R===null)break;ae=R,R=ae.next,ae.next=null,f.lastBaseUpdate=ae,f.shared.pending=null}}while(!0);le===null&&(P=ue),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=le,x===null&&(f.shared.lanes=0),qa|=j,e.lanes=j,e.memoizedState=ue}}function $p(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Vp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)$p(l[e],n)}var dl=M(null),Ni=M(0);function Pp(e,n){e=Na,W(Ni,e),W(dl,n),Na=e|n.baseLanes}function Vc(){W(Ni,Na),W(dl,dl.current)}function Pc(){Na=Ni.current,Y(dl),Y(Ni)}var jn=M(null),Un=null;function Pa(e){var n=e.alternate;W(Lt,Lt.current&1),W(jn,e),Un===null&&(n===null||dl.current!==null||n.memoizedState!==null)&&(Un=e)}function Fc(e){W(Lt,Lt.current),W(jn,e),Un===null&&(Un=e)}function Fp(e){e.tag===22?(W(Lt,Lt.current),W(jn,e),Un===null&&(Un=e)):Fa()}function Fa(){W(Lt,Lt.current),W(jn,jn.current)}function Sn(e){Y(jn),Un===e&&(Un=null),Y(Lt)}var Lt=M(0);function Ti(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Xu(l)||Qu(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var ya=0,He=null,ct=null,Ot=null,Ri=!1,fl=!1,Ar=!1,Ai=0,ls=0,pl=null,qb=0;function Rt(){throw Error(o(321))}function Gc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!yn(e[l],n[l]))return!1;return!0}function Wc(e,n,l,i,f,x){return ya=x,He=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,L.H=e===null||e.memoizedState===null?Nm:iu,Ar=!1,x=l(i,f),Ar=!1,fl&&(x=Wp(n,l,i,f)),Gp(e),x}function Gp(e){L.H=os;var n=ct!==null&&ct.next!==null;if(ya=0,Ot=ct=He=null,Ri=!1,ls=0,pl=null,n)throw Error(o(300));e===null||Bt||(e=e.dependencies,e!==null&&bi(e)&&(Bt=!0))}function Wp(e,n,l,i){He=e;var f=0;do{if(fl&&(pl=null),ls=0,fl=!1,25<=f)throw Error(o(301));if(f+=1,Ot=ct=null,e.updateQueue!=null){var x=e.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}L.H=Tm,x=n(l,i)}while(fl);return x}function Yb(){var e=L.H,n=e.useState()[0];return n=typeof n.then=="function"?ss(n):n,e=e.useState()[0],(ct!==null?ct.memoizedState:null)!==e&&(He.flags|=1024),n}function qc(){var e=Ai!==0;return Ai=0,e}function Yc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Kc(e){if(Ri){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ri=!1}ya=0,Ot=ct=He=null,fl=!1,ls=Ai=0,pl=null}function ln(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?He.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function zt(){if(ct===null){var e=He.alternate;e=e!==null?e.memoizedState:null}else e=ct.next;var n=Ot===null?He.memoizedState:Ot.next;if(n!==null)Ot=n,ct=e;else{if(e===null)throw He.alternate===null?Error(o(467)):Error(o(310));ct=e,e={memoizedState:ct.memoizedState,baseState:ct.baseState,baseQueue:ct.baseQueue,queue:ct.queue,next:null},Ot===null?He.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function Mi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ss(e){var n=ls;return ls+=1,pl===null&&(pl=[]),e=Op(pl,e,n),n=He,(Ot===null?n.memoizedState:Ot.next)===null&&(n=n.alternate,L.H=n===null||n.memoizedState===null?Nm:iu),e}function Li(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ss(e);if(e.$$typeof===A)return Xt(e)}throw Error(o(438,String(e)))}function Xc(e){var n=null,l=He.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=He.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Mi(),He.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=U;return n.index++,l}function ba(e,n){return typeof n=="function"?n(e):n}function zi(e){var n=zt();return Qc(n,ct,e)}function Qc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,x=i.pending;if(x!==null){if(f!==null){var j=f.next;f.next=x.next,x.next=j}n.baseQueue=f=x,i.pending=null}if(x=e.baseState,f===null)e.memoizedState=x;else{n=f.next;var R=j=null,P=null,Z=n,le=!1;do{var ue=Z.lane&-536870913;if(ue!==Z.lane?(qe&ue)===ue:(ya&ue)===ue){var ee=Z.revertLane;if(ee===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ue===il&&(le=!0);else if((ya&ee)===ee){Z=Z.next,ee===il&&(le=!0);continue}else ue={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ue,j=x):P=P.next=ue,He.lanes|=ee,qa|=ee;ue=Z.action,Ar&&l(x,ue),x=Z.hasEagerState?Z.eagerState:l(x,ue)}else ee={lane:ue,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ee,j=x):P=P.next=ee,He.lanes|=ue,qa|=ue;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=x:P.next=R,!yn(x,e.memoizedState)&&(Bt=!0,le&&(l=ol,l!==null)))throw l;e.memoizedState=x,e.baseState=j,e.baseQueue=P,i.lastRenderedState=x}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Zc(e){var n=zt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,x=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do x=e(x,j.action),j=j.next;while(j!==f);yn(x,n.memoizedState)||(Bt=!0),n.memoizedState=x,n.baseQueue===null&&(n.baseState=x),l.lastRenderedState=x}return[x,i]}function qp(e,n,l){var i=He,f=zt(),x=Ke;if(x){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!yn((ct||f).memoizedState,l);if(j&&(f.memoizedState=l,Bt=!0),f=f.queue,tu(Xp.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||Ot!==null&&Ot.memoizedState.tag&1){if(i.flags|=2048,ml(9,{destroy:void 0},Kp.bind(null,i,f,l,n),null),mt===null)throw Error(o(349));x||(ya&127)!==0||Yp(i,n,l)}return l}function Yp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=He.updateQueue,n===null?(n=Mi(),He.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Kp(e,n,l,i){n.value=l,n.getSnapshot=i,Qp(n)&&Zp(e)}function Xp(e,n,l){return l(function(){Qp(n)&&Zp(e)})}function Qp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!yn(e,l)}catch{return!0}}function Zp(e){var n=jr(e,2);n!==null&&vn(n,e,2)}function Jc(e){var n=ln();if(typeof e=="function"){var l=e;if(e=l(),Ar){xt(!0);try{l()}finally{xt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:e},n}function Jp(e,n,l,i){return e.baseState=l,Qc(e,ct,typeof i=="function"?i:ba)}function Kb(e,n,l,i,f){if(Oi(e))throw Error(o(485));if(e=n.action,e!==null){var x={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){x.listeners.push(j)}};L.T!==null?l(!0):x.isTransition=!1,i(x),l=n.pending,l===null?(x.next=n.pending=x,em(n,x)):(x.next=l.next,n.pending=l.next=x)}}function em(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var x=L.T,j={};L.T=j;try{var R=l(f,i),P=L.S;P!==null&&P(j,R),tm(e,n,R)}catch(Z){eu(e,n,Z)}finally{x!==null&&j.types!==null&&(x.types=j.types),L.T=x}}else try{x=l(f,i),tm(e,n,x)}catch(Z){eu(e,n,Z)}}function tm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){nm(e,n,i)},function(i){return eu(e,n,i)}):nm(e,n,l)}function nm(e,n,l){n.status="fulfilled",n.value=l,am(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,em(e,l)))}function eu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,am(n),n=n.next;while(n!==i)}e.action=null}function am(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function rm(e,n){return n}function lm(e,n){if(Ke){var l=mt.formState;if(l!==null){e:{var i=He;if(Ke){if(vt){t:{for(var f=vt,x=In;f.nodeType!==8;){if(!x){f=null;break t}if(f=Hn(f.nextSibling),f===null){f=null;break t}}x=f.data,f=x==="F!"||x==="F"?f:null}if(f){vt=Hn(f.nextSibling),i=f.data==="F!";break e}}Ia(i)}i=!1}i&&(n=l[0])}}return l=ln(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:rm,lastRenderedState:n},l.queue=i,l=wm.bind(null,He,i),i.dispatch=l,i=Jc(!1),x=su.bind(null,He,!1,i.queue),i=ln(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=Kb.bind(null,He,f,x,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function sm(e){var n=zt();return im(n,ct,e)}function im(e,n,l){if(n=Qc(e,n,rm)[0],e=zi(ba)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=ss(n)}catch(j){throw j===cl?ki:j}else i=n;n=zt();var f=n.queue,x=f.dispatch;return l!==n.memoizedState&&(He.flags|=2048,ml(9,{destroy:void 0},Xb.bind(null,f,l),null)),[i,x,e]}function Xb(e,n){e.action=n}function om(e){var n=zt(),l=ct;if(l!==null)return im(n,l,e);zt(),n=n.memoizedState,l=zt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function ml(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=He.updateQueue,n===null&&(n=Mi(),He.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function cm(){return zt().memoizedState}function Di(e,n,l,i){var f=ln();He.flags|=e,f.memoizedState=ml(1|n,{destroy:void 0},l,i===void 0?null:i)}function _i(e,n,l,i){var f=zt();i=i===void 0?null:i;var x=f.memoizedState.inst;ct!==null&&i!==null&&Gc(i,ct.memoizedState.deps)?f.memoizedState=ml(n,x,l,i):(He.flags|=e,f.memoizedState=ml(1|n,x,l,i))}function um(e,n){Di(8390656,8,e,n)}function tu(e,n){_i(2048,8,e,n)}function Qb(e){He.flags|=4;var n=He.updateQueue;if(n===null)n=Mi(),He.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function dm(e){var n=zt().memoizedState;return Qb({ref:n,nextImpl:e}),function(){if((nt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function fm(e,n){return _i(4,2,e,n)}function pm(e,n){return _i(4,4,e,n)}function mm(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function hm(e,n,l){l=l!=null?l.concat([e]):null,_i(4,4,mm.bind(null,n,e),l)}function nu(){}function xm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&Gc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function gm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&Gc(n,i[1]))return i[0];if(i=e(),Ar){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i}function au(e,n,l){return l===void 0||(ya&1073741824)!==0&&(qe&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=vh(),He.lanes|=e,qa|=e,l)}function vm(e,n,l,i){return yn(l,n)?l:dl.current!==null?(e=au(e,l,i),yn(e,n)||(Bt=!0),e):(ya&42)===0||(ya&1073741824)!==0&&(qe&261930)===0?(Bt=!0,e.memoizedState=l):(e=vh(),He.lanes|=e,qa|=e,n)}function ym(e,n,l,i,f){var x=_.p;_.p=x!==0&&8>x?x:8;var j=L.T,R={};L.T=R,su(e,!1,n,l);try{var P=f(),Z=L.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var le=Wb(P,i);is(e,n,le,Cn(e))}else is(e,n,i,Cn(e))}catch(ue){is(e,n,{then:function(){},status:"rejected",reason:ue},Cn())}finally{_.p=x,j!==null&&R.types!==null&&(j.types=R.types),L.T=j}}function Zb(){}function ru(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=bm(e).queue;ym(e,f,n,I,l===null?Zb:function(){return jm(e),l(i)})}function bm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:I},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function jm(e){var n=bm(e);n.next===null&&(n=e.alternate.memoizedState),is(e,n.next.queue,{},Cn())}function lu(){return Xt(ws)}function Sm(){return zt().memoizedState}function km(){return zt().memoizedState}function Jb(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Cn();e=$a(l);var i=Va(n,e,l);i!==null&&(vn(i,n,l),ns(i,n,l)),n={cache:Dc()},e.payload=n;return}n=n.return}}function e1(e,n,l){var i=Cn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Oi(e)?Cm(n,l):(l=kc(e,n,l,i),l!==null&&(vn(l,e,i),Em(l,n,i)))}function wm(e,n,l){var i=Cn();is(e,n,l,i)}function is(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Oi(e))Cm(n,f);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=n.lastRenderedReducer,x!==null))try{var j=n.lastRenderedState,R=x(j,l);if(f.hasEagerState=!0,f.eagerState=R,yn(R,j))return xi(e,n,f,0),mt===null&&hi(),!1}catch{}finally{}if(l=kc(e,n,f,i),l!==null)return vn(l,e,i),Em(l,n,i),!0}return!1}function su(e,n,l,i){if(i={lane:2,revertLane:Iu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Oi(e)){if(n)throw Error(o(479))}else n=kc(e,l,i,2),n!==null&&vn(n,e,2)}function Oi(e){var n=e.alternate;return e===He||n!==null&&n===He}function Cm(e,n){fl=Ri=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Em(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pr(e,l)}}var os={readContext:Xt,use:Li,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};os.useEffectEvent=Rt;var Nm={readContext:Xt,use:Li,useCallback:function(e,n){return ln().memoizedState=[e,n===void 0?null:n],e},useContext:Xt,useEffect:um,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Di(4194308,4,mm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Di(4194308,4,e,n)},useInsertionEffect:function(e,n){Di(4,2,e,n)},useMemo:function(e,n){var l=ln();n=n===void 0?null:n;var i=e();if(Ar){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=ln();if(l!==void 0){var f=l(n);if(Ar){xt(!0);try{l(n)}finally{xt(!1)}}}else f=n;return i.memoizedState=i.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},i.queue=e,e=e.dispatch=e1.bind(null,He,e),[i.memoizedState,e]},useRef:function(e){var n=ln();return e={current:e},n.memoizedState=e},useState:function(e){e=Jc(e);var n=e.queue,l=wm.bind(null,He,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:nu,useDeferredValue:function(e,n){var l=ln();return au(l,e,n)},useTransition:function(){var e=Jc(!1);return e=ym.bind(null,He,e.queue,!0,!1),ln().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=He,f=ln();if(Ke){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),mt===null)throw Error(o(349));(qe&127)!==0||Yp(i,n,l)}f.memoizedState=l;var x={value:l,getSnapshot:n};return f.queue=x,um(Xp.bind(null,i,x,e),[e]),i.flags|=2048,ml(9,{destroy:void 0},Kp.bind(null,i,x,l,n),null),l},useId:function(){var e=ln(),n=mt.identifierPrefix;if(Ke){var l=ra,i=aa;l=(i&~(1<<32-gt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Ai++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=qb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:lu,useFormState:lm,useActionState:lm,useOptimistic:function(e){var n=ln();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=su.bind(null,He,!0,l),l.dispatch=n,[e,n]},useMemoCache:Xc,useCacheRefresh:function(){return ln().memoizedState=Jb.bind(null,He)},useEffectEvent:function(e){var n=ln(),l={impl:e};return n.memoizedState=l,function(){if((nt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},iu={readContext:Xt,use:Li,useCallback:xm,useContext:Xt,useEffect:tu,useImperativeHandle:hm,useInsertionEffect:fm,useLayoutEffect:pm,useMemo:gm,useReducer:zi,useRef:cm,useState:function(){return zi(ba)},useDebugValue:nu,useDeferredValue:function(e,n){var l=zt();return vm(l,ct.memoizedState,e,n)},useTransition:function(){var e=zi(ba)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:qp,useId:Sm,useHostTransitionStatus:lu,useFormState:sm,useActionState:sm,useOptimistic:function(e,n){var l=zt();return Jp(l,ct,e,n)},useMemoCache:Xc,useCacheRefresh:km};iu.useEffectEvent=dm;var Tm={readContext:Xt,use:Li,useCallback:xm,useContext:Xt,useEffect:tu,useImperativeHandle:hm,useInsertionEffect:fm,useLayoutEffect:pm,useMemo:gm,useReducer:Zc,useRef:cm,useState:function(){return Zc(ba)},useDebugValue:nu,useDeferredValue:function(e,n){var l=zt();return ct===null?au(l,e,n):vm(l,ct.memoizedState,e,n)},useTransition:function(){var e=Zc(ba)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:qp,useId:Sm,useHostTransitionStatus:lu,useFormState:om,useActionState:om,useOptimistic:function(e,n){var l=zt();return ct!==null?Jp(l,ct,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Xc,useCacheRefresh:km};Tm.useEffectEvent=dm;function ou(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var cu={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$a(i);f.payload=n,l!=null&&(f.callback=l),n=Va(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$a(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Va(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Cn(),i=$a(l);i.tag=2,n!=null&&(i.callback=n),n=Va(e,i,l),n!==null&&(vn(n,e,l),ns(n,e,l))}};function Rm(e,n,l,i,f,x,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,x,j):n.prototype&&n.prototype.isPureReactComponent?!Yl(l,i)||!Yl(f,x):!0}function Am(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&cu.enqueueReplaceState(n,n.state,null)}function Mr(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Mm(e){mi(e)}function Lm(e){console.error(e)}function zm(e){mi(e)}function Bi(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function Dm(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function uu(e,n,l){return l=$a(l),l.tag=3,l.payload={element:null},l.callback=function(){Bi(e,n)},l}function _m(e){return e=$a(e),e.tag=3,e}function Om(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var x=i.value;e.payload=function(){return f(x)},e.callback=function(){Dm(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){Dm(n,l,i),typeof f!="function"&&(Ya===null?Ya=new Set([this]):Ya.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function t1(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&sl(n,l,f,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Un===null?Ki():l.alternate===null&&At===0&&(At=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===wi?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),_u(e,i,f)),!1;case 22:return l.flags|=65536,i===wi?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),_u(e,i,f)),!1}throw Error(o(435,l.tag))}return _u(e,i,f),Ki(),!1}if(Ke)return n=jn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Rc&&(e=Error(o(422),{cause:i}),Ql(_n(e,l)))):(i!==Rc&&(n=Error(o(423),{cause:i}),Ql(_n(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=_n(i,l),f=uu(e.stateNode,i,f),Hc(e,f),At!==4&&(At=2)),!1;var x=Error(o(520),{cause:i});if(x=_n(x,l),xs===null?xs=[x]:xs.push(x),At!==4&&(At=2),n===null)return!0;i=_n(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=uu(l.stateNode,i,e),Hc(l,e),!1;case 1:if(n=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Ya===null||!Ya.has(x))))return l.flags|=65536,f&=-f,l.lanes|=f,f=_m(f),Om(f,e,l,i),Hc(l,f),!1}l=l.return}while(l!==null);return!1}var du=Error(o(461)),Bt=!1;function Qt(e,n,l,i){n.child=e===null?Hp(n,null,l,i):Rr(n,e.child,l,i)}function Bm(e,n,l,i,f){l=l.render;var x=n.ref;if("ref"in i){var j={};for(var R in i)R!=="ref"&&(j[R]=i[R])}else j=i;return Cr(n),i=Wc(e,n,l,j,x,f),R=qc(),e!==null&&!Bt?(Yc(e,n,f),ja(e,n,f)):(Ke&&R&&Nc(n),n.flags|=1,Qt(e,n,i,f),n.child)}function Im(e,n,l,i,f){if(e===null){var x=l.type;return typeof x=="function"&&!wc(x)&&x.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=x,Um(e,n,x,i,f)):(e=vi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(x=e.child,!yu(e,f)){var j=x.memoizedProps;if(l=l.compare,l=l!==null?l:Yl,l(j,i)&&e.ref===n.ref)return ja(e,n,f)}return n.flags|=1,e=ha(x,i),e.ref=n.ref,e.return=n,n.child=e}function Um(e,n,l,i,f){if(e!==null){var x=e.memoizedProps;if(Yl(x,i)&&e.ref===n.ref)if(Bt=!1,n.pendingProps=i=x,yu(e,f))(e.flags&131072)!==0&&(Bt=!0);else return n.lanes=e.lanes,ja(e,n,f)}return fu(e,n,l,i,f)}function Hm(e,n,l,i){var f=i.children,x=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(x=x!==null?x.baseLanes|l:l,e!==null){for(i=n.child=e.child,f=0;i!==null;)f=f|i.lanes|i.childLanes,i=i.sibling;i=f&~x}else i=0,n.child=null;return $m(e,n,x,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Si(n,x!==null?x.cachePool:null),x!==null?Pp(n,x):Vc(),Fp(n);else return i=n.lanes=536870912,$m(e,n,x!==null?x.baseLanes|l:l,l,i)}else x!==null?(Si(n,x.cachePool),Pp(n,x),Fa(),n.memoizedState=null):(e!==null&&Si(n,null),Vc(),Fa());return Qt(e,n,f,l),n.child}function cs(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function $m(e,n,l,i,f){var x=Oc();return x=x===null?null:{parent:_t._currentValue,pool:x},n.memoizedState={baseLanes:l,cachePool:x},e!==null&&Si(n,null),Vc(),Fp(n),e!==null&&sl(e,n,i,!0),n.childLanes=f,null}function Ii(e,n){return n=Hi({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Vm(e,n,l){return Rr(n,e.child,null,l),e=Ii(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function n1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ke){if(i.mode==="hidden")return e=Ii(n,i),n.lanes=536870912,cs(null,e);if(Fc(n),(e=vt)?(e=ex(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Oa!==null?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},l=Cp(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ia(n);return n.lanes=536870912,null}return Ii(n,i)}var x=e.memoizedState;if(x!==null){var j=x.dehydrated;if(Fc(n),f)if(n.flags&256)n.flags&=-257,n=Vm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(Bt||sl(e,n,l,!1),f=(l&e.childLanes)!==0,Bt||f){if(i=mt,i!==null&&(j=mr(i,l),j!==0&&j!==x.retryLane))throw x.retryLane=j,jr(e,j),vn(i,e,j),du;Ki(),n=Vm(e,n,l)}else e=x.treeContext,vt=Hn(j.nextSibling),Kt=n,Ke=!0,Ba=null,In=!1,e!==null&&Tp(n,e),n=Ii(n,i),n.flags|=4096;return n}return e=ha(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Ui(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function fu(e,n,l,i,f){return Cr(n),l=Wc(e,n,l,i,void 0,f),i=qc(),e!==null&&!Bt?(Yc(e,n,f),ja(e,n,f)):(Ke&&i&&Nc(n),n.flags|=1,Qt(e,n,l,f),n.child)}function Pm(e,n,l,i,f,x){return Cr(n),n.updateQueue=null,l=Wp(n,i,l,f),Gp(e),i=qc(),e!==null&&!Bt?(Yc(e,n,x),ja(e,n,x)):(Ke&&i&&Nc(n),n.flags|=1,Qt(e,n,l,x),n.child)}function Fm(e,n,l,i,f){if(Cr(n),n.stateNode===null){var x=nl,j=l.contextType;typeof j=="object"&&j!==null&&(x=Xt(j)),x=new l(i,x),n.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=cu,n.stateNode=x,x._reactInternals=n,x=n.stateNode,x.props=i,x.state=n.memoizedState,x.refs={},Ic(n),j=l.contextType,x.context=typeof j=="object"&&j!==null?Xt(j):nl,x.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(ou(n,l,j,i),x.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(j=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),j!==x.state&&cu.enqueueReplaceState(x,x.state,null),rs(n,i,x,f),as(),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){x=n.stateNode;var R=n.memoizedProps,P=Mr(l,R);x.props=P;var Z=x.context,le=l.contextType;j=nl,typeof le=="object"&&le!==null&&(j=Xt(le));var ue=l.getDerivedStateFromProps;le=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,le||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(R||Z!==j)&&Am(n,x,i,j),Ha=!1;var ee=n.memoizedState;x.state=ee,rs(n,i,x,f),as(),Z=n.memoizedState,R||ee!==Z||Ha?(typeof ue=="function"&&(ou(n,l,ue,i),Z=n.memoizedState),(P=Ha||Rm(n,l,P,i,ee,Z,j))?(le||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),x.props=i,x.state=Z,x.context=j,i=P):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{x=n.stateNode,Uc(e,n),j=n.memoizedProps,le=Mr(l,j),x.props=le,ue=n.pendingProps,ee=x.context,Z=l.contextType,P=nl,typeof Z=="object"&&Z!==null&&(P=Xt(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(j!==ue||ee!==P)&&Am(n,x,i,P),Ha=!1,ee=n.memoizedState,x.state=ee,rs(n,i,x,f),as();var ae=n.memoizedState;j!==ue||ee!==ae||Ha||e!==null&&e.dependencies!==null&&bi(e.dependencies)?(typeof R=="function"&&(ou(n,l,R,i),ae=n.memoizedState),(le=Ha||Rm(n,l,le,i,ee,ae,P)||e!==null&&e.dependencies!==null&&bi(e.dependencies))?(Z||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,ae,P),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,ae,P)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=ae),x.props=i,x.state=ae,x.context=P,i=le):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return x=i,Ui(e,n),i=(n.flags&128)!==0,x||i?(x=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:x.render(),n.flags|=1,e!==null&&i?(n.child=Rr(n,e.child,null,f),n.child=Rr(n,null,l,f)):Qt(e,n,l,f),n.memoizedState=x.state,e=n.child):e=ja(e,n,f),e}function Gm(e,n,l,i){return kr(),n.flags|=256,Qt(e,n,l,i),n.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mu(e){return{baseLanes:e,cachePool:Dp()}}function hu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=wn),e}function Wm(e,n,l){var i=n.pendingProps,f=!1,x=(n.flags&128)!==0,j;if((j=x)||(j=e!==null&&e.memoizedState===null?!1:(Lt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ke){if(f?Pa(n):Fa(),(e=vt)?(e=ex(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Oa!==null?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},l=Cp(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ia(n);return Qu(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,f?(Fa(),f=n.mode,R=Hi({mode:"hidden",children:R},f),i=Sr(i,f,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=mu(l),i.childLanes=hu(e,j,l),n.memoizedState=pu,cs(null,i)):(Pa(n),xu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(x)n.flags&256?(Pa(n),n.flags&=-257,n=gu(e,n,l)):n.memoizedState!==null?(Fa(),n.child=e.child,n.flags|=128,n=null):(Fa(),R=i.fallback,f=n.mode,i=Hi({mode:"visible",children:i.children},f),R=Sr(R,f,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,Rr(n,e.child,null,l),i=n.child,i.memoizedState=mu(l),i.childLanes=hu(e,j,l),n.memoizedState=pu,n=cs(null,i));else if(Pa(n),Qu(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Ql({value:i,source:null,stack:null}),n=gu(e,n,l)}else if(Bt||sl(e,n,l,!1),j=(l&e.childLanes)!==0,Bt||j){if(j=mt,j!==null&&(i=mr(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,jr(e,i),vn(j,e,i),du;Xu(R)||Ki(),n=gu(e,n,l)}else Xu(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,vt=Hn(R.nextSibling),Kt=n,Ke=!0,Ba=null,In=!1,e!==null&&Tp(n,e),n=xu(n,i.children),n.flags|=4096);return n}return f?(Fa(),R=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=ha(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=ha(Z,R):(R=Sr(R,f,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,cs(null,i),i=n.child,R=e.child.memoizedState,R===null?R=mu(l):(f=R.cachePool,f!==null?(P=_t._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=Dp(),R={baseLanes:R.baseLanes|l,cachePool:f}),i.memoizedState=R,i.childLanes=hu(e,j,l),n.memoizedState=pu,cs(e.child,i)):(Pa(n),l=e.child,e=l.sibling,l=ha(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(j=n.deletions,j===null?(n.deletions=[e],n.flags|=16):j.push(e)),n.child=l,n.memoizedState=null,l)}function xu(e,n){return n=Hi({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Hi(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function gu(e,n,l){return Rr(n,e.child,null,l),e=xu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function qm(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),Lc(e.return,n,l)}function vu(e,n,l,i,f,x){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:x}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=x)}function Ym(e,n,l){var i=n.pendingProps,f=i.revealOrder,x=i.tail;i=i.children;var j=Lt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,W(Lt,j),Qt(e,n,i,l),i=Ke?Xl:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&qm(e,l,n);else if(e.tag===19)qm(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&Ti(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),vu(n,!1,f,l,x,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ti(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}vu(n,!0,l,null,x,i);break;case"together":vu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function ja(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),qa|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(sl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=ha(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=ha(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function yu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&bi(e)))}function a1(e,n,l){switch(n.tag){case 3:de(n,n.stateNode.containerInfo),Ua(n,_t,e.memoizedState.cache),kr();break;case 27:case 5:Ae(n);break;case 4:de(n,n.stateNode.containerInfo);break;case 10:Ua(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Fc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Pa(n),n.flags|=128,null):(l&n.child.childLanes)!==0?Wm(e,n,l):(Pa(n),e=ja(e,n,l),e!==null?e.sibling:null);Pa(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(sl(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Ym(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),W(Lt,Lt.current),i)break;return null;case 22:return n.lanes=0,Hm(e,n,l,n.pendingProps);case 24:Ua(n,_t,e.memoizedState.cache)}return ja(e,n,l)}function Km(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Bt=!0;else{if(!yu(e,l)&&(n.flags&128)===0)return Bt=!1,a1(e,n,l);Bt=(e.flags&131072)!==0}else Bt=!1,Ke&&(n.flags&1048576)!==0&&Np(n,Xl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Nr(n.elementType),n.type=e,typeof e=="function")wc(e)?(i=Mr(e,i),n.tag=1,n=Fm(null,n,e,i,l)):(n.tag=0,n=fu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===B){n.tag=11,n=Bm(null,n,e,i,l);break e}else if(f===w){n.tag=14,n=Im(null,n,e,i,l);break e}}throw n=J(e)||e,Error(o(306,n,""))}}return n;case 0:return fu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Mr(i,n.pendingProps),Fm(e,n,i,f,l);case 3:e:{if(de(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var x=n.memoizedState;f=x.element,Uc(e,n),rs(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Ua(n,_t,i),i!==x.cache&&zc(n,[_t],l,!0),as(),i=j.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=x,n.memoizedState=x,n.flags&256){n=Gm(e,n,i,l);break e}else if(i!==f){f=_n(Error(o(424)),n),Ql(f),n=Gm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(vt=Hn(e.firstChild),Kt=n,Ke=!0,Ba=null,In=!0,l=Hp(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(kr(),i===f){n=ja(e,n,l);break e}Qt(e,n,i,l)}n=n.child}return n;case 26:return Ui(e,n),e===null?(l=sx(n.type,null,n.pendingProps,null))?n.memoizedState=l:Ke||(l=n.type,e=n.pendingProps,i=no(ie.current).createElement(l),i[Ht]=n,i[ot]=e,Zt(i,l,e),Wt(i),n.stateNode=i):n.memoizedState=sx(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Ae(n),e===null&&Ke&&(i=n.stateNode=ax(n.type,n.pendingProps,ie.current),Kt=n,In=!0,f=vt,Za(n.type)?(Zu=f,vt=Hn(i.firstChild)):vt=f),Qt(e,n,n.pendingProps.children,l),Ui(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ke&&((f=i=vt)&&(i=z1(i,n.type,n.pendingProps,In),i!==null?(n.stateNode=i,Kt=n,vt=Hn(i.firstChild),In=!1,f=!0):f=!1),f||Ia(n)),Ae(n),f=n.type,x=n.pendingProps,j=e!==null?e.memoizedProps:null,i=x.children,qu(f,x)?i=null:j!==null&&qu(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=Wc(e,n,Yb,null,null,l),ws._currentValue=f),Ui(e,n),Qt(e,n,i,l),n.child;case 6:return e===null&&Ke&&((e=l=vt)&&(l=D1(l,n.pendingProps,In),l!==null?(n.stateNode=l,Kt=n,vt=null,e=!0):e=!1),e||Ia(n)),null;case 13:return Wm(e,n,l);case 4:return de(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=Rr(n,null,i,l):Qt(e,n,i,l),n.child;case 11:return Bm(e,n,n.type,n.pendingProps,l);case 7:return Qt(e,n,n.pendingProps,l),n.child;case 8:return Qt(e,n,n.pendingProps.children,l),n.child;case 12:return Qt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ua(n,n.type,i.value),Qt(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Cr(n),f=Xt(f),i=i(f),n.flags|=1,Qt(e,n,i,l),n.child;case 14:return Im(e,n,n.type,n.pendingProps,l);case 15:return Um(e,n,n.type,n.pendingProps,l);case 19:return Ym(e,n,l);case 31:return n1(e,n,l);case 22:return Hm(e,n,l,n.pendingProps);case 24:return Cr(n),i=Xt(_t),e===null?(f=Oc(),f===null&&(f=mt,x=Dc(),f.pooledCache=x,x.refCount++,x!==null&&(f.pooledCacheLanes|=l),f=x),n.memoizedState={parent:i,cache:f},Ic(n),Ua(n,_t,f)):((e.lanes&l)!==0&&(Uc(e,n),rs(n,null,null,l),as()),f=e.memoizedState,x=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ua(n,_t,i)):(i=x.cache,Ua(n,_t,i),i!==f.cache&&zc(n,[_t],l,!0))),Qt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Sa(e){e.flags|=4}function bu(e,n,l,i,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Sh())e.flags|=8192;else throw Tr=wi,Bc}else e.flags&=-16777217}function Xm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!dx(n))if(Sh())e.flags|=8192;else throw Tr=wi,Bc}function $i(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?qn():536870912,e.lanes|=n,vl|=n)}function us(e,n){if(!Ke)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags&65011712,i|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags,i|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function r1(e,n,l){var i=n.pendingProps;switch(Tc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return yt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),va(_t),Se(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(ll(n)?Sa(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Ac())),yt(n),null;case 26:var f=n.type,x=n.memoizedState;return e===null?(Sa(n),x!==null?(yt(n),Xm(n,x)):(yt(n),bu(n,f,null,i,l))):x?x!==e.memoizedState?(Sa(n),yt(n),Xm(n,x)):(yt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Sa(n),yt(n),bu(n,f,e,i,l)),null;case 27:if(_e(n),l=ie.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}e=te.current,ll(n)?Rp(n):(e=ax(f,i,l),n.stateNode=e,Sa(n))}return yt(n),null;case 5:if(_e(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}if(x=te.current,ll(n))Rp(n);else{var j=no(ie.current);switch(x){case 1:x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":x=j.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}x[Ht]=n,x[ot]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===n)break e;for(;j.sibling===null;){if(j.return===null||j.return===n)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}n.stateNode=x;e:switch(Zt(x,f,i),f){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Sa(n)}}return yt(n),bu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Sa(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=ie.current,ll(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Kt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[Ht]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Wh(e.nodeValue,l)),e||Ia(n,!0)}else e=no(e).createTextNode(i),e[Ht]=n,n.stateNode=e}return yt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=ll(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Ht]=n}else kr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),e=!1}else l=Ac(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return yt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=ll(n),i!==null&&i.dehydrated!==null){if(e===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[Ht]=n}else kr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),f=!1}else f=Ac(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,f=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(f=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),$i(n,n.updateQueue),yt(n),null);case 4:return Se(),e===null&&Vu(n.stateNode.containerInfo),yt(n),null;case 10:return va(n.type),yt(n),null;case 19:if(Y(Lt),i=n.memoizedState,i===null)return yt(n),null;if(f=(n.flags&128)!==0,x=i.rendering,x===null)if(f)us(i,!1);else{if(At!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=Ti(e),x!==null){for(n.flags|=128,us(i,!1),e=x.updateQueue,n.updateQueue=e,$i(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)wp(l,e),l=l.sibling;return W(Lt,Lt.current&1|2),Ke&&xa(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Qe()>Wi&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ti(x),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,$i(n,e),us(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Ke)return yt(n),null}else 2*Qe()-i.renderingStartTime>Wi&&l!==536870912&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304);i.isBackwards?(x.sibling=n.child,n.child=x):(e=i.last,e!==null?e.sibling=x:n.child=x,i.last=x)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Qe(),e.sibling=null,l=Lt.current,W(Lt,f?l&1|2:l&1),Ke&&xa(n,i.treeForkCount),e):(yt(n),null);case 22:case 23:return Sn(n),Pc(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),l=n.updateQueue,l!==null&&$i(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&Y(Er),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),va(_t),yt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function l1(e,n){switch(Tc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return va(_t),Se(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(o(340));kr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));kr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Y(Lt),null;case 4:return Se(),null;case 10:return va(n.type),null;case 22:case 23:return Sn(n),Pc(),e!==null&&Y(Er),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return va(_t),null;case 25:return null;default:return null}}function Qm(e,n){switch(Tc(n),n.tag){case 3:va(_t),Se();break;case 26:case 27:case 5:_e(n);break;case 4:Se();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:Y(Lt);break;case 10:va(n.type);break;case 22:case 23:Sn(n),Pc(),e!==null&&Y(Er);break;case 24:va(_t)}}function ds(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var f=i.next;l=f;do{if((l.tag&e)===e){i=void 0;var x=l.create,j=l.inst;i=x(),j.destroy=i}l=l.next}while(l!==f)}}catch(R){st(n,n.return,R)}}function Ga(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var x=f.next;i=x;do{if((i.tag&e)===e){var j=i.inst,R=j.destroy;if(R!==void 0){j.destroy=void 0,f=n;var P=l,Z=R;try{Z()}catch(le){st(f,P,le)}}}i=i.next}while(i!==x)}}catch(le){st(n,n.return,le)}}function Zm(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Vp(n,l)}catch(i){st(e,e.return,i)}}}function Jm(e,n,l){l.props=Mr(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){st(e,n,i)}}function fs(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(f){st(e,n,f)}}function la(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){st(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){st(e,n,f)}else l.current=null}function eh(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(f){st(e,e.return,f)}}function ju(e,n,l){try{var i=e.stateNode;N1(i,e.type,l,n),i[ot]=n}catch(f){st(e,e.return,f)}}function th(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Za(e.type)||e.tag===4}function Su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||th(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&&Za(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ku(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=pa));else if(i!==4&&(i===27&&Za(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(ku(e,n,l),e=e.sibling;e!==null;)ku(e,n,l),e=e.sibling}function Vi(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Za(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Vi(e,n,l),e=e.sibling;e!==null;)Vi(e,n,l),e=e.sibling}function nh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);Zt(n,i,l),n[Ht]=e,n[ot]=l}catch(x){st(e,e.return,x)}}var ka=!1,It=!1,wu=!1,ah=typeof WeakSet=="function"?WeakSet:Set,qt=null;function s1(e,n){if(e=e.containerInfo,Gu=co,e=hp(e),gc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var f=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var j=0,R=-1,P=-1,Z=0,le=0,ue=e,ee=null;t:for(;;){for(var ae;ue!==l||f!==0&&ue.nodeType!==3||(R=j+f),ue!==x||i!==0&&ue.nodeType!==3||(P=j+i),ue.nodeType===3&&(j+=ue.nodeValue.length),(ae=ue.firstChild)!==null;)ee=ue,ue=ae;for(;;){if(ue===e)break t;if(ee===l&&++Z===f&&(R=j),ee===x&&++le===i&&(P=j),(ae=ue.nextSibling)!==null)break;ue=ee,ee=ue.parentNode}ue=ae}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(Wu={focusedElem:e,selectionRange:l},co=!1,qt=n;qt!==null;)if(n=qt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,qt=e;else for(;qt!==null;){switch(n=qt,x=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&x!==null){e=void 0,l=n,f=x.memoizedProps,x=x.memoizedState,i=l.stateNode;try{var we=Mr(l.type,f);e=i.getSnapshotBeforeUpdate(we,x),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){st(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Ku(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ku(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,qt=e;break}qt=n.return}}function rh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Ca(e,l),i&4&&ds(5,l);break;case 1:if(Ca(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){st(l,l.return,j)}else{var f=Mr(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){st(l,l.return,j)}}i&64&&Zm(l),i&512&&fs(l,l.return);break;case 3:if(Ca(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Vp(e,n)}catch(j){st(l,l.return,j)}}break;case 27:n===null&&i&4&&nh(l);case 26:case 5:Ca(e,l),n===null&&i&4&&eh(l),i&512&&fs(l,l.return);break;case 12:Ca(e,l);break;case 31:Ca(e,l),i&4&&ih(e,l);break;case 13:Ca(e,l),i&4&&oh(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=h1.bind(null,l),_1(e,l))));break;case 22:if(i=l.memoizedState!==null||ka,!i){n=n!==null&&n.memoizedState!==null||It,f=ka;var x=It;ka=i,(It=n)&&!x?Ea(e,l,(l.subtreeFlags&8772)!==0):Ca(e,l),ka=f,It=x}break;case 30:break;default:Ca(e,l)}}function lh(e){var n=e.alternate;n!==null&&(e.alternate=null,lh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&ec(n)),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 St=null,mn=!1;function wa(e,n,l){for(l=l.child;l!==null;)sh(e,n,l),l=l.sibling}function sh(e,n,l){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Mn,l)}catch{}switch(l.tag){case 26:It||la(l,n),wa(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:It||la(l,n);var i=St,f=mn;Za(l.type)&&(St=l.stateNode,mn=!1),wa(e,n,l),js(l.stateNode),St=i,mn=f;break;case 5:It||la(l,n);case 6:if(i=St,f=mn,St=null,wa(e,n,l),St=i,mn=f,St!==null)if(mn)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(l.stateNode)}catch(x){st(l,n,x)}else try{St.removeChild(l.stateNode)}catch(x){st(l,n,x)}break;case 18:St!==null&&(mn?(e=St,Zh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),El(e)):Zh(St,l.stateNode));break;case 4:i=St,f=mn,St=l.stateNode.containerInfo,mn=!0,wa(e,n,l),St=i,mn=f;break;case 0:case 11:case 14:case 15:Ga(2,l,n),It||Ga(4,l,n),wa(e,n,l);break;case 1:It||(la(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&Jm(l,n,i)),wa(e,n,l);break;case 21:wa(e,n,l);break;case 22:It=(i=It)||l.memoizedState!==null,wa(e,n,l),It=i;break;default:wa(e,n,l)}}function ih(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{El(e)}catch(l){st(n,n.return,l)}}}function oh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{El(e)}catch(l){st(n,n.return,l)}}function i1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ah),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ah),n;default:throw Error(o(435,e.tag))}}function Pi(e,n){var l=i1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=x1.bind(null,e,i);i.then(f,f)}})}function hn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],x=e,j=n,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(Za(R.type)){St=R.stateNode,mn=!1;break e}break;case 5:St=R.stateNode,mn=!1;break e;case 3:case 4:St=R.stateNode.containerInfo,mn=!0;break e}R=R.return}if(St===null)throw Error(o(160));sh(x,j,f),St=null,mn=!1,x=f.alternate,x!==null&&(x.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)ch(n,e),n=n.sibling}var Kn=null;function ch(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),xn(e),i&4&&(Ga(3,e,e.return),ds(3,e),Ga(5,e,e.return));break;case 1:hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),i&64&&ka&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var f=Kn;if(hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),i&4){var x=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(i){case"title":x=f.getElementsByTagName("title")[0],(!x||x[Ul]||x[Ht]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=f.createElement(i),f.head.insertBefore(x,f.querySelector("head > title"))),Zt(x,i,l),x[Ht]=e,Wt(x),i=x;break e;case"link":var j=cx("link","href",f).get(i+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(x=j[R],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(R,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;case"meta":if(j=cx("meta","content",f).get(i+(l.content||""))){for(R=0;R<j.length;R++)if(x=j[R],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(R,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;default:throw Error(o(468,i))}x[Ht]=e,Wt(x),i=x}e.stateNode=i}else ux(f,e.type,e.stateNode);else e.stateNode=ox(f,i,e.memoizedProps);else x!==i?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,i===null?ux(f,e.type,e.stateNode):ox(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&ju(e,e.memoizedProps,l.memoizedProps)}break;case 27:hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),l!==null&&i&4&&ju(e,e.memoizedProps,l.memoizedProps);break;case 5:if(hn(n,e),xn(e),i&512&&(It||l===null||la(l,l.return)),e.flags&32){f=e.stateNode;try{Kr(f,"")}catch(we){st(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,ju(e,f,l!==null?l.memoizedProps:f)),i&1024&&(wu=!0);break;case 6:if(hn(n,e),xn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){st(e,e.return,we)}}break;case 3:if(lo=null,f=Kn,Kn=ao(n.containerInfo),hn(n,e),Kn=f,xn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{El(n.containerInfo)}catch(we){st(e,e.return,we)}wu&&(wu=!1,uh(e));break;case 4:i=Kn,Kn=ao(e.stateNode.containerInfo),hn(n,e),xn(e),Kn=i;break;case 12:hn(n,e),xn(e);break;case 31:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 13:hn(n,e),xn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Gi=Qe()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=ka,le=It;if(ka=Z||f,It=le||P,hn(n,e),It=le,ka=Z,xn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||ka||It||Lr(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(x=P.stateNode,f)j=x.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var ue=P.memoizedProps.style,ee=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;R.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(we){st(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){st(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var ae=P.stateNode;f?Jh(ae,!0):Jh(P.stateNode,!1)}catch(we){st(P,P.return,we)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Pi(e,l))));break;case 19:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Pi(e,i)));break;case 30:break;case 21:break;default:hn(n,e),xn(e)}}function xn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(th(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,x=Su(e);Vi(e,x,f);break;case 5:var j=l.stateNode;l.flags&32&&(Kr(j,""),l.flags&=-33);var R=Su(e);Vi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=Su(e);ku(e,Z,P);break;default:throw Error(o(161))}}catch(le){st(e,e.return,le)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function uh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;uh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Ca(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)rh(e,n.alternate,n),n=n.sibling}function Lr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ga(4,n,n.return),Lr(n);break;case 1:la(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&Jm(n,n.return,l),Lr(n);break;case 27:js(n.stateNode);case 26:case 5:la(n,n.return),Lr(n);break;case 22:n.memoizedState===null&&Lr(n);break;case 30:Lr(n);break;default:Lr(n)}e=e.sibling}}function Ea(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,x=n,j=x.flags;switch(x.tag){case 0:case 11:case 15:Ea(f,x,l),ds(4,x);break;case 1:if(Ea(f,x,l),i=x,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){st(i,i.return,Z)}if(i=x,f=i.updateQueue,f!==null){var R=i.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)$p(P[f],R)}catch(Z){st(i,i.return,Z)}}l&&j&64&&Zm(x),fs(x,x.return);break;case 27:nh(x);case 26:case 5:Ea(f,x,l),l&&i===null&&j&4&&eh(x),fs(x,x.return);break;case 12:Ea(f,x,l);break;case 31:Ea(f,x,l),l&&j&4&&ih(f,x);break;case 13:Ea(f,x,l),l&&j&4&&oh(f,x);break;case 22:x.memoizedState===null&&Ea(f,x,l),fs(x,x.return);break;case 30:break;default:Ea(f,x,l)}n=n.sibling}}function Cu(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&Zl(l))}function Eu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e))}function Xn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)dh(e,n,l,i),n=n.sibling}function dh(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Xn(e,n,l,i),f&2048&&ds(9,n);break;case 1:Xn(e,n,l,i);break;case 3:Xn(e,n,l,i),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e)));break;case 12:if(f&2048){Xn(e,n,l,i),e=n.stateNode;try{var x=n.memoizedProps,j=x.id,R=x.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){st(n,n.return,P)}}else Xn(e,n,l,i);break;case 31:Xn(e,n,l,i);break;case 13:Xn(e,n,l,i);break;case 23:break;case 22:x=n.stateNode,j=n.alternate,n.memoizedState!==null?x._visibility&2?Xn(e,n,l,i):ps(e,n):x._visibility&2?Xn(e,n,l,i):(x._visibility|=2,hl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Cu(j,n);break;case 24:Xn(e,n,l,i),f&2048&&Eu(n.alternate,n);break;default:Xn(e,n,l,i)}}function hl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var x=e,j=n,R=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:hl(x,j,R,P,f),ds(8,j);break;case 23:break;case 22:var le=j.stateNode;j.memoizedState!==null?le._visibility&2?hl(x,j,R,P,f):ps(x,j):(le._visibility|=2,hl(x,j,R,P,f)),f&&Z&2048&&Cu(j.alternate,j);break;case 24:hl(x,j,R,P,f),f&&Z&2048&&Eu(j.alternate,j);break;default:hl(x,j,R,P,f)}n=n.sibling}}function ps(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,f=i.flags;switch(i.tag){case 22:ps(l,i),f&2048&&Cu(i.alternate,i);break;case 24:ps(l,i),f&2048&&Eu(i.alternate,i);break;default:ps(l,i)}n=n.sibling}}var ms=8192;function xl(e,n,l){if(e.subtreeFlags&ms)for(e=e.child;e!==null;)fh(e,n,l),e=e.sibling}function fh(e,n,l){switch(e.tag){case 26:xl(e,n,l),e.flags&ms&&e.memoizedState!==null&&q1(l,Kn,e.memoizedState,e.memoizedProps);break;case 5:xl(e,n,l);break;case 3:case 4:var i=Kn;Kn=ao(e.stateNode.containerInfo),xl(e,n,l),Kn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=ms,ms=16777216,xl(e,n,l),ms=i):xl(e,n,l));break;default:xl(e,n,l)}}function ph(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function hs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,hh(i,e)}ph(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)mh(e),e=e.sibling}function mh(e){switch(e.tag){case 0:case 11:case 15:hs(e),e.flags&2048&&Ga(9,e,e.return);break;case 3:hs(e);break;case 12:hs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Fi(e)):hs(e);break;default:hs(e)}}function Fi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,hh(i,e)}ph(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ga(8,n,n.return),Fi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Fi(n));break;default:Fi(n)}e=e.sibling}}function hh(e,n){for(;qt!==null;){var l=qt;switch(l.tag){case 0:case 11:case 15:Ga(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Zl(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,qt=i;else e:for(l=e;qt!==null;){i=qt;var f=i.sibling,x=i.return;if(lh(i),i===l){qt=null;break e}if(f!==null){f.return=x,qt=f;break e}qt=x}}}var o1={getCacheForType:function(e){var n=Xt(_t),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Xt(_t).controller.signal}},c1=typeof WeakMap=="function"?WeakMap:Map,nt=0,mt=null,Ge=null,qe=0,lt=0,kn=null,Wa=!1,gl=!1,Nu=!1,Na=0,At=0,qa=0,zr=0,Tu=0,wn=0,vl=0,xs=null,gn=null,Ru=!1,Gi=0,xh=0,Wi=1/0,qi=null,Ya=null,$t=0,Ka=null,yl=null,Ta=0,Au=0,Mu=null,gh=null,gs=0,Lu=null;function Cn(){return(nt&2)!==0&&qe!==0?qe&-qe:L.T!==null?Iu():it()}function vh(){if(wn===0)if((qe&536870912)===0||Ke){var e=oe;oe<<=1,(oe&3932160)===0&&(oe=262144),wn=e}else wn=536870912;return e=jn.current,e!==null&&(e.flags|=32),wn}function vn(e,n,l){(e===mt&&(lt===2||lt===9)||e.cancelPendingCommit!==null)&&(bl(e,0),Xa(e,qe,wn,!1)),fr(e,l),((nt&2)===0||e!==mt)&&(e===mt&&((nt&2)===0&&(zr|=l),At===4&&Xa(e,qe,wn,!1)),sa(e))}function yh(e,n,l){if((nt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||fn(e,n),f=i?f1(e,n):Du(e,n,!0),x=i;do{if(f===0){gl&&!i&&Xa(e,n,0,!1);break}else{if(l=e.current.alternate,x&&!u1(l)){f=Du(e,n,!1),x=!1;continue}if(f===2){if(x=n,e.errorRecoveryDisabledLanes&x)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var R=e;f=xs;var P=R.current.memoizedState.isDehydrated;if(P&&(bl(R,j).flags|=256),j=Du(R,j,!1),j!==2){if(Nu&&!P){R.errorRecoveryDisabledLanes|=x,zr|=x,f=4;break e}x=gn,gn=f,x!==null&&(gn===null?gn=x:gn.push.apply(gn,x))}f=j}if(x=!1,f!==2)continue}}if(f===1){bl(e,0),Xa(e,n,0,!0);break}e:{switch(i=e,x=f,x){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Xa(i,n,wn,!Wa);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Gi+300-Qe(),10<f)){if(Xa(i,n,wn,!Wa),dn(i,0,!0)!==0)break e;Ta=n,i.timeoutHandle=Xh(bh.bind(null,i,l,gn,qi,Ru,n,wn,zr,vl,Wa,x,"Throttled",-0,0),f);break e}bh(i,l,gn,qi,Ru,n,wn,zr,vl,Wa,x,null,-0,0)}}break}while(!0);sa(e)}function bh(e,n,l,i,f,x,j,R,P,Z,le,ue,ee,ae){if(e.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pa},fh(n,x,ue);var we=(x&62914560)===x?Gi-Qe():(x&4194048)===x?xh-Qe():0;if(we=Y1(ue,we),we!==null){Ta=x,e.cancelPendingCommit=we(Th.bind(null,e,n,x,l,i,f,j,R,P,le,ue,null,ee,ae)),Xa(e,x,j,!Z);return}}Th(e,n,x,l,i,f,j,R,P)}function u1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var f=l[i],x=f.getSnapshot;f=f.value;try{if(!yn(x(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Xa(e,n,l,i){n&=~Tu,n&=~zr,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var x=31-gt(f),j=1<<x;i[x]=-1,f&=~j}l!==0&&ta(e,l,n)}function Yi(){return(nt&6)===0?(vs(0),!1):!0}function zu(){if(Ge!==null){if(lt===0)var e=Ge.return;else e=Ge,ga=wr=null,Kc(e),ul=null,es=0,e=Ge;for(;e!==null;)Qm(e.alternate,e),e=e.return;Ge=null}}function bl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,A1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Ta=0,zu(),mt=e,Ge=l=ha(e.current,null),qe=n,lt=0,kn=null,Wa=!1,gl=fn(e,n),Nu=!1,vl=wn=Tu=zr=qa=At=0,gn=xs=null,Ru=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var f=31-gt(i),x=1<<f;n|=e[f],i&=~x}return Na=n,hi(),l}function jh(e,n){He=null,L.H=os,n===cl||n===ki?(n=Bp(),lt=3):n===Bc?(n=Bp(),lt=4):lt=n===du?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,Ge===null&&(At=1,Bi(e,_n(n,e.current)))}function Sh(){var e=jn.current;return e===null?!0:(qe&4194048)===qe?Un===null:(qe&62914560)===qe||(qe&536870912)!==0?e===Un:!1}function kh(){var e=L.H;return L.H=os,e===null?os:e}function wh(){var e=L.A;return L.A=o1,e}function Ki(){At=4,Wa||(qe&4194048)!==qe&&jn.current!==null||(gl=!0),(qa&134217727)===0&&(zr&134217727)===0||mt===null||Xa(mt,qe,wn,!1)}function Du(e,n,l){var i=nt;nt|=2;var f=kh(),x=wh();(mt!==e||qe!==n)&&(qi=null,bl(e,n)),n=!1;var j=At;e:do try{if(lt!==0&&Ge!==null){var R=Ge,P=kn;switch(lt){case 8:zu(),j=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(n=!0);var Z=lt;if(lt=0,kn=null,jl(e,R,P,Z),l&&gl){j=0;break e}break;default:Z=lt,lt=0,kn=null,jl(e,R,P,Z)}}d1(),j=At;break}catch(le){jh(e,le)}while(!0);return n&&e.shellSuspendCounter++,ga=wr=null,nt=i,L.H=f,L.A=x,Ge===null&&(mt=null,qe=0,hi()),j}function d1(){for(;Ge!==null;)Ch(Ge)}function f1(e,n){var l=nt;nt|=2;var i=kh(),f=wh();mt!==e||qe!==n?(qi=null,Wi=Qe()+500,bl(e,n)):gl=fn(e,n);e:do try{if(lt!==0&&Ge!==null){n=Ge;var x=kn;t:switch(lt){case 1:lt=0,kn=null,jl(e,n,x,1);break;case 2:case 9:if(_p(x)){lt=0,kn=null,Eh(n);break}n=function(){lt!==2&&lt!==9||mt!==e||(lt=7),sa(e)},x.then(n,n);break e;case 3:lt=7;break e;case 4:lt=5;break e;case 7:_p(x)?(lt=0,kn=null,Eh(n)):(lt=0,kn=null,jl(e,n,x,7));break;case 5:var j=null;switch(Ge.tag){case 26:j=Ge.memoizedState;case 5:case 27:var R=Ge;if(j?dx(j):R.stateNode.complete){lt=0,kn=null;var P=R.sibling;if(P!==null)Ge=P;else{var Z=R.return;Z!==null?(Ge=Z,Xi(Z)):Ge=null}break t}}lt=0,kn=null,jl(e,n,x,5);break;case 6:lt=0,kn=null,jl(e,n,x,6);break;case 8:zu(),At=6;break e;default:throw Error(o(462))}}p1();break}catch(le){jh(e,le)}while(!0);return ga=wr=null,L.H=i,L.A=f,nt=l,Ge!==null?0:(mt=null,qe=0,hi(),At)}function p1(){for(;Ge!==null&&!Dt();)Ch(Ge)}function Ch(e){var n=Km(e.alternate,e,Na);e.memoizedProps=e.pendingProps,n===null?Xi(e):Ge=n}function Eh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Pm(l,n,n.pendingProps,n.type,void 0,qe);break;case 11:n=Pm(l,n,n.pendingProps,n.type.render,n.ref,qe);break;case 5:Kc(n);default:Qm(l,n),n=Ge=wp(n,Na),n=Km(l,n,Na)}e.memoizedProps=e.pendingProps,n===null?Xi(e):Ge=n}function jl(e,n,l,i){ga=wr=null,Kc(n),ul=null,es=0;var f=n.return;try{if(t1(e,f,n,l,qe)){At=1,Bi(e,_n(l,e.current)),Ge=null;return}}catch(x){if(f!==null)throw Ge=f,x;At=1,Bi(e,_n(l,e.current)),Ge=null;return}n.flags&32768?(Ke||i===1?e=!0:gl||(qe&536870912)!==0?e=!1:(Wa=e=!0,(i===2||i===9||i===3||i===6)&&(i=jn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Nh(n,e)):Xi(n)}function Xi(e){var n=e;do{if((n.flags&32768)!==0){Nh(n,Wa);return}e=n.return;var l=r1(n.alternate,n,Na);if(l!==null){Ge=l;return}if(n=n.sibling,n!==null){Ge=n;return}Ge=n=e}while(n!==null);At===0&&(At=5)}function Nh(e,n){do{var l=l1(e.alternate,e);if(l!==null){l.flags&=32767,Ge=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ge=e;return}Ge=e=l}while(e!==null);At=6,Ge=null}function Th(e,n,l,i,f,x,j,R,P){e.cancelPendingCommit=null;do Qi();while($t!==0);if((nt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(x=n.lanes|n.childLanes,x|=Sc,Il(e,l,x,j,R,P),e===mt&&(Ge=mt=null,qe=0),yl=n,Ka=e,Ta=l,Au=x,Mu=f,gh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,g1(Ct,function(){return zh(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=L.T,L.T=null,f=_.p,_.p=2,j=nt,nt|=4;try{s1(e,n,l)}finally{nt=j,_.p=f,L.T=i}}$t=1,Rh(),Ah(),Mh()}}function Rh(){if($t===1){$t=0;var e=Ka,n=yl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{ch(n,e);var x=Wu,j=hp(e.containerInfo),R=x.focusedElem,P=x.selectionRange;if(j!==R&&R&&R.ownerDocument&&mp(R.ownerDocument.documentElement,R)){if(P!==null&&gc(R)){var Z=P.start,le=P.end;if(le===void 0&&(le=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(le,R.value.length);else{var ue=R.ownerDocument||document,ee=ue&&ue.defaultView||window;if(ee.getSelection){var ae=ee.getSelection(),we=R.textContent.length,Le=Math.min(P.start,we),dt=P.end===void 0?Le:Math.min(P.end,we);!ae.extend&&Le>dt&&(j=dt,dt=Le,Le=j);var K=pp(R,Le),G=pp(R,dt);if(K&&G&&(ae.rangeCount!==1||ae.anchorNode!==K.node||ae.anchorOffset!==K.offset||ae.focusNode!==G.node||ae.focusOffset!==G.offset)){var Q=ue.createRange();Q.setStart(K.node,K.offset),ae.removeAllRanges(),Le>dt?(ae.addRange(Q),ae.extend(G.node,G.offset)):(Q.setEnd(G.node,G.offset),ae.addRange(Q))}}}}for(ue=[],ae=R;ae=ae.parentNode;)ae.nodeType===1&&ue.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<ue.length;R++){var ce=ue[R];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}co=!!Gu,Wu=Gu=null}finally{nt=f,_.p=i,L.T=l}}e.current=n,$t=2}}function Ah(){if($t===2){$t=0;var e=Ka,n=yl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{rh(e,n.alternate,n)}finally{nt=f,_.p=i,L.T=l}}$t=3}}function Mh(){if($t===4||$t===3){$t=0,Tt();var e=Ka,n=yl,l=Ta,i=gh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?$t=5:($t=0,yl=Ka=null,Lh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Ya=null),Da(l),n=n.stateNode,Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Mn,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=L.T,f=_.p,_.p=2,L.T=null;try{for(var x=e.onRecoverableError,j=0;j<i.length;j++){var R=i[j];x(R.value,{componentStack:R.stack})}}finally{L.T=n,_.p=f}}(Ta&3)!==0&&Qi(),sa(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Lu?gs++:(gs=0,Lu=e):gs=0,vs(0)}}function Lh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Zl(n)))}function Qi(){return Rh(),Ah(),Mh(),zh()}function zh(){if($t!==5)return!1;var e=Ka,n=Au;Au=0;var l=Da(Ta),i=L.T,f=_.p;try{_.p=32>l?32:l,L.T=null,l=Mu,Mu=null;var x=Ka,j=Ta;if($t=0,yl=Ka=null,Ta=0,(nt&6)!==0)throw Error(o(331));var R=nt;if(nt|=4,mh(x.current),dh(x,x.current,j,l),nt=R,vs(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Mn,x)}catch{}return!0}finally{_.p=f,L.T=i,Lh(e,n)}}function Dh(e,n,l){n=_n(l,n),n=uu(e.stateNode,n,2),e=Va(e,n,2),e!==null&&(fr(e,2),sa(e))}function st(e,n,l){if(e.tag===3)Dh(e,e,l);else for(;n!==null;){if(n.tag===3){Dh(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Ya===null||!Ya.has(i))){e=_n(l,e),l=_m(2),i=Va(n,l,2),i!==null&&(Om(l,i,n,e),fr(i,2),sa(i));break}}n=n.return}}function _u(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new c1;var f=new Set;i.set(n,f)}else f=i.get(n),f===void 0&&(f=new Set,i.set(n,f));f.has(l)||(Nu=!0,f.add(l),e=m1.bind(null,e,n,l),n.then(e,e))}function m1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,mt===e&&(qe&l)===l&&(At===4||At===3&&(qe&62914560)===qe&&300>Qe()-Gi?(nt&2)===0&&bl(e,0):Tu|=l,vl===qe&&(vl=0)),sa(e)}function _h(e,n){n===0&&(n=qn()),e=jr(e,n),e!==null&&(fr(e,n),sa(e))}function h1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),_h(e,l)}function x1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),_h(e,l)}function g1(e,n){return Nt(e,n)}var Zi=null,Sl=null,Ou=!1,Ji=!1,Bu=!1,Qa=0;function sa(e){e!==Sl&&e.next===null&&(Sl===null?Zi=Sl=e:Sl=Sl.next=e),Ji=!0,Ou||(Ou=!0,y1())}function vs(e,n){if(!Bu&&Ji){Bu=!0;do for(var l=!1,i=Zi;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var x=0;else{var j=i.suspendedLanes,R=i.pingedLanes;x=(1<<31-gt(42|e)+1)-1,x&=f&~(j&~R),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,Uh(i,x))}else x=qe,x=dn(i,i===mt?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||fn(i,x)||(l=!0,Uh(i,x));i=i.next}while(l);Bu=!1}}function v1(){Oh()}function Oh(){Ji=Ou=!1;var e=0;Qa!==0&&R1()&&(e=Qa);for(var n=Qe(),l=null,i=Zi;i!==null;){var f=i.next,x=Bh(i,n);x===0?(i.next=null,l===null?Zi=f:l.next=f,f===null&&(Sl=l)):(l=i,(e!==0||(x&3)!==0)&&(Ji=!0)),i=f}$t!==0&&$t!==5||vs(e),Qa!==0&&(Qa=0)}function Bh(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,x=e.pendingLanes&-62914561;0<x;){var j=31-gt(x),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&i)!==0)&&(f[j]=ai(R,n)):P<=n&&(e.expiredLanes|=R),x&=~R}if(n=mt,l=qe,l=dn(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(lt===2||lt===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&ht(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||fn(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&ht(i),Da(l)){case 2:case 8:l=pt;break;case 32:l=Ct;break;case 268435456:l=un;break;default:l=Ct}return i=Ih.bind(null,e),l=Nt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&ht(i),e.callbackPriority=2,e.callbackNode=null,2}function Ih(e,n){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Qi()&&e.callbackNode!==l)return null;var i=qe;return i=dn(e,e===mt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(yh(e,i,n),Bh(e,Qe()),e.callbackNode!=null&&e.callbackNode===l?Ih.bind(null,e):null)}function Uh(e,n){if(Qi())return null;yh(e,n,!0)}function y1(){M1(function(){(nt&6)!==0?Nt(be,v1):Oh()})}function Iu(){if(Qa===0){var e=il;e===0&&(e=Et,Et<<=1,(Et&261888)===0&&(Et=256)),Qa=e}return Qa}function Hh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ii(""+e)}function $h(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function b1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var x=Hh((f[ot]||null).action),j=i.submitter;j&&(n=(n=j[ot]||null)?Hh(n.formAction):j.getAttribute("formAction"),n!==null&&(x=n,j=null));var R=new di("action","action",null,i,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Qa!==0){var P=j?$h(f,j):new FormData(f);ru(l,{pending:!0,data:P,method:f.method,action:x},null,P)}}else typeof x=="function"&&(R.preventDefault(),P=j?$h(f,j):new FormData(f),ru(l,{pending:!0,data:P,method:f.method,action:x},x,P))},currentTarget:f}]})}}for(var Uu=0;Uu<jc.length;Uu++){var Hu=jc[Uu],j1=Hu.toLowerCase(),S1=Hu[0].toUpperCase()+Hu.slice(1);Yn(j1,"on"+S1)}Yn(vp,"onAnimationEnd"),Yn(yp,"onAnimationIteration"),Yn(bp,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(Ib,"onTransitionRun"),Yn(Ub,"onTransitionStart"),Yn(Hb,"onTransitionCancel"),Yn(jp,"onTransitionEnd"),qr("onMouseEnter",["mouseout","mouseover"]),qr("onMouseLeave",["mouseout","mouseover"]),qr("onPointerEnter",["pointerout","pointerover"]),qr("onPointerLeave",["pointerout","pointerover"]),gr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),gr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),gr("onBeforeInput",["compositionend","keypress","textInput","paste"]),gr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),gr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),gr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ys="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(" "),k1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ys));function Vh(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],f=i.event;i=i.listeners;e:{var x=void 0;if(n)for(var j=i.length-1;0<=j;j--){var R=i[j],P=R.instance,Z=R.currentTarget;if(R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(le){mi(le)}f.currentTarget=null,x=P}else for(j=0;j<i.length;j++){if(R=i[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(le){mi(le)}f.currentTarget=null,x=P}}}}function We(e,n){var l=n[na];l===void 0&&(l=n[na]=new Set);var i=e+"__bubble";l.has(i)||(Ph(n,e,2,!1),l.add(i))}function $u(e,n,l){var i=0;n&&(i|=4),Ph(l,e,i,n)}var eo="_reactListening"+Math.random().toString(36).slice(2);function Vu(e){if(!e[eo]){e[eo]=!0,Of.forEach(function(l){l!=="selectionchange"&&(k1.has(l)||$u(l,!1,e),$u(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[eo]||(n[eo]=!0,$u("selectionchange",!1,n))}}function Ph(e,n,l,i){switch(vx(n)){case 2:var f=Q1;break;case 8:f=Z1;break;default:f=ad}l=f.bind(null,n,l,e),f=void 0,!oc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),i?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Pu(e,n,l,i,f){var x=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var j=i.tag;if(j===3||j===4){var R=i.stateNode.containerInfo;if(R===f)break;if(j===4)for(j=i.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;R!==null;){if(j=Fr(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=x=j;continue e}R=R.parentNode}}i=i.return}Yf(function(){var Z=x,le=sc(l),ue=[];e:{var ee=Sp.get(e);if(ee!==void 0){var ae=di,we=e;switch(e){case"keypress":if(ci(l)===0)break e;case"keydown":case"keyup":ae=xb;break;case"focusin":we="focus",ae=fc;break;case"focusout":we="blur",ae=fc;break;case"beforeblur":case"afterblur":ae=fc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=Qf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=rb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=yb;break;case vp:case yp:case bp:ae=ib;break;case jp:ae=jb;break;case"scroll":case"scrollend":ae=nb;break;case"wheel":ae=kb;break;case"copy":case"cut":case"paste":ae=cb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Jf;break;case"toggle":case"beforetoggle":ae=Cb}var Le=(n&4)!==0,dt=!Le&&(e==="scroll"||e==="scrollend"),K=Le?ee!==null?ee+"Capture":null:ee;Le=[];for(var G=Z,Q;G!==null;){var ce=G;if(Q=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||Q===null||K===null||(ce=$l(G,K),ce!=null&&Le.push(bs(G,ce,Q))),dt)break;G=G.return}0<Le.length&&(ee=new ae(ee,we,null,l,le),ue.push({event:ee,listeners:Le}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",ae=e==="mouseout"||e==="pointerout",ee&&l!==lc&&(we=l.relatedTarget||l.fromElement)&&(Fr(we)||we[xr]))break e;if((ae||ee)&&(ee=le.window===le?le:(ee=le.ownerDocument)?ee.defaultView||ee.parentWindow:window,ae?(we=l.relatedTarget||l.toElement,ae=Z,we=we?Fr(we):null,we!==null&&(dt=u(we),Le=we.tag,we!==dt||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(ae=null,we=Z),ae!==we)){if(Le=Qf,ce="onMouseLeave",K="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Le=Jf,ce="onPointerLeave",K="onPointerEnter",G="pointer"),dt=ae==null?ee:Hl(ae),Q=we==null?ee:Hl(we),ee=new Le(ce,G+"leave",ae,l,le),ee.target=dt,ee.relatedTarget=Q,ce=null,Fr(le)===Z&&(Le=new Le(K,G+"enter",we,l,le),Le.target=Q,Le.relatedTarget=dt,ce=Le),dt=ce,ae&&we)t:{for(Le=w1,K=ae,G=we,Q=0,ce=K;ce;ce=Le(ce))Q++;ce=0;for(var Me=G;Me;Me=Le(Me))ce++;for(;0<Q-ce;)K=Le(K),Q--;for(;0<ce-Q;)G=Le(G),ce--;for(;Q--;){if(K===G||G!==null&&K===G.alternate){Le=K;break t}K=Le(K),G=Le(G)}Le=null}else Le=null;ae!==null&&Fh(ue,ee,ae,Le,!1),we!==null&&dt!==null&&Fh(ue,dt,we,Le,!0)}}e:{if(ee=Z?Hl(Z):window,ae=ee.nodeName&&ee.nodeName.toLowerCase(),ae==="select"||ae==="input"&&ee.type==="file")var Ze=ip;else if(lp(ee))if(op)Ze=_b;else{Ze=zb;var Ne=Lb}else ae=ee.nodeName,!ae||ae.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&rc(Z.elementType)&&(Ze=ip):Ze=Db;if(Ze&&(Ze=Ze(e,Z))){sp(ue,Ze,l,le);break e}Ne&&Ne(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&ac(ee,"number",ee.value)}switch(Ne=Z?Hl(Z):window,e){case"focusin":(lp(Ne)||Ne.contentEditable==="true")&&(Jr=Ne,vc=Z,Kl=null);break;case"focusout":Kl=vc=Jr=null;break;case"mousedown":yc=!0;break;case"contextmenu":case"mouseup":case"dragend":yc=!1,xp(ue,l,le);break;case"selectionchange":if(Bb)break;case"keydown":case"keyup":xp(ue,l,le)}var Ve;if(mc)e:{switch(e){case"compositionstart":var Ye="onCompositionStart";break e;case"compositionend":Ye="onCompositionEnd";break e;case"compositionupdate":Ye="onCompositionUpdate";break e}Ye=void 0}else Zr?ap(e,l)&&(Ye="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ye="onCompositionStart");Ye&&(ep&&l.locale!=="ko"&&(Zr||Ye!=="onCompositionStart"?Ye==="onCompositionEnd"&&Zr&&(Ve=Kf()):(_a=le,cc="value"in _a?_a.value:_a.textContent,Zr=!0)),Ne=to(Z,Ye),0<Ne.length&&(Ye=new Zf(Ye,e,null,l,le),ue.push({event:Ye,listeners:Ne}),Ve?Ye.data=Ve:(Ve=rp(l),Ve!==null&&(Ye.data=Ve)))),(Ve=Nb?Tb(e,l):Rb(e,l))&&(Ye=to(Z,"onBeforeInput"),0<Ye.length&&(Ne=new Zf("onBeforeInput","beforeinput",null,l,le),ue.push({event:Ne,listeners:Ye}),Ne.data=Ve)),b1(ue,e,Z,l,le)}Vh(ue,n)})}function bs(e,n,l){return{instance:e,listener:n,currentTarget:l}}function to(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,x=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||x===null||(f=$l(e,l),f!=null&&i.unshift(bs(e,f,x)),f=$l(e,n),f!=null&&i.push(bs(e,f,x))),e.tag===3)return i;e=e.return}return[]}function w1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Fh(e,n,l,i,f){for(var x=n._reactName,j=[];l!==null&&l!==i;){var R=l,P=R.alternate,Z=R.stateNode;if(R=R.tag,P!==null&&P===i)break;R!==5&&R!==26&&R!==27||Z===null||(P=Z,f?(Z=$l(l,x),Z!=null&&j.unshift(bs(l,Z,P))):f||(Z=$l(l,x),Z!=null&&j.push(bs(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var C1=/\r\n?/g,E1=/\u0000|\uFFFD/g;function Gh(e){return(typeof e=="string"?e:""+e).replace(C1,`
50
+ `).replace(E1,"")}function Wh(e,n){return n=Gh(n),Gh(e)===n}function ut(e,n,l,i,f,x){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Kr(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Kr(e,""+i);break;case"className":li(e,"class",i);break;case"tabIndex":li(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":li(e,l,i);break;case"style":Wf(e,i,x);break;case"data":if(n!=="object"){li(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ii(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"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 x=="function"&&(l==="formAction"?(n!=="input"&&ut(e,n,"name",f.name,f,null),ut(e,n,"formEncType",f.formEncType,f,null),ut(e,n,"formMethod",f.formMethod,f,null),ut(e,n,"formTarget",f.formTarget,f,null)):(ut(e,n,"encType",f.encType,f,null),ut(e,n,"method",f.method,f,null),ut(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ii(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=pa);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=ii(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);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":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":We("beforetoggle",e),We("toggle",e),ri(e,"popover",i);break;case"xlinkActuate":fa(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":fa(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":fa(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":fa(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":fa(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":fa(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":fa(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":fa(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":fa(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":ri(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=eb.get(l)||l,ri(e,l,i))}}function Fu(e,n,l,i,f,x){switch(l){case"style":Wf(e,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Kr(e,i):(typeof i=="number"||typeof i=="bigint")&&Kr(e,""+i);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"onClick":i!=null&&(e.onclick=pa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),x=e[ot]||null,x=x!=null?x[l]:null,typeof x=="function"&&e.removeEventListener(n,x,f),typeof i=="function")){typeof x!="function"&&x!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,f);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):ri(e,l,i)}}}function Zt(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var i=!1,f=!1,x;for(x in l)if(l.hasOwnProperty(x)){var j=l[x];if(j!=null)switch(x){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,x,j,l,null)}}f&&ut(e,n,"srcSet",l.srcSet,l,null),i&&ut(e,n,"src",l.src,l,null);return;case"input":We("invalid",e);var R=x=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var le=l[i];if(le!=null)switch(i){case"name":f=le;break;case"type":j=le;break;case"checked":P=le;break;case"defaultChecked":Z=le;break;case"value":x=le;break;case"defaultValue":R=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(o(137,n));break;default:ut(e,n,i,le,l,null)}}Vf(e,x,R,P,Z,j,f,!1);return;case"select":We("invalid",e),i=j=x=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":x=R;break;case"defaultValue":j=R;break;case"multiple":i=R;default:ut(e,n,f,R,l,null)}n=x,l=j,e.multiple=!!i,n!=null?Yr(e,!!i,n,!1):l!=null&&Yr(e,!!i,l,!0);return;case"textarea":We("invalid",e),x=f=i=null;for(j in l)if(l.hasOwnProperty(j)&&(R=l[j],R!=null))switch(j){case"value":i=R;break;case"defaultValue":f=R;break;case"children":x=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:ut(e,n,j,R,l,null)}Ff(e,i,f,x);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(i=l[P],i!=null))switch(P){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:ut(e,n,P,i,l,null)}return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(i=0;i<ys.length;i++)We(ys[i],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("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(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,Z,i,l,null)}return;default:if(rc(n)){for(le in l)l.hasOwnProperty(le)&&(i=l[le],i!==void 0&&Fu(e,n,le,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&ut(e,n,R,i,l,null))}function N1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,x=null,j=null,R=null,P=null,Z=null,le=null;for(ae in l){var ue=l[ae];if(l.hasOwnProperty(ae)&&ue!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":P=ue;default:i.hasOwnProperty(ae)||ut(e,n,ae,null,i,ue)}}for(var ee in i){var ae=i[ee];if(ue=l[ee],i.hasOwnProperty(ee)&&(ae!=null||ue!=null))switch(ee){case"type":x=ae;break;case"name":f=ae;break;case"checked":Z=ae;break;case"defaultChecked":le=ae;break;case"value":j=ae;break;case"defaultValue":R=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(o(137,n));break;default:ae!==ue&&ut(e,n,ee,ae,i,ue)}}nc(e,j,R,P,Z,le,x,f);return;case"select":ae=j=R=ee=null;for(x in l)if(P=l[x],l.hasOwnProperty(x)&&P!=null)switch(x){case"value":break;case"multiple":ae=P;default:i.hasOwnProperty(x)||ut(e,n,x,null,i,P)}for(f in i)if(x=i[f],P=l[f],i.hasOwnProperty(f)&&(x!=null||P!=null))switch(f){case"value":ee=x;break;case"defaultValue":R=x;break;case"multiple":j=x;default:x!==P&&ut(e,n,f,x,i,P)}n=R,l=j,i=ae,ee!=null?Yr(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Yr(e,!!l,n,!0):Yr(e,!!l,l?[]:"",!1));return;case"textarea":ae=ee=null;for(R in l)if(f=l[R],l.hasOwnProperty(R)&&f!=null&&!i.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:ut(e,n,R,null,i,f)}for(j in i)if(f=i[j],x=l[j],i.hasOwnProperty(j)&&(f!=null||x!=null))switch(j){case"value":ee=f;break;case"defaultValue":ae=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==x&&ut(e,n,j,f,i,x)}Pf(e,ee,ae);return;case"option":for(var we in l)if(ee=l[we],l.hasOwnProperty(we)&&ee!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:ut(e,n,we,null,i,ee)}for(P in i)if(ee=i[P],ae=l[P],i.hasOwnProperty(P)&&ee!==ae&&(ee!=null||ae!=null))switch(P){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:ut(e,n,P,ee,i,ae)}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 Le in l)ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!i.hasOwnProperty(Le)&&ut(e,n,Le,null,i,ee);for(Z in i)if(ee=i[Z],ae=l[Z],i.hasOwnProperty(Z)&&ee!==ae&&(ee!=null||ae!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:ut(e,n,Z,ee,i,ae)}return;default:if(rc(n)){for(var dt in l)ee=l[dt],l.hasOwnProperty(dt)&&ee!==void 0&&!i.hasOwnProperty(dt)&&Fu(e,n,dt,void 0,i,ee);for(le in i)ee=i[le],ae=l[le],!i.hasOwnProperty(le)||ee===ae||ee===void 0&&ae===void 0||Fu(e,n,le,ee,i,ae);return}}for(var K in l)ee=l[K],l.hasOwnProperty(K)&&ee!=null&&!i.hasOwnProperty(K)&&ut(e,n,K,null,i,ee);for(ue in i)ee=i[ue],ae=l[ue],!i.hasOwnProperty(ue)||ee===ae||ee==null&&ae==null||ut(e,n,ue,ee,i,ae)}function qh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function T1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var f=l[i],x=f.transferSize,j=f.initiatorType,R=f.duration;if(x&&R&&qh(j)){for(j=0,R=f.responseEnd,i+=1;i<l.length;i++){var P=l[i],Z=P.startTime;if(Z>R)break;var le=P.transferSize,ue=P.initiatorType;le&&qh(ue)&&(P=P.responseEnd,j+=le*(P<R?1:(R-Z)/(P-Z)))}if(--i,n+=8*(x+j)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Gu=null,Wu=null;function no(e){return e.nodeType===9?e:e.ownerDocument}function Yh(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 Kh(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function qu(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Yu=null;function R1(){var e=window.event;return e&&e.type==="popstate"?e===Yu?!1:(Yu=e,!0):(Yu=null,!1)}var Xh=typeof setTimeout=="function"?setTimeout:void 0,A1=typeof clearTimeout=="function"?clearTimeout:void 0,Qh=typeof Promise=="function"?Promise:void 0,M1=typeof queueMicrotask=="function"?queueMicrotask:typeof Qh<"u"?function(e){return Qh.resolve(null).then(e).catch(L1)}:Xh;function L1(e){setTimeout(function(){throw e})}function Za(e){return e==="head"}function Zh(e,n){var l=n,i=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(f),El(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")js(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,js(l);for(var x=l.firstChild;x;){var j=x.nextSibling,R=x.nodeName;x[Ul]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=j}}else l==="body"&&js(e.ownerDocument.body);l=f}while(l);El(n)}function Jh(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Ku(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ku(l),ec(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function z1(e,n,l,i){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[Ul])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(x=e.getAttribute("rel"),x==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(x!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(x=e.getAttribute("src"),(x!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&x&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var x=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===x)return e}else return e;if(e=Hn(e.nextSibling),e===null)break}return null}function D1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Hn(e.nextSibling),e===null))return null;return e}function ex(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Hn(e.nextSibling),e===null))return null;return e}function Xu(e){return e.data==="$?"||e.data==="$~"}function Qu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function _1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function Hn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Zu=null;function tx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Hn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function nx(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function ax(e,n,l){switch(n=no(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function js(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);ec(e)}var $n=new Map,rx=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ra=_.d;_.d={f:O1,r:B1,D:I1,C:U1,L:H1,m:$1,X:P1,S:V1,M:F1};function O1(){var e=Ra.f(),n=Yi();return e||n}function B1(e){var n=Gr(e);n!==null&&n.tag===5&&n.type==="form"?jm(n):Ra.r(e)}var kl=typeof document>"u"?null:document;function lx(e,n,l){var i=kl;if(i&&typeof n=="string"&&n){var f=zn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),rx.has(f)||(rx.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function I1(e){Ra.D(e),lx("dns-prefetch",e,null)}function U1(e,n){Ra.C(e,n),lx("preconnect",e,n)}function H1(e,n,l){Ra.L(e,n,l);var i=kl;if(i&&e&&n){var f='link[rel="preload"][as="'+zn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+zn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+zn(l.imageSizes)+'"]')):f+='[href="'+zn(e)+'"]';var x=f;switch(n){case"style":x=wl(e);break;case"script":x=Cl(e)}$n.has(x)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),$n.set(x,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(Ss(x))||n==="script"&&i.querySelector(ks(x))||(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function $1(e,n){Ra.m(e,n);var l=kl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+zn(i)+'"][href="'+zn(e)+'"]',x=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Cl(e)}if(!$n.has(x)&&(e=v({rel:"modulepreload",href:e},n),$n.set(x,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ks(x)))return}i=l.createElement("link"),Zt(i,"link",e),Wt(i),l.head.appendChild(i)}}}function V1(e,n,l){Ra.S(e,n,l);var i=kl;if(i&&e){var f=Wr(i).hoistableStyles,x=wl(e);n=n||"default";var j=f.get(x);if(!j){var R={loading:0,preload:null};if(j=i.querySelector(Ss(x)))R.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=$n.get(x))&&Ju(e,l);var P=j=i.createElement("link");Wt(P),Zt(P,"link",e),P._p=new Promise(function(Z,le){P.onload=Z,P.onerror=le}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,ro(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(x,j)}}}function P1(e,n){Ra.X(e,n);var l=kl;if(l&&e){var i=Wr(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0},n),(n=$n.get(f))&&ed(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function F1(e,n){Ra.M(e,n);var l=kl;if(l&&e){var i=Wr(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0,type:"module"},n),(n=$n.get(f))&&ed(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function sx(e,n,l,i){var f=(f=ie.current)?ao(f):null;if(!f)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=wl(l.href),l=Wr(f).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=wl(l.href);var x=Wr(f).hoistableStyles,j=x.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=f.querySelector(Ss(e)))&&!x._p&&(j.instance=x,j.state.loading=5),$n.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},$n.set(e,l),x||G1(f,e,l,j.state))),n&&i===null)throw Error(o(528,""));return j}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Cl(l),l=Wr(f).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function wl(e){return'href="'+zn(e)+'"'}function Ss(e){return'link[rel="stylesheet"]['+e+"]"}function ix(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function G1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),Zt(n,"link",l),Wt(n),e.head.appendChild(n))}function Cl(e){return'[src="'+zn(e)+'"]'}function ks(e){return"script[async]"+e}function ox(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+zn(l.href)+'"]');if(i)return n.instance=i,Wt(i),i;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Wt(i),Zt(i,"style",f),ro(i,l.precedence,e),n.instance=i;case"stylesheet":f=wl(l.href);var x=e.querySelector(Ss(f));if(x)return n.state.loading|=4,n.instance=x,Wt(x),x;i=ix(l),(f=$n.get(f))&&Ju(i,f),x=(e.ownerDocument||e).createElement("link"),Wt(x);var j=x;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),Zt(x,"link",i),n.state.loading|=4,ro(x,l.precedence,e),n.instance=x;case"script":return x=Cl(l.src),(f=e.querySelector(ks(x)))?(n.instance=f,Wt(f),f):(i=l,(f=$n.get(x))&&(i=v({},l),ed(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Wt(f),Zt(f,"link",i),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,ro(i,l.precedence,e));return n.instance}function ro(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,x=f,j=0;j<i.length;j++){var R=i[j];if(R.dataset.precedence===n)x=R;else if(x!==f)break}x?x.parentNode.insertBefore(e,x.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function Ju(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function ed(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var lo=null;function cx(e,n,l){if(lo===null){var i=new Map,f=lo=new Map;f.set(l,i)}else f=lo,i=f.get(l),i||(i=new Map,f.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var x=l[f];if(!(x[Ul]||x[Ht]||e==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var j=x.getAttribute(n)||"";j=e+j;var R=i.get(j);R?R.push(x):i.set(j,[x])}}return i}function ux(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function W1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function dx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function q1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=wl(i.href),x=n.querySelector(Ss(f));if(x){n=x._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=so.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=x,Wt(x);return}x=n.ownerDocument||n,i=ix(i),(f=$n.get(f))&&Ju(i,f),x=x.createElement("link"),Wt(x);var j=x;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),Zt(x,"link",i),l.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=so.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var td=0;function Y1(e,n){return e.stylesheets&&e.count===0&&oo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&oo(e,e.stylesheets),e.unsuspend){var x=e.unsuspend;e.unsuspend=null,x()}},6e4+n);0<e.imgBytes&&td===0&&(td=62500*T1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oo(e,e.stylesheets),e.unsuspend)){var x=e.unsuspend;e.unsuspend=null,x()}},(e.imgBytes>td?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function so(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)oo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var io=null;function oo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,io=new Map,n.forEach(K1,e),io=null,so.call(e))}function K1(e,n){if(!(n.state.loading&4)){var l=io.get(e);if(l)var i=l.get(null);else{l=new Map,io.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<f.length;x++){var j=f[x];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),i=j)}i&&l.set(null,i)}f=n.instance,j=f.getAttribute("data-precedence"),x=l.get(j)||i,x===i&&l.set(null,f),l.set(j,f),this.count++,i=so.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),x?x.parentNode.insertBefore(f,x.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var ws={$$typeof:A,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function X1(e,n,l,i,f,x,j,R,P){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=Bl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bl(0),this.hiddenUpdates=Bl(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=x,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function fx(e,n,l,i,f,x,j,R,P,Z,le,ue){return e=new X1(e,n,l,j,P,Z,le,ue,R),n=1,x===!0&&(n|=24),x=bn(3,null,null,n),e.current=x,x.stateNode=e,n=Dc(),n.refCount++,e.pooledCache=n,n.refCount++,x.memoizedState={element:i,isDehydrated:l,cache:n},Ic(x),e}function px(e){return e?(e=nl,e):nl}function mx(e,n,l,i,f,x){f=px(f),i.context===null?i.context=f:i.pendingContext=f,i=$a(n),i.payload={element:l},x=x===void 0?null:x,x!==null&&(i.callback=x),l=Va(e,i,n),l!==null&&(vn(l,e,n),ns(l,e,n))}function hx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function nd(e,n){hx(e,n),(e=e.alternate)&&hx(e,n)}function xx(e){if(e.tag===13||e.tag===31){var n=jr(e,67108864);n!==null&&vn(n,e,67108864),nd(e,67108864)}}function gx(e){if(e.tag===13||e.tag===31){var n=Cn();n=Pr(n);var l=jr(e,n);l!==null&&vn(l,e,n),nd(e,n)}}var co=!0;function Q1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=2,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function Z1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=8,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function ad(e,n,l,i){if(co){var f=rd(i);if(f===null)Pu(e,n,i,uo,l),yx(e,i);else if(e0(f,e,n,l,i))i.stopPropagation();else if(yx(e,i),n&4&&-1<J1.indexOf(e)){for(;f!==null;){var x=Gr(f);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var j=Ee(x.pendingLanes);if(j!==0){var R=x;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-gt(j);R.entanglements[1]|=P,j&=~P}sa(x),(nt&6)===0&&(Wi=Qe()+500,vs(0))}}break;case 31:case 13:R=jr(x,2),R!==null&&vn(R,x,2),Yi(),nd(x,2)}if(x=rd(i),x===null&&Pu(e,n,i,uo,l),x===f)break;f=x}f!==null&&i.stopPropagation()}else Pu(e,n,i,null,l)}}function rd(e){return e=sc(e),ld(e)}var uo=null;function ld(e){if(uo=null,e=Fr(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return uo=e,null}function vx(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(tt()){case be:return 2;case pt:return 8;case Ct:case Yt:return 32;case un:return 268435456;default:return 32}default:return 32}}var sd=!1,Ja=null,er=null,tr=null,Cs=new Map,Es=new Map,nr=[],J1="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 yx(e,n){switch(e){case"focusin":case"focusout":Ja=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":Cs.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Es.delete(n.pointerId)}}function Ns(e,n,l,i,f,x){return e===null||e.nativeEvent!==x?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:x,targetContainers:[f]},n!==null&&(n=Gr(n),n!==null&&xx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function e0(e,n,l,i,f){switch(n){case"focusin":return Ja=Ns(Ja,e,n,l,i,f),!0;case"dragenter":return er=Ns(er,e,n,l,i,f),!0;case"mouseover":return tr=Ns(tr,e,n,l,i,f),!0;case"pointerover":var x=f.pointerId;return Cs.set(x,Ns(Cs.get(x)||null,e,n,l,i,f)),!0;case"gotpointercapture":return x=f.pointerId,Es.set(x,Ns(Es.get(x)||null,e,n,l,i,f)),!0}return!1}function bx(e){var n=Fr(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,hr(e.priority,function(){gx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,hr(e.priority,function(){gx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function fo(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=rd(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);lc=i,l.target.dispatchEvent(i),lc=null}else return n=Gr(l),n!==null&&xx(n),e.blockedOn=l,!1;n.shift()}return!0}function jx(e,n,l){fo(e)&&l.delete(n)}function t0(){sd=!1,Ja!==null&&fo(Ja)&&(Ja=null),er!==null&&fo(er)&&(er=null),tr!==null&&fo(tr)&&(tr=null),Cs.forEach(jx),Es.forEach(jx)}function po(e,n){e.blockedOn===n&&(e.blockedOn=null,sd||(sd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,t0)))}var mo=null;function Sx(e){mo!==e&&(mo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){mo===e&&(mo=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],f=e[n+2];if(typeof i!="function"){if(ld(i||l)===null)continue;break}var x=Gr(l);x!==null&&(e.splice(n,3),n-=3,ru(x,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function El(e){function n(P){return po(P,e)}Ja!==null&&po(Ja,e),er!==null&&po(er,e),tr!==null&&po(tr,e),Cs.forEach(n),Es.forEach(n);for(var l=0;l<nr.length;l++){var i=nr[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<nr.length&&(l=nr[0],l.blockedOn===null);)bx(l),l.blockedOn===null&&nr.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],x=l[i+1],j=f[ot]||null;if(typeof x=="function")j||Sx(l);else if(j){var R=null;if(x&&x.hasAttribute("formAction")){if(f=x,j=x[ot]||null)R=j.formAction;else if(ld(f)!==null)continue}else R=j.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),Sx(l)}}}function kx(){function e(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function id(e){this._internalRoot=e}ho.prototype.render=id.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Cn();mx(l,i,e,n,null,null)},ho.prototype.unmount=id.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;mx(e.current,2,null,e,null,null),Yi(),n[xr]=null}};function ho(e){this._internalRoot=e}ho.prototype.unstable_scheduleHydration=function(e){if(e){var n=it();e={blockedOn:null,target:e,priority:n};for(var l=0;l<nr.length&&n!==0&&n<nr[l].priority;l++);nr.splice(l,0,e),l===0&&bx(e)}};var wx=r.version;if(wx!=="19.2.4")throw Error(o(527,wx,"19.2.4"));_.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=p(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var n0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xo.isDisabled&&xo.supportsFiber)try{Mn=xo.inject(n0),Mt=xo}catch{}}return Rs.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=Mm,x=Lm,j=zm;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(x=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=fx(e,1,!1,null,null,l,i,null,f,x,j,kx),e[xr]=n.current,Vu(e),new id(n)},Rs.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",x=Mm,j=Lm,R=zm,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=fx(e,1,!0,n,l??null,i,f,P,x,j,R,kx),n.context=px(null),l=n.current,i=Cn(),i=Pr(i),f=$a(i),f.callback=null,Va(l,f,i),l=i,n.current.lanes=l,fr(n,l),sa(n),e[xr]=n.current,Vu(e),new ho(n)},Rs.version="19.2.4",Rs}var Dx;function d0(){if(Dx)return ud.exports;Dx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),ud.exports=u0(),ud.exports}var f0=d0();/**
51
51
  * react-router v7.13.1
52
52
  *
53
53
  * Copyright (c) Remix Software Inc.
@@ -56,47 +56,47 @@ Error generating stack: `+i.message+`
56
56
  * LICENSE.md file in the root directory of this source tree.
57
57
  *
58
58
  * @license MIT
59
- */var _x="popstate";function Ox(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function d0(t={}){function r(c,u){let{pathname:d="/",search:h="",hash:g=""}=zl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),Wd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,m=g.indexOf("#");h=m===-1?g:g.slice(0,m)}return h+"#"+(typeof u=="string"?u:Us(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return p0(r,s,o,t)}function Ft(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function Zn(t,r){if(!t){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function f0(){return Math.random().toString(36).substring(2,10)}function Bx(t,r){return{usr:t.state,key:t.key,idx:r,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Wd(t,r,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof r=="string"?zl(r):r,state:s,key:r&&r.key||o||f0(),unstable_mask:c}}function Us({pathname:t="/",search:r="",hash:s=""}){return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function zl(t){let r={};if(t){let s=t.indexOf("#");s>=0&&(r.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(r.search=t.substring(o),t=t.substring(0,o)),t&&(r.pathname=t)}return r}function p0(t,r,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,m=y();m==null&&(m=0,d.replaceState({...d.state,idx:m},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-m;m=C,g&&g({action:h,location:w.location,delta:N})}function b(C,N){h="PUSH";let R=Ox(C)?C:Wd(w.location,C,N);s&&s(R,C),m=y()+1;let L=Bx(R,m),B=w.createHref(R.unstable_mask||R);try{d.pushState(L,"",B)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(B)}u&&g&&g({action:h,location:w.location,delta:1})}function S(C,N){h="REPLACE";let R=Ox(C)?C:Wd(w.location,C,N);s&&s(R,C),m=y();let L=Bx(R,m),B=w.createHref(R.unstable_mask||R);d.replaceState(L,"",B),u&&g&&g({action:h,location:w.location,delta:0})}function k(C){return m0(C)}let w={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(_x,v),g=C,()=>{c.removeEventListener(_x,v),g=null}},createHref(C){return r(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return w}function m0(t,r=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ft(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Us(t);return o=o.replace(/ $/,"%20"),!r&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function sv(t,r,s="/"){return h0(t,r,s,!1)}function h0(t,r,s,o){let c=typeof r=="string"?zl(r):r,u=Ma(c.pathname||"/",s);if(u==null)return null;let d=iv(t);x0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let m=N0(u);h=C0(d[g],m,o)}return h}function iv(t,r=[],s=[],o="",c=!1){let u=(d,h,g=c,m)=>{let y={relativePath:m===void 0?d.path||"":m,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Ft(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=ca([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Ft(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),iv(d.children,r,b,v,g)),!(d.path==null&&!d.index)&&r.push({path:v,score:k0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let m of ov(d.path))u(d,h,!0,m)}),r}function ov(t){let r=t.split("/");if(r.length===0)return[];let[s,...o]=r,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=ov(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function x0(t){t.sort((r,s)=>r.score!==s.score?s.score-r.score:w0(r.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var g0=/^:[\w-]+$/,v0=3,y0=2,b0=1,j0=10,S0=-2,Ix=t=>t==="*";function k0(t,r){let s=t.split("/"),o=s.length;return s.some(Ix)&&(o+=S0),r&&(o+=y0),s.filter(c=>!Ix(c)).reduce((c,u)=>c+(g0.test(u)?v0:u===""?b0:j0),o)}function w0(t,r){return t.length===r.length&&t.slice(0,-1).every((o,c)=>o===r[c])?t[t.length-1]-r[r.length-1]:0}function C0(t,r,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],m=h===o.length-1,y=u==="/"?r:r.slice(u.length)||"/",v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:m},y),b=g.route;if(!v&&m&&s&&!o[o.length-1].route.index&&(v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:ca([u,v.pathname]),pathnameBase:M0(ca([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=ca([u,v.pathnameBase]))}return d}function _o(t,r){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=E0(t.path,t.caseSensitive,t.end),c=r.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((m,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?m[y]=void 0:m[y]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:d,pattern:t}}function E0(t,r=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,m,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(m+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,r?void 0:"i"),o]}function N0(t){try{return t.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),t}}function Ma(t,r){if(r==="/")return t;if(!t.toLowerCase().startsWith(r.toLowerCase()))return null;let s=r.endsWith("/")?r.length-1:r.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var T0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function R0(t,r="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?zl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Hx(s.substring(1),"/"):u=Hx(s,r)):u=r,{pathname:u,search:L0(o),hash:z0(c)}}function Hx(t,r){let s=r.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function md(t,r,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${r}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function A0(t){return t.filter((r,s)=>s===0||r.route.path&&r.route.path.length>0)}function cv(t){let r=A0(t);return r.map((s,o)=>o===r.length-1?s.pathname:s.pathnameBase)}function ff(t,r,s,o=!1){let c;typeof t=="string"?c=zl(t):(c={...t},Ft(!c.pathname||!c.pathname.includes("?"),md("?","pathname","search",c)),Ft(!c.pathname||!c.pathname.includes("#"),md("#","pathname","hash",c)),Ft(!c.search||!c.search.includes("#"),md("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=r.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?r[v]:"/"}let g=R0(c,h),m=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(m||y)&&(g.pathname+="/"),g}var ca=t=>t.join("/").replace(/\/\/+/g,"/"),M0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),L0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,z0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,D0=class{constructor(t,r,s,o=!1){this.status=t,this.statusText=r||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function _0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function O0(t){return t.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var uv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function dv(t,r){let s=t;if(typeof s!="string"||!T0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(uv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Ma(d.pathname,r);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var fv=["POST","PUT","PATCH","DELETE"];new Set(fv);var B0=["GET",...fv];new Set(B0);var Dl=p.createContext(null);Dl.displayName="DataRouter";var $o=p.createContext(null);$o.displayName="DataRouterState";var I0=p.createContext(!1),pv=p.createContext({isTransitioning:!1});pv.displayName="ViewTransition";var H0=p.createContext(new Map);H0.displayName="Fetchers";var U0=p.createContext(null);U0.displayName="Await";var Gn=p.createContext(null);Gn.displayName="Navigation";var Vo=p.createContext(null);Vo.displayName="Location";var La=p.createContext({outlet:null,matches:[],isDataRoute:!1});La.displayName="Route";var pf=p.createContext(null);pf.displayName="RouteError";var mv="REACT_ROUTER_ERROR",$0="REDIRECT",V0="ROUTE_ERROR_RESPONSE";function P0(t){if(t.startsWith(`${mv}:${$0}:{`))try{let r=JSON.parse(t.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function F0(t){if(t.startsWith(`${mv}:${V0}:{`))try{let r=JSON.parse(t.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new D0(r.status,r.statusText,r.data)}catch{}}function G0(t,{relative:r}={}){Ft(Ys(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=p.useContext(Gn),{hash:c,pathname:u,search:d}=Ks(t,{relative:r}),h=u;return s!=="/"&&(h=u==="/"?s:ca([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Ys(){return p.useContext(Vo)!=null}function or(){return Ft(Ys(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Vo).location}var hv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function xv(t){p.useContext(Gn).static||p.useLayoutEffect(t)}function W0(){let{isDataRoute:t}=p.useContext(La);return t?lj():q0()}function q0(){Ft(Ys(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Dl),{basename:r,navigator:s}=p.useContext(Gn),{matches:o}=p.useContext(La),{pathname:c}=or(),u=JSON.stringify(cv(o)),d=p.useRef(!1);return xv(()=>{d.current=!0}),p.useCallback((g,m={})=>{if(Zn(d.current,hv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=ff(g,JSON.parse(u),c,m.relative==="path");t==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:ca([r,y.pathname])),(m.replace?s.replace:s.push)(y,m.state,m)},[r,s,u,c,t])}p.createContext(null);function Ks(t,{relative:r}={}){let{matches:s}=p.useContext(La),{pathname:o}=or(),c=JSON.stringify(cv(s));return p.useMemo(()=>ff(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function Y0(t,r,s){Ft(Ys(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=p.useContext(Gn),{matches:c}=p.useContext(La),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",m=u&&u.route;{let C=m&&m.path||"";vv(h,!m||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
59
+ */var _x="popstate";function Ox(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function p0(t={}){function r(c,u){let{pathname:d="/",search:h="",hash:g=""}=zl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),Wd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,p=g.indexOf("#");h=p===-1?g:g.slice(0,p)}return h+"#"+(typeof u=="string"?u:Hs(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return h0(r,s,o,t)}function Ft(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function Zn(t,r){if(!t){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function m0(){return Math.random().toString(36).substring(2,10)}function Bx(t,r){return{usr:t.state,key:t.key,idx:r,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Wd(t,r,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof r=="string"?zl(r):r,state:s,key:r&&r.key||o||m0(),unstable_mask:c}}function Hs({pathname:t="/",search:r="",hash:s=""}){return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function zl(t){let r={};if(t){let s=t.indexOf("#");s>=0&&(r.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(r.search=t.substring(o),t=t.substring(0,o)),t&&(r.pathname=t)}return r}function h0(t,r,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,p=y();p==null&&(p=0,d.replaceState({...d.state,idx:p},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-p;p=C,g&&g({action:h,location:E.location,delta:N})}function b(C,N){h="PUSH";let T=Ox(C)?C:Wd(E.location,C,N);s&&s(T,C),p=y()+1;let A=Bx(T,p),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(B)}u&&g&&g({action:h,location:E.location,delta:1})}function S(C,N){h="REPLACE";let T=Ox(C)?C:Wd(E.location,C,N);s&&s(T,C),p=y();let A=Bx(T,p),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&g&&g({action:h,location:E.location,delta:0})}function k(C){return x0(C)}let E={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(_x,v),g=C,()=>{c.removeEventListener(_x,v),g=null}},createHref(C){return r(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return E}function x0(t,r=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ft(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Hs(t);return o=o.replace(/ $/,"%20"),!r&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function iv(t,r,s="/"){return g0(t,r,s,!1)}function g0(t,r,s,o){let c=typeof r=="string"?zl(r):r,u=Ma(c.pathname||"/",s);if(u==null)return null;let d=ov(t);v0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let p=R0(u);h=N0(d[g],p,o)}return h}function ov(t,r=[],s=[],o="",c=!1){let u=(d,h,g=c,p)=>{let y={relativePath:p===void 0?d.path||"":p,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Ft(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=ca([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Ft(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),ov(d.children,r,b,v,g)),!(d.path==null&&!d.index)&&r.push({path:v,score:C0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let p of cv(d.path))u(d,h,!0,p)}),r}function cv(t){let r=t.split("/");if(r.length===0)return[];let[s,...o]=r,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=cv(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function v0(t){t.sort((r,s)=>r.score!==s.score?s.score-r.score:E0(r.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var y0=/^:[\w-]+$/,b0=3,j0=2,S0=1,k0=10,w0=-2,Ix=t=>t==="*";function C0(t,r){let s=t.split("/"),o=s.length;return s.some(Ix)&&(o+=w0),r&&(o+=j0),s.filter(c=>!Ix(c)).reduce((c,u)=>c+(y0.test(u)?b0:u===""?S0:k0),o)}function E0(t,r){return t.length===r.length&&t.slice(0,-1).every((o,c)=>o===r[c])?t[t.length-1]-r[r.length-1]:0}function N0(t,r,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],p=h===o.length-1,y=u==="/"?r:r.slice(u.length)||"/",v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:p},y),b=g.route;if(!v&&p&&s&&!o[o.length-1].route.index&&(v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:ca([u,v.pathname]),pathnameBase:z0(ca([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=ca([u,v.pathnameBase]))}return d}function _o(t,r){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=T0(t.path,t.caseSensitive,t.end),c=r.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((p,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?p[y]=void 0:p[y]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:u,pathnameBase:d,pattern:t}}function T0(t,r=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,p,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(p+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,r?void 0:"i"),o]}function R0(t){try{return t.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),t}}function Ma(t,r){if(r==="/")return t;if(!t.toLowerCase().startsWith(r.toLowerCase()))return null;let s=r.endsWith("/")?r.length-1:r.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var A0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function M0(t,r="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?zl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Ux(s.substring(1),"/"):u=Ux(s,r)):u=r,{pathname:u,search:D0(o),hash:_0(c)}}function Ux(t,r){let s=r.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function md(t,r,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${r}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function L0(t){return t.filter((r,s)=>s===0||r.route.path&&r.route.path.length>0)}function uv(t){let r=L0(t);return r.map((s,o)=>o===r.length-1?s.pathname:s.pathnameBase)}function ff(t,r,s,o=!1){let c;typeof t=="string"?c=zl(t):(c={...t},Ft(!c.pathname||!c.pathname.includes("?"),md("?","pathname","search",c)),Ft(!c.pathname||!c.pathname.includes("#"),md("#","pathname","hash",c)),Ft(!c.search||!c.search.includes("#"),md("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=r.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?r[v]:"/"}let g=M0(c,h),p=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(p||y)&&(g.pathname+="/"),g}var ca=t=>t.join("/").replace(/\/\/+/g,"/"),z0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),D0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,_0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,O0=class{constructor(t,r,s,o=!1){this.status=t,this.statusText=r||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function B0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function I0(t){return t.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var dv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fv(t,r){let s=t;if(typeof s!="string"||!A0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(dv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Ma(d.pathname,r);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var pv=["POST","PUT","PATCH","DELETE"];new Set(pv);var U0=["GET",...pv];new Set(U0);var Dl=m.createContext(null);Dl.displayName="DataRouter";var $o=m.createContext(null);$o.displayName="DataRouterState";var H0=m.createContext(!1),mv=m.createContext({isTransitioning:!1});mv.displayName="ViewTransition";var $0=m.createContext(new Map);$0.displayName="Fetchers";var V0=m.createContext(null);V0.displayName="Await";var Gn=m.createContext(null);Gn.displayName="Navigation";var Vo=m.createContext(null);Vo.displayName="Location";var La=m.createContext({outlet:null,matches:[],isDataRoute:!1});La.displayName="Route";var pf=m.createContext(null);pf.displayName="RouteError";var hv="REACT_ROUTER_ERROR",P0="REDIRECT",F0="ROUTE_ERROR_RESPONSE";function G0(t){if(t.startsWith(`${hv}:${P0}:{`))try{let r=JSON.parse(t.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function W0(t){if(t.startsWith(`${hv}:${F0}:{`))try{let r=JSON.parse(t.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new O0(r.status,r.statusText,r.data)}catch{}}function q0(t,{relative:r}={}){Ft(Ys(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=m.useContext(Gn),{hash:c,pathname:u,search:d}=Ks(t,{relative:r}),h=u;return s!=="/"&&(h=u==="/"?s:ca([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Ys(){return m.useContext(Vo)!=null}function or(){return Ft(Ys(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Vo).location}var xv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function gv(t){m.useContext(Gn).static||m.useLayoutEffect(t)}function Y0(){let{isDataRoute:t}=m.useContext(La);return t?ij():K0()}function K0(){Ft(Ys(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(Dl),{basename:r,navigator:s}=m.useContext(Gn),{matches:o}=m.useContext(La),{pathname:c}=or(),u=JSON.stringify(uv(o)),d=m.useRef(!1);return gv(()=>{d.current=!0}),m.useCallback((g,p={})=>{if(Zn(d.current,xv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=ff(g,JSON.parse(u),c,p.relative==="path");t==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:ca([r,y.pathname])),(p.replace?s.replace:s.push)(y,p.state,p)},[r,s,u,c,t])}m.createContext(null);function Ks(t,{relative:r}={}){let{matches:s}=m.useContext(La),{pathname:o}=or(),c=JSON.stringify(uv(s));return m.useMemo(()=>ff(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function X0(t,r,s){Ft(Ys(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=m.useContext(Gn),{matches:c}=m.useContext(La),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",p=u&&u.route;{let C=p&&p.path||"";yv(h,!p||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
60
60
 
61
- Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=or(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=sv(t,{pathname:S});return Zn(m||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),J0(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:ca([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:ca([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function K0(){let t=rj(),r=_0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:u},"ErrorBoundary")," or"," ",p.createElement("code",{style:u},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},r),s?p.createElement("pre",{style:c},s):null,d)}var X0=p.createElement(K0,null),gv=class extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){this.props.onError?this.props.onError(t,r):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=F0(t.digest);s&&(t=s)}let r=t!==void 0?p.createElement(La.Provider,{value:this.props.routeContext},p.createElement(pf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(Q0,{error:t},r):r}};gv.contextType=I0;var hd=new WeakMap;function Q0({children:t,error:r}){let{basename:s}=p.useContext(Gn);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=P0(r.digest);if(o){let c=hd.get(r);if(c)throw c;let u=dv(o.location,s);if(uv&&!hd.get(r))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw hd.set(r,d),d}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Z0({routeContext:t,match:r,children:s}){let o=p.useContext(Dl);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),p.createElement(La.Provider,{value:t},s)}function J0(t,r=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(r.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,m=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:O0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,w=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,w=v.route.errorElement||X0,d&&(h<0&&b===0?(vv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=r.concat(c.slice(0,b+1)),R=()=>{let L;return S?L=w:k?L=C:v.route.Component?L=p.createElement(v.route.Component,null):v.route.element?L=v.route.element:L=y,p.createElement(Z0,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:L})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?p.createElement(gv,{location:o.location,revalidation:o.revalidation,component:w,error:S,children:R(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:m}):R()},null)}function mf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ej(t){let r=p.useContext(Dl);return Ft(r,mf(t)),r}function tj(t){let r=p.useContext($o);return Ft(r,mf(t)),r}function nj(t){let r=p.useContext(La);return Ft(r,mf(t)),r}function hf(t){let r=nj(t),s=r.matches[r.matches.length-1];return Ft(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function aj(){return hf("useRouteId")}function rj(){var o;let t=p.useContext(pf),r=tj("useRouteError"),s=hf("useRouteError");return t!==void 0?t:(o=r.errors)==null?void 0:o[s]}function lj(){let{router:t}=ej("useNavigate"),r=hf("useNavigate"),s=p.useRef(!1);return xv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{Zn(s.current,hv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:r,...u}))},[t,r])}var Ux={};function vv(t,r,s){!r&&!Ux[t]&&(Ux[t]=!0,Zn(!1,s))}p.memo(sj);function sj({routes:t,future:r,state:s,isStatic:o,onError:c}){return Y0(t,void 0,{state:s,isStatic:o,onError:c})}function ij({basename:t="/",children:r=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Ft(!Ys(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=p.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=zl(s));let{pathname:m="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,w=p.useMemo(()=>{let C=Ma(m,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,m,y,v,b,S,o,k]);return Zn(w!=null,`<Router basename="${h}"> is not able to match the URL "${m}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:p.createElement(Gn.Provider,{value:g},p.createElement(Vo.Provider,{children:r,value:w}))}var To="get",Ro="application/x-www-form-urlencoded";function Po(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function oj(t){return Po(t)&&t.tagName.toLowerCase()==="button"}function cj(t){return Po(t)&&t.tagName.toLowerCase()==="form"}function uj(t){return Po(t)&&t.tagName.toLowerCase()==="input"}function dj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function fj(t,r){return t.button===0&&(!r||r==="_self")&&!dj(t)}var go=null;function pj(){if(go===null)try{new FormData(document.createElement("form"),0),go=!1}catch{go=!0}return go}var mj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xd(t){return t!=null&&!mj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ro}"`),null):t}function hj(t,r){let s,o,c,u,d;if(cj(t)){let h=t.getAttribute("action");o=h?Ma(h,r):null,s=t.getAttribute("method")||To,c=xd(t.getAttribute("enctype"))||Ro,u=new FormData(t)}else if(oj(t)||uj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Ma(g,r):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||To,c=xd(t.getAttribute("formenctype"))||xd(h.getAttribute("enctype"))||Ro,u=new FormData(h,t),!pj()){let{name:m,type:y,value:v}=t;if(y==="image"){let b=m?`${m}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else m&&u.append(m,v)}}else{if(Po(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=To,o=null,c=Ro,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function xf(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function xj(t,r,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:r&&Ma(c.pathname,r)==="/"?c.pathname=`${r.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function gj(t,r){if(t.id in r)return r[t.id];try{let s=await import(t.module);return r[t.id]=s,s}catch(s){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function vj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function yj(t,r,s){let o=await Promise.all(t.map(async c=>{let u=r.routes[c.route.id];if(u){let d=await gj(u,s);return d.links?d.links():[]}return[]}));return kj(o.flat(1).filter(vj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function $x(t,r,s,o,c,u){let d=(g,m)=>s[m]?g.route.id!==s[m].route.id:!0,h=(g,m)=>{var y;return s[m].pathname!==g.pathname||((y=s[m].route.path)==null?void 0:y.endsWith("*"))&&s[m].params["*"]!==g.params["*"]};return u==="assets"?r.filter((g,m)=>d(g,m)||h(g,m)):u==="data"?r.filter((g,m)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,m)||h(g,m))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function bj(t,r,{includeHydrateFallback:s}={}){return jj(t.map(o=>{let c=r.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function jj(t){return[...new Set(t)]}function Sj(t){let r={},s=Object.keys(t).sort();for(let o of s)r[o]=t[o];return r}function kj(t,r){let s=new Set;return new Set(r),t.reduce((o,c)=>{let u=JSON.stringify(Sj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function yv(){let t=p.useContext(Dl);return xf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function wj(){let t=p.useContext($o);return xf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var gf=p.createContext(void 0);gf.displayName="FrameworkContext";function bv(){let t=p.useContext(gf);return xf(t,"You must render this element inside a <HydratedRouter> element"),t}function Cj(t,r){let s=p.useContext(gf),[o,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:m,onMouseLeave:y,onTouchStart:v}=r,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let w=N=>{N.forEach(R=>{d(R.isIntersecting)})},C=new IntersectionObserver(w,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),p.useEffect(()=>{if(o){let w=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(w)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:As(h,S),onBlur:As(g,k),onMouseEnter:As(m,S),onMouseLeave:As(y,k),onTouchStart:As(v,S)}]:[!1,b,{}]}function As(t,r){return s=>{t&&t(s),s.defaultPrevented||r(s)}}function Ej({page:t,...r}){let{router:s}=yv(),o=p.useMemo(()=>sv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?p.createElement(Tj,{page:t,matches:o,...r}):null}function Nj(t){let{manifest:r,routeModules:s}=bv(),[o,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return yj(t,r,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,r,s]),o}function Tj({page:t,matches:r,...s}){let o=or(),{future:c,manifest:u,routeModules:d}=bv(),{basename:h}=yv(),{loaderData:g,matches:m}=wj(),y=p.useMemo(()=>$x(t,r,m,u,o,"data"),[t,r,m,u,o]),v=p.useMemo(()=>$x(t,r,m,u,o,"assets"),[t,r,m,u,o]),b=p.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let w=new Set,C=!1;if(r.forEach(R=>{var B;let L=u.routes[R.route.id];!L||!L.hasLoader||(!y.some(D=>D.route.id===R.route.id)&&R.route.id in g&&((B=d[R.route.id])!=null&&B.shouldRevalidate)||L.hasClientLoader?C=!0:w.add(R.route.id))}),w.size===0)return[];let N=xj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&w.size>0&&N.searchParams.set("_routes",r.filter(R=>w.has(R.route.id)).map(R=>R.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,r,t,d]),S=p.useMemo(()=>bj(v,u),[v,u]),k=Nj(v);return p.createElement(p.Fragment,null,b.map(w=>p.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...s})),S.map(w=>p.createElement("link",{key:w,rel:"modulepreload",href:w,...s})),k.map(({key:w,link:C})=>p.createElement("link",{key:w,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Rj(...t){return r=>{t.forEach(s=>{typeof s=="function"?s(r):s!=null&&(s.current=r)})}}var Aj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Aj&&(window.__reactRouterVersion="7.13.1")}catch{}function Mj({basename:t,children:r,unstable_useTransitions:s,window:o}){let c=p.useRef();c.current==null&&(c.current=d0({window:o,v5Compat:!0}));let u=c.current,[d,h]=p.useState({action:u.action,location:u.location}),g=p.useCallback(m=>{s===!1?h(m):p.startTransition(()=>h(m))},[s]);return p.useLayoutEffect(()=>u.listen(g),[u,g]),p.createElement(ij,{basename:t,children:r,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var jv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Sv=p.forwardRef(function({onClick:r,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:m,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},w){let{basename:C,navigator:N,unstable_useTransitions:R}=p.useContext(Gn),L=typeof y=="string"&&jv.test(y),B=dv(y,C);y=B.to;let D=G0(y,{relative:c}),F=or(),E=null;if(h){let $=ff(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:ca([C,$.pathname])),E=N.createHref($)}let[H,z,I]=Cj(o,k),U=_j(y,{replace:d,unstable_mask:h,state:g,target:m,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:R});function q($){r&&r($),$.defaultPrevented||U($)}let X=!(B.isExternal||u),J=p.createElement("a",{...k,...I,href:(X?E:void 0)||B.absoluteURL||D,onClick:X?q:r,ref:Rj(w,z),target:m,"data-discover":!L&&s==="render"?"true":void 0});return H&&!L?p.createElement(p.Fragment,null,J,p.createElement(Ej,{page:D})):J});Sv.displayName="Link";var Lj=p.forwardRef(function({"aria-current":r="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...m},y){let v=Ks(d,{relative:m.relative}),b=or(),S=p.useContext($o),{navigator:k,basename:w}=p.useContext(Gn),C=S!=null&&Uj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,R=b.pathname,L=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(R=R.toLowerCase(),L=L?L.toLowerCase():null,N=N.toLowerCase()),L&&w&&(L=Ma(L,w)||L);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let D=R===N||!c&&R.startsWith(N)&&R.charAt(B)==="/",F=L!=null&&(L===N||!c&&L.startsWith(N)&&L.charAt(N.length)==="/"),E={isActive:D,isPending:F,isTransitioning:C},H=D?r:void 0,z;typeof o=="function"?z=o(E):z=[o,D?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let I=typeof u=="function"?u(E):u;return p.createElement(Sv,{...m,"aria-current":H,className:z,ref:y,style:I,to:d,viewTransition:h},typeof g=="function"?g(E):g)});Lj.displayName="NavLink";var zj=p.forwardRef(({discover:t="render",fetcherKey:r,navigate:s,reloadDocument:o,replace:c,state:u,method:d=To,action:h,onSubmit:g,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:w}=p.useContext(Gn),C=Ij(),N=Hj(h,{relative:m}),R=d.toLowerCase()==="get"?"get":"post",L=typeof h=="string"&&jv.test(h),B=D=>{if(g&&g(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,E=(F==null?void 0:F.getAttribute("formmethod"))||d,H=()=>C(F||D.currentTarget,{fetcherKey:r,method:E,navigate:s,replace:c,state:u,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});w&&s!==!1?p.startTransition(()=>H()):H()};return p.createElement("form",{ref:k,method:R,action:N,onSubmit:o?g:B,...S,"data-discover":!L&&t==="render"?"true":void 0})});zj.displayName="Form";function Dj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kv(t){let r=p.useContext(Dl);return Ft(r,Dj(t)),r}function _j(t,{target:r,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:m}={}){let y=W0(),v=or(),b=Ks(t,{relative:d});return p.useCallback(S=>{if(fj(S,r)){S.preventDefault();let k=s!==void 0?s:Us(v)===Us(b),w=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});m?p.startTransition(()=>w()):w()}},[v,y,b,s,o,c,r,t,u,d,h,g,m])}var Oj=0,Bj=()=>`__${String(++Oj)}__`;function Ij(){let{router:t}=kv("useSubmit"),{basename:r}=p.useContext(Gn),s=aj(),o=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:g,encType:m,formData:y,body:v}=hj(u,r);if(d.navigate===!1){let b=d.fetcherKey||Bj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,r,s])}function Hj(t,{relative:r}={}){let{basename:s}=p.useContext(Gn),o=p.useContext(La);Ft(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Ks(t||".",{relative:r})},d=or();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:ca([s,u.pathname])),Us(u)}function Uj(t,{relative:r}={}){let s=p.useContext(pv);Ft(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=kv("useViewTransitionState"),c=Ks(t,{relative:r});if(!s.isTransitioning)return!1;let u=Ma(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Ma(s.nextLocation.pathname,o)||s.nextLocation.pathname;return _o(c.pathname,d)!=null||_o(c.pathname,u)!=null}var Fo=lv();const $j=rv(Fo),Vj="modulepreload",Pj=function(t){return"/"+t},Vx={},Xs=function(r,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(m=>{if(m=Pj(m),m in Vx)return;Vx[m]=!0;const y=m.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":Vj,y||(b.as="script"),b.crossOrigin="",b.href=m,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})},Px={own:"authoring-project",installed:"available-project",global:"available-personal"},qd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Fj(t){if(typeof t=="string"){if(qd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Px,t))return Px[t]}return"authoring-project"}function Gj(t){return t.startsWith("available-")?"available":"authoring"}function Wj(t){const r=t.indexOf("-");return t.slice(r+1)}const Vn="";class Os extends Error{constructor(r,s){super(r),this.name="ApiError",this.status=s}}async function $e(t,r){const s=await fetch(`${Vn}${t}`,r);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function Jt(t){return typeof t=="string"&&t.length>0?t:null}function qj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function gd(t){if(!Array.isArray(t))return null;const r=t.filter(s=>typeof s=="string"&&s.length>0);return r.length>0?r:null}function Yj(t){const r=t??{};let s;r.origin==="source"||r.origin==="installed"?s=r.origin:(s="source",console.warn(`[api.getSkills] skill ${String(r.plugin)}/${String(r.skill)} has invalid origin=${JSON.stringify(r.origin)}; defaulting to 'source'`));let o;r.scope==="own"||r.scope==="installed"||r.scope==="global"?o=r.scope:o=s==="installed"?"installed":"own";let c;r.installMethod==="authored"||r.installMethod==="copied"||r.installMethod==="symlinked"?c=r.installMethod:c=o==="own"?"authored":"copied";const u=typeof r.scopeV2=="string"&&qd.has(r.scopeV2)?r.scopeV2:Fj(r.scope),d=Gj(u),h=Wj(u),g=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let m;r.shadowedBy===null?m=null:typeof r.shadowedBy=="string"&&qd.has(r.shadowedBy)?m=r.shadowedBy:m=void 0;const y={plugin:typeof r.plugin=="string"?r.plugin:"",skill:typeof r.skill=="string"?r.skill:"",dir:typeof r.dir=="string"?r.dir:"",hasEvals:!!r.hasEvals,hasBenchmark:!!r.hasBenchmark,evalCount:typeof r.evalCount=="number"?r.evalCount:0,assertionCount:typeof r.assertionCount=="number"?r.assertionCount:0,benchmarkStatus:r.benchmarkStatus==="pass"||r.benchmarkStatus==="fail"||r.benchmarkStatus==="pending"||r.benchmarkStatus==="stale"||r.benchmarkStatus==="missing"?r.benchmarkStatus:"missing",lastBenchmark:typeof r.lastBenchmark=="string"?r.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:Jt(r.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:Jt(r.pluginName),pluginNamespace:Jt(r.pluginNamespace),pluginMarketplace:Jt(r.pluginMarketplace),pluginManifestPath:Jt(r.pluginManifestPath),pluginVersion:Jt(r.pluginVersion),precedenceRank:g,shadowedBy:m,description:Jt(r.description),version:Jt(r.version),category:Jt(r.category),author:Jt(r.author),license:Jt(r.license),homepage:Jt(r.homepage),repoUrl:Jt(r.repoUrl),skillPath:Jt(r.skillPath),tags:gd(r.tags),deps:gd(r.deps),mcpDeps:gd(r.mcpDeps),entryPoint:Jt(r.entryPoint),lastModified:Jt(r.lastModified),sizeBytes:qj(r.sizeBytes),sourceAgent:Jt(r.sourceAgent)};if(r.provenance&&typeof r.provenance=="object"){const v=r.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else r.provenance===null&&(y.provenance=null);return typeof r.updateAvailable=="boolean"&&(y.updateAvailable=r.updateAvailable),typeof r.currentVersion=="string"&&(y.currentVersion=r.currentVersion),typeof r.latestVersion=="string"&&(y.latestVersion=r.latestVersion),typeof r.pinnedVersion=="string"&&(y.pinnedVersion=r.pinnedVersion),y}const Ce={getConfig(){return $e("/api/config")},setConfig(t,r){return $e("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:r})})},async getSkills(t){const r=new URLSearchParams;t!=null&&t.scope&&r.set("scope",t.scope),t!=null&&t.agent&&r.set("agent",t.agent);const s=r.toString(),o=await $e(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Yj):[]},getAgents(){return $e("/api/agents")},getSkillDetail(t,r){return $e(`/api/skills/${t}/${r}`)},async getEvals(t,r){const s=await $e(`/api/skills/${t}/${r}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:r,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/evals`)},getActivationHistoryEnvelope(t,r){return $e(`/api/skills/${t}/${r}/activation-history`)},saveEvals(t,r,s){return $e(`/api/skills/${t}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,r){return $e(`/api/skills/${t}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,r){const s=await fetch(`${Vn}/api/skills/${t}/${r}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,r,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return $e(`/api/skills/${t}/${r}/history${c?"?"+c:""}`)},getHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`)},compareRuns(t,r,s,o){return $e(`/api/skills/${t}/${r}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,r,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return $e(`/api/skills/${t}/${r}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,r){return $e(`/api/skills/${t}/${r}`,{method:"DELETE"})},improveSkill(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,r,s){return $e(`/api/skills/${t}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,r){return $e(`/api/skills/${t}/${r}/stats`)},getDependencies(t,r){return $e(`/api/skills/${t}/${r}/dependencies`)},getProjectLayout(){return $e("/api/project-layout")},createSkill(t){return $e("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return $e("/api/studio/detect-engines")},saveDraft(t){return $e("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return $e("/api/skill-creator-status")},generateSkill(t){return $e("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,r){return $e(`/api/skills/${t}/${r}/files`)},getSkillFile(t,r,s){return $e(`/api/skills/${t}/${r}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,r,s,o){return $e(`/api/skills/${t}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,r){return $e(`/api/skills/${t}/${r}/leaderboard`)},getLeaderboardEntry(t,r,s){return $e(`/api/skills/${t}/${r}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,r){return $e(`/api/credentials/${t}/${r}`)},setCredential(t,r,s,o){return $e(`/api/credentials/${t}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,r){return $e(`/api/credentials/${t}/${r}/params`)},getParamsRevealed(t,r,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return $e(`/api/credentials/${t}/${r}/params?${o}`)},searchModels(){return $e("/api/openrouter/models")},async getSkillVersions(t,r){const s=await $e(`/api/skills/${t}/${r}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/versions`)},getVersionDiff(t,r,s,o){return $e(`/api/skills/${t}/${r}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const r=`${Vn}/api/skills/batch-update`,s=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,r){const s=`${Vn}/api/skills/${t}/${r}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/update`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let u,d="";if(c.body){const h=c.body.getReader(),g=new TextDecoder;let m=!1,y="";for(;!m;){const b=await h.read();if(m=b.done,b.value){const S=g.decode(b.value,{stream:!m});y+=S,d.length<200&&(d+=S)}}const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}d=d.slice(0,200)}else{const h=await c.text();d=h.slice(0,200);const g=h.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(g)try{u=JSON.parse(g[1]).version}catch{}}return{ok:c.ok,status:c.status,body:d,version:u}},async rescanSkill(t,r){const s=`${t}/${r}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:[...t].sort()})});if(!r.ok)return[];const s=await r.json().catch(()=>null);return Array.isArray(s)?s:s&&typeof s=="object"&&Array.isArray(s.results)?s.results.map(o=>({skillId:typeof o.skillId=="string"?o.skillId:typeof o.name=="string"?o.name:"",version:typeof o.version=="string"?o.version:typeof o.latest=="string"?o.latest:"",eventId:typeof o.eventId=="string"?o.eventId:"",publishedAt:typeof o.publishedAt=="string"?o.publishedAt:"",diffSummary:typeof o.diffSummary=="string"?o.diffSummary:void 0,trackedForUpdates:typeof o.trackedForUpdates=="boolean"?o.trackedForUpdates:void 0,updateAvailable:typeof o.updateAvailable=="boolean"?o.updateAvailable:void 0,installed:typeof o.installed=="string"?o.installed:void 0,latest:typeof o.latest=="string"?o.latest:void 0,name:typeof o.name=="string"?o.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!r.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await r.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,r,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return vd(`/api/skills/${t}/${r}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,r,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return vd(`/api/skills/${t}/${r}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,r,s){return vd(`/api/skills/${t}/${r}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const r=new URLSearchParams;(t==null?void 0:t.before)!=null&&r.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&r.set("limit",String(t.limit));const s=r.toString();return $e(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return $e(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Vn}/api/studio/ops/stream`)}};async function vd(t,r,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Os(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,m=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
62
- `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const w={type:h,...k};r==null||r(w),w.type==="done"&&(g=w),w.type==="error"&&(m=w)}h=""}}if(m){const y=new Os(m.message,500);throw y.code=m.code,y}if(!g)throw new Os("Transfer stream ended without 'done' event",500);return g}function Kj(t,r){if(!r.length)return t;const s=new Map,o=new Map;for(const c of r){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Xj(t){const[r,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const Qj=500,Yd="vskill.updates.seenLastId";function Zj(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Yd)}catch{return null}}function yd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Yd):window.localStorage.setItem(Yd,t)}catch{}}function Jj(){let t=new Map;const r=new Set,s=new Set,o=[];let c=Zj();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>Qj){const g=o.shift();g&&s.delete(g)}c=h,yd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,yd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,yd(null),u()}}}const Dr=Jj(),eS=3e5,tS=500,nS=15e3,aS=6e4,rS=6e4,lS="/api/v1/skills/stream";function Fx(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Gx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function sS(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function iS(t){const r=(t==null?void 0:t.intervalMs)??eS,s=(t==null?void 0:t.debounceMs)??tS,o=(t==null?void 0:t.timeoutMs)??nS,c=(t==null?void 0:t.staleAfterMs)??aS,u=(t==null?void 0:t.disconnectFallbackMs)??rS,d=(t==null?void 0:t.streamUrlBase)??lS,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=p.useMemo(()=>{const A=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return A.length===0?"":[...A].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,y]=p.useState([]),[v,b]=p.useState(()=>new Map),[S,k]=p.useState(0),[w,C]=p.useState(!1),[N,R]=p.useState(null),[L,B]=p.useState(null),D=p.useRef(null),F=p.useRef(null),E=p.useRef(null),H=p.useRef(null),z=p.useRef(!0),[I,U]=p.useState(()=>h?"connecting":"fallback"),q=p.useRef(I);q.current=I;const X=p.useSyncExternalStore(A=>Dr.subscribe(A),()=>Dr.getSnapshot(),()=>Dr.getSnapshot()),J=X.size,$=p.useCallback(async()=>{C(!0);const A=new AbortController,Y=setTimeout(()=>A.abort(),o);try{const W=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{A.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(W==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(W),b(Fx(W)),k(Gx(W)),F.current=Date.now(),R(F.current),B(null)}catch(W){if(!z.current)return;B(W instanceof Error?W:new Error(String(W)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),M=p.useCallback(()=>{if(D.current)return D.current;const A=$().finally(()=>{D.current=null});return D.current=A,A},[$]),_=p.useCallback(()=>{E.current==null&&(E.current=setInterval(()=>{M()},r))},[r,M]),O=p.useCallback(()=>{E.current!=null&&(clearInterval(E.current),E.current=null)},[]);p.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&M(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const W=()=>{if(H.current&&(clearTimeout(H.current),H.current=null),document.visibilityState==="hidden"){O();return}H.current=setTimeout(()=>{H.current=null,(F.current==null||Date.now()-F.current>c)&&M(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",W),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",W),H.current&&clearTimeout(H.current),O()}},[]);const V=p.useCallback(async A=>{if(A.length!==0)try{const Y=await Ce.checkSkillUpdates(A);if(!z.current||Y.length===0)return;const W=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:W}));te.length>0&&Dr.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,re=ye.get(_e);if(re){const he={...re};re.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Fx(Se)),k(Gx(Se)),Se})}catch{}},[]);p.useEffect(()=>{const A=h||g;if(!A){U("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){U("fallback");return}U("connecting");const Y=A.split(","),W=`${d}?skills=${encodeURIComponent(A)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&U("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let xe;try{xe=JSON.parse(pe.data)}catch{return}if(!sS(xe)||Dr.ingest(xe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${xe.skillId} updated to ${xe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:xe.skillId,version:xe.version,eventId:xe.eventId}}))}},re=()=>{z.current&&(Dr.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(W),te.onopen=()=>{z.current&&(de(),U("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",re))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",re)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),p.useEffect(()=>{if(!g)return;const A=g.split(",");V(A)},[g,V]);const se=p.useCallback(A=>{Dr.dismiss(A)},[]);return{updates:m,updatesMap:v,updateCount:S,isRefreshing:w,lastFetchAt:N,error:L,refresh:M,updatesById:X,pushUpdateCount:J,status:I,dismiss:se}}function oS(t){const r=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),r.push(u)}return r}const cS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function uS(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const wv=p.createContext(null),Cv=wv;function ea(){const t=p.useContext(Cv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function dS({children:t}){const[r,s]=p.useReducer(uS,cS),o=Xj("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=p.useState(()=>{try{const O=window.localStorage.getItem("vskill.studio.prefs");if(!O)return null;const V=JSON.parse(O);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function O(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",O),()=>window.removeEventListener("studio:agent-changed",O)},[]),p.useEffect(()=>{if(d)return;let O=!1;return Ce.getAgents().then(V=>{if(O)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(A=>A??se),h(!0)}).catch(()=>{O||(u(V=>V??"claude-code"),h(!0))}),()=>{O=!0}},[d]);const g=p.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const O={agent:c};Ce.getSkills(O).then(V=>{s({type:"SET_SKILLS",skills:V});const A=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(A){const[,Y,W]=A,te=V.find(fe=>fe.plugin===Y&&fe.skill===W);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:W,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);p.useEffect(()=>{g()},[g]);const m=p.useCallback(O=>{s({type:"SELECT_SKILL",skill:O}),window.location.hash=`/skills/${O.plugin}/${O.skill}`},[]),y=p.useRef(r.skills);p.useEffect(()=>{y.current=r.skills},[r.skills]);const v=p.useCallback((O,V)=>{const se=y.current,A=O?se.find(te=>te.plugin===O&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!O&&!A){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(A==null?void 0:A.plugin)??O,W=(A==null?void 0:A.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:W}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=p.useCallback(O=>{s({type:"SET_MODE",mode:O})},[]),w=p.useCallback(O=>{s({type:"SET_SEARCH",query:O})},[]),C=p.useCallback(O=>{s({type:"SET_MOBILE_VIEW",view:O})},[]),N=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),R=p.useRef(new Map),L=p.useRef(""),B=p.useRef(!1),[D,F]=p.useState(""),E=p.useMemo(()=>r.skills.map(O=>`${O.plugin}/${O.skill}`),[r.skills]),H=p.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=iS({skillIds:H,trackingSkillIds:E}),I=p.useRef("");p.useEffect(()=>{const O=r.skills.filter(W=>W.origin==="installed");if(O.length===0){F(""),I.current="";return}const V=new Map;for(const W of z.updates)V.set(W.name.split("/").pop()||W.name,W);const se=O.map(W=>{const te=V.get(W.skill);return{plugin:W.plugin,skill:W.skill,name:(te==null?void 0:te.name)??W.skill,currentVersion:W.currentVersion??(te==null?void 0:te.installed)??"0.0.0"}}),A=se.map(W=>`${W.plugin}/${W.skill}@${W.currentVersion}#${W.name}`).sort().join("|");if(A===I.current)return;I.current=A;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(W=>{if(Y)return;const ie=[...oS(W).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==L.current&&(L.current=ie,R.current=new Map(W.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(W=>{if(Y||(I.current=""),!B.current){B.current=!0;const te=W instanceof Error?W.message:String(W);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[r.skills,z.updates]);const U=p.useMemo(()=>{const O=r.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Kj(O,z.updates)},[r.skills,z.updates]),q=p.useMemo(()=>{const O={source:0,installed:0};for(const V of U)V.updateAvailable&&(O[V.origin]+=1);return O},[U]),X=p.useMemo(()=>({...r,skills:U}),[r,U]),J=z.updateCount,$=z.refresh,M=z.isRefreshing,_=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:k,setSearch:w,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:M,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,m,S,k,w,C,g,J,N,z.updates,q,M,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return a.jsx(Cv.Provider,{value:_,children:t})}const fS={config:null,loading:!0};function pS(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Ev=p.createContext(null);function Ur(){const t=p.useContext(Ev);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function mS({children:t}){const[r,s]=p.useReducer(pS,fS),o=p.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{o()},[o]);const c=p.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=p.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(Ev.Provider,{value:u,children:t})}function hS({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const m={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:m,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Wx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],xS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},gS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},vS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},yS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function bS(t,r){var h,g;const s=xS[t.id]??null,o=gS[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:yS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:jS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:vS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function jS(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function SS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Wx){const c=r.get(o);c&&s.push(c)}for(const o of t)Wx.includes(o.id)||s.push(o);return s}function kS(t){const[r,s]=p.useState(null),[o,c]=p.useState("loading"),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null),y=p.useRef(0),v=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=p.useCallback(async()=>{try{const R=await fetch("/api/config");if(!R.ok)throw new Error(`/api/config returned ${R.status}`);const L=await R.json(),B=SS((L.providers||[]).map(D=>bS(D,L.detection)));s({agents:B,activeAgent:L.provider??null,activeModel:L.model??null}),c("ready"),d(null)}catch(R){c("error"),d(R.message)}},[]);p.useEffect(()=>{S()},[S]);const k=p.useCallback(async()=>{var L;const R=Date.now();if(!(R-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=R,g(null),s(H=>{if(!H)return H;const z=H.agents.map(I=>{if(I.id!=="openrouter")return I;const U=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...I,models:U,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...H,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((L=v.current)==null||L.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),w=p.useCallback(R=>{m.current=R,R==="openrouter"&&k()},[k]),C=p.useCallback(()=>{y.current=0,S()},[S]),N=p.useCallback(async(R,L)=>{var F,E;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:R,model:L})})}catch(H){(F=b.current)==null||F.call(b,`Network error while setting ${R}: ${H.message}`);return}if(B.ok){s(H=>H&&{...H,activeAgent:R,activeModel:L});return}let D=`Failed to set ${R} (${B.status})`;try{const H=await B.json();H&&typeof H.error=="string"&&(D=H.error)}catch{}(E=b.current)==null||E.call(b,D)},[]);return{status:o,catalog:r,error:u,openRouterError:h,focusAgent:w,refresh:C,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:N}}function bd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Kd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const wS={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <plugin> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,r)=>`${t} of ${r}`},CS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},ES={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},NS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},TS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},RS={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},AS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},MS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},LS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},zS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},DS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},_S={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},OS={subscriptionBilling:"· subscription",free:"· free"},BS={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},IS={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},HS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},US={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},$S={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},VS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},PS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},FS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:wS,shell:CS,detail:ES,actions:NS,palette:TS,shortcuts:RS,toasts:AS,connection:MS,forms:LS,errors:zS,picker:DS,providers:_S,models:OS,settings:BS,statusBar:IS,scopePicker:HS,scopeSection:US,claudeCodeLabel:$S,setupDrawer:VS,setupProviders:FS,scopeLabels:PS},GS=new Set(["claude-cli","claude-code"]);function qx(t){return GS.has(t)}const Yx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function WS({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Yx.has(g.id)),h=t.filter(g=>!Yx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Kx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},m=qx(t.id),y={minHeight:36,height:m?"auto":36,padding:m?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),qx(t.id)&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Kd,{unlocked:!0,size:10}):a.jsx(Kd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(bd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(bd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(bd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function qS(t,r,s,o){const d=t>=80,h=p.useRef(null),[g,m]=p.useState(0),y=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/r)-4),k=Math.ceil(s/r)+8,w=Math.min(t,S+k);return{visibleStart:S,visibleEnd:w}},[d,g,r,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*r,offsetTop:v*r,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Nv=44,YS=352,KS=60,Xx=480;function XS(t){var u,d;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function QS(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function ZS({agent:t,activeModelId:r,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>g(u),KS);return()=>clearTimeout(b)},[u]),p.useEffect(()=>{t.id==="openrouter"&&t.available&&m.current&&m.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Xx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=p.useMemo(()=>QS(t.models,h),[t.models,h]),v=qS(y.length,Nv,YS);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Xx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:m,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),a.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):a.jsx("div",{...v.containerProps,children:a.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return a.jsx(e2,{model:b,isActive:b.id===r,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function JS(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function e2({model:t,isActive:r,isFocused:s,onSelect:o,resolvedModel:c}){const u=XS(t),d=JS(t.id,c,t.resolvedId),h=d!==null,g=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",m=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Nv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:m,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Qx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function t2(){const[t,r]=p.useState(null),[s,o]=p.useState(!0),[c,u]=p.useState(null),d=p.useCallback(async()=>{o(!0);try{const m=await fetch("/api/settings/keys");if(!m.ok)throw new Error(`GET /api/settings/keys returned ${m.status}`);const y=await m.json();r({...Qx,...y}),u(null)}catch(m){u(m.message),r(Qx)}finally{o(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=p.useCallback(async m=>{const y=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function n2({onMigrated:t,fetchImpl:r}){const[s,o]=p.useState({kind:"loading"}),c=r??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((m=v.darwinKeys)==null?void 0:m.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);p.useEffect(()=>{u()},[u]);const d=p.useCallback(async()=>{o({kind:"working"});try{const m=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok){o({kind:"error",message:`Migration failed (${m.status})`});return}const y=await m.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(m){o({kind:"error",message:m.message})}},[c,u,t]),h=p.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:jd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...jd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...jd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const jd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},a2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function r2(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function Tv({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=t2(),g=p.useRef(null),m=p.useRef(null),[y,v]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const w=await k.json();S||v(w.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const w=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(w);C==null||C.focus()},0);return()=>{var w;clearTimeout(k),(w=S==null?void 0:S.focus)==null||w.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),r();return}if(k.key==="Tab"&&g.current){const w=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(w.length===0)return;const C=w[0],N=w[w.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]);const b=p.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),a.jsx(n2,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),a2.map(S=>a.jsx(l2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const w=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),w},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?m:void 0},S.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Or,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function l2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[m,y]=p.useState(""),[v,b]=p.useState(!1),[S,k]=p.useState(!1),[w,C]=p.useState(!1),[N,R]=p.useState(null),L=m.trim(),B=L.length===0,D=L.length>0&&!L.startsWith(o),F=p.useCallback(async()=>{if(B)return;k(!0);const z=L;y("");try{const I=await d(z);I.warning?R(I.warning):R(null)}finally{k(!1)}},[B,d,L]),E=p.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const I=await navigator.clipboard.readText();y(I)}catch{}},[]),H=p.useCallback(async()=>{C(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:m,onChange:z=>{y(z.target.value),R(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>b(!v),style:Or,children:v?ne.settings.hide:ne.settings.show}),a.jsx("button",{type:"button",onClick:E,style:Or,children:ne.settings.paste})]}),D&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Zx,children:ne.settings.prefixWarn(r)}),N&&a.jsx("div",{role:"status",style:Zx,children:N}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Or,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:w?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:H,"data-testid":`remove-confirm-${t}`,style:{...Or,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>C(!1),style:Or,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Or,color:"var(--text-muted)"},children:ne.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(r2(u.updatedAt)):ne.settings.noKey})]})]})}const Or={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Zx={fontSize:11,color:"var(--warning, var(--text-muted))"};function s2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function i2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=kS({onStaleCatalog:(I,U)=>{const q=Math.round(U/6e4);t==null||t(`Using cached ${I} catalog (${q} min old)`)},onSetActiveError:I=>t==null?void 0:t(I)}),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(),[v,b]=p.useState(null),[S,k]=p.useState("agents"),[w,C]=p.useState(0),N=p.useRef(null);p.useRef(null),p.useEffect(()=>{var I;s&&!v&&b(s.activeAgent??((I=s.agents[0])==null?void 0:I.id)??null)},[s,v]);const R=(s==null?void 0:s.agents)??[],L=p.useMemo(()=>R.find(I=>I.id===v)??R[0],[R,v]);p.useEffect(()=>{C(0)},[v]);const B=p.useCallback(()=>{var I;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((I=R[0])==null?void 0:I.id)??null),C(0)},[s,R]),D=p.useCallback(()=>{var I;d(!1),(I=N.current)==null||I.focus()},[]);p.useEffect(()=>{const I=U=>{var X;if(!(U.metaKey||U.ctrlKey)||U.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(U.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),p.useEffect(()=>{if(!u)return;const I=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),U(1);return}if(q.key==="ArrowUp"){q.preventDefault(),U(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((L==null?void 0:L.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&L)k("models"),C(0);else if(S==="models"&&L){const X=Math.max(0,Math.min(L.models.length-1,w)),J=L.models[X];J&&(c(L.id,J.id),D())}return}};function U(q){if(S==="agents"){const X=R.findIndex($=>$.id===v),J=R[Math.max(0,Math.min(R.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&L){const X=L.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[u,S,R,v,L,w,D,o,c]);const F=p.useCallback(I=>{y(I==="anthropic"||I==="openrouter"?I:void 0),g(!0),d(!1)},[]),E=R.find(I=>I.id===(s==null?void 0:s.activeAgent)),H=E==null?void 0:E.models.find(I=>I.id===(s==null?void 0:s.activeModel)),z=p.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const I=(E==null?void 0:E.displayName)??"Agent",U=(H==null?void 0:H.displayName)??s.activeModel??"Model";return`${I} · ${U}`},[r,s,E,H]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:E!=null&&E.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:z})]}),u&&typeof document<"u"&&Fo.createPortal(a.jsxs(o2,{reducedMotion:s2(),onClickOutside:D,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx(WS,{agents:R,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:I=>{b(I),o(I)},onSelect:I=>{b(I),o(I),k("models")},onOpenSettings:F}),L&&a.jsx(ZS,{agent:L,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?w:-1,onSelect:I=>{c(L.id,I),D()},onOpenSettings:F})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),a.jsx(Tv,{open:h,onClose:()=>g(!1),initialProvider:m,onToast:t})]})}function o2({children:t,reducedMotion:r,onClickOutside:s}){const o=p.useRef(null);return p.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
61
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=or(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=iv(t,{pathname:S});return Zn(p||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),tj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:ca([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:ca([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function Q0(){let t=sj(),r=B0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:u},"ErrorBoundary")," or"," ",m.createElement("code",{style:u},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},r),s?m.createElement("pre",{style:c},s):null,d)}var Z0=m.createElement(Q0,null),vv=class extends m.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){this.props.onError?this.props.onError(t,r):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=W0(t.digest);s&&(t=s)}let r=t!==void 0?m.createElement(La.Provider,{value:this.props.routeContext},m.createElement(pf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(J0,{error:t},r):r}};vv.contextType=H0;var hd=new WeakMap;function J0({children:t,error:r}){let{basename:s}=m.useContext(Gn);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=G0(r.digest);if(o){let c=hd.get(r);if(c)throw c;let u=fv(o.location,s);if(dv&&!hd.get(r))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw hd.set(r,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function ej({routeContext:t,match:r,children:s}){let o=m.useContext(Dl);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),m.createElement(La.Provider,{value:t},s)}function tj(t,r=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(r.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,p=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:I0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,E=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||Z0,d&&(h<0&&b===0?(yv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=r.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:k?A=C:v.route.Component?A=m.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,m.createElement(ej,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?m.createElement(vv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:p}):T()},null)}function mf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nj(t){let r=m.useContext(Dl);return Ft(r,mf(t)),r}function aj(t){let r=m.useContext($o);return Ft(r,mf(t)),r}function rj(t){let r=m.useContext(La);return Ft(r,mf(t)),r}function hf(t){let r=rj(t),s=r.matches[r.matches.length-1];return Ft(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function lj(){return hf("useRouteId")}function sj(){var o;let t=m.useContext(pf),r=aj("useRouteError"),s=hf("useRouteError");return t!==void 0?t:(o=r.errors)==null?void 0:o[s]}function ij(){let{router:t}=nj("useNavigate"),r=hf("useNavigate"),s=m.useRef(!1);return gv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{Zn(s.current,xv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:r,...u}))},[t,r])}var Hx={};function yv(t,r,s){!r&&!Hx[t]&&(Hx[t]=!0,Zn(!1,s))}m.memo(oj);function oj({routes:t,future:r,state:s,isStatic:o,onError:c}){return X0(t,void 0,{state:s,isStatic:o,onError:c})}function cj({basename:t="/",children:r=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Ft(!Ys(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=m.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=zl(s));let{pathname:p="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,E=m.useMemo(()=>{let C=Ma(p,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,p,y,v,b,S,o,k]);return Zn(E!=null,`<Router basename="${h}"> is not able to match the URL "${p}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(Gn.Provider,{value:g},m.createElement(Vo.Provider,{children:r,value:E}))}var To="get",Ro="application/x-www-form-urlencoded";function Po(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function uj(t){return Po(t)&&t.tagName.toLowerCase()==="button"}function dj(t){return Po(t)&&t.tagName.toLowerCase()==="form"}function fj(t){return Po(t)&&t.tagName.toLowerCase()==="input"}function pj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function mj(t,r){return t.button===0&&(!r||r==="_self")&&!pj(t)}var go=null;function hj(){if(go===null)try{new FormData(document.createElement("form"),0),go=!1}catch{go=!0}return go}var xj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xd(t){return t!=null&&!xj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ro}"`),null):t}function gj(t,r){let s,o,c,u,d;if(dj(t)){let h=t.getAttribute("action");o=h?Ma(h,r):null,s=t.getAttribute("method")||To,c=xd(t.getAttribute("enctype"))||Ro,u=new FormData(t)}else if(uj(t)||fj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Ma(g,r):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||To,c=xd(t.getAttribute("formenctype"))||xd(h.getAttribute("enctype"))||Ro,u=new FormData(h,t),!hj()){let{name:p,type:y,value:v}=t;if(y==="image"){let b=p?`${p}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else p&&u.append(p,v)}}else{if(Po(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=To,o=null,c=Ro,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function xf(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function vj(t,r,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:r&&Ma(c.pathname,r)==="/"?c.pathname=`${r.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function yj(t,r){if(t.id in r)return r[t.id];try{let s=await import(t.module);return r[t.id]=s,s}catch(s){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function bj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function jj(t,r,s){let o=await Promise.all(t.map(async c=>{let u=r.routes[c.route.id];if(u){let d=await yj(u,s);return d.links?d.links():[]}return[]}));return Cj(o.flat(1).filter(bj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function $x(t,r,s,o,c,u){let d=(g,p)=>s[p]?g.route.id!==s[p].route.id:!0,h=(g,p)=>{var y;return s[p].pathname!==g.pathname||((y=s[p].route.path)==null?void 0:y.endsWith("*"))&&s[p].params["*"]!==g.params["*"]};return u==="assets"?r.filter((g,p)=>d(g,p)||h(g,p)):u==="data"?r.filter((g,p)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,p)||h(g,p))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Sj(t,r,{includeHydrateFallback:s}={}){return kj(t.map(o=>{let c=r.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function kj(t){return[...new Set(t)]}function wj(t){let r={},s=Object.keys(t).sort();for(let o of s)r[o]=t[o];return r}function Cj(t,r){let s=new Set;return new Set(r),t.reduce((o,c)=>{let u=JSON.stringify(wj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function bv(){let t=m.useContext(Dl);return xf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ej(){let t=m.useContext($o);return xf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var gf=m.createContext(void 0);gf.displayName="FrameworkContext";function jv(){let t=m.useContext(gf);return xf(t,"You must render this element inside a <HydratedRouter> element"),t}function Nj(t,r){let s=m.useContext(gf),[o,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:p,onMouseLeave:y,onTouchStart:v}=r,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),m.useEffect(()=>{if(o){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:As(h,S),onBlur:As(g,k),onMouseEnter:As(p,S),onMouseLeave:As(y,k),onTouchStart:As(v,S)}]:[!1,b,{}]}function As(t,r){return s=>{t&&t(s),s.defaultPrevented||r(s)}}function Tj({page:t,...r}){let{router:s}=bv(),o=m.useMemo(()=>iv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?m.createElement(Aj,{page:t,matches:o,...r}):null}function Rj(t){let{manifest:r,routeModules:s}=jv(),[o,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return jj(t,r,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,r,s]),o}function Aj({page:t,matches:r,...s}){let o=or(),{future:c,manifest:u,routeModules:d}=jv(),{basename:h}=bv(),{loaderData:g,matches:p}=Ej(),y=m.useMemo(()=>$x(t,r,p,u,o,"data"),[t,r,p,u,o]),v=m.useMemo(()=>$x(t,r,p,u,o,"assets"),[t,r,p,u,o]),b=m.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,C=!1;if(r.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!y.some(D=>D.route.id===T.route.id)&&T.route.id in g&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?C=!0:E.add(T.route.id))}),E.size===0)return[];let N=vj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&E.size>0&&N.searchParams.set("_routes",r.filter(T=>E.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,r,t,d]),S=m.useMemo(()=>Sj(v,u),[v,u]),k=Rj(v);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:C})=>m.createElement("link",{key:E,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Mj(...t){return r=>{t.forEach(s=>{typeof s=="function"?s(r):s!=null&&(s.current=r)})}}var Lj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Lj&&(window.__reactRouterVersion="7.13.1")}catch{}function zj({basename:t,children:r,unstable_useTransitions:s,window:o}){let c=m.useRef();c.current==null&&(c.current=p0({window:o,v5Compat:!0}));let u=c.current,[d,h]=m.useState({action:u.action,location:u.location}),g=m.useCallback(p=>{s===!1?h(p):m.startTransition(()=>h(p))},[s]);return m.useLayoutEffect(()=>u.listen(g),[u,g]),m.createElement(cj,{basename:t,children:r,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Sv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kv=m.forwardRef(function({onClick:r,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:p,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},E){let{basename:C,navigator:N,unstable_useTransitions:T}=m.useContext(Gn),A=typeof y=="string"&&Sv.test(y),B=fv(y,C);y=B.to;let D=q0(y,{relative:c}),F=or(),w=null;if(h){let $=ff(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:ca([C,$.pathname])),w=N.createHref($)}let[O,z,U]=Nj(o,k),H=Bj(y,{replace:d,unstable_mask:h,state:g,target:p,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function q($){r&&r($),$.defaultPrevented||H($)}let X=!(B.isExternal||u),J=m.createElement("a",{...k,...U,href:(X?w:void 0)||B.absoluteURL||D,onClick:X?q:r,ref:Mj(E,z),target:p,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,J,m.createElement(Tj,{page:D})):J});kv.displayName="Link";var Dj=m.forwardRef(function({"aria-current":r="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...p},y){let v=Ks(d,{relative:p.relative}),b=or(),S=m.useContext($o),{navigator:k,basename:E}=m.useContext(Gn),C=S!=null&&Vj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=b.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&E&&(A=Ma(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let D=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",F=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),w={isActive:D,isPending:F,isTransitioning:C},O=D?r:void 0,z;typeof o=="function"?z=o(w):z=[o,D?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(w):u;return m.createElement(kv,{...p,"aria-current":O,className:z,ref:y,style:U,to:d,viewTransition:h},typeof g=="function"?g(w):g)});Dj.displayName="NavLink";var _j=m.forwardRef(({discover:t="render",fetcherKey:r,navigate:s,reloadDocument:o,replace:c,state:u,method:d=To,action:h,onSubmit:g,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:E}=m.useContext(Gn),C=Hj(),N=$j(h,{relative:p}),T=d.toLowerCase()==="get"?"get":"post",A=typeof h=="string"&&Sv.test(h),B=D=>{if(g&&g(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,w=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>C(F||D.currentTarget,{fetcherKey:r,method:w,navigate:s,replace:c,state:u,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});E&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:k,method:T,action:N,onSubmit:o?g:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});_j.displayName="Form";function Oj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wv(t){let r=m.useContext(Dl);return Ft(r,Oj(t)),r}function Bj(t,{target:r,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:p}={}){let y=Y0(),v=or(),b=Ks(t,{relative:d});return m.useCallback(S=>{if(mj(S,r)){S.preventDefault();let k=s!==void 0?s:Hs(v)===Hs(b),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});p?m.startTransition(()=>E()):E()}},[v,y,b,s,o,c,r,t,u,d,h,g,p])}var Ij=0,Uj=()=>`__${String(++Ij)}__`;function Hj(){let{router:t}=wv("useSubmit"),{basename:r}=m.useContext(Gn),s=lj(),o=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:h,method:g,encType:p,formData:y,body:v}=gj(u,r);if(d.navigate===!1){let b=d.fetcherKey||Uj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,r,s])}function $j(t,{relative:r}={}){let{basename:s}=m.useContext(Gn),o=m.useContext(La);Ft(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Ks(t||".",{relative:r})},d=or();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:ca([s,u.pathname])),Hs(u)}function Vj(t,{relative:r}={}){let s=m.useContext(mv);Ft(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=wv("useViewTransitionState"),c=Ks(t,{relative:r});if(!s.isTransitioning)return!1;let u=Ma(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Ma(s.nextLocation.pathname,o)||s.nextLocation.pathname;return _o(c.pathname,d)!=null||_o(c.pathname,u)!=null}var Fo=sv();const Pj=lv(Fo),Fj="modulepreload",Gj=function(t){return"/"+t},Vx={},Xs=function(r,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(p=>{if(p=Gj(p),p in Vx)return;Vx[p]=!0;const y=p.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":Fj,y||(b.as="script"),b.crossOrigin="",b.href=p,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})},Px={own:"authoring-project",installed:"available-project",global:"available-personal"},qd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Wj(t){if(typeof t=="string"){if(qd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Px,t))return Px[t]}return"authoring-project"}function qj(t){return t.startsWith("available-")?"available":"authoring"}function Yj(t){const r=t.indexOf("-");return t.slice(r+1)}const Vn="";class Os extends Error{constructor(r,s){super(r),this.name="ApiError",this.status=s}}async function $e(t,r){const s=await fetch(`${Vn}${t}`,r);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function Jt(t){return typeof t=="string"&&t.length>0?t:null}function Kj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function gd(t){if(!Array.isArray(t))return null;const r=t.filter(s=>typeof s=="string"&&s.length>0);return r.length>0?r:null}function Xj(t){const r=t??{};let s;r.origin==="source"||r.origin==="installed"?s=r.origin:(s="source",console.warn(`[api.getSkills] skill ${String(r.plugin)}/${String(r.skill)} has invalid origin=${JSON.stringify(r.origin)}; defaulting to 'source'`));let o;r.scope==="own"||r.scope==="installed"||r.scope==="global"?o=r.scope:o=s==="installed"?"installed":"own";let c;r.installMethod==="authored"||r.installMethod==="copied"||r.installMethod==="symlinked"?c=r.installMethod:c=o==="own"?"authored":"copied";const u=typeof r.scopeV2=="string"&&qd.has(r.scopeV2)?r.scopeV2:Wj(r.scope),d=qj(u),h=Yj(u),g=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let p;r.shadowedBy===null?p=null:typeof r.shadowedBy=="string"&&qd.has(r.shadowedBy)?p=r.shadowedBy:p=void 0;const y={plugin:typeof r.plugin=="string"?r.plugin:"",skill:typeof r.skill=="string"?r.skill:"",dir:typeof r.dir=="string"?r.dir:"",hasEvals:!!r.hasEvals,hasBenchmark:!!r.hasBenchmark,evalCount:typeof r.evalCount=="number"?r.evalCount:0,assertionCount:typeof r.assertionCount=="number"?r.assertionCount:0,benchmarkStatus:r.benchmarkStatus==="pass"||r.benchmarkStatus==="fail"||r.benchmarkStatus==="pending"||r.benchmarkStatus==="stale"||r.benchmarkStatus==="missing"?r.benchmarkStatus:"missing",lastBenchmark:typeof r.lastBenchmark=="string"?r.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:Jt(r.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:Jt(r.pluginName),pluginNamespace:Jt(r.pluginNamespace),pluginMarketplace:Jt(r.pluginMarketplace),pluginManifestPath:Jt(r.pluginManifestPath),pluginVersion:Jt(r.pluginVersion),precedenceRank:g,shadowedBy:p,description:Jt(r.description),version:Jt(r.version),category:Jt(r.category),author:Jt(r.author),license:Jt(r.license),homepage:Jt(r.homepage),repoUrl:Jt(r.repoUrl),skillPath:Jt(r.skillPath),tags:gd(r.tags),deps:gd(r.deps),mcpDeps:gd(r.mcpDeps),entryPoint:Jt(r.entryPoint),lastModified:Jt(r.lastModified),sizeBytes:Kj(r.sizeBytes),sourceAgent:Jt(r.sourceAgent)};if(r.provenance&&typeof r.provenance=="object"){const v=r.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else r.provenance===null&&(y.provenance=null);return typeof r.updateAvailable=="boolean"&&(y.updateAvailable=r.updateAvailable),typeof r.currentVersion=="string"&&(y.currentVersion=r.currentVersion),typeof r.latestVersion=="string"&&(y.latestVersion=r.latestVersion),typeof r.pinnedVersion=="string"&&(y.pinnedVersion=r.pinnedVersion),y}const Ce={getConfig(){return $e("/api/config")},setConfig(t,r){return $e("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:r})})},async getSkills(t){const r=new URLSearchParams;t!=null&&t.scope&&r.set("scope",t.scope),t!=null&&t.agent&&r.set("agent",t.agent);const s=r.toString(),o=await $e(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Xj):[]},getAgents(){return $e("/api/agents")},getSkillDetail(t,r){return $e(`/api/skills/${t}/${r}`)},async getEvals(t,r){const s=await $e(`/api/skills/${t}/${r}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:r,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/evals`)},getActivationHistoryEnvelope(t,r){return $e(`/api/skills/${t}/${r}/activation-history`)},saveEvals(t,r,s){return $e(`/api/skills/${t}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,r){return $e(`/api/skills/${t}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,r){const s=await fetch(`${Vn}/api/skills/${t}/${r}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,r,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return $e(`/api/skills/${t}/${r}/history${c?"?"+c:""}`)},getHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`)},compareRuns(t,r,s,o){return $e(`/api/skills/${t}/${r}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,r,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return $e(`/api/skills/${t}/${r}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,r){return $e(`/api/skills/${t}/${r}`,{method:"DELETE"})},improveSkill(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,r,s){return $e(`/api/skills/${t}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,r){return $e(`/api/skills/${t}/${r}/stats`)},getDependencies(t,r){return $e(`/api/skills/${t}/${r}/dependencies`)},getProjectLayout(){return $e("/api/project-layout")},createSkill(t){return $e("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return $e("/api/studio/detect-engines")},saveDraft(t){return $e("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return $e("/api/skill-creator-status")},generateSkill(t){return $e("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,r){return $e(`/api/skills/${t}/${r}/files`)},getSkillFile(t,r,s){return $e(`/api/skills/${t}/${r}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,r,s,o){return $e(`/api/skills/${t}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,r){return $e(`/api/skills/${t}/${r}/leaderboard`)},getLeaderboardEntry(t,r,s){return $e(`/api/skills/${t}/${r}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,r){return $e(`/api/credentials/${t}/${r}`)},setCredential(t,r,s,o){return $e(`/api/credentials/${t}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,r){return $e(`/api/credentials/${t}/${r}/params`)},getParamsRevealed(t,r,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return $e(`/api/credentials/${t}/${r}/params?${o}`)},searchModels(){return $e("/api/openrouter/models")},async getSkillVersions(t,r){const s=await $e(`/api/skills/${t}/${r}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/versions`)},getVersionDiff(t,r,s,o){return $e(`/api/skills/${t}/${r}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const r=`${Vn}/api/skills/batch-update`,s=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,r){const s=`${Vn}/api/skills/${t}/${r}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/update`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let u,d="";if(c.body){const h=c.body.getReader(),g=new TextDecoder;let p=!1,y="";for(;!p;){const b=await h.read();if(p=b.done,b.value){const S=g.decode(b.value,{stream:!p});y+=S,d.length<200&&(d+=S)}}const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}d=d.slice(0,200)}else{const h=await c.text();d=h.slice(0,200);const g=h.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(g)try{u=JSON.parse(g[1]).version}catch{}}return{ok:c.ok,status:c.status,body:d,version:u}},async rescanSkill(t,r){const s=`${t}/${r}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:[...t].sort()})});if(!r.ok)return[];const s=await r.json().catch(()=>null);return Array.isArray(s)?s:s&&typeof s=="object"&&Array.isArray(s.results)?s.results.map(o=>({skillId:typeof o.skillId=="string"?o.skillId:typeof o.name=="string"?o.name:"",version:typeof o.version=="string"?o.version:typeof o.latest=="string"?o.latest:"",eventId:typeof o.eventId=="string"?o.eventId:"",publishedAt:typeof o.publishedAt=="string"?o.publishedAt:"",diffSummary:typeof o.diffSummary=="string"?o.diffSummary:void 0,trackedForUpdates:typeof o.trackedForUpdates=="boolean"?o.trackedForUpdates:void 0,updateAvailable:typeof o.updateAvailable=="boolean"?o.updateAvailable:void 0,installed:typeof o.installed=="string"?o.installed:void 0,latest:typeof o.latest=="string"?o.latest:void 0,name:typeof o.name=="string"?o.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!r.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await r.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,r,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return vd(`/api/skills/${t}/${r}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,r,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return vd(`/api/skills/${t}/${r}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,r,s){return vd(`/api/skills/${t}/${r}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const r=new URLSearchParams;(t==null?void 0:t.before)!=null&&r.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&r.set("limit",String(t.limit));const s=r.toString();return $e(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return $e(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Vn}/api/studio/ops/stream`)}};async function vd(t,r,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Os(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,p=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
62
+ `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};r==null||r(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Os(p.message,500);throw y.code=p.code,y}if(!g)throw new Os("Transfer stream ended without 'done' event",500);return g}function Qj(t,r){if(!r.length)return t;const s=new Map,o=new Map;for(const c of r){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Zj(t){const[r,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const Jj=500,Yd="vskill.updates.seenLastId";function eS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Yd)}catch{return null}}function yd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Yd):window.localStorage.setItem(Yd,t)}catch{}}function tS(){let t=new Map;const r=new Set,s=new Set,o=[];let c=eS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>Jj){const g=o.shift();g&&s.delete(g)}c=h,yd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,yd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,yd(null),u()}}}const Dr=tS(),nS=3e5,aS=500,rS=15e3,lS=6e4,sS=6e4,iS="/api/v1/skills/stream";function Fx(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Gx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function oS(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function cS(t){const r=(t==null?void 0:t.intervalMs)??nS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??rS,c=(t==null?void 0:t.staleAfterMs)??lS,u=(t==null?void 0:t.disconnectFallbackMs)??sS,d=(t==null?void 0:t.streamUrlBase)??iS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,k]=m.useState(0),[E,C]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),D=m.useRef(null),F=m.useRef(null),w=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[U,H]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(U);q.current=U;const X=m.useSyncExternalStore(M=>Dr.subscribe(M),()=>Dr.getSnapshot(),()=>Dr.getSnapshot()),J=X.size,$=m.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const W=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(W==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(W),b(Fx(W)),k(Gx(W)),F.current=Date.now(),T(F.current),B(null)}catch(W){if(!z.current)return;B(W instanceof Error?W:new Error(String(W)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=m.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=m.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},r))},[r,L]),I=m.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);m.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const W=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",W),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",W),O.current&&clearTimeout(O.current),I()}},[]);const V=m.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const W=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:W}));te.length>0&&Dr.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,re=ye.get(_e);if(re){const he={...re};re.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Fx(Se)),k(Gx(Se)),Se})}catch{}},[]);m.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),W=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let ge;try{ge=JSON.parse(pe.data)}catch{return}if(!oS(ge)||Dr.ingest(ge)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${ge.skillId} updated to ${ge.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}},re=()=>{z.current&&(Dr.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(W),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",re))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",re)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),m.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const se=m.useCallback(M=>{Dr.dismiss(M)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:se}}function uS(t){const r=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),r.push(u)}return r}const dS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function fS(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Cv=m.createContext(null),Ev=Cv;function ea(){const t=m.useContext(Ev);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function pS({children:t}){const[r,s]=m.useReducer(fS,dS),o=Zj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=m.useState(c!==null);m.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),m.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??se),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=m.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,W]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===W);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:W,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{g()},[g]);const p=m.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=m.useRef(r.skills);m.useEffect(()=>{y.current=r.skills},[r.skills]);const v=m.useCallback((I,V)=>{const se=y.current,M=I?se.find(te=>te.plugin===I&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,W=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:W}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=m.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=m.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[D,F]=m.useState(""),w=m.useMemo(()=>r.skills.map(I=>`${I.plugin}/${I.skill}`),[r.skills]),O=m.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=cS({skillIds:O,trackingSkillIds:w}),U=m.useRef("");m.useEffect(()=>{const I=r.skills.filter(W=>W.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const W of z.updates)V.set(W.name.split("/").pop()||W.name,W);const se=I.map(W=>{const te=V.get(W.skill);return{plugin:W.plugin,skill:W.skill,name:(te==null?void 0:te.name)??W.skill,currentVersion:W.currentVersion??(te==null?void 0:te.installed)??"0.0.0"}}),M=se.map(W=>`${W.plugin}/${W.skill}@${W.currentVersion}#${W.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(W=>{if(Y)return;const ie=[...uS(W).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(W.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(W=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=W instanceof Error?W.message:String(W);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[r.skills,z.updates]);const H=m.useMemo(()=>{const I=r.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Qj(I,z.updates)},[r.skills,z.updates]),q=m.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=m.useMemo(()=>({...r,skills:H}),[r,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=m.useMemo(()=>({state:X,selectSkill:p,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,p,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return a.jsx(Ev.Provider,{value:_,children:t})}const mS={config:null,loading:!0};function hS(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Nv=m.createContext(null);function Hr(){const t=m.useContext(Nv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function xS({children:t}){const[r,s]=m.useReducer(hS,mS),o=m.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(Nv.Provider,{value:u,children:t})}function gS({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:p,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Wx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],vS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},yS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},bS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},jS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function SS(t,r){var h,g;const s=vS[t.id]??null,o=yS[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:jS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:kS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:bS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function kS(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function wS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Wx){const c=r.get(o);c&&s.push(c)}for(const o of t)Wx.includes(o.id)||s.push(o);return s}function CS(t){const[r,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=wS((A.providers||[]).map(D=>SS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{p.current=T,T==="openrouter"&&k()},[k]),C=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:r,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:N}}function bd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Kd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const ES={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,r)=>`${t} of ${r}`},NS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},TS={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},RS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},AS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},MS={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},LS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},zS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},DS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},_S={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},OS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},BS={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},IS={subscriptionBilling:"· subscription",free:"· free"},US={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},HS={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},$S={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},VS={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},PS={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},FS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},GS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},WS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:ES,shell:NS,detail:TS,actions:RS,palette:AS,shortcuts:MS,toasts:LS,connection:zS,forms:DS,errors:_S,picker:OS,providers:BS,models:IS,settings:US,statusBar:HS,scopePicker:$S,scopeSection:VS,claudeCodeLabel:PS,setupDrawer:FS,setupProviders:WS,scopeLabels:GS},qS=new Set(["claude-cli","claude-code"]);function qx(t){return qS.has(t)}const Yx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function YS({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Yx.has(g.id)),h=t.filter(g=>!Yx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Kx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=qx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),qx(t.id)&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Kd,{unlocked:!0,size:10}):a.jsx(Kd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(bd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(bd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(bd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function KS(t,r,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/r)-4),k=Math.ceil(s/r)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,r,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*r,offsetTop:v*r,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Tv=44,XS=352,QS=60,Xx=480;function ZS(t){var u,d;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function JS(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function e2({agent:t,activeModelId:r,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),QS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Xx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>JS(t.models,h),[t.models,h]),v=KS(y.length,Tv,XS);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Xx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:p,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),a.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):a.jsx("div",{...v.containerProps,children:a.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return a.jsx(n2,{model:b,isActive:b.id===r,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function t2(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function n2({model:t,isActive:r,isFocused:s,onSelect:o,resolvedModel:c}){const u=ZS(t),d=t2(t.id,c,t.resolvedId),h=d!==null,g=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Tv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Qx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,r]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();r({...Qx,...y}),u(null)}catch(p){u(p.message),r(Qx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function r2({onMigrated:t,fetchImpl:r}){const[s,o]=m.useState({kind:"loading"}),c=r??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:jd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...jd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...jd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const jd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},l2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function s2(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function Rv({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),r();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]);const b=m.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),a.jsx(r2,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),l2.map(S=>a.jsx(i2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Or,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function i2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[S,k]=m.useState(!1),[E,C]=m.useState(!1),[N,T]=m.useState(null),A=p.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=m.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>b(!v),style:Or,children:v?ne.settings.hide:ne.settings.show}),a.jsx("button",{type:"button",onClick:w,style:Or,children:ne.settings.paste})]}),D&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Zx,children:ne.settings.prefixWarn(r)}),N&&a.jsx("div",{role:"status",style:Zx,children:N}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Or,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:E?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Or,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>C(!1),style:Or,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Or,color:"var(--text-muted)"},children:ne.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(s2(u.updatedAt)):ne.settings.noKey})]})]})}const Or={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Zx={fontSize:11,color:"var(--warning, var(--text-muted))"};function o2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function c2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=CS({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[S,k]=m.useState("agents"),[E,C]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);m.useEffect(()=>{C(0)},[v]);const B=m.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=m.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);m.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),m.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=m.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[r,s,w,O]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:z})]}),u&&typeof document<"u"&&Fo.createPortal(a.jsxs(u2,{reducedMotion:o2(),onClickOutside:D,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx(YS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&a.jsx(e2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),a.jsx(Rv,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function u2({children:t,reducedMotion:r,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
63
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
64
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
- }`})]})}function Jx(){typeof window>"u"||(window.location.hash="#/")}function c2({onHome:t}){const[r,s]=p.useState(!1),[o,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Jx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Jx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const u2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",d2=p.lazy(()=>Xs(()=>import("./UpdateDropdown-B6bbI5Am.js"),__vite__mapDeps([0,1])));function f2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=ea(),d=p.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[w,C]of u)C.diffSummary&&k.set(w,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=p.useState(!1),m=p.useRef(null),y=p.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:m,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:u2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(p.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(d2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const w=k.name.split("/"),C=w.length>=2?w[w.length-2]:w[0],N=w[w.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:m})})]})}function eg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function p2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(c2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(tg,{segment:"origin",onClick:()=>eg({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(ng,{}),a.jsx(tg,{segment:"plugin",onClick:()=>eg({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(ng,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(i2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(f2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function tg({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Go="vskill-theme";function Rv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function m2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function h2(t){try{const r=t.getItem(Go);return Rv(r)}catch{return"auto"}}function x2(t,r){try{t.setItem(Go,r)}catch{}}function g2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function v2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Av=p.createContext(null);function y2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=p.useState(()=>c?h2(c):"auto"),[m,y]=p.useState(()=>v2(u)),v=p.useMemo(()=>m2(h,m),[h,m]);p.useEffect(()=>{d&&g2(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),w=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",w),()=>k.removeEventListener("change",w);const C=k;return C.addListener(w),()=>C.removeListener(w)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const k=w=>{w.key===Go&&g(Rv(w.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),p.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const w=R=>{R?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};w(k.matches);const C=R=>w(R.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=p.useCallback(k=>{g(k),c&&x2(c,k)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Av.Provider,{value:S,children:o})}function Mv(){const t=p.useContext(Av);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function b2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=r.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function j2(t){const[r,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function S2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=b2(t),c=j2(640),[u,d]=p.useState(!1),h=p.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(m=>m.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(m=>a.jsx(rg,{p:m,onClick:h},m.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(rg,{p:g,onClick:h,compact:!0},g.id))})}function rg({p:t,onClick:r,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Kd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function k2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Go)}catch{return null}}function w2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:m}=Mv(),v=k2()==="auto",b=C2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(lg,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(E2,{color:S}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(lg,{}),a.jsx(S2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>m(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(N2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function C2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function E2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function lg(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function N2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Xd=new Set;function Lv(){for(const t of Xd)t()}const T2=5,R2=1e3,A2=6e4;function M2(){const[t,r]=p.useState(void 0),[s,o]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),g=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),w=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const R=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const L=await R.json();if(!m.current)return;d.current=0,r(L.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{m.current&&b(B=>B+1)},A2)}catch(R){if(!m.current||R instanceof DOMException&&R.name==="AbortError")return;if(d.current+=1,u(!1),d.current>T2){o(!0);return}const L=R2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{m.current&&b(B=>B+1)},L)}},[k]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),k()}),[k]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),w())},[v,w]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(R=>R+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=p.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(Xd.add(C),()=>{Xd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const Wo=0,cr=1,_l=2,zv=4;function sg(t){return()=>t}function L2(t){t()}function Dv(t,r){return s=>t(r(s))}function ig(t,r){return()=>t(r)}function z2(t,r){return s=>t(r,s)}function vf(t){return t!==void 0}function D2(...t){return()=>{t.map(L2)}}function Ol(){}function qo(t,r){return r(t),t}function _2(t,r){return r(t)}function jt(...t){return t}function at(t,r){return t(cr,r)}function Pe(t,r){t(Wo,r)}function yf(t){t(_l)}function wt(t){return t(zv)}function Te(t,r){return at(t,z2(r,Wo))}function Qn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function og(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function _v(t,r){return t===r}function bt(t=_v){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function De(t){return r=>s=>{t(s)&&r(s)}}function ke(t){return r=>Dv(r,t)}function ia(t){return r=>()=>{r(t)}}function me(t,...r){const s=O2(...r);return((o,c)=>{switch(o){case _l:yf(t);return;case cr:return at(t,s(c))}})}function oa(t,r){return s=>o=>{s(r=t(r,o))}}function Hr(t){return r=>s=>{t>0?t--:r(s)}}function Aa(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Fe(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const m=s;s|=h,r[d]=g,m!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function O2(...t){return r=>t.reduceRight(_2,r)}function B2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=at(t,u),r):(o(),Ol);case _l:o(),s=null;return}}}function ge(t){let r=t;const s=Xe();return((o,c)=>{switch(o){case Wo:r=c;break;case cr:{c(r);break}case zv:return r}return s(o,c)})}function nn(t,r){return qo(ge(r),s=>Te(t,s))}function Xe(){const t=[];return((r,s)=>{switch(r){case Wo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return qo(Xe(),r=>Te(t,r))}function et(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:I2(),singleton:s}}const I2=()=>Symbol();function H2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Ht(...t){const r=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Pe(r,s)})}),function(u,d){switch(u){case _l:{yf(r);return}case cr:return o===c&&d(s),at(r,d)}}}function ze(t,r=_v){return me(t,bt(r))}function Qd(...t){return function(r,s){switch(r){case _l:return;case cr:return D2(...t.map(o=>at(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},U2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},$2=()=>typeof globalThis>"u"?window:globalThis,ur=et(()=>{const t=ge(Pt.ERROR);return{log:ge((r,s,o=Pt.INFO)=>{const c=$2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[U2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function $r(t,r,s){return bf(t,r,s).callbackRef}function bf(t,r,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function V2(t,r,s,o,c,u,d,h,g){const m=Ne.useCallback(y=>{const v=P2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const w=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(w,0),viewportHeight:N}),u==null||u(h?cg("column-gap",getComputedStyle(y).columnGap,c):cg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return bf(m,s,g)}function P2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}function Ov(t,r,s){const o=Ne.useRef(null),c=Ne.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const m=g.getBoundingClientRect(),y=m.width;let v,b;if(r){const S=r.getBoundingClientRect(),k=m.top-S.top;b=S.height-Math.max(0,k),v=k+r.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}o.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=bf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var m;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=et(()=>{const t=Xe(),r=Xe(),s=ge(0),o=Xe(),c=ge(0),u=Xe(),d=Xe(),h=ge(0),g=ge(0),m=ge(0),y=ge(0),v=Xe(),b=Xe(),S=ge(!1),k=ge(!1),w=ge(!1);return Te(me(t,ke(({scrollTop:C})=>C)),r),Te(me(t,ke(({scrollHeight:C})=>C)),d),Te(r,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),$s={lvl:0};function Bv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===$s}function Vs(t,r){if(!ft(t))return r===t.k?t.v:r<t.k?Vs(t.l,r):Vs(t.r,r)}function Jn(t,r,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Jn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,r,s)}function En(t,r,s){return ft(t)?Uv(r,s,1):r===t.k?Vt(t,{k:r,v:s}):r<t.k?ug(Vt(t,{l:En(t.l,r,s)})):ug(Vt(t,{r:En(t.r,r,s)}))}function Rl(){return $s}function Al(t,r,s){if(ft(t))return[];const o=Jn(t,r)[0];return F2(Jd(t,o,s))}function Zd(t,r){if(ft(t))return $s;const{k:s,l:o,r:c}=t;if(r===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=Hv(o);return Ao(Vt(t,{k:u,l:Iv(o),v:d}))}return r<s?Ao(Vt(t,{l:Zd(o,r)})):Ao(Vt(t,{r:Zd(c,r)}))}function Ir(t){return ft(t)?[]:[...Ir(t.l),{k:t.k,v:t.v},...Ir(t.r)]}function Jd(t,r,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Jd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Jd(u,r,s))),h}function Ao(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(Sd(r))return $v(Vt(t,{lvl:s-1}));if(!ft(r)&&!ft(r.r))return Vt(r.r,{l:Vt(r,{r:r.r.l}),lvl:s,r:Vt(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Sd(t))return ef(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=Sd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:ef(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,r){return Uv(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function Iv(t){return ft(t.r)?t.l:Ao(Vt(t,{r:Iv(t.r)}))}function Sd(t){return ft(t)||t.lvl>t.r.lvl}function Hv(t){return ft(t.r)?[t.k,t.v]:Hv(t.r)}function Uv(t,r,s,o=$s,c=$s){return{k:t,l:o,lvl:s,r:c,v:r}}function ug(t){return ef($v(t))}function $v(t){const{l:r}=t;return!ft(r)&&r.lvl===t.lvl?Vt(r,{r:Vt(t,{l:r.r})}):t}function ef(t){const{lvl:r,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===r&&s.r.lvl===r?Vt(s,{l:Vt(t,{r:s.l}),lvl:r+1}):t}function F2(t){return Bv(t,({k:r,v:s})=>({index:r,value:s}))}function Vv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Ps(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const jf=et(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Pv(t,r,s){return t[Oo(t,r,s)]}function Oo(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function G2(t,r,s,o){const c=Oo(t,r,o),u=Oo(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Yo(t){return!ft(t.groupOffsetTree)}function Sf({index:t},r){return r===t?0:r<t?-1:1}function W2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function q2(t,r){let s=ft(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(ek(o)))continue;let g=!1,m=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Zd(t,v)):(m=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));m&&(t=En(t,d,u))}return[t,s]}function Y2(t){return typeof t.groupIndex<"u"}function K2({offset:t},r){return r===t?0:r<t?-1:1}function Fs(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Pv(r,t,Sf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Fv(t,r){if(!Yo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Gv(t,r,s){if(Y2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Fv(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function X2(t,r,s,o=0){return o>0&&(r=Math.max(r,Pv(t,o,Sf).offset)),Bv(G2(t,r,s,K2),J2)}function Q2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&r.length===2){const b=r[0].size,S=r[1].size;d=s.reduce((k,w)=>En(En(k,w,b),w+1,S),d)}else[d,h]=q2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v}=tf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Fs(S,v,c)),Rl()),lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function Z2(t){return Ir(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function dg(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function tf(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Oo(c,r-1,Sf),h=c[g].offset;const m=Jn(s,r-1);u=m[0],d=m[1],c.length&&c[g].size===Jn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:m,value:y}of Al(s,r,1/0)){const v=m-u,b=v*d+h+v*o;c.push({index:m,offset:b,size:y}),u=m,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function J2(t){return{index:t.index,value:t}}function ek(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const tk={offsetHeight:"height",offsetWidth:"width"},ua=et(([{log:t},{recalcInProgress:r}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ge(0),g=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((E,H)=>ir(E,tk[H])),k=ge(void 0),w=ge(0),C=W2(),N=nn(me(s,Fe(g,t,w),oa(Q2,C),bt()),C),R=nn(me(g,bt(),oa((E,H)=>({current:H,prev:E.current}),{current:[],prev:[]}),ke(({prev:E})=>E)),[]);Te(me(g,De(E=>E.length>0),Fe(N,w),ke(([E,H,z])=>{const I=E.reduce((U,q,X)=>En(U,q,Fs(q,H.offsetTree,z)||X),Rl());return{...H,groupIndices:E,groupOffsetTree:I}})),N),Te(me(o,Fe(N),De(([E,{lastIndex:H}])=>E<H),ke(([E,{lastIndex:H,lastSize:z}])=>[{endIndex:H,size:z,startIndex:E}])),s),Te(m,y);const L=nn(me(m,ke(E=>E===void 0)),!0);Te(me(y,De(E=>E!==void 0&&ft(wt(N).sizeTree)),ke(E=>{const H=wt(v),z=wt(g).length>0;return H!==void 0&&H!==0?z?[{endIndex:0,size:H,startIndex:0},{endIndex:1,size:E,startIndex:1}]:[]:[{endIndex:0,size:E,startIndex:0}]})),s),Te(me(b,De(E=>E!==void 0&&E.length>0&&ft(wt(N).sizeTree)),ke(E=>{const H=[];let z=E[0],I=0;for(let U=1;U<E.length;U++){const q=E[U];q!==z&&(H.push({endIndex:U-1,size:z,startIndex:I}),z=q,I=U)}return H.push({endIndex:E.length-1,size:z,startIndex:I}),H})),s),Te(me(g,Fe(v,y),De(([,E,H])=>E!==void 0&&H!==void 0),ke(([E,H,z])=>{const I=[];for(let U=0;U<E.length;U++){const q=E[U],X=E[U+1];I.push({startIndex:q,endIndex:q,size:H}),X!==void 0&&I.push({startIndex:q+1,endIndex:X-1,size:z})}return I})),s);const B=Nn(me(s,Fe(N),oa(({sizes:E},[H,z])=>({changed:z!==E,sizes:z}),{changed:!1,sizes:C}),ke(E=>E.changed)));at(me(h,oa((E,H)=>({diff:E.prev-H,prev:H}),{diff:0,prev:0}),ke(E=>E.diff)),E=>{const{groupIndices:H}=wt(N);if(E>0)Pe(r,!0),Pe(u,E+dg(E,H));else if(E<0){const z=wt(R);z.length>0&&(E-=dg(-E,z)),Pe(d,E)}}),at(me(h,Fe(t)),([E,H])=>{E<0&&H("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Te(me(u,Fe(N),ke(([E,H])=>{const z=H.groupIndices.length>0,I=[],U=H.lastSize;if(z){const q=Vs(H.sizeTree,0);let X=0,J=0;for(;X<E;){const M=H.groupIndices[J],_=H.groupIndices.length===J+1?1/0:H.groupIndices[J+1]-M-1;I.push({endIndex:M,size:q,startIndex:M}),I.push({endIndex:M+1+_-1,size:U,startIndex:M+1}),J++,X+=_+1}const $=Ir(H.sizeTree);return X!==E&&$.shift(),$.reduce((M,{k:_,v:O})=>{let V=M.ranges;return M.prevSize!==0&&(V=[...M.ranges,{endIndex:_+E-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:_+E,prevSize:O,ranges:V}},{prevIndex:E,prevSize:0,ranges:I}).ranges}return Ir(H.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+E,prevSize:J,ranges:[...q.ranges,{endIndex:X+E-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:U,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,w),ke(([E,{offsetTree:H},z])=>{const I=-E;return Fs(I,H,z)})));return Te(me(d,Fe(N,w),ke(([E,H,z])=>{if(H.groupIndices.length>0){if(ft(H.sizeTree))return H;let U=Rl();const q=wt(R);let X=0,J=0,$=0;for(;X<-E;){$=q[J];const M=q[J+1]-$-1;J++,X+=M+1}if(U=Ir(H.sizeTree).reduce((M,{k:_,v:O})=>En(M,Math.max(0,_+E),O),U),X!==-E){const M=Vs(H.sizeTree,$);U=En(U,0,M);const _=Jn(H.sizeTree,-E+1)[1];U=En(U,1,_)}return{...H,sizeTree:U,...tf(H.offsetTree,0,U,z)}}const I=Ir(H.sizeTree).reduce((U,{k:q,v:X})=>En(U,Math.max(0,q+E),X),Rl());return{...H,sizeTree:I,...tf(H.offsetTree,0,I,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:w,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:L,unshiftWith:u}},jt(ur,jf),{singleton:!0});function nk(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const Wv=et(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(nk)));return Te(me(h,ke(g=>g.totalCount)),s),Te(me(h,ke(g=>g.groupIndices)),t),Te(me(Ht(c,r,o),De(([g,m])=>Yo(m)),ke(([g,m,y])=>Jn(m.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ua,cn)),dr=et(([{log:t}])=>{const r=ge(!1),s=Nn(me(r,De(o=>o),bt()));return at(r,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:r}},jt(ur),{singleton:!0}),ak=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function qv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!ak)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Qs=et(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),w=ge(0);let C=null,N=null,R=null;function L(){C!==null&&(C(),C=null),R!==null&&(R(),R=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Te(me(S,Fe(s,v,o,w,h,d,b),Fe(t,u,c),ke(([[B,D,F,E,H,z,I,U],q,X,J])=>{const $=qv(B),{align:M,behavior:_,offset:O}=$,V=E-1,se=Gv($,D,V);let A=Fs(se,D.offsetTree,q)+z;M==="end"?(A+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(A+=I)):M==="center"?A+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:A-=H,O!==void 0&&O!==0&&(A+=O);const Y=W=>{L(),W?(U("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),U("list did not change, scroll successful",{},Pt.DEBUG))};if(L(),_==="smooth"){let W=!1;R=at(r,te=>{W=W||te}),C=Qn(y,()=>{Y(W)})}else C=Qn(me(r,rk(150)),Y);return N=setTimeout(()=>{L()},1200),Pe(g,!0),U("scrolling from index to",{behavior:_,index:se,top:A},Pt.DEBUG),{behavior:_,top:A}})),m),{scrollTargetReached:k,scrollToIndex:S,topListHeight:w}},jt(ua,cn,ur),{singleton:!0});function rk(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function kf(t,r){t===0?r():requestAnimationFrame(()=>{kf(t-1,r)})}function wf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Zs=et(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),g=ge(0),m=ge(!0);return Te(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),h),Te(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),m),at(me(Ht(r,d),Fe(h,s,t,m),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||vf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(m,!0)}),kf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ua,cn,Qs,dr),{singleton:!0});function Yv(t,r){return Math.abs(t-r)<1.01}const Gs="up",Bs="down",lk="none",sk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ik=0,Js=et(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),g=Xe(),m=Xe(),y=ge(4),v=ge(ik),b=nn(me(Qd(me(ze(c),Hr(1),ia(!0)),me(ze(c),Hr(1),ia(!1),og(100))),bt()),!1),S=nn(me(Qd(me(s,ia(!0)),me(s,ia(!1),og(200))),bt()),!1);Te(me(Ht(ze(c),ze(v)),ke(([R,L])=>R<=L),bt()),h),Te(me(h,Aa(50)),m);const k=Nn(me(Ht(o,ze(u),ze(r),ze(t),ze(y)),oa((R,[{scrollHeight:L,scrollTop:B},D,F,E,H])=>{const z=B+D-L>-H,I={scrollHeight:L,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>R.state.scrollTop?(q="SCROLLED_DOWN",X=R.state.scrollTop-B):(q="SIZE_DECREASED",X=R.state.scrollTop-B||R.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:I}}let U;return I.scrollHeight>R.state.scrollHeight?U="SIZE_INCREASED":D<R.state.viewportHeight?U="VIEWPORT_HEIGHT_DECREASING":B<R.state.scrollTop?U="SCROLLING_UPWARDS":U="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:U,state:I}},sk),bt((R,L)=>R!==void 0&&R.atBottom===L.atBottom))),w=nn(me(o,oa((R,{scrollHeight:L,scrollTop:B,viewportHeight:D})=>{if(!Yv(R.scrollHeight,L)){const F=L-(B+D)<1;return R.scrollTop!==B&&F?{changed:!0,jump:R.scrollTop-B,scrollHeight:L,scrollTop:B}:{changed:!0,jump:0,scrollHeight:L,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:L,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(R=>R.changed),ke(R=>R.jump)),0);Te(me(k,ke(R=>R.atBottom)),d),Te(me(d,Aa(50)),g);const C=ge(Bs);Te(me(o,ke(({scrollTop:R})=>R),bt(),oa((R,L)=>wt(S)?{direction:R.direction,prevScrollTop:L}:{direction:L<R.prevScrollTop?Gs:Bs,prevScrollTop:L},{direction:Bs,prevScrollTop:0}),ke(R=>R.direction)),C),Te(me(o,Aa(50),ia(lk)),C);const N=ge(0);return Te(me(b,De(R=>!R),ia(0)),N),Te(me(c,Aa(100),Fe(b),De(([R,L])=>L),oa(([R,L],[B])=>[L,B],[0,0]),ke(([R,L])=>L-R)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:w,scrollDirection:C,scrollVelocity:N}},jt(cn)),Ws="top",qs="bottom",fg="none";function pg(t,r,s){return typeof t=="number"?s===Gs&&r===Ws||s===Bs&&r===qs?t:0:s===Gs?r===Ws?t.main:t.reverse:r===qs?t.main:t.reverse}function mg(t,r){return typeof t=="number"?t:t[r]??0}const Cf=et(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ge(0),h=ge(0),g=ge(0),m=nn(me(Ht(ze(o),ze(c),ze(s),ze(u,Ps),ze(g),ze(d),ze(r),ze(t),ze(h)),ke(([y,v,b,[S,k],w,C,N,R,L])=>{const B=y-R,D=C+N,F=Math.max(b-B,0);let E=fg;const H=mg(L,Ws),z=mg(L,qs);return S-=R,S+=b+N,k+=b+N,k-=R,S>y+D-H&&(E=Gs),k<y-F+v+z&&(E=Bs),E!==fg?[Math.max(B-b-pg(w,Ws,E)-H,0),B-F-N+v+pg(w,qs,E)+z]:null}),De(y=>y!==null),bt(Ps)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:m}},jt(cn),{singleton:!0});function ok(t,r,s){if(Yo(r)){const o=Fv(t,r);return[{index:Jn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const kd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Mo(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const w=t[t.length-1];y=w.offset+w.size}const v=s-d,b=h+v*g+(v-1)*o,S=m,k=b-y;return{bottom:y,firstItemIndex:u,items:hg(t,c,u),offsetBottom:k,offsetTop:m,top:S,topItems:hg(r,c,u),topListHeight:r.reduce((w,C)=>C.size+w,0),totalCount:s}}function Kv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=wf(r,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Mo(m,[],h,c,s,o)}function hg(t,r,s){if(t.length===0)return[];if(!Yo(r))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(r.groupOffsetTree,o,c);let h,g=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:m.index-(g+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function xg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Vr=et(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const w=ge([]),C=ge(0),N=Xe(),R=ge(0);Te(u.topItemsIndexes,w);const L=nn(me(Ht(S,k,ze(g,Ps),ze(c),ze(o),ze(m),y,ze(w),ze(r),ze(s),ze(R),t),De(([E,H,,z,,,,,,,,I])=>{const U=I!==void 0&&I.length!==z;return E&&!H&&!U}),ke(([,,[E,H],z,I,U,q,X,J,$,M,_])=>{var Se,Ae;const O=I,{offsetTree:V,sizeTree:se}=O,A=wt(C);if(z===0)return{...kd,totalCount:z};if(E===0&&H===0)return A===0?{...kd,totalCount:z}:Kv(A,U,I,J,$,_||[]);if(ft(se))return A>0?null:Mo(ok(wf(U,z),O,_),[],z,$,O,J);const Y=[];if(X.length>0){const _e=X[0],re=X[X.length-1];let he=0;for(const pe of Al(se,_e,re)){const xe=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,re);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:xe}),he+=xe}}if(!q)return Mo([],Y,z,$,O,J);const W=X.length>0?X[X.length-1]+1:0,te=X2(V,E,H,W);if(te.length===0)return null;const fe=z-1,ie=qo([],_e=>{for(const re of te){const he=re.value;let pe=he.offset,xe=re.start;const je=he.size;if(he.offset<E){xe+=Math.floor((E-he.offset+$)/(je+$));const Oe=xe-re.start;pe+=Oe*je+Oe*$}xe<W&&(pe+=(W-xe)*je,xe=W);const Be=Math.min(re.end,fe);for(let Oe=xe;Oe<=Be&&!(pe>=H);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=xg(M,Ws),de=xg(M,qs);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],re=ie[ie.length-1];if(ye>0&&_e.index>W){const he=Math.min(ye,_e.index-W),pe=[];let xe=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;xe-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:xe,size:Be})}ie.unshift(...pe)}if(de>0&&re.index<fe){const he=Math.min(de,fe-re.index);let pe=re.offset+re.size+$;for(let xe=re.index+1;xe<=re.index+he;xe++){const je=((Ae=Al(se,xe,xe)[0])==null?void 0:Ae.value)??re.size;ie.push({data:_==null?void 0:_[xe],index:xe,offset:pe,size:je}),pe+=je+$}}}return Mo(ie,Y,z,$,O,J)}),De(E=>E!==null),bt()),kd);Te(me(t,De(vf),ke(E=>E==null?void 0:E.length)),c),Te(me(L,ke(E=>E.topListHeight)),v),Te(v,h),Te(me(L,ke(E=>[E.top,E.bottom])),d),Te(me(L,ke(E=>E.items)),N);const B=Nn(me(L,De(({items:E})=>E.length>0),Fe(c,t),De(([{items:E},H])=>E[E.length-1].originalIndex===H-1),ke(([,E,H])=>[E-1,H]),bt(Ps),ke(([E])=>E))),D=Nn(me(L,Aa(200),De(({items:E,topItems:H})=>E.length>0&&E[0].originalIndex===H.length),ke(({items:E})=>E[0].index),bt())),F=Nn(me(L,De(({items:E})=>E.length>0),ke(({items:E})=>{let H=0,z=E.length-1;for(;E[H].type==="group"&&H<z;)H++;for(;E[z].type==="group"&&z>H;)z--;return{endIndex:E[z].index,startIndex:E[H].index}}),bt(Vv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:L,minOverscanItemCount:R,rangeChanged:F,startReached:D,topItemsIndexes:w,...b}},jt(ua,Wv,Cf,Zs,Qs,Js,dr,jf),{singleton:!0}),Xv=et(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ht(s,t,o,r,c),ke(([h,g,m,y,v])=>h+g+m+y+v.offsetBottom+v.bottom)),0);return Te(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Vr),{singleton:!0}),ck=et(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ge(!1),o=nn(me(Ht(s,t,r),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Aa(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Xv),{singleton:!0}),Qv=et(()=>({context:ge(null)})),uk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Zv=et(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:m}])=>{const y=Xe();return Te(me(y,Fe(r,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,w,C,N,R],L])=>{const{calculateViewLocation:B=uk,done:D,...F}=v,E=Gv(v,b,k-1),H=Fs(E,b.offsetTree,L)+w+C,z=H+Jn(b.sizeTree,E)[1],I=R+C,U=R+S-N,q=B({itemBottom:z,itemTop:H,locationParams:F,viewportBottom:U,viewportTop:I});return q!==null?D&&Qn(me(d,De(X=>!X),Hr(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),m),{scrollIntoView:y}},jt(ua,cn,Qs,Vr,ur),{singleton:!0});function gg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const dk=(t,r)=>typeof t=="function"?gg(t(r)):r&&gg(t),fk=et(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ge(!1),w=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}at(me(Ht(me(ze(r),Hr(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],E,H,z,I])=>{let U=F&&z,q="auto";return U&&(q=dk(E,H||I),U=U&&q!==!1),{followOutputBehavior:q,shouldFollow:U,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function R(D){const F=Qn(c,E=>{D&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ht(ze(k),r,m),De(([D,,F])=>D!==!1&&F),oa(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,r)),([,D])=>{wt(h)&&R(D!==!1)}),at(w,()=>{R(wt(k)!==!1)}),at(Ht(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const L=ge(null),B=Xe();return Te(Qd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(r))),B),at(me(Ht(me(B,Hr(1)),g),Fe(ze(L),h,v,b),ke(([[D,F],E,H,z,I])=>F&&H&&(E==null?void 0:E({context:I,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Aa(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:w,followOutput:k,scrollIntoViewOnChange:L}},jt(ua,Js,Qs,Zs,dr,ur,cn,Qv,Zv)),pk=et(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,r,s,t),ke(([[,g],m,y,v,b,S=[]])=>Kv(g,m,y,v,b,S))),d),{}),jt(ua,Zs,Vr,dr),{singleton:!0}),mk=et(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ge(0);return at(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Hr(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(r,c)})})}),{initialScrollTop:o}},jt(dr,cn,Vr),{singleton:!0}),Jv=et(([{scrollVelocity:t}])=>{const r=ge(!1),s=Xe(),o=ge(!1);return Te(me(t,Fe(o,r,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:m}=u;if(d){if(m(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),r),at(me(Ht(r,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(Js),{singleton:!0}),Ef=et(([{scrollContainerState:t,scrollTo:r}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ge(!1),d=ge(void 0);return Te(me(Ht(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:g}))),t),Te(me(r,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),hk=et(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const m=Xe(),y=ge(void 0),v=ge(null),b=ge(null);return Te(h,v),Te(g,b),at(me(m,Fe(r,o,d,v,b,s)),([S,k,w,C,N,R,L])=>{const B=Z2(k.sizeTree);C&&N!==null&&R!==null&&(w=N.scrollTop-R.offsetTop),w-=L,S({ranges:B,scrollTop:w})}),Te(me(y,De(vf),ke(xk)),c),Te(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},jt(ua,cn,Zs,dr,Ef));function xk(t){return{align:"start",index:0,offset:t.scrollTop}}const gk=et(([{topItemsIndexes:t}])=>{const r=ge(0);return Te(me(r,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},jt(Vr));function ey(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const vk=ey(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),yk=et(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const w=Nn(me(g,Fe(d),oa(([,N,R,L],[{bottom:B,items:D,offsetBottom:F,totalCount:E},H])=>{const z=B+F;let I=0;return R===E&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(I=z-L,I!==0&&(I+=H))),[I,D,E,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,R,L,,,B])=>!B&&!L&&N!==0&&R===Gs),ke(([[N],,,,,R])=>(R("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(r,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(r,{behavior:"auto",top:-N}))}return at(me(w,Fe(t,u)),([N,R,L])=>{L&&vk()?Pe(t,R-N):C(-N)}),at(me(Ht(nn(u,!1),t,k),De(([N,R,L])=>!N&&!L&&R!==0),ke(([N,R])=>R),Aa(1)),C),Te(me(v,ke(N=>({top:-N}))),r),at(me(m,Fe(b,y),ke(([N,{groupIndices:R,lastSize:L,sizeTree:B},D])=>{function F(U){return U*(L+D)}if(R.length===0)return F(N);let E=0;const H=Vs(B,0);let z=0,I=0;for(;z<N;){z++,E+=H;let U=R.length===I+1?1/0:R[I+1]-R[I]-1;z+U>N&&(E-=H,U=N-z+1),z+=U,E+=F(U),I++}return E})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(r,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,Js,Vr,ua,ur,jf)),bk=et(([t,r,s,o,c,u,d,h,g,m,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...m,...y}),jt(Cf,pk,dr,Jv,Xv,mk,ck,Ef,Zv,ur,Qv)),ty=et(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:w,scrolledToInitialItem:C},N,R,L,B,{scrollToIndex:D},F,{topItemCount:E},{groupCounts:H},z])=>{const{listState:I,minOverscanItemCount:U,topItemsIndexes:q,rangeChanged:X,...J}=B;return Te(X,z.scrollSeekRangeChanged),Te(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:H,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:w,scrolledToInitialItem:C,sizeRanges:m,topItemCount:E,topItemsIndexes:q,totalCount:b,...L,groupIndices:d,itemSize:g,listState:I,minOverscanItemCount:U,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...R}},jt(ua,Zs,cn,hk,fk,Vr,Qs,yk,gk,Wv,bk));function jk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const vo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function ny(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Ne.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const R of o){const L=C[r.required[R]];Pe(L,N[R])}for(const R of c)if(R in N){const L=C[r.optional[R]];Pe(L,N[R])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function m(C){return u.reduce((N,R)=>(N[R]=L=>{const B=C[r.methods[R]];Pe(B,L)},N),{})}function y(C){return d.reduce((N,R)=>(N[R]=B2(C[r.events[R]]),N),{})}const v=Ne.forwardRef(function(C,N){const{children:R,...L}=C,[B]=Ne.useState(()=>qo(H2(t),E=>{g(E,L)})),[D]=Ne.useState(ig(y,B));vo(()=>{for(const E of d)E in L&&at(D[E],L[E]);return()=>{Object.values(D).map(yf)}},[L,D,B]),vo(()=>{g(B,L)}),Ne.useImperativeHandle(N,sg(m(B)));const F=s;return a.jsx(h.Provider,{value:B,children:s!==void 0?a.jsx(F,{...jk([...o,...c,...d],L),children:R}):R})}),b=C=>{const N=Ne.useContext(h);return Ne.useCallback(R=>{Pe(N[C],R)},[N,C])},S=C=>{const N=Ne.useContext(h)[C],R=Ne.useCallback(L=>at(N,L),[N]);return Ne.useSyncExternalStore(R,()=>wt(N),()=>wt(N))},k=C=>{const N=Ne.useContext(h)[C],[R,L]=Ne.useState(ig(wt,N));return vo(()=>at(N,B=>{B!==R&&L(sg(B))}),[N,R]),R},w=parseInt(Ne.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const R=Ne.useContext(h)[C];vo(()=>at(R,N),[N,R])},useEmitterValue:w,usePublisher:b}}const ay=Ne.createContext(void 0),ry=Ne.createContext(void 0),wd="-webkit-sticky",vg="sticky",Nf=ey(()=>{if(typeof document>"u")return vg;const t=document.createElement("div");return t.style.position=wd,t.style.position===wd?wd:vg}),ly=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Cd(t){return"self"in t}function Sk(t){return"body"in t}function sy(t,r,s,o=Ol,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),g=Ne.useRef(null),m=Ne.useCallback(b=>{let S,k,w;const C=b.target;if(Sk(C)||Cd(C)){const R=Cd(C)?C:C.defaultView;w=u===!0?R.scrollX:R.scrollY,S=u===!0?R.document.documentElement.scrollWidth:R.document.documentElement.scrollHeight,k=u===!0?R.innerWidth:R.innerHeight}else w=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(w,0),viewportHeight:k})};b.suppressFlushSync===!0?N():$j.flushSync(N),h.current!==null&&(w===h.current||w<=0||w===S-k)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Ne.useEffect(()=>{const b=c||d.current;return o(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",m)}},[d,m,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let w,C,N;Cd(S)?(C=Math.max(ir(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),w=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],w=ir(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const R=C-w;if(b.top=Math.ceil(Math.max(Math.min(R,b.top),0)),Yv(w,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:w}),k&&r(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Tf(t){return t}const kk=et(()=>{const t=ge(h=>`Item ${h}`),r=ge(h=>`Group ${h}`),s=ge({}),o=ge(Tf),c=ge("div"),u=ge(Ol),d=(h,g=null)=>nn(me(s,ke(m=>m[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),wk=et(([t,r])=>({...t,...r}),jt(ty,kk)),Ck=({height:t})=>a.jsx("div",{style:{height:t}}),Ek={overflowAnchor:"none",position:Nf(),zIndex:1},iy={overflowAnchor:"none"},Nk={...iy,display:"inline-block",height:"100%"},yg=Ne.memo(function({showTopList:t=!1}){const r=He("listState"),s=Pn("sizeRanges"),o=He("useWindowScroll"),c=He("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=He("itemContent"),m=He("context"),y=He("groupContent"),v=He("trackItemSizes"),b=He("itemSize"),S=He("log"),k=Pn("gap"),w=He("horizontalDirection"),{callbackRef:C}=V2(s,b,v,t?Ol:h,S,k,c,w,He("skipAnimationFrameInResizeObserver")),[N,R]=Ne.useState(0);Rf("deviation",J=>{N!==J&&R(J)});const L=He("EmptyPlaceholder"),B=He("ScrollSeekPlaceholder")??Ck,D=He("ListComponent"),F=He("ItemComponent"),E=He("GroupComponent"),H=He("computeItemKey"),z=He("isSeeking"),I=He("groupIndices").length>0,U=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:N!==0?N:U?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:U?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&L!==null&&L!==void 0?a.jsx(L,{...tn(L,m)}):a.jsx(D,{...tn(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(J=>{const $=J.originalIndex,M=H($+r.firstItemIndex,J.data,m);return z?p.createElement(B,{...tn(B,m),height:J.size,index:J.index,key:M,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?p.createElement(E,{...tn(E,m),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:M,style:Ek},y(J.index,m)):p.createElement(F,{...tn(F,m),...Mk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:M,style:w?Nk:iy},I?g(J.index,J.groupIndex,J.data,m):g(J.index,J.data,m))})})}),Tk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Rk={outline:"none",overflowX:"auto",position:"relative"},Ko=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Ak={position:Nf(),top:0,width:"100%",zIndex:1};function tn(t,r){if(typeof t!="string")return{context:r}}function Mk(t,r){return{item:typeof t=="string"?void 0:r}}const Lk=Ne.memo(function(){const t=He("HeaderComponent"),r=Pn("headerHeight"),s=He("HeaderFooterTag"),o=$r(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),zk=Ne.memo(function(){const t=He("FooterComponent"),r=Pn("footerHeight"),s=He("HeaderFooterTag"),o=$r(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null});function oy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=sy(h,m,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Rk:Tk,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function cy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),S=Ne.useRef(null),k=r("scrollerRef"),{scrollByCallback:w,scrollerRef:C,scrollToCallback:N}=sy(h,m,g,k,b);return ly(()=>{var R;return C.current=b||((R=S.current)==null?void 0:R.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",w),a.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Dk=({children:t})=>{const r=Ne.useContext(ay),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>Dv(s,g=>ir(g,u?"width":"height")),[s,u]),h=$r(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Ko(c),children:t})},_k=({children:t})=>{const r=Ne.useContext(ay),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=He("customScrollParent"),u=Ov(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Ko(d),children:t})},Ok=({children:t})=>{const r=He("TopItemListComponent")??"div",s=He("headerHeight"),o={...Ak,marginTop:`${s}px`},c=He("context");return a.jsx(r,{style:o,...tn(r,c),children:t})},Bk=Ne.memo(function(t){const r=He("useWindowScroll"),s=He("topItemsIndexes").length>0,o=He("customScrollParent"),c=He("context");return a.jsxs(o||r?Uk:Hk,{...t,context:c,children:[s&&a.jsx(Ok,{children:a.jsx(yg,{showTopList:!0})}),a.jsxs(o||r?_k:Dk,{children:[a.jsx(Lk,{}),a.jsx(yg,{}),a.jsx(zk,{})]})]})}),{Component:Ik,useEmitter:Rf,useEmitterValue:He,usePublisher:Pn}=ny(wk,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Bk),Hk=oy({useEmitter:Rf,useEmitterValue:He,usePublisher:Pn}),Uk=cy({useEmitter:Rf,useEmitterValue:He,usePublisher:Pn}),$k=Ik,Vk=et(()=>{const t=ge(m=>a.jsxs("td",{children:["Item $",m]})),r=ge(null),s=ge(m=>a.jsxs("td",{colSpan:1e3,children:["Group ",m]})),o=ge(null),c=ge(null),u=ge({}),d=ge(Tf),h=ge(Ol),g=(m,y=null)=>nn(me(u,ke(v=>v[m]),bt()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ty,Vk);Nf();const bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Pk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jg,floor:Bo,max:Is,min:Ed,round:Sg}=Math;function kg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Fk(t){return{...Pk,items:t}}function yo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function Gk(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Wk=et(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:w},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:R,windowScrollTo:L,windowViewportRect:B},D])=>{const F=ge(0),E=ge(0),H=ge(bg),z=ge({height:0,width:0}),I=ge({height:0,width:0}),U=Xe(),q=Xe(),X=ge(0),J=ge(null),$=ge({column:0,row:0}),M=Xe(),_=Xe(),O=ge(!1),V=ge(0),se=ge(!0),A=ge(!1),Y=ge(!1);at(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),at(me(Ht(k,se,I,z,V,A),De(([de,Se,Ae,_e,,re])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!re)),([,,,,de])=>{Pe(A,!0),kf(1,()=>{Pe(U,de)}),Qn(me(m),()=>{Pe(r,[0,0]),Pe(se,!0)})}),Te(me(_,De(de=>de!=null&&de.scrollTop>0),ia(0)),E),at(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(I,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(O,!0),Qn(me(m,Hr(1)),Se=>{Pe(O,!1)}),Pe(g,{top:de.scrollTop})))}),Te(me(z,ke(({height:de})=>de)),v),Te(me(Ht(ze(z,yo),ze(I,yo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(m)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),M),Te(me(Ht(ze(F),o,ze($,Gk),ze(I,yo),ze(z,yo),ze(J),ze(E),ze(O),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,re,he,pe,xe,,je,Be])=>{const{column:Oe,row:rt}=_e,{height:Nt,width:ht}=re,{width:Dt}=he;if(xe===0&&(de===0||Dt===0))return bg;if(ht===0){const Gt=wf(Be,de),an=Gt+Math.max(xe-1,0);return Fk(kg(Gt,an,pe))}const Tt=uy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&xe>0?(Qe=0,tt=xe-1):(Qe=Tt*Bo((Se+rt)/(Nt+rt)),tt=Tt*jg((Ae+rt)/(Nt+rt))-1,tt=Ed(de-1,Is(tt,Tt-1)),Qe=Ed(tt,Is(0,Qe))):(Qe=0,tt=-1);const be=kg(Qe,tt,pe),{bottom:pt,top:Ct}=wg(he,_e,re,be),Yt=jg(de/Tt),un=Yt*Nt+(Yt-1)*rt-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),H),Te(me(J,De(de=>de!==null),ke(de=>de.length)),F),Te(me(Ht(z,I,H,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:re,top:he}=wg(de,_e,Se,Ae);return[he,re]}),bt(Ps)),r);const W=ge(!1);Te(me(m,Fe(W),ke(([de,Se])=>Se||de!==0)),W);const te=Nn(me(Ht(H,F),De(([{items:de}])=>de.length>0),Fe(W),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(H),De(({items:de})=>de.length>0&&de[0].index===0),ia(0),bt())),ie=Nn(me(ze(H),Fe(O),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Vv),Aa(0)));Te(ie,S.scrollSeekRangeChanged),Te(me(U,Fe(z,I,F,$),ke(([de,Se,Ae,_e,re])=>{const he=qv(de),{align:pe,behavior:xe,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Is(0,Be,Ed(_e-1,Be));let Oe=nf(Se,re,Ae,Be);return pe==="end"?Oe=Sg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=Sg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:xe,top:Oe}})),g);const ye=nn(me(H,ke(de=>de.offsetBottom+de.bottom)),0);return Te(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:E,itemDimensions:I,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:U,scrollTop:m,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:R,windowScrollTo:L,windowViewportRect:B,...S,gridState:H,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:w,rangeChanged:ie,startReached:fe,stateChanged:M,stateRestoreInProgress:O,...D}},jt(Cf,cn,Js,Jv,dr,Ef,ur));function uy(t,r,s){return Is(1,Bo((t+s)/(Bo(r)+s)))}function wg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=nf(t,r,s,o[0].index);return{bottom:nf(t,r,s,o[o.length-1].index)+c,top:u}}function nf(t,r,s,o){const c=uy(t.width,s.width,r.column),u=Bo(o/c),d=u*s.height+Is(0,u-1)*r.row;return d>0?d+r.row:d}const qk=et(()=>{const t=ge(v=>`Item ${v}`),r=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Tf),d=ge("div"),h=ge(Ol),g=(v,b=null)=>nn(me(r,ke(S=>S[v]),bt()),b),m=ge(!1),y=ge(!1);return Te(ze(y),m),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Yk=et(([t,r])=>({...t,...r}),jt(Wk,qk)),Kk=Ne.memo(function(){const t=kt("gridState"),r=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),m=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),w=Fn("reportReadyState"),C=$r(Ne.useMemo(()=>N=>{const R=N.parentElement.parentElement.scrollHeight;d(R);const L=N.firstChild;if(L!==null){const{height:B,width:D}=L.getBoundingClientRect();v({height:B,width:D})}b({column:Cg("column-gap",getComputedStyle(N).columnGap,S),row:Cg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return ly(()=>{t.itemHeight>0&&t.itemWidth>0&&w(!0)},[t]),k?null:a.jsx(g,{className:r,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const R=c(N.index,N.data,y);return u?a.jsx(m,{...tn(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},R):p.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:R},o(N.index,N.data,y))})})}),Xk=Ne.memo(function(){const t=kt("HeaderComponent"),r=Fn("headerHeight"),s=kt("headerFooterTag"),o=$r(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),Qk=Ne.memo(function(){const t=kt("FooterComponent"),r=Fn("footerHeight"),s=kt("headerFooterTag"),o=$r(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),Zk=({children:t})=>{const r=Ne.useContext(ry),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$r(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Ko(!1),children:t})},Jk=({children:t})=>{const r=Ne.useContext(ry),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Ov(s,c,!1);return Ne.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Ko(!1),children:t})},ew=Ne.memo(function({...t}){const r=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||r?nw:tw,c=s||r?Jk:Zk,u=kt("context");return a.jsx(o,{...t,...tn(o,u),children:a.jsxs(c,{children:[a.jsx(Xk,{}),a.jsx(Kk,{}),a.jsx(Qk,{})]})})}),{useEmitter:dy,useEmitterValue:kt,usePublisher:Fn}=ny(Yk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},ew),tw=oy({useEmitter:dy,useEmitterValue:kt,usePublisher:Fn}),nw=cy({useEmitter:dy,useEmitterValue:kt,usePublisher:Fn});function Cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}const aw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},fy={source:"Own",installed:"Installed"};function rw(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function lw(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Eg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=aw[t],[d,h]=p.useState(()=>rw(u)),g=p.useCallback(()=>{h(b=>{const S=!b;return lw(u,S),S})},[u]),m=fy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(iw,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(sw,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function sw({origin:t,updateCount:r}){const[s,o]=p.useState(!1),c=fy[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function iw({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Af(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function ow({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return p.useEffect(()=>{function g(m){var b;if(m.key!=="/")return;const y=m.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function cw({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function uw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function dw({skillId:t,trackedForUpdates:r}){let s=null;try{s=p.useContext(wv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ei(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function fw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(ei,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(cw,{target:t.symlinkTarget??null}),a.jsx(uw,{skill:t}),a.jsx(dw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Io=p.memo(fw);function pw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Io,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function mw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function Ng({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=r??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,m]=p.useState(()=>mw(o,s)),y=d?!1:g,v=p.useCallback(()=>{m(k=>{const w=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(w))}catch{}return w})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>a.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const Lo=new Map,Br=new Map,Ds=new Map;function Tn(t){Lo.delete(t),Br.delete(t);const r=Ds.get(t);if(r)for(const s of r)s()}function ti(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=p.useState(0),d=p.useRef(!0),h=p.useRef(t);h.current=t;const g=()=>Tn(t);p.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),p.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Ds.has(t)||Ds.set(t,new Set),Ds.get(t).add(b),()=>{var S;(S=Ds.get(t))==null||S.delete(b)}},[t,c]),p.useEffect(()=>{if(!c)return;const b=Lo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Br.has(t)){const C=Br.get(t),N=()=>{d.current&&h.current===t&&u(R=>R+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},w=r().then(C=>{Lo.set(t,{data:C,fetchedAt:Date.now()}),Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=w,Br.set(t,k)},[t,r,o,c]);const m=Lo.get(t),y=c&&!m&&Br.has(t);return{data:m==null?void 0:m.data,loading:y||c&&!m,error:void 0,revalidate:g}}function hw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=p.useState(!1),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null);p.useEffect(()=>{if(!o)return;function v(b){m.current&&!m.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Lv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:m,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Nd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Nd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Nd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Nd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Tg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",m=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:m?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[m&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(xw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function xw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function gw(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function vw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function yw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function bw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function af(t,r={}){const{enabled:s=!0,target:o}=r,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(vw),p.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const m=g,y=yw(m.target);for(const v of c.current){if(!bw(m,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const jw=200;function Sw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function kw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Af(g,r)),d={};for(const g of u){const m=g.pluginName??g.plugin;(d[m]||(d[m]=[])).push(g)}const h=Object.entries(d).sort((g,m)=>g[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function ww(t,r){const s=[],o=[],c=[];for(const d of t){const h=Sw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Af(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const m=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(o),global:u(c)}}function Cw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var m;const d=u.filter(y=>Af(y,r)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Ew({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(W=>W.scope!==void 0&&W.scope!==null),k=g??"claude-cli",[w,C]=p.useState(""),N=p.useDeferredValue(w),R=p.useMemo(()=>ww(t,N),[t,N]),L=p.useMemo(()=>kw(t,N),[t,N]),B=k==="claude-code",{plugins:D}=M2(),F=B?{plugins:D??[]}:void 0,E=p.useMemo(()=>{const W=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=W.get(te.name);W.set(te.name,!!fe||!!te.enabled)}return W},[F==null?void 0:F.plugins]),[H,z]=p.useState(()=>rf(`vskill-sidebar-${k}-group-available-collapsed`)),[I,U]=p.useState(()=>rf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=p.useCallback(W=>{z(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(W))}catch{}},[k]),X=p.useCallback(W=>{U(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(W))}catch{}},[k]),{own:J,installed:$}=p.useMemo(()=>Cw(t,N),[t,N]),_=R.own.filtered+R.installed.filtered+R.global.filtered>=jw,O=p.useMemo(()=>{const W=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...W(R.own.byPlugin),...W(R.installed.byPlugin),...W(R.global.byPlugin)]:[...W(J.byPlugin),...W($.byPlugin)]},[S,R.own.byPlugin,R.installed.byPlugin,R.global.byPlugin,J.byPlugin,$.byPlugin]),V=p.useMemo(()=>r?O.findIndex(W=>W.plugin===r.plugin&&W.skill===r.skill):-1,[O,r]),se=p.useCallback(W=>{if(O.length===0)return;const te=V<0?W>0?0:O.length-1:Math.min(Math.max(V+W,0),O.length-1);s(O[te])},[O,V,s]),A=p.useMemo(()=>{if(!v)return null;const[W,te]=v.split("/");if(!W||!te)return null;const fe=t.find(de=>de.plugin===W&&de.skill===te);if(!fe)return{plugin:W,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??W:null;return{plugin:W,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=p.useRef(null);return p.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const W=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${W}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(O[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(ow,{value:w,onChange:C}),o&&a.jsx(Mw,{}),!o&&c&&a.jsx(Lw,{error:c,onRetry:u}),!o&&!c&&S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Tg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:H,onToggle:q,count:L.availableProject.total+L.availablePersonal.total+L.availablePlugin.total}),!H&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:L.availableProject.total,filteredCount:w?L.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),children:L.availableProject.filtered===0?a.jsx(Ag,{queryActive:!!w,agentId:k}):a.jsx(Ls,{items:L.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:L.availablePersonal.total,filteredCount:w?L.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:L.availablePersonal.filtered===0?a.jsx(Tw,{queryActive:!!w,agentId:k}):a.jsx(Ls,{items:L.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:L.availablePlugin.total,filteredCount:w?L.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),L.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):L.availablePlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-available-${W}-collapsed`,headerActionSlot:B?a.jsx(hw,{pluginName:W,enabled:E.get(W)??!0}):void 0,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${W}`))]})]}),a.jsx(Aw,{}),a.jsx(Tg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:A?!1:I,onToggle:X,count:L.authoringProject.total+L.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!I||A)&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:L.authoringProject.total,filteredCount:w?L.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(A==null?void 0:A.bucket)==="project",children:L.authoringProject.filtered===0?a.jsx(Rg,{queryActive:!!w}):a.jsx(Ls,{items:L.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:L.authoringPlugin.total,filteredCount:w?L.authoringPlugin.filtered:null,forceOpen:(A==null?void 0:A.bucket)==="plugin",children:L.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):L.authoringPlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-authoring-${W}-collapsed`,forceOpen:(A==null?void 0:A.bucket)==="plugin"&&A.pluginName===W,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${W}`))})]})]}),!o&&!c&&!S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Eg,{origin:"source",count:J.total,filteredCount:w?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?a.jsx(Rg,{queryActive:!!w}):a.jsx(Ls,{items:J.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Rw,{}),a.jsx(Eg,{origin:"installed",count:$.total,filteredCount:w?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?a.jsx(Ag,{queryActive:!!w}):a.jsx(Ls,{items:$.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function rf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=p.useState(()=>rf(r)),m=d?!1:h,y=p.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(S))}catch{}return S})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!m,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:m?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!m&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function Nw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ls({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Nw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx($k,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,m=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Io,{skill:g,isSelected:m,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(pw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Rg({queryActive:t}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Mf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ag({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install <plugin>"})," to add one."]})})}function Tw({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install --global <plugin>"})," to add one."]})})}function Ml({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Mf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Rw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Aw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function Mw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(gw,{},t))})}function Lw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:zw(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function zw(t){const r=t.split(`
66
- `)[0]??t;return r.length>80?r.slice(0,77)+"…":r}const py=240,my=480,hy="vskill-sidebar-width",Hs=320;function Lf(t){return Number.isFinite(t)?Math.round(Math.max(py,Math.min(my,t))):Hs}function Dw(){try{const t=localStorage.getItem(hy);if(!t)return Hs;const r=Number(t);return Number.isFinite(r)?Lf(r):Hs}catch{return Hs}}function _w(t){try{localStorage.setItem(hy,String(Lf(t)))}catch{}}function Ow({initialWidth:t,onChange:r}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),o=p.useRef(t);return p.useEffect(()=>{o.current=t},[t]),p.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=Lf(s.current.startWidth+h);o.current=g,r(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,_w(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[r]),a.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":py,"aria-valuemax":my,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Bw({connected:t,hint:r,onRetry:s}){return t?null:a.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),a.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&a.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),a.jsx("div",{style:{flex:1}}),s&&a.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function xy(t,r){if(t!==401||typeof window>"u"||!r||typeof r!="object")return;const s=r;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function gy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(r){console.error("Failed to serialize request body:",r);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Td(){const[t,r]=p.useState([]),[s,o]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useCallback(async(v,b)=>{r([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=gy(b),w=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!w.ok||!w.body){let B=`HTTP ${w.status}`,D;try{D=await w.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw xy(w.status,D),new Error(B)}const C=w.body.getReader(),N=new TextDecoder;let R="",L="";for(;;){const{done:B,value:D}=await C.read();if(B)break;R+=N.decode(D,{stream:!0});const F=R.split(`
67
- `);R=F.pop()||"";for(const E of F)if(E.startsWith("event: "))L=E.slice(7).trim();else if(E.startsWith("data: ")){try{const H=JSON.parse(E.slice(6)),z={event:L,data:H};L==="done"?(u(!0),r(I=>[...I,z])):r(I=>[...I,z])}catch{}L=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=p.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:y}}function Iw(t){const r=p.useRef(t);r.current=t;const[s,o]=p.useState(new Set),c=p.useRef(new Map),u=p.useCallback(async(m,y,v)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),o(k=>{const w=new Set(k);return w.add(m),w});try{const k=gy(v),w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!w.ok||!w.body){let B=`HTTP ${w.status}`,D;try{D=await w.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw xy(w.status,D),new Error(B)}const C=w.body.getReader(),N=new TextDecoder;let R="",L="";for(;;){const{done:B,value:D}=await C.read();if(B)break;R+=N.decode(D,{stream:!0});const F=R.split(`
68
- `);R=F.pop()||"";for(const E of F)if(E.startsWith("event: "))L=E.slice(7).trim();else if(E.startsWith("data: ")){try{const H=JSON.parse(E.slice(6)),z={event:L,data:H};r.current.onEvent(m,z)}catch{}L=""}}r.current.onDone(m)}catch(k){k.name!=="AbortError"&&r.current.onError(m,k.message)}finally{o(k=>{const w=new Set(k);return w.delete(m),w}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var y;(y=c.current.get(m))==null||y.abort()},[]),h=p.useCallback(()=>{for(const m of c.current.values())m.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Hw={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Uw(t,r){var s,o;switch(r.type){case"SET_LOADING":return{...t,loading:r.loading};case"SET_ERROR":return{...t,error:r.error};case"INIT_DATA":{const c=new Map;if(r.benchmark)for(const d of r.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=r.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:r.panel};case"SET_CONTENT":return{...t,skillContent:r.content,isDirty:r.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:r.evals};case"SELECT_CASE":return{...t,selectedCaseId:r.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...t,caseRunStates:c,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,r.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);return c.set(r.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of r.caseIds)c.set(u,{status:"queued",mode:r.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:r.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(r.evalId,r.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const c=r.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(r.index,!c.get(r.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:r.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:r.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,r.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:r.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:r.runs,activationHistoryLoading:!1};default:return t}}function $w(t){if(t==="unit"||t==="integration")return t}function Vw(t,r){const s=r.data;if(r.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),r.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),r.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}r.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const vy=p.createContext(null);function An(){const t=p.useContext(vy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Pw({plugin:t,skill:r,origin:s,children:o}){const c=s==="installed",[u,d]=p.useReducer(Uw,{...Hw,plugin:t,skill:r}),h=p.useRef(new Set),g=p.useRef(new Set),m=p.useRef(new Map),y=p.useCallback((re,he)=>{let pe=m.current.get(re);pe||(pe={assertions:[]},m.current.set(re,pe)),Vw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:re,result:{...pe,assertions:[...pe.assertions]}})},[]),v=p.useCallback(re=>{if(g.current.has(re))return;g.current.add(re);const he=m.current.get(re)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:re,result:{...he,assertions:[...he.assertions]}}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,r]),b=p.useCallback((re,he)=>{g.current.has(re)||(g.current.add(re),d({type:"CASE_RUN_ERROR",caseId:re,error:he}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,r]),{startCase:S,stopCase:k,stopAll:w}=Iw({onEvent:y,onDone:v,onError:b});p.useEffect(()=>()=>{w()},[w]);const C=p.useCallback(async()=>{try{const re=await fetch(`/api/skills/${t}/${r}/activation-history`);if(!re.ok){if(re.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await re.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,r]);p.useEffect(()=>{let re=!1;async function he(){try{const[pe,xe,je]=await Promise.allSettled([Ce.getSkillDetail(t,r),Ce.getEvals(t,r),Ce.getLatestBenchmark(t,r)]);if(re)return;let Be=null,Oe=null;if(xe.status==="fulfilled")Be=xe.value;else{const rt=xe.reason;Oe=(rt==null?void 0:rt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){re||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{re=!0}},[t,r,C]);const N=p.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,r,u.skillContent),d({type:"CONTENT_SAVED"})}catch(re){d({type:"SET_ERROR",error:re.message})}},[c,t,r,u.skillContent]),R=p.useCallback(async re=>{if(!c)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,r]),L=p.useCallback((re,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(re);if((pe==null?void 0:pe.status)!=="running")if(m.current.delete(re),g.current.delete(re),d({type:"CASE_RUN_START",caseId:re,mode:he}),he==="comparison"){const xe=`/api/skills/${t}/${r}/compare`;S(re,xe,{eval_ids:[re]})}else{const xe=`/api/skills/${t}/${r}/benchmark/case/${re}`;S(re,xe,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.caseRunStates,S]),B=p.useCallback((re="benchmark")=>{var xe;if(c)return;const he=((xe=u.evals)==null?void 0:xe.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)m.current.delete(je),g.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:re}),h.current=new Set(pe);for(const je of pe)if(re==="comparison")S(je,`/api/skills/${t}/${r}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${r}/benchmark/case/${je}`;S(je,Be,re==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.evals,S]),D=p.useCallback(re=>{k(re),d({type:"CASE_RUN_CANCEL",caseId:re}),h.current.delete(re),g.current.add(re)},[k]),F=p.useCallback(()=>{w(),d({type:"CANCEL_ALL"}),h.current.clear()},[w]),E=p.useCallback(async(re,he)=>{d({type:"OPEN_IMPROVE",evalId:re})},[]),H=p.useCallback(async(re,he)=>{try{await Ce.applyImprovement(t,r,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),L(re,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,r,L]),z=Td(),I=p.useRef(null),U=p.useRef(0);p.useEffect(()=>{const re=z.events;for(let he=U.current;he<re.length;he++){const pe=re[he],xe=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const je=xe.improved,Be=xe.reasoning,Oe=xe.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const je=xe;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}U.current=re.length},[z.events]),p.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),p.useEffect(()=>()=>{z.stop()},[z.stop]);const q=p.useCallback(async(re,he,pe)=>{c||(U.current=0,d({type:"AI_EDIT_LOADING"}),I.current=z.stop,z.start(`/api/skills/${t}/${r}/improve?sse`,{mode:"instruct",instruction:re,content:u.skillContent,evals:u.evals??{skill_name:r,evals:[]},provider:he,model:pe}))},[c,t,r,u.skillContent,u.evals,z]),X=p.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=p.useCallback(async()=>{const re=u.aiEditResult;if(re!=null&&re.improved)try{if(await Ce.applyImprovement(t,r,re.improved),d({type:"SET_CONTENT",content:re.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Xs(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),xe=u.evals??{skill_name:r,evals:[]},je=pe(xe,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,r,je);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,r,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),M=p.useCallback(re=>{d({type:"TOGGLE_EVAL_CHANGE",index:re})},[]),_=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),O=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=p.useCallback(async()=>{const re=u.aiEditEvalsRetry;if(re)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,r,u.aiEditEvalsRetry]),se=p.useCallback(async()=>{try{const re=await Ce.getSkillDetail(t,r);d({type:"SET_CONTENT",content:re.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,r]),{config:A}=Ur(),Y=Td(),W=p.useRef(0);p.useEffect(()=>{const re=Y.events;for(let he=W.current;he<re.length;he++){const pe=re[he],xe=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const je=xe;Ce.saveEvals(t,r,je).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:xe})}W.current=re.length},[Y.events,t,r]),p.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),p.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=p.useCallback(async re=>{if(c)return;W.current=0,d({type:"GENERATE_EVALS_START"});const he={};A!=null&&A.provider&&(he.provider=A.provider),A!=null&&A.model&&(he.model=A.model);const pe=$w(re==null?void 0:re.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${r}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,r,Y,A]),fe=Td(),ie=p.useRef(0);p.useEffect(()=>()=>{fe.stop()},[fe.stop]),p.useEffect(()=>{const re=fe.events;for(let he=ie.current;he<re.length;he++){const pe=re[he];if(pe.event==="classifying"){const xe=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:xe.index,total:xe.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const xe=pe.data;if(xe.error)d({type:"ACTIVATION_ERROR",error:xe.error});else{d({type:"ACTIVATION_DONE",summary:xe});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(A==null?void 0:A.model)||"unknown",provider:(A==null?void 0:A.provider)||"unknown",promptCount:xe.total,summary:{precision:xe.precision,recall:xe.recall,reliability:xe.reliability,tp:xe.tp,tn:xe.tn,fp:xe.fp,fn:xe.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}ie.current=re.length},[fe.events,A,u.activationHistory]),p.useEffect(()=>{fe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ye=p.useRef(null),de=p.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),Se=p.useCallback(re=>{const pe=re.trim().split(`
69
- `).filter(Boolean).map(je=>je.startsWith("!")?{prompt:je.slice(1).trim(),expected:"should_not_activate"}:je.startsWith("+")?{prompt:je.slice(1).trim(),expected:"should_activate"}:{prompt:je.trim(),expected:"auto"});ie.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:re});const xe={prompts:pe};A!=null&&A.provider&&(xe.provider=A.provider),A!=null&&A.model&&(xe.model=A.model),fe.start(`/api/skills/${t}/${r}/activation-test`,xe),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{fe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ye.current=null},12e4)},[t,r,fe,A]),Ae=p.useCallback(async(re=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:re};A!=null&&A.provider&&(he.provider=A.provider),A!=null&&A.model&&(he.model=A.model);const pe=await fetch(`/api/skills/${t}/${r}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let ht=`HTTP ${pe.status}`;try{const Dt=await pe.json();Dt.error&&(ht=Dt.error)}catch{}throw new Error(ht)}const xe=pe.body.getReader(),je=new TextDecoder;let Be="",Oe="",rt=[];for(;;){const{done:ht,value:Dt}=await xe.read();if(ht)break;Be+=je.decode(Dt,{stream:!0});const Tt=Be.split(`
65
+ }`})]})}function Jx(){typeof window>"u"||(window.location.hash="#/")}function d2({onHome:t}){const[r,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Jx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Jx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const f2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",p2=m.lazy(()=>Xs(()=>import("./UpdateDropdown-C-4cwFXV.js"),__vite__mapDeps([0,1])));function m2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=ea(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:f2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(m.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(p2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function eg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function h2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(d2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(tg,{segment:"origin",onClick:()=>eg({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(ng,{}),a.jsx(tg,{segment:"plugin",onClick:()=>eg({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(ng,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(c2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(m2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function tg({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Go="vskill-theme";function Av(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function x2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function g2(t){try{const r=t.getItem(Go);return Av(r)}catch{return"auto"}}function v2(t,r){try{t.setItem(Go,r)}catch{}}function y2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function b2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Mv=m.createContext(null);function j2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?g2(c):"auto"),[p,y]=m.useState(()=>b2(u)),v=m.useMemo(()=>x2(h,p),[h,p]);m.useEffect(()=>{d&&y2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Go&&g(Av(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&v2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Mv.Provider,{value:S,children:o})}function Lv(){const t=m.useContext(Mv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function S2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=r.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function k2(t){const[r,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function w2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=S2(t),c=k2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(rg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(rg,{p:g,onClick:h,compact:!0},g.id))})}function rg({p:t,onClick:r,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Kd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function C2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Go)}catch{return null}}function E2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=Lv(),v=C2()==="auto",b=N2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(lg,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(T2,{color:S}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(lg,{}),a.jsx(w2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(R2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function N2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function T2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function lg(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function R2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Xd=new Set;function zv(){for(const t of Xd)t()}const A2=5,M2=1e3,L2=6e4;function z2(){const[t,r]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,r(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},L2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>A2){o(!0);return}const A=M2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Xd.add(C),()=>{Xd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const Wo=0,cr=1,_l=2,Dv=4;function sg(t){return()=>t}function D2(t){t()}function _v(t,r){return s=>t(r(s))}function ig(t,r){return()=>t(r)}function _2(t,r){return s=>t(r,s)}function vf(t){return t!==void 0}function O2(...t){return()=>{t.map(D2)}}function Ol(){}function qo(t,r){return r(t),t}function B2(t,r){return r(t)}function jt(...t){return t}function at(t,r){return t(cr,r)}function Pe(t,r){t(Wo,r)}function yf(t){t(_l)}function wt(t){return t(Dv)}function Re(t,r){return at(t,_2(r,Wo))}function Qn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function og(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Ov(t,r){return t===r}function bt(t=Ov){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function De(t){return r=>s=>{t(s)&&r(s)}}function ke(t){return r=>_v(r,t)}function ia(t){return r=>()=>{r(t)}}function me(t,...r){const s=I2(...r);return((o,c)=>{switch(o){case _l:yf(t);return;case cr:return at(t,s(c))}})}function oa(t,r){return s=>o=>{s(r=t(r,o))}}function Ur(t){return r=>s=>{t>0?t--:r(s)}}function Aa(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Fe(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const p=s;s|=h,r[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function I2(...t){return r=>t.reduceRight(B2,r)}function U2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=at(t,u),r):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let r=t;const s=Xe();return((o,c)=>{switch(o){case Wo:r=c;break;case cr:{c(r);break}case Dv:return r}return s(o,c)})}function nn(t,r){return qo(ve(r),s=>Re(t,s))}function Xe(){const t=[];return((r,s)=>{switch(r){case Wo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return qo(Xe(),r=>Re(t,r))}function et(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:H2(),singleton:s}}const H2=()=>Symbol();function $2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Ut(...t){const r=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Pe(r,s)})}),function(u,d){switch(u){case _l:{yf(r);return}case cr:return o===c&&d(s),at(r,d)}}}function ze(t,r=Ov){return me(t,bt(r))}function Qd(...t){return function(r,s){switch(r){case _l:return;case cr:return O2(...t.map(o=>at(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},V2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},P2=()=>typeof globalThis>"u"?window:globalThis,ur=et(()=>{const t=ve(Pt.ERROR);return{log:ve((r,s,o=Pt.INFO)=>{const c=P2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[V2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function $r(t,r,s){return bf(t,r,s).callbackRef}function bf(t,r,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function F2(t,r,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=G2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?cg("column-gap",getComputedStyle(y).columnGap,c):cg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return bf(p,s,g)}function G2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}function Bv(t,r,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(r){const S=r.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+r.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=bf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=et(()=>{const t=Xe(),r=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),r),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),$s={lvl:0};function Iv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===$s}function Vs(t,r){if(!ft(t))return r===t.k?t.v:r<t.k?Vs(t.l,r):Vs(t.r,r)}function Jn(t,r,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Jn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,r,s)}function En(t,r,s){return ft(t)?$v(r,s,1):r===t.k?Vt(t,{k:r,v:s}):r<t.k?ug(Vt(t,{l:En(t.l,r,s)})):ug(Vt(t,{r:En(t.r,r,s)}))}function Rl(){return $s}function Al(t,r,s){if(ft(t))return[];const o=Jn(t,r)[0];return W2(Jd(t,o,s))}function Zd(t,r){if(ft(t))return $s;const{k:s,l:o,r:c}=t;if(r===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=Hv(o);return Ao(Vt(t,{k:u,l:Uv(o),v:d}))}return r<s?Ao(Vt(t,{l:Zd(o,r)})):Ao(Vt(t,{r:Zd(c,r)}))}function Ir(t){return ft(t)?[]:[...Ir(t.l),{k:t.k,v:t.v},...Ir(t.r)]}function Jd(t,r,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Jd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Jd(u,r,s))),h}function Ao(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(Sd(r))return Vv(Vt(t,{lvl:s-1}));if(!ft(r)&&!ft(r.r))return Vt(r.r,{l:Vt(r,{r:r.r.l}),lvl:s,r:Vt(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Sd(t))return ef(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=Sd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:ef(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,r){return $v(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function Uv(t){return ft(t.r)?t.l:Ao(Vt(t,{r:Uv(t.r)}))}function Sd(t){return ft(t)||t.lvl>t.r.lvl}function Hv(t){return ft(t.r)?[t.k,t.v]:Hv(t.r)}function $v(t,r,s,o=$s,c=$s){return{k:t,l:o,lvl:s,r:c,v:r}}function ug(t){return ef(Vv(t))}function Vv(t){const{l:r}=t;return!ft(r)&&r.lvl===t.lvl?Vt(r,{r:Vt(t,{l:r.r})}):t}function ef(t){const{lvl:r,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===r&&s.r.lvl===r?Vt(s,{l:Vt(t,{r:s.l}),lvl:r+1}):t}function W2(t){return Iv(t,({k:r,v:s})=>({index:r,value:s}))}function Pv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Ps(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const jf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Fv(t,r,s){return t[Oo(t,r,s)]}function Oo(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function q2(t,r,s,o){const c=Oo(t,r,o),u=Oo(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Yo(t){return!ft(t.groupOffsetTree)}function Sf({index:t},r){return r===t?0:r<t?-1:1}function Y2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function K2(t,r){let s=ft(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(nk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Zd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function X2(t){return typeof t.groupIndex<"u"}function Q2({offset:t},r){return r===t?0:r<t?-1:1}function Fs(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Fv(r,t,Sf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Gv(t,r){if(!Yo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Wv(t,r,s){if(X2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Gv(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function Z2(t,r,s,o=0){return o>0&&(r=Math.max(r,Fv(t,o,Sf).offset)),Iv(q2(t,r,s,Q2),tk)}function J2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&r.length===2){const b=r[0].size,S=r[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=K2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=tf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Fs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function ek(t){return Ir(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function dg(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function tf(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Oo(c,r-1,Sf),h=c[g].offset;const p=Jn(s,r-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,r,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function tk(t){return{index:t.index,value:t}}function nk(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ua=et(([{log:t},{recalcInProgress:r}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ir(w,ak[O])),k=ve(void 0),E=ve(0),C=Y2(),N=nn(me(s,Fe(g,t,E),oa(J2,C),bt()),C),T=nn(me(g,bt(),oa((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Fs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),oa(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));at(me(h,oa((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(r,!0),Pe(u,w+dg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=dg(-w,z)),Pe(d,w)}}),at(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Vs(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ir(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ir(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Fs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ir(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Vs(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...tf(O.offsetTree,0,H,z)}}const U=Ir(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...tf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ur,jf),{singleton:!0});function rk(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const qv=et(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(rk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,r,o),De(([g,p])=>Yo(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ua,cn)),dr=et(([{log:t}])=>{const r=ve(!1),s=Nn(me(r,De(o=>o),bt()));return at(r,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:r}},jt(ur),{singleton:!0}),lk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!lk)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Qs=et(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Yv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=Wv($,D,V);let M=Fs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=W=>{A(),W?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let W=!1;T=at(r,te=>{W=W||te}),C=Qn(y,()=>{Y(W)})}else C=Qn(me(r,sk(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ua,cn,ur),{singleton:!0});function sk(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function kf(t,r){t===0?r():requestAnimationFrame(()=>{kf(t-1,r)})}function wf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Zs=et(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),p),at(me(Ut(r,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||vf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),kf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ua,cn,Qs,dr),{singleton:!0});function Kv(t,r){return Math.abs(t-r)<1.01}const Gs="up",Bs="down",ik="none",ok={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ck=0,Js=et(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(ck),b=nn(me(Qd(me(ze(c),Ur(1),ia(!0)),me(ze(c),Ur(1),ia(!1),og(100))),bt()),!1),S=nn(me(Qd(me(s,ia(!0)),me(s,ia(!1),og(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Aa(50)),p);const k=Nn(me(Ut(o,ze(u),ze(r),ze(t),ze(y)),oa((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ok),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,oa((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Kv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Aa(50)),g);const C=ve(Bs);Re(me(o,ke(({scrollTop:T})=>T),bt(),oa((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Gs:Bs,prevScrollTop:A},{direction:Bs,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Aa(50),ia(ik)),C);const N=ve(0);return Re(me(b,De(T=>!T),ia(0)),N),Re(me(c,Aa(100),Fe(b),De(([T,A])=>A),oa(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),Ws="top",qs="bottom",fg="none";function pg(t,r,s){return typeof t=="number"?s===Gs&&r===Ws||s===Bs&&r===qs?t:0:s===Gs?r===Ws?t.main:t.reverse:r===qs?t.main:t.reverse}function mg(t,r){return typeof t=="number"?t:t[r]??0}const Cf=et(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Ps),ze(g),ze(d),ze(r),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=fg;const O=mg(A,Ws),z=mg(A,qs);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Gs),k<y-F+v+z&&(w=Bs),w!==fg?[Math.max(B-b-pg(E,Ws,w)-O,0),B-F-N+v+pg(E,qs,w)+z]:null}),De(y=>y!==null),bt(Ps)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function uk(t,r,s){if(Yo(r)){const o=Gv(t,r);return[{index:Jn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const kd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Mo(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:hg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:hg(r,c,u),topListHeight:r.reduce((E,C)=>C.size+E,0),totalCount:s}}function Xv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=wf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Mo(p,[],h,c,s,o)}function hg(t,r,s){if(t.length===0)return[];if(!Yo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function xg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Vr=et(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Ps),ze(c),ze(o),ze(p),y,ze(E),ze(r),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...kd,totalCount:z};if(w===0&&O===0)return M===0?{...kd,totalCount:z}:Xv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Mo(uk(wf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],re=X[X.length-1];let he=0;for(const pe of Al(se,_e,re)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,re);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Mo([],Y,z,$,I,J);const W=X.length>0?X[X.length-1]+1:0,te=Z2(V,w,O,W);if(te.length===0)return null;const fe=z-1,ie=qo([],_e=>{for(const re of te){const he=re.value;let pe=he.offset,ge=re.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-re.start;pe+=Oe*je+Oe*$}ge<W&&(pe+=(W-ge)*je,ge=W);const Be=Math.min(re.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=xg(L,Ws),de=xg(L,qs);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],re=ie[ie.length-1];if(ye>0&&_e.index>W){const he=Math.min(ye,_e.index-W),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&re.index<fe){const he=Math.min(de,fe-re.index);let pe=re.offset+re.size+$;for(let ge=re.index+1;ge<=re.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??re.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Mo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),kd);Re(me(t,De(vf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Ps),ke(([w])=>w))),D=Nn(me(A,Aa(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Pv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ua,qv,Cf,Zs,Qs,Js,dr,jf),{singleton:!0}),Qv=et(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,r,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Vr),{singleton:!0}),dk=et(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ve(!1),o=nn(me(Ut(s,t,r),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Aa(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Qv),{singleton:!0}),Zv=et(()=>({context:ve(null)})),fk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Jv=et(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(r,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=fk,done:D,...F}=v,w=Wv(v,b,k-1),O=Fs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ur(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ua,cn,Qs,Vr,ur),{singleton:!0});function gg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const pk=(t,r)=>typeof t=="function"?gg(t(r)):r&&gg(t),mk=et(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}at(me(Ut(me(ze(r),Ur(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=pk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ut(ze(k),r,p),De(([D,,F])=>D!==!1&&F),oa(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,r)),([,D])=>{wt(h)&&T(D!==!1)}),at(E,()=>{T(wt(k)!==!1)}),at(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Qd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(r))),B),at(me(Ut(me(B,Ur(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Aa(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ua,Js,Qs,Zs,dr,ur,cn,Zv,Jv)),hk=et(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,r,s,t),ke(([[,g],p,y,v,b,S=[]])=>Xv(g,p,y,v,b,S))),d),{}),jt(ua,Zs,Vr,dr),{singleton:!0}),xk=et(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ve(0);return at(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ur(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(r,c)})})}),{initialScrollTop:o}},jt(dr,cn,Vr),{singleton:!0}),ey=et(([{scrollVelocity:t}])=>{const r=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,r,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),r),at(me(Ut(r,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(Js),{singleton:!0}),Ef=et(([{scrollContainerState:t,scrollTo:r}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(r,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),gk=et(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),at(me(p,Fe(r,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=ek(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(vf),ke(vk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ua,cn,Zs,dr,Ef));function vk(t){return{align:"start",index:0,offset:t.scrollTop}}const yk=et(([{topItemsIndexes:t}])=>{const r=ve(0);return Re(me(r,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},jt(Vr));function ty(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const bk=ty(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),jk=et(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),oa(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Gs),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(r,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(r,{behavior:"auto",top:-N}))}return at(me(E,Fe(t,u)),([N,T,A])=>{A&&bk()?Pe(t,T-N):C(-N)}),at(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Aa(1)),C),Re(me(v,ke(N=>({top:-N}))),r),at(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Vs(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(r,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,Js,Vr,ua,ur,jf)),Sk=et(([t,r,s,o,c,u,d,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Cf,hk,dr,ey,Qv,xk,dk,Ef,Jv,ur,Zv)),ny=et(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ua,Zs,cn,gk,mk,Vr,Qs,jk,yk,qv,Sk));function kk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const vo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[r.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[r.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[r.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=U2(C[r.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>qo($2(t),w=>{g(w,A)})),[D]=Te.useState(ig(y,B));vo(()=>{for(const w of d)w in A&&at(D[w],A[w]);return()=>{Object.values(D).map(yf)}},[A,D,B]),vo(()=>{g(B,A)}),Te.useImperativeHandle(N,sg(p(B)));const F=s;return a.jsx(h.Provider,{value:B,children:s!==void 0?a.jsx(F,{...kk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>at(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(ig(wt,N));return vo(()=>at(N,B=>{B!==T&&A(sg(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];vo(()=>at(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ry=Te.createContext(void 0),ly=Te.createContext(void 0),wd="-webkit-sticky",vg="sticky",Nf=ty(()=>{if(typeof document>"u")return vg;const t=document.createElement("div");return t.style.position=wd,t.style.position===wd?wd:vg}),sy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Cd(t){return"self"in t}function wk(t){return"body"in t}function iy(t,r,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(wk(C)||Cd(C)){const T=Cd(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Pj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Cd(S)?(C=Math.max(ir(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ir(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Kv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&r(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Tf(t){return t}const Ck=et(()=>{const t=ve(h=>`Item ${h}`),r=ve(h=>`Group ${h}`),s=ve({}),o=ve(Tf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Ek=et(([t,r])=>({...t,...r}),jt(ny,Ck)),Nk=({height:t})=>a.jsx("div",{style:{height:t}}),Tk={overflowAnchor:"none",position:Nf(),zIndex:1},oy={overflowAnchor:"none"},Rk={...oy,display:"inline-block",height:"100%"},yg=Te.memo(function({showTopList:t=!1}){const r=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=F2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Rf("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Nk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&A!==null&&A!==void 0?a.jsx(A,{...tn(A,p)}):a.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(J=>{const $=J.originalIndex,L=O($+r.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Tk},y(J.index,p)):m.createElement(F,{...tn(F,p),...zk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Rk:oy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Ak={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Mk={outline:"none",overflowX:"auto",position:"relative"},Ko=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Lk={position:Nf(),top:0,width:"100%",zIndex:1};function tn(t,r){if(typeof t!="string")return{context:r}}function zk(t,r){return{item:typeof t=="string"?void 0:r}}const Dk=Te.memo(function(){const t=Ue("HeaderComponent"),r=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),_k=Te.memo(function(){const t=Ue("FooterComponent"),r=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null});function cy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=iy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Mk:Ak,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function uy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),S=Te.useRef(null),k=r("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=iy(h,p,g,k,b);return sy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),a.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Ok=({children:t})=>{const r=Te.useContext(ry),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>_v(s,g=>ir(g,u?"width":"height")),[s,u]),h=$r(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Ko(c),children:t})},Bk=({children:t})=>{const r=Te.useContext(ry),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Bv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Ko(d),children:t})},Ik=({children:t})=>{const r=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...Lk,marginTop:`${s}px`},c=Ue("context");return a.jsx(r,{style:o,...tn(r,c),children:t})},Uk=Te.memo(function(t){const r=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return a.jsxs(o||r?Vk:$k,{...t,context:c,children:[s&&a.jsx(Ik,{children:a.jsx(yg,{showTopList:!0})}),a.jsxs(o||r?Bk:Ok,{children:[a.jsx(Dk,{}),a.jsx(yg,{}),a.jsx(_k,{})]})]})}),{Component:Hk,useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}=ay(Ek,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Uk),$k=cy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Vk=uy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Pk=Hk,Fk=et(()=>{const t=ve(p=>a.jsxs("td",{children:["Item $",p]})),r=ve(null),s=ve(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Tf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ny,Fk);Nf();const bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Gk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jg,floor:Bo,max:Is,min:Ed,round:Sg}=Math;function kg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Wk(t){return{...Gk,items:t}}function yo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function qk(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Yk=et(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(bg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);at(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),at(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,re])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!re)),([,,,,de])=>{Pe(M,!0),kf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(r,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ia(0)),w),at(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ur(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,yo),ze(U,yo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,qk),ze(U,yo),ze(z,yo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,re,he,pe,ge,,je,Be])=>{const{column:Oe,row:rt}=_e,{height:Nt,width:ht}=re,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return bg;if(ht===0){const Gt=wf(Be,de),an=Gt+Math.max(ge-1,0);return Wk(kg(Gt,an,pe))}const Tt=dy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Bo((Se+rt)/(Nt+rt)),tt=Tt*jg((Ae+rt)/(Nt+rt))-1,tt=Ed(de-1,Is(tt,Tt-1)),Qe=Ed(tt,Is(0,Qe))):(Qe=0,tt=-1);const be=kg(Qe,tt,pe),{bottom:pt,top:Ct}=wg(he,_e,re,be),Yt=jg(de/Tt),un=Yt*Nt+(Yt-1)*rt-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:re,top:he}=wg(de,_e,Se,Ae);return[he,re]}),bt(Ps)),r);const W=ve(!1);Re(me(p,Fe(W),ke(([de,Se])=>Se||de!==0)),W);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(W),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ia(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Pv),Aa(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,re])=>{const he=Yv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Is(0,Be,Ed(_e-1,Be));let Oe=nf(Se,re,Ae,Be);return pe==="end"?Oe=Sg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=Sg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Cf,cn,Js,ey,dr,Ef,ur));function dy(t,r,s){return Is(1,Bo((t+s)/(Bo(r)+s)))}function wg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=nf(t,r,s,o[0].index);return{bottom:nf(t,r,s,o[o.length-1].index)+c,top:u}}function nf(t,r,s,o){const c=dy(t.width,s.width,r.column),u=Bo(o/c),d=u*s.height+Is(0,u-1)*r.row;return d>0?d+r.row:d}const Kk=et(()=>{const t=ve(v=>`Item ${v}`),r=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Tf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(r,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Xk=et(([t,r])=>({...t,...r}),jt(Yk,Kk)),Qk=Te.memo(function(){const t=kt("gridState"),r=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$r(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Cg("column-gap",getComputedStyle(N).columnGap,S),row:Cg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return sy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:a.jsx(g,{className:r,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?a.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Zk=Te.memo(function(){const t=kt("HeaderComponent"),r=Fn("headerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),Jk=Te.memo(function(){const t=kt("FooterComponent"),r=Fn("footerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),ew=({children:t})=>{const r=Te.useContext(ly),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$r(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Ko(!1),children:t})},tw=({children:t})=>{const r=Te.useContext(ly),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Bv(s,c,!1);return Te.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Ko(!1),children:t})},nw=Te.memo(function({...t}){const r=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||r?rw:aw,c=s||r?tw:ew,u=kt("context");return a.jsx(o,{...t,...tn(o,u),children:a.jsxs(c,{children:[a.jsx(Zk,{}),a.jsx(Qk,{}),a.jsx(Jk,{})]})})}),{useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}=ay(Xk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},nw),aw=cy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}),rw=uy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn});function Cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}const lw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},py={source:"Own",installed:"Installed"};function sw(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function iw(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Eg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=lw[t],[d,h]=m.useState(()=>sw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return iw(u,S),S})},[u]),p=py[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(cw,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(ow,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function ow({origin:t,updateCount:r}){const[s,o]=m.useState(!1),c=py[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function cw({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Af(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function uw({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function dw({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function fw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function pw({skillId:t,trackedForUpdates:r}){let s=null;try{s=m.useContext(Cv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ei(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function mw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(ei,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(dw,{target:t.symlinkTarget??null}),a.jsx(fw,{skill:t}),a.jsx(pw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Io=m.memo(mw);function hw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Io,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function xw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function Ng({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=r??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>xw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>a.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const Lo=new Map,Br=new Map,Ds=new Map;function Tn(t){Lo.delete(t),Br.delete(t);const r=Ds.get(t);if(r)for(const s of r)s()}function ti(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Ds.has(t)||Ds.set(t,new Set),Ds.get(t).add(b),()=>{var S;(S=Ds.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=Lo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Br.has(t)){const C=Br.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=r().then(C=>{Lo.set(t,{data:C,fetchedAt:Date.now()}),Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Br.set(t,k)},[t,r,o,c]);const p=Lo.get(t),y=c&&!p&&Br.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function gw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),zv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Nd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Nd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Nd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Nd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Tg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(vw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function vw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function yw(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function bw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function jw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function Sw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function af(t,r={}){const{enabled:s=!0,target:o}=r,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(bw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=jw(p.target);for(const v of c.current){if(!Sw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const kw=200;function ww(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Cw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Af(g,r)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Ew(t,r){const s=[],o=[],c=[];for(const d of t){const h=ww(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Af(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Nw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Af(y,r)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Tw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(W=>W.scope!==void 0&&W.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Ew(t,N),[t,N]),A=m.useMemo(()=>Cw(t,N),[t,N]),B=k==="claude-code",{plugins:D}=z2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const W=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=W.get(te.name);W.set(te.name,!!fe||!!te.enabled)}return W},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>rf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>rf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(W=>{z(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(W))}catch{}},[k]),X=m.useCallback(W=>{H(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(W))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Nw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=kw,I=m.useMemo(()=>{const W=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...W(T.own.byPlugin),...W(T.installed.byPlugin),...W(T.global.byPlugin)]:[...W(J.byPlugin),...W($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>r?I.findIndex(W=>W.plugin===r.plugin&&W.skill===r.skill):-1,[I,r]),se=m.useCallback(W=>{if(I.length===0)return;const te=V<0?W>0?0:I.length-1:Math.min(Math.max(V+W,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[W,te]=v.split("/");if(!W||!te)return null;const fe=t.find(de=>de.plugin===W&&de.skill===te);if(!fe)return{plugin:W,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??W:null;return{plugin:W,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const W=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${W}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(uw,{value:E,onChange:C}),o&&a.jsx(zw,{}),!o&&c&&a.jsx(Dw,{error:c,onRetry:u}),!o&&!c&&S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Tg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?a.jsx(Ag,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?a.jsx(Aw,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-available-${W}-collapsed`,headerActionSlot:B?a.jsx(gw,{pluginName:W,enabled:w.get(W)??!0}):void 0,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${W}`))]})]}),a.jsx(Lw,{}),a.jsx(Tg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-authoring-${W}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===W,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${W}`))})]})]}),!o&&!c&&!S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Eg,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:J.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Mw,{}),a.jsx(Eg,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?a.jsx(Ag,{queryActive:!!E}):a.jsx(Ls,{items:$.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function rf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>rf(r)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(S))}catch{}return S})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function Rw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ls({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Rw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Pk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Io,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(hw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Rg({queryActive:t}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Mf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ag({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install <skill>"})," to add one."]})})}function Aw({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install --global <skill>"})," to add one."]})})}function Ml({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Mf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Mw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Lw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function zw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(yw,{},t))})}function Dw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:_w(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function _w(t){const r=t.split(`
66
+ `)[0]??t;return r.length>80?r.slice(0,77)+"…":r}const my=240,hy=480,xy="vskill-sidebar-width",Us=320;function Lf(t){return Number.isFinite(t)?Math.round(Math.max(my,Math.min(hy,t))):Us}function Ow(){try{const t=localStorage.getItem(xy);if(!t)return Us;const r=Number(t);return Number.isFinite(r)?Lf(r):Us}catch{return Us}}function Bw(t){try{localStorage.setItem(xy,String(Lf(t)))}catch{}}function Iw({initialWidth:t,onChange:r}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),o=m.useRef(t);return m.useEffect(()=>{o.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=Lf(s.current.startWidth+h);o.current=g,r(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Bw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[r]),a.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":my,"aria-valuemax":hy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Uw({connected:t,hint:r,onRetry:s}){return t?null:a.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),a.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&a.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),a.jsx("div",{style:{flex:1}}),s&&a.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function gy(t,r){if(t!==401||typeof window>"u"||!r||typeof r!="object")return;const s=r;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function vy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(r){console.error("Failed to serialize request body:",r);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Td(){const[t,r]=m.useState([]),[s,o]=m.useState(!1),[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useCallback(async(v,b)=>{r([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=vy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw gy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
67
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};A==="done"?(u(!0),r(U=>[...U,z])):r(U=>[...U,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=m.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:p,stop:y}}function Hw(t){const r=m.useRef(t);r.current=t;const[s,o]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(p,y,v)=>{var S;(S=c.current.get(p))==null||S.abort();const b=new AbortController;c.current.set(p,b),o(k=>{const E=new Set(k);return E.add(p),E});try{const k=vy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw gy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
68
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};r.current.onEvent(p,z)}catch{}A=""}}r.current.onDone(p)}catch(k){k.name!=="AbortError"&&r.current.onError(p,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(p),E}),c.current.delete(p)}},[]),d=m.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=m.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const $w={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Vw(t,r){var s,o;switch(r.type){case"SET_LOADING":return{...t,loading:r.loading};case"SET_ERROR":return{...t,error:r.error};case"INIT_DATA":{const c=new Map;if(r.benchmark)for(const d of r.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=r.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:r.panel};case"SET_CONTENT":return{...t,skillContent:r.content,isDirty:r.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:r.evals};case"SELECT_CASE":return{...t,selectedCaseId:r.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...t,caseRunStates:c,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,r.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);return c.set(r.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of r.caseIds)c.set(u,{status:"queued",mode:r.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:r.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(r.evalId,r.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const c=r.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(r.index,!c.get(r.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:r.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:r.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,r.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:r.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:r.runs,activationHistoryLoading:!1};default:return t}}function Pw(t){if(t==="unit"||t==="integration")return t}function Fw(t,r){const s=r.data;if(r.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),r.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),r.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}r.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const yy=m.createContext(null);function An(){const t=m.useContext(yy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Gw({plugin:t,skill:r,origin:s,children:o}){const c=s==="installed",[u,d]=m.useReducer(Vw,{...$w,plugin:t,skill:r}),h=m.useRef(new Set),g=m.useRef(new Set),p=m.useRef(new Map),y=m.useCallback((re,he)=>{let pe=p.current.get(re);pe||(pe={assertions:[]},p.current.set(re,pe)),Fw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:re,result:{...pe,assertions:[...pe.assertions]}})},[]),v=m.useCallback(re=>{if(g.current.has(re))return;g.current.add(re);const he=p.current.get(re)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:re,result:{...he,assertions:[...he.assertions]}}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,r]),b=m.useCallback((re,he)=>{g.current.has(re)||(g.current.add(re),d({type:"CASE_RUN_ERROR",caseId:re,error:he}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,r]),{startCase:S,stopCase:k,stopAll:E}=Hw({onEvent:y,onDone:v,onError:b});m.useEffect(()=>()=>{E()},[E]);const C=m.useCallback(async()=>{try{const re=await fetch(`/api/skills/${t}/${r}/activation-history`);if(!re.ok){if(re.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await re.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,r]);m.useEffect(()=>{let re=!1;async function he(){try{const[pe,ge,je]=await Promise.allSettled([Ce.getSkillDetail(t,r),Ce.getEvals(t,r),Ce.getLatestBenchmark(t,r)]);if(re)return;let Be=null,Oe=null;if(ge.status==="fulfilled")Be=ge.value;else{const rt=ge.reason;Oe=(rt==null?void 0:rt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){re||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{re=!0}},[t,r,C]);const N=m.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,r,u.skillContent),d({type:"CONTENT_SAVED"})}catch(re){d({type:"SET_ERROR",error:re.message})}},[c,t,r,u.skillContent]),T=m.useCallback(async re=>{if(!c)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,r]),A=m.useCallback((re,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(re);if((pe==null?void 0:pe.status)!=="running")if(p.current.delete(re),g.current.delete(re),d({type:"CASE_RUN_START",caseId:re,mode:he}),he==="comparison"){const ge=`/api/skills/${t}/${r}/compare`;S(re,ge,{eval_ids:[re]})}else{const ge=`/api/skills/${t}/${r}/benchmark/case/${re}`;S(re,ge,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.caseRunStates,S]),B=m.useCallback((re="benchmark")=>{var ge;if(c)return;const he=((ge=u.evals)==null?void 0:ge.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)p.current.delete(je),g.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:re}),h.current=new Set(pe);for(const je of pe)if(re==="comparison")S(je,`/api/skills/${t}/${r}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${r}/benchmark/case/${je}`;S(je,Be,re==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.evals,S]),D=m.useCallback(re=>{k(re),d({type:"CASE_RUN_CANCEL",caseId:re}),h.current.delete(re),g.current.add(re)},[k]),F=m.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=m.useCallback(async(re,he)=>{d({type:"OPEN_IMPROVE",evalId:re})},[]),O=m.useCallback(async(re,he)=>{try{await Ce.applyImprovement(t,r,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(re,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,r,A]),z=Td(),U=m.useRef(null),H=m.useRef(0);m.useEffect(()=>{const re=z.events;for(let he=H.current;he<re.length;he++){const pe=re[he],ge=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge.improved,Be=ge.reasoning,Oe=ge.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const je=ge;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}H.current=re.length},[z.events]),m.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),m.useEffect(()=>()=>{z.stop()},[z.stop]);const q=m.useCallback(async(re,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=z.stop,z.start(`/api/skills/${t}/${r}/improve?sse`,{mode:"instruct",instruction:re,content:u.skillContent,evals:u.evals??{skill_name:r,evals:[]},provider:he,model:pe}))},[c,t,r,u.skillContent,u.evals,z]),X=m.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=m.useCallback(async()=>{const re=u.aiEditResult;if(re!=null&&re.improved)try{if(await Ce.applyImprovement(t,r,re.improved),d({type:"SET_CONTENT",content:re.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Xs(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),ge=u.evals??{skill_name:r,evals:[]},je=pe(ge,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,r,je);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,r,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=m.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=m.useCallback(re=>{d({type:"TOGGLE_EVAL_CHANGE",index:re})},[]),_=m.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=m.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(async()=>{const re=u.aiEditEvalsRetry;if(re)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,r,u.aiEditEvalsRetry]),se=m.useCallback(async()=>{try{const re=await Ce.getSkillDetail(t,r);d({type:"SET_CONTENT",content:re.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,r]),{config:M}=Hr(),Y=Td(),W=m.useRef(0);m.useEffect(()=>{const re=Y.events;for(let he=W.current;he<re.length;he++){const pe=re[he],ge=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge;Ce.saveEvals(t,r,je).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:ge})}W.current=re.length},[Y.events,t,r]),m.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),m.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=m.useCallback(async re=>{if(c)return;W.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Pw(re==null?void 0:re.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${r}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,r,Y,M]),fe=Td(),ie=m.useRef(0);m.useEffect(()=>()=>{fe.stop()},[fe.stop]),m.useEffect(()=>{const re=fe.events;for(let he=ie.current;he<re.length;he++){const pe=re[he];if(pe.event==="classifying"){const ge=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:ge.index,total:ge.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ge=pe.data;if(ge.error)d({type:"ACTIVATION_ERROR",error:ge.error});else{d({type:"ACTIVATION_DONE",summary:ge});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:ge.total,summary:{precision:ge.precision,recall:ge.recall,reliability:ge.reliability,tp:ge.tp,tn:ge.tn,fp:ge.fp,fn:ge.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}ie.current=re.length},[fe.events,M,u.activationHistory]),m.useEffect(()=>{fe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ye=m.useRef(null),de=m.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),Se=m.useCallback(re=>{const pe=re.trim().split(`
69
+ `).filter(Boolean).map(je=>je.startsWith("!")?{prompt:je.slice(1).trim(),expected:"should_not_activate"}:je.startsWith("+")?{prompt:je.slice(1).trim(),expected:"should_activate"}:{prompt:je.trim(),expected:"auto"});ie.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:re});const ge={prompts:pe};M!=null&&M.provider&&(ge.provider=M.provider),M!=null&&M.model&&(ge.model=M.model),fe.start(`/api/skills/${t}/${r}/activation-test`,ge),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{fe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ye.current=null},12e4)},[t,r,fe,M]),Ae=m.useCallback(async(re=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:re};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=await fetch(`/api/skills/${t}/${r}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let ht=`HTTP ${pe.status}`;try{const Dt=await pe.json();Dt.error&&(ht=Dt.error)}catch{}throw new Error(ht)}const ge=pe.body.getReader(),je=new TextDecoder;let Be="",Oe="",rt=[];for(;;){const{done:ht,value:Dt}=await ge.read();if(ht)break;Be+=je.decode(Dt,{stream:!0});const Tt=Be.split(`
70
70
  `);Be=Tt.pop()||"";for(const Qe of Tt)if(Qe.startsWith("event: "))Oe=Qe.slice(7).trim();else if(Qe.startsWith("data: ")){try{const tt=JSON.parse(Qe.slice(6));if(Oe==="done"){if(tt.error)throw new Error(tt.error);rt=tt.prompts||[]}if(Oe==="error")throw new Error(tt.message||tt.description||"Generation failed")}catch(tt){if(!(tt instanceof SyntaxError))throw tt}Oe=""}}const Nt=rt.map(ht=>`${ht.expected==="should_activate"?"+":"!"}${ht.prompt}`).join(`
71
- `);d({type:"SET_ACTIVATION_PROMPTS",prompts:Nt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,r,A]),_e=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:R,runCase:L,runAll:B,cancelCase:D,cancelAll:F,improveForCase:E,applyImproveAndRerun:H,refreshSkillContent:se,generateEvals:te,runActivationTest:Se,cancelActivation:de,generateActivationPrompts:Ae,fetchActivationHistory:C,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:M,selectAllEvalChanges:_,deselectAllEvalChanges:O,retryEvalsSave:V}),[u,c,N,R,L,B,D,F,E,H,se,te,Se,de,Ae,C,q,X,J,$,M,_,O,V]);return a.jsx(vy.Provider,{value:_e,children:o})}function Fw(t){if(!t)return[];const r=t.split(`
72
- `),s=[];for(const o of r)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function zf({contentDiff:t,fromLabel:r,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[g,m]=p.useState(u),[y,v]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),k=p.useMemo(()=>Fw(t),[t]),w=p.useMemo(()=>{const D=k.filter(E=>E.type==="add").length,F=k.filter(E=>E.type==="remove").length;return{added:D,removed:F}},[k]),C=p.useMemo(()=>{let D=0,F=0;return k.filter(E=>E.type!=="header").map(E=>E.type==="remove"?(D++,{...E,origNum:D,newNum:null}):E.type==="add"?(F++,{...E,origNum:null,newNum:F}):(D++,F++,{...E,origNum:D,newNum:F}))},[k]),N=p.useMemo(()=>{const D=[],F=[];for(const E of C)if(E.type==="remove")D.push(E);else if(E.type==="add")F.push(E);else{for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});D.push(E),F.push(E)}for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:D,right:F}},[C]),R=p.useCallback(D=>{const F=D==="left"?b.current:S.current,E=D==="left"?S.current:b.current;F&&E&&(E.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return a.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&a.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const L=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=a.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[r," → ",s]}),a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",w.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",w.removed]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&a.jsx("button",{onClick:()=>m(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&a.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:C.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:D.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:D.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:D.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:D.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:D.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:D.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:D.type==="add"?"var(--green)":D.type==="remove"?"var(--red)":"transparent",borderRight:D.type==="add"?"2px solid var(--green)":D.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:D.type==="add"?"+":D.type==="remove"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})}):a.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>R("left"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.left.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:D.origNum??""}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})}),a.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>R("right"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.right.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:D.newNum??""}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})})]}))]});return d==="modal"?a.jsx("div",{className:L,children:a.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Rd="https://verified-skill.com/submit",Gw=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function Ww(t){if(!t)return Rd;const r=t.trim();return!r||!Gw.test(r)?Rd:`${Rd}?repo=${encodeURIComponent(r)}`}const Mg={CERTIFIED:{bg:"var(--yellow-muted)",text:"var(--yellow)"},VERIFIED:{bg:"var(--accent-muted)",text:"var(--accent)"},COMMUNITY:{bg:"var(--surface-3)",text:"var(--text-tertiary)"}};function qw(t,r){return t?t.length>r?t.slice(0,r)+"…":t:""}function Yw(){const{state:t}=An(),{plugin:r,skill:s}=t,o=ea(),{refreshSkills:c,updateCount:u}=o,d=p.useMemo(()=>o.state.skills.find(M=>M.plugin===r&&M.skill===s)??null,[o.state.skills,r,s]),h=`versions/${r}/${s}`,g=p.useCallback(()=>Ce.getSkillVersions(r,s),[r,s]),{data:m,loading:y}=ti(h,g),[v,b]=p.useState(null),[S,k]=p.useState(null),[w,C]=p.useState(null),[N,R]=p.useState(!1),[L,B]=p.useState("idle"),[D,F]=p.useState(null),E=p.useRef(null),H=p.useRef(null),z=p.useMemo(()=>(m==null?void 0:m.find(M=>M.isInstalled))??null,[m]),I=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),U=z&&I&&z.version!==I.version,q=p.useCallback(M=>{v?!S&&M!==v?k(M):(b(M),k(null),C(null)):(b(M),C(null))},[v,S]),X=p.useCallback(async(M,_)=>{R(!0);try{const O=await Ce.getVersionDiff(r,s,M,_);C(O)}catch{C(null)}finally{R(!1)}},[r,s]);p.useEffect(()=>{if(v&&S){const M=m||[],_=M.findIndex(A=>A.version===v),O=M.findIndex(A=>A.version===S),[V,se]=_>O?[v,S]:[S,v];X(V,se)}},[v,S,m,X]);const J=p.useCallback(()=>{!z||!I||(b(z.version),k(I.version))},[z,I]),$=p.useCallback(async()=>{B("updating"),F(null);const M=new AbortController;E.current=M;try{const _=await Ce.postSkillUpdate(r,s,M.signal);if(_.ok)B("done"),c(),Tn(h);else{const O=`Update failed (HTTP ${_.status}): ${_.body||"no response body"}`;B("error"),F(O)}}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;const O=_ instanceof Error?_.message:"Network error";B("error"),F(O)}finally{E.current===M&&(E.current=null)}},[r,s,h,c]);if(p.useEffect(()=>()=>{var M;(M=E.current)==null||M.abort(),E.current=null},[]),y)return a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!m||m.length===0){if((d==null?void 0:d.origin)==="source"){const _=Ww((d==null?void 0:d.homepage)??null);return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[a.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),a.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),a.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return a.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:a.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),a.jsxs("div",{className:"flex items-center gap-2",children:[U&&a.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),U&&L!=="done"&&(L==="error"?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),a.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):a.jsx("button",{onClick:$,disabled:L!=="idle",className:"btn btn-primary text-[11px]",children:L==="idle"?`Update to ${I==null?void 0:I.version}`:L==="updating"?"Starting update...":L==="scanning"?"Scanning...":"Installing..."})),u>1&&a.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",u,")"]})]})]}),v&&!S&&a.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",v]}),a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),a.jsx("div",{className:"space-y-1",children:m.map(M=>{const _=Mg[M.certTier]||Mg.COMMUNITY,O=M.version===v||M.version===S,V=M.isInstalled;return a.jsxs("button",{onClick:()=>q(M.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:O?"var(--accent-muted)":"transparent",border:O?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:se=>{O||(se.currentTarget.style.background="var(--surface-1)")},onMouseLeave:se=>{O||(se.currentTarget.style.background="transparent")},children:[a.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:V?10:8,height:V?10:8,background:V?"var(--accent)":"var(--surface-3)",border:V?"2px solid var(--accent)":"2px solid var(--border-default)"}}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:M.version}),a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.bg,color:_.text},children:M.certTier}),V&&a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(M.createdAt).toLocaleDateString()})]}),M.diffSummary&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:qw(M.diffSummary,80)})]},M.version)})}),a.jsx("div",{ref:H,style:{height:1}})]}),N&&a.jsx("div",{className:"mt-4",children:a.jsx("div",{className:"skeleton h-48 rounded-xl"})}),w&&!N&&a.jsx("div",{className:"mt-4",children:a.jsx(zf,{contentDiff:w.contentDiff,fromLabel:w.from,toLabel:w.to,diffSummary:w.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(w.from,w.to)})})]})}function Kw(t){const r=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!r)return{metadata:{},body:t};const s=r[1],o=r[2].trim(),c={},u=s.split(`
73
- `);let d="",h=!1;for(const g of u){const m=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(m&&d&&h){const b=m[1],S=m[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const w=S.match(/^\[(.+)\]$/);w?k[b]=w[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(y[1].trim().replace(/^["']|["']$/g,"")):c[d]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){d=v[1];const b=v[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Xo(t){if(!t)return"";try{let r=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=Xw(r);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function Xw(t){const r=t.split(`
74
- `),s=[];let o=0;for(;o<r.length;)if(r[o].trim().startsWith("|")&&o+1<r.length&&r[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(r[o+1])){const c=Lg(r[o]);o+=2;const u=[];for(;o<r.length&&r[o].trim().startsWith("|");)u.push(Lg(r[o])),o++;const d='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const m of c)g+=`<th ${d}>${m}</th>`;g+="</tr></thead><tbody>";for(const m of u){g+="<tr>";for(const y of m)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(r[o]),o++;return s.join(`
71
+ `);d({type:"SET_ACTIVATION_PROMPTS",prompts:Nt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,r,M]),_e=m.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:T,runCase:A,runAll:B,cancelCase:D,cancelAll:F,improveForCase:w,applyImproveAndRerun:O,refreshSkillContent:se,generateEvals:te,runActivationTest:Se,cancelActivation:de,generateActivationPrompts:Ae,fetchActivationHistory:C,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:L,selectAllEvalChanges:_,deselectAllEvalChanges:I,retryEvalsSave:V}),[u,c,N,T,A,B,D,F,w,O,se,te,Se,de,Ae,C,q,X,J,$,L,_,I,V]);return a.jsx(yy.Provider,{value:_e,children:o})}function Ww(t){if(!t)return[];const r=t.split(`
72
+ `),s=[];for(const o of r)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function zf({contentDiff:t,fromLabel:r,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[g,p]=m.useState(u),[y,v]=m.useState("unified"),b=m.useRef(null),S=m.useRef(null),k=m.useMemo(()=>Ww(t),[t]),E=m.useMemo(()=>{const D=k.filter(w=>w.type==="add").length,F=k.filter(w=>w.type==="remove").length;return{added:D,removed:F}},[k]),C=m.useMemo(()=>{let D=0,F=0;return k.filter(w=>w.type!=="header").map(w=>w.type==="remove"?(D++,{...w,origNum:D,newNum:null}):w.type==="add"?(F++,{...w,origNum:null,newNum:F}):(D++,F++,{...w,origNum:D,newNum:F}))},[k]),N=m.useMemo(()=>{const D=[],F=[];for(const w of C)if(w.type==="remove")D.push(w);else if(w.type==="add")F.push(w);else{for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});D.push(w),F.push(w)}for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:D,right:F}},[C]),T=m.useCallback(D=>{const F=D==="left"?b.current:S.current,w=D==="left"?S.current:b.current;F&&w&&(w.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return a.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&a.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const A=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=a.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[r," → ",s]}),a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",E.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",E.removed]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&a.jsx("button",{onClick:()=>p(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&a.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:C.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:D.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:D.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:D.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:D.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:D.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:D.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:D.type==="add"?"var(--green)":D.type==="remove"?"var(--red)":"transparent",borderRight:D.type==="add"?"2px solid var(--green)":D.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:D.type==="add"?"+":D.type==="remove"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})}):a.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>T("left"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.left.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:D.origNum??""}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})}),a.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>T("right"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.right.map((D,F)=>a.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:D.newNum??""}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":"var(--text-secondary)"},children:D.content||"​"})]},F))})})})]}))]});return d==="modal"?a.jsx("div",{className:A,children:a.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Rd="https://verified-skill.com/submit",qw=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function Yw(t){if(!t)return Rd;const r=t.trim();return!r||!qw.test(r)?Rd:`${Rd}?repo=${encodeURIComponent(r)}`}const Mg={CERTIFIED:{bg:"var(--yellow-muted)",text:"var(--yellow)"},VERIFIED:{bg:"var(--accent-muted)",text:"var(--accent)"},COMMUNITY:{bg:"var(--surface-3)",text:"var(--text-tertiary)"}};function Kw(t,r){return t?t.length>r?t.slice(0,r)+"…":t:""}function Xw(){const{state:t}=An(),{plugin:r,skill:s}=t,o=ea(),{refreshSkills:c,updateCount:u}=o,d=m.useMemo(()=>o.state.skills.find(L=>L.plugin===r&&L.skill===s)??null,[o.state.skills,r,s]),h=`versions/${r}/${s}`,g=m.useCallback(()=>Ce.getSkillVersions(r,s),[r,s]),{data:p,loading:y}=ti(h,g),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),[A,B]=m.useState("idle"),[D,F]=m.useState(null),w=m.useRef(null),O=m.useRef(null),z=m.useMemo(()=>(p==null?void 0:p.find(L=>L.isInstalled))??null,[p]),U=m.useMemo(()=>(p==null?void 0:p[0])??null,[p]),H=z&&U&&z.version!==U.version,q=m.useCallback(L=>{v?!S&&L!==v?k(L):(b(L),k(null),C(null)):(b(L),C(null))},[v,S]),X=m.useCallback(async(L,_)=>{T(!0);try{const I=await Ce.getVersionDiff(r,s,L,_);C(I)}catch{C(null)}finally{T(!1)}},[r,s]);m.useEffect(()=>{if(v&&S){const L=p||[],_=L.findIndex(M=>M.version===v),I=L.findIndex(M=>M.version===S),[V,se]=_>I?[v,S]:[S,v];X(V,se)}},[v,S,p,X]);const J=m.useCallback(()=>{!z||!U||(b(z.version),k(U.version))},[z,U]),$=m.useCallback(async()=>{B("updating"),F(null);const L=new AbortController;w.current=L;try{const _=await Ce.postSkillUpdate(r,s,L.signal);if(_.ok)B("done"),c(),Tn(h);else{const I=`Update failed (HTTP ${_.status}): ${_.body||"no response body"}`;B("error"),F(I)}}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;const I=_ instanceof Error?_.message:"Network error";B("error"),F(I)}finally{w.current===L&&(w.current=null)}},[r,s,h,c]);if(m.useEffect(()=>()=>{var L;(L=w.current)==null||L.abort(),w.current=null},[]),y)return a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!p||p.length===0){if((d==null?void 0:d.origin)==="source"){const _=Yw((d==null?void 0:d.homepage)??null);return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[a.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),a.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),a.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return a.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:a.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),a.jsxs("div",{className:"flex items-center gap-2",children:[H&&a.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),H&&A!=="done"&&(A==="error"?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),a.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):a.jsx("button",{onClick:$,disabled:A!=="idle",className:"btn btn-primary text-[11px]",children:A==="idle"?`Update to ${U==null?void 0:U.version}`:A==="updating"?"Starting update...":A==="scanning"?"Scanning...":"Installing..."})),u>1&&a.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",u,")"]})]})]}),v&&!S&&a.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",v]}),a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),a.jsx("div",{className:"space-y-1",children:p.map(L=>{const _=Mg[L.certTier]||Mg.COMMUNITY,I=L.version===v||L.version===S,V=L.isInstalled;return a.jsxs("button",{onClick:()=>q(L.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:I?"var(--accent-muted)":"transparent",border:I?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:se=>{I||(se.currentTarget.style.background="var(--surface-1)")},onMouseLeave:se=>{I||(se.currentTarget.style.background="transparent")},children:[a.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:V?10:8,height:V?10:8,background:V?"var(--accent)":"var(--surface-3)",border:V?"2px solid var(--accent)":"2px solid var(--border-default)"}}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:L.version}),a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.bg,color:_.text},children:L.certTier}),V&&a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(L.createdAt).toLocaleDateString()})]}),L.diffSummary&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:Kw(L.diffSummary,80)})]},L.version)})}),a.jsx("div",{ref:O,style:{height:1}})]}),N&&a.jsx("div",{className:"mt-4",children:a.jsx("div",{className:"skeleton h-48 rounded-xl"})}),E&&!N&&a.jsx("div",{className:"mt-4",children:a.jsx(zf,{contentDiff:E.contentDiff,fromLabel:E.from,toLabel:E.to,diffSummary:E.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(E.from,E.to)})})]})}function Qw(t){const r=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!r)return{metadata:{},body:t};const s=r[1],o=r[2].trim(),c={},u=s.split(`
73
+ `);let d="",h=!1;for(const g of u){const p=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(p&&d&&h){const b=p[1],S=p[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const E=S.match(/^\[(.+)\]$/);E?k[b]=E[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(y[1].trim().replace(/^["']|["']$/g,"")):c[d]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){d=v[1];const b=v[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Xo(t){if(!t)return"";try{let r=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=Zw(r);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function Zw(t){const r=t.split(`
74
+ `),s=[];let o=0;for(;o<r.length;)if(r[o].trim().startsWith("|")&&o+1<r.length&&r[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(r[o+1])){const c=Lg(r[o]);o+=2;const u=[];for(;o<r.length&&r[o].trim().startsWith("|");)u.push(Lg(r[o])),o++;const d='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const p of c)g+=`<th ${d}>${p}</th>`;g+="</tr></thead><tbody>";for(const p of u){g+="<tr>";for(const y of p)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(r[o]),o++;return s.join(`
75
75
  `)}function Lg(t){return t.split("|").map(r=>r.trim()).filter(r=>r.length>0)}function Qo(t,r){const s=t.split(`
76
76
  `),o=r.split(`
77
- `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?d[y][v]=d[y-1][v-1]+1:d[y][v]=Math.max(d[y-1][v],d[y][v-1]);const h=[];let g=c,m=u;for(;g>0||m>0;)g>0&&m>0&&s[g-1]===o[m-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,m--):m>0&&(g===0||d[g][m-1]>=d[g-1][m])?(h.push({type:"added",content:o[m-1]}),m--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function Qw(t,r){if(r&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return a.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return a.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ni({entries:t,isRunning:r}){const[s,o]=p.useState(!1),c=p.useRef(null);return p.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!r?null:a.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[a.jsxs("span",{className:"flex items-center gap-2",children:[r&&a.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&a.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,d)=>{const h=d===t.length-1&&r,g=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return a.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[Qw(u.phase,h),a.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),a.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&a.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const zg={rate_limit:{icon:"⏱",color:"var(--amber, #f59e0b)"},context_window:{icon:"⚠",color:"var(--amber, #f59e0b)"},auth:{icon:"🔒",color:"var(--red, #ef4444)"},timeout:{icon:"⌛",color:"var(--amber, #f59e0b)"},model_not_found:{icon:"🔍",color:"var(--red, #ef4444)"},provider_unavailable:{icon:"⚡",color:"var(--red, #ef4444)"},parse_error:{icon:"❓",color:"var(--amber, #f59e0b)"},unknown:{icon:"❌",color:"var(--red, #ef4444)"}};function Zo({error:t,onRetry:r,onDismiss:s}){const[o,c]=p.useState(null),u=p.useRef(null);p.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),p.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=zg[t.category]||zg.unknown,h=o!=null&&o>0;return a.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${d.color} 30%, transparent)`,background:`color-mix(in srgb, ${d.color} 6%, var(--surface-1))`},children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{fontSize:14},children:d.icon}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&a.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-3.5 pb-3",children:[a.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),a.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(r||o!=null)&&a.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:r&&a.jsx("button",{onClick:r,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function Zw({plugin:t,skill:r,skillContent:s,onApplied:o}){const[c,u]=p.useState("closed"),{config:d}=Ur(),[h,g]=p.useState("claude-cli"),[m,y]=p.useState("opus"),[v,b]=p.useState([]),[S,k]=p.useState(""),[w,C]=p.useState(""),[N,R]=p.useState(null),[L,B]=p.useState(null),[D,F]=p.useState([]),[E,H]=p.useState(!1),z=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(_=>_.id==="claude-cli"&&_.available)&&(g("claude-cli"),y("opus"))},[d]),p.useEffect(()=>()=>{var M;(M=z.current)==null||M.abort()},[]);function I(){return d==null?void 0:d.providers.find(M=>M.id===h&&M.available)}const U=p.useCallback(()=>{var M;(M=z.current)==null||M.abort(),u("open")},[]);async function q(){u("loading"),R(null),B(null),F([]);const M=new AbortController;z.current=M;try{const _=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(r)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:m}),signal:M.signal});if(!_.ok||!_.body){let Y=`HTTP ${_.status}`;try{const W=await _.json();W.error&&(Y=W.error)}catch{}throw new Error(Y)}const O=_.body.getReader(),V=new TextDecoder;let se="",A="";for(;;){const{done:Y,value:W}=await O.read();if(Y)break;se+=V.decode(W,{stream:!0});const te=se.split(`
78
- `);se=te.pop()||"";for(const fe of te)if(fe.startsWith("event: "))A=fe.slice(7).trim();else if(fe.startsWith("data: ")){try{const ie=JSON.parse(fe.slice(6));A==="progress"?F(ye=>[...ye,{phase:ie.phase,message:ie.message,timestamp:Date.now()}]):A==="done"||A==="complete"?(k(ie.improved),C(ie.reasoning||""),b(Qo(ie.original||s,ie.improved)),u("diff_shown")):A==="error"&&(R(ie.message||ie.description||"Unknown error"),ie.category&&B(ie),u("open"))}catch{}A=""}}}catch(_){_.name!=="AbortError"&&(R(_.message),u("open"))}finally{z.current=null}}async function X(){H(!0);try{await Ce.applyImprovement(t,r,S),o(S),u("closed")}catch(M){R(M.message)}finally{H(!1)}}function J(){u("closed"),b([]),k(""),C(""),R(null)}if(c==="closed")return a.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=I();return a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),a.jsx("button",{onClick:J,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:M=>{M.currentTarget.style.background="var(--surface-3)"},onMouseLeave:M=>{M.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:M=>{g(M.target.value);const _=d==null?void 0:d.providers.find(O=>O.id===M.target.value);_!=null&&_.models[0]&&y(_.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(M=>M.available).map(M=>a.jsx("option",{value:M.id,children:M.label},M.id))})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:m,onChange:M=>y(M.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(M=>a.jsx("option",{value:M.id,children:M.label},M.id))})]}),c==="loading"?a.jsx("button",{onClick:U,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):a.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&a.jsx("div",{className:"mt-3",children:a.jsx(ni,{entries:D,isRunning:!0})})]}),N&&a.jsx("div",{className:"mb-4",children:L?a.jsx(Zo,{error:L,onRetry:q,onDismiss:()=>{R(null),B(null)}}):a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&a.jsxs(a.Fragment,{children:[w&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),w]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((M,_)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:M.type==="added"?"rgba(34,197,94,0.1)":M.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:M.type==="added"?"var(--green)":M.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:M.type==="added"?"3px solid var(--green)":M.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:M.type==="added"?"+":M.type==="removed"?"-":" "}),M.content]},_))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:X,disabled:E,className:"btn btn-primary",children:E?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),a.jsx("button",{onClick:J,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const Dg={remove:{bg:"var(--red-muted)",color:"var(--red)",label:"REMOVE"},modify:{bg:"rgba(251,191,36,0.15)",color:"#fbbf24",label:"MODIFY"},add:{bg:"var(--green-muted)",color:"var(--green)",label:"ADD"}},Jw={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function eC({change:t,index:r,selected:s,onToggle:o,originalEval:c}){var v;const[u,d]=p.useState(!1),h=Dg[t.action]??Dg.add,g=Jw[t.action]??"var(--border-subtle)",m=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=p.useCallback(()=>o(r),[o,r]);return a.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),a.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),a.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:m}),a.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),a.jsx("button",{onClick:()=>d(!u),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-3)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:u?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&a.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&a.jsx(tC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&a.jsx(nC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&a.jsx(aC,{evalCase:c})]})]})}function tC({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[a.jsx(lf,{label:"Prompt",value:t.prompt}),a.jsx(lf,{label:"Expected",value:t.expected_output}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>a.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function nC({original:t,proposed:r}){const s=[];t.name!==r.name&&s.push({label:"Name",old:t.name,new:r.name}),t.prompt!==r.prompt&&s.push({label:"Prompt",old:t.prompt,new:r.prompt}),t.expected_output!==r.expected_output&&s.push({label:"Expected",old:t.expected_output,new:r.expected_output});const o=t.assertions??[],c=r.assertions??[],u=new Set(o.map(m=>m.text)),d=new Set(c.map(m=>m.text)),h=c.filter(m=>!u.has(m.text)),g=o.filter(m=>!d.has(m.text));return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(m=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:m.label}),a.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[a.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",sf(m.old,120)]}),a.jsxs("div",{style:{color:"var(--green)"},children:["+ ",sf(m.new,120)]})]})]},m.label)),(h.length>0||g.length>0)&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),a.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(m=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",m.text]},m.id)),h.map(m=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",m.text]},m.id))]})]}),s.length===0&&h.length===0&&g.length===0&&a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function aC({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[a.jsx(lf,{label:"Prompt",value:t.prompt}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>a.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function lf({label:t,value:r}){return a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a.jsx("div",{className:"mt-0.5 text-[11px] p-2 rounded font-mono",style:{background:"var(--surface-1)",color:"var(--text-secondary)",whiteSpace:"pre-wrap"},children:sf(r,300)})]})}function sf(t,r){return t.length>r?t.slice(0,r)+"...":t}const _g={remove:0,modify:1,add:2};function rC({changes:t,selections:r,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((g,m)=>({change:g,originalIndex:m}));d.sort((g,m)=>(_g[g.change.action]??2)-(_g[m.change.action]??2));const h=Array.from(r.values()).filter(Boolean).length;return a.jsxs("div",{className:"mt-3 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),a.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),a.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:g,originalIndex:m})=>a.jsx(eC,{change:g,index:m,selected:r.get(m)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},m))})]})}function lC(){var M;const{state:t,dispatch:r,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:m}=An(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:w,aiEditEvalSelections:C,aiEditEvalsRetry:N}=t,[R,L]=p.useState(""),{config:B}=Ur(),[D,F]=p.useState("claude-cli"),[E,H]=p.useState("opus"),z=p.useRef(null);p.useEffect(()=>{var _;(_=z.current)==null||_.focus()},[]),p.useEffect(()=>{if(!B)return;B.providers.find(O=>O.id==="claude-cli"&&O.available)&&(F("claude-cli"),H("opus"))},[B]);const I=B==null?void 0:B.providers.find(_=>_.id===D&&_.available),U=p.useCallback(()=>{const _=R.trim();!_||y||s(_,D,E)},[R,y,s,D,E]),q=p.useCallback(_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),U()),_.key==="Escape"&&(_.preventDefault(),y?u():c())},[U,y,u,c]),X=p.useCallback(()=>{r({type:"CLOSE_AI_EDIT"}),r({type:"OPEN_AI_EDIT"})},[r]),J=v?Qo(t.skillContent,v.improved):[],$=((M=t.evals)==null?void 0:M.evals)??[];return a.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),a.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--surface-3)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-4 py-3",children:[!v&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{ref:z,value:R,onChange:_=>L(_.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),a.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:D,onChange:_=>{F(_.target.value);const O=B==null?void 0:B.providers.find(V=>V.id===_.target.value);O!=null&&O.models[0]&&H(O.models[0].id)},disabled:y,style:{width:"100%"},children:B==null?void 0:B.providers.filter(_=>_.available).map(_=>a.jsx("option",{value:_.id,children:_.label},_.id))})]}),a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:E,onChange:_=>H(_.target.value),disabled:y,style:{width:"100%"},children:I==null?void 0:I.models.map(_=>a.jsx("option",{value:_.id,children:_.label},_.id))})]}),a.jsx("div",{className:"flex-1"}),y?a.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):a.jsx("button",{onClick:U,disabled:!R.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&a.jsx("div",{className:"mt-2.5",children:a.jsx(ni,{entries:k,isRunning:!0})})]}),b&&a.jsx("div",{className:"mt-3",children:S?a.jsx(Zo,{error:S,onRetry:X,onDismiss:c}):a.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),v&&a.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&a.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),a.jsx("div",{className:"mb-1",children:a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:J.map((_,O)=>a.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:_.type==="added"?"rgba(34,197,94,0.1)":_.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:_.type==="added"?"var(--green)":_.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:_.type==="added"?"3px solid var(--green)":_.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:_.type==="added"?"+":_.type==="removed"?"-":" "}),_.content]},O))}),a.jsx(rC,{changes:w,selections:C,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:g}),N&&a.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[a.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),a.jsx("button",{onClick:m,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),a.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function sC(t,r){const[s,o]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),b=p.useCallback(async()=>{try{const w=await Ce.getSkillFiles(t,r);o(w.files)}catch{o([])}},[t,r]);p.useEffect(()=>{u("SKILL.md"),h(null),v(null),b()},[t,r,b]);const S=p.useCallback(async w=>{if(u(w),w==="SKILL.md"){h(null),v(null);return}m(!0),v(null);try{const C=await Ce.getSkillFile(t,r,w);h(C)}catch(C){v(`Unable to open file: ${C.message}`),h(null)}finally{m(!1)}},[t,r]),k=p.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function iC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function oC(t){const r=[],s=new Map;for(const o of t){const c=o.path.split("/"),d={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,d)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&r.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(o.path);d&&h&&d.children.push(h)}}return r}function yy({expanded:t}){return a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function by(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.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"})})}function cC(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function uC(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"23 4 23 10 17 10"}),a.jsx("polyline",{points:"1 20 1 14 7 14"}),a.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function jy({node:t,depth:r,activeFile:s,onSelect:o}){const[c,u]=p.useState(!0),d=t.path===s;return t.type==="dir"?a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[a.jsx(yy,{expanded:c}),a.jsx(by,{}),a.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>a.jsx(jy,{node:h,depth:r+1,activeFile:s,onSelect:o},h.path))]}):a.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:d?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:d?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[a.jsx("span",{style:{width:10}}),a.jsx(cC,{}),a.jsx("span",{style:{flex:1},children:t.name}),a.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:iC(t.size)})]})}function dC({files:t,activeFile:r,onSelect:s,onRefresh:o}){const[c,u]=p.useState(!1),d=p.useMemo(()=>oC(t),[t]);return a.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[a.jsx(yy,{expanded:c}),a.jsx(by,{}),a.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),a.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:a.jsx(uC,{})})]}),c&&a.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>a.jsx(jy,{node:h,depth:0,activeFile:r,onSelect:s},h.path))})]})}function bo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function fC(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function pC(t){const r=t.toLowerCase();return r.endsWith(".json")?"json":r.endsWith(".md")?"md":"other"}function Og({content:t}){return a.jsx("textarea",{readOnly:!0,value:t,style:{flex:1,width:"100%",resize:"none",background:"var(--surface-1)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}})}function Bg({content:t,fileType:r}){if(r==="json"){const s=fC(t);return a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s})}return r==="md"?a.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 20px",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:13,lineHeight:1.6},dangerouslySetInnerHTML:{__html:Xo(t)}}):a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function Ig(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function mC({file:t,loading:r,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[g,m]=p.useState(o),[y,v]=p.useState(!1),[b,S]=p.useState(""),[k,w]=p.useState(!1),[C,N]=p.useState(null),R=o!==g?o:g;p.useEffect(()=>{h==null||h(y)},[y,h]);const L=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),B=p.useCallback(()=>{v(!1)},[]),D=p.useCallback(async()=>{if(!(!c||!u||!t)){w(!0);try{await Ce.saveSkillFile(c,u,t.path,b),N("Saved"),v(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(H){N(`Save failed: ${H.message}`),setTimeout(()=>N(null),3e3)}finally{w(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!y)return;const H=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),D())};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[y,D]),r)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:a.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[a.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),a.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return a.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",bo(t.size),") — cannot be displayed"]});const F=t.content??"",E=pC(t.path);return a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&a.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",bo(512*1024)," — ",bo(t.size)," total"]}),a.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(E==="md"||E==="json")&&["raw","split","preview"].map(H=>a.jsx("button",{onClick:()=>m(H),style:{padding:"2px 8px",fontSize:11,background:R===H?"var(--accent-muted)":"none",color:R===H?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:H},H)),a.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[bo(t.size),c&&u&&!t.binary&&!y&&a.jsx("button",{onClick:L,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:D,disabled:k,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),a.jsx("button",{onClick:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&a.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[a.jsx("textarea",{value:b,onChange:H=>S(H.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),a.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),a.jsx("button",{onClick:D,disabled:k,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),a.jsx("button",{onClick:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):R==="split"&&E!=="other"?a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:a.jsx(Og,{content:F})}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:E==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ig(F)}}):a.jsx(Bg,{content:F,fileType:E})})]}):R==="preview"&&E!=="other"?E==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ig(F)}}):a.jsx(Bg,{content:F,fileType:E}):a.jsx(Og,{content:F})})]})}function hC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function xC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),a.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function gC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function vC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}function Ad({size:t=15}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function yC(){const{state:t,dispatch:r,saveContent:s,isReadOnly:o}=An(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:g,aiEditOpen:m}=t,[y,v]=p.useState("split"),[b,S]=p.useState(!1),k=p.useRef(null),[w,C]=p.useState(!1),[N,R]=p.useState(""),[L,B]=p.useState(!1),[D,F]=p.useState(null),[E,H]=p.useState([]),[z,I]=p.useState([]),[U,q]=p.useState(null),X=p.useRef(null),{config:J}=Ur(),{files:$,activeFile:M,secondaryContent:_,loading:O,error:V,selectFile:se,refresh:A,isSkillMd:Y}=sC(c??"",u??""),[W,te]=p.useState(!1),fe=p.useCallback(be=>{W&&!window.confirm("You have unsaved changes. Discard?")||se(be)},[W,se]);p.useEffect(()=>()=>{var be;(be=X.current)==null||be.abort()},[]);const{metadata:ie,body:ye}=Kw(d),de=ie["allowed-tools"],Se=Array.isArray(de)?de:typeof de=="string"?[de]:[],Ae=ie.name,_e=ie.description,re=ie.metadata,he=typeof re=="object"&&!Array.isArray(re)?re:null,pe=ie.version||(he==null?void 0:he.version),xe=ie.tags||(he==null?void 0:he.tags),je=Array.isArray(xe)?xe:typeof xe=="string"?xe.split(",").map(be=>be.trim()).filter(Boolean):[],Be=new Set(["name","description","metadata","allowed-tools","version","tags"]),Oe=Object.entries(ie).filter(([be])=>!Be.has(be)),rt=p.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),Nt=p.useCallback(be=>{(be.ctrlKey||be.metaKey)&&be.key==="s"&&(be.preventDefault(),be.stopPropagation(),h&&rt()),(be.ctrlKey||be.metaKey)&&be.key==="k"&&(be.preventDefault(),be.stopPropagation(),r({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,rt,m,r]),ht=p.useCallback(async()=>{var pt,Ct;if(!N.trim())return;(pt=X.current)==null||pt.abort();const be=new AbortController;X.current=be,B(!0),q(null),I([]),F(null),H([]);try{const Yt=(J==null?void 0:J.provider)||"claude-cli",un=(J==null?void 0:J.model)||"sonnet",Gt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Yt,model:un}),signal:be.signal});if(!Gt.ok||!Gt.body){let gt=`HTTP ${Gt.status}`;try{const da=await Gt.json();da.error&&(gt=da.error)}catch{}throw new Error(gt)}const an=Gt.body.getReader(),Mn=new TextDecoder;let Mt="",xt="";for(;;){const{done:gt,value:da}=await an.read();if(gt)break;Mt+=Mn.decode(da,{stream:!0});const za=Mt.split(`
79
- `);Mt=za.pop()||"";for(const Wn of za)if(Wn.startsWith("event: "))xt=Wn.slice(7).trim();else if(Wn.startsWith("data: ")){try{const Et=JSON.parse(Wn.slice(6));if(xt==="progress")I(ce=>[...ce,{phase:Et.phase,message:Et.message,timestamp:Date.now()}]);else if(xt==="done"||xt==="complete"){const ce=["---"];Et.name&&ce.push(`name: ${Et.name}`),Et.description&&ce.push(`description: "${Et.description.replace(/"/g,'\\"')}"`),Et.model&&ce.push(`model: ${Et.model}`),(Ct=Et.allowedTools)!=null&&Ct.trim()&&ce.push(`allowed-tools: ${Et.allowedTools.trim()}`),ce.push("---","",Et.body||"");const ve=ce.join(`
80
- `);F(ve),H(Qo(d,ve)),B(!1)}else xt==="error"&&(q(Et.message||Et.description||"Generation failed"),B(!1))}catch{}xt=""}}}catch(Yt){Yt.name!=="AbortError"&&q(Yt.message)}finally{B(!1),X.current=null}},[N,J,d]),Dt=p.useCallback(()=>{D&&r({type:"SET_CONTENT",content:D}),C(!1),F(null),H([]),R(""),I([])},[D,r]),Tt=p.useCallback(()=>{C(!1),F(null),H([]),R(""),I([]),q(null)},[]),Qe=p.useCallback(()=>{var be;w?((be=X.current)==null||be.abort(),Tt()):(m&&r({type:"CLOSE_AI_EDIT"}),C(!0))},[w,m,r,Tt]),tt=[{mode:"raw",icon:a.jsx(hC,{}),label:"Editor"},{mode:"split",icon:a.jsx(xC,{}),label:"Split"},{mode:"preview",icon:a.jsx(gC,{}),label:"Preview"}];return a.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Nt,tabIndex:-1,children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:tt.map(({mode:be,icon:pt,label:Ct})=>a.jsxs("button",{onClick:()=>v(be),title:Ct,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===be?"var(--surface-4)":"transparent",color:y===be?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===be?600:400,border:"none",cursor:"pointer"},children:[pt,a.jsx("span",{style:{letterSpacing:"0.01em"},children:Ct})]},be))}),Y?o?a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>{m?r({type:"CLOSE_AI_EDIT"}):(w&&Tt(),r({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:m?600:400,border:"none",cursor:"pointer",color:m?"var(--purple)":"var(--text-tertiary)",background:m?"var(--purple-muted)":"transparent"},children:[a.jsx(vC,{size:13}),a.jsx("span",{children:"AI Edit"})]}),a.jsxs("button",{onClick:Qe,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:w?600:400,border:"none",cursor:"pointer",color:w?"var(--purple)":"var(--text-tertiary)",background:w?"var(--purple-muted)":"transparent"},children:[a.jsx(Ad,{size:13}),a.jsx("span",{children:"Regenerate"})]}),a.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&a.jsx("button",{onClick:()=>r({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),a.jsx("button",{onClick:rt,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&a.jsx(dC,{files:$,activeFile:M,onSelect:fe,onRefresh:A}),!Y&&a.jsx(mC,{file:_,loading:O,error:V,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{se(M),A()},onDirtyChange:te}),Y&&a.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&a.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:a.jsx("textarea",{ref:k,value:d,onChange:be=>{o||r({type:"SET_CONTENT",content:be.target.value})},onKeyDown:Nt,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&a.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:a.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Ae||pe||_e)&&a.jsxs("div",{style:{marginBottom:20},children:[a.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Ae&&a.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Ae}),pe&&a.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",pe]})]}),_e&&a.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:_e})]}),je.length>0&&a.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:je.map(be=>a.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:be},be))}),Se.length>0&&a.jsx("div",{style:{marginBottom:16},children:a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),Se.map(be=>a.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:be},be))]})}),Oe.length>0&&a.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Oe.map(([be,pt],Ct)=>{const Yt=Array.isArray(pt)?pt.join(", "):typeof pt=="object"?Object.entries(pt).map(([un,Gt])=>`${un}: ${Array.isArray(Gt)?Gt.join(", "):Gt}`).join(" | "):pt;return a.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Ct>0?"1px solid var(--border-subtle)":"none"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:be}),a.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Yt})]},be)})}),(Ae||_e||je.length>0||Se.length>0||Oe.length>0)&&ye&&a.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ye&&a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Xo(ye)}})]})})]}),Y&&m&&a.jsx(lC,{}),Y&&w&&a.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:a.jsxs("div",{className:"px-4 py-3",children:[!D&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ad,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),a.jsx("div",{className:"flex gap-2 mb-2",children:a.jsx("textarea",{value:N,onChange:be=>R(be.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:L,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:L?.5:1},onKeyDown:be=>{be.key==="Enter"&&(be.ctrlKey||be.metaKey)&&N.trim()&&!L&&(be.preventDefault(),ht())}})}),a.jsxs("div",{className:"flex items-center gap-2",children:[L?a.jsx("button",{onClick:()=>{var be;(be=X.current)==null||be.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):a.jsx("button",{onClick:ht,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),a.jsx("button",{onClick:Tt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),L&&z.length>0&&a.jsx("div",{className:"mt-2",children:a.jsx(ni,{entries:z,isRunning:!0})}),U&&a.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[U,a.jsx("button",{onClick:ht,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),D&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ad,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:E.map((be,pt)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:be.type==="added"?"var(--green-muted)":be.type==="removed"?"var(--red-muted)":"transparent",color:be.type==="added"?"var(--green)":be.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:be.type==="added"?"3px solid var(--green)":be.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:be.type==="added"?"+":be.type==="removed"?"-":" "}),be.content]},pt))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:Dt,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:Tt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&g!==null&&c&&u&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(Zw,{plugin:c,skill:u,skillContent:d,onApplied:be=>{r({type:"SET_CONTENT",content:be}),r({type:"CONTENT_SAVED"}),r({type:"CLOSE_IMPROVE"})}})})]})}function Nl(t){return t.testType==="integration"?"integration":"unit"}function Ll(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function Sy(t){const r=new Date(t);return r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function ky(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const bC=new Set(["benchmark","comparison","baseline"]);function Hg(t,r,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(r-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function wy({entries:t}){const r=t.filter(v=>bC.has(v.type)).slice().reverse(),s=r.map((v,b,S)=>({rate:v.pass_rate,idx:b,total:S.length})).filter((v,b)=>{const S=r[b].type;return S==="benchmark"||S==="comparison"}),o=r.flatMap((v,b)=>v.type==="baseline"?[{rate:v.pass_rate,idx:b,total:r.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:b,total:r.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Hg(s,c,u,d):[],g=o.length>=2?Hg(o,c,u,d):[],m=h[h.length-1],y=g[g.length-1];return a.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&a.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&a.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&a.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),m&&a.jsx("circle",{cx:parseFloat(m.split(",")[0]),cy:parseFloat(m.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Cy(t,r,s){const o=isNaN(r)?0:r,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const m=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${m}`}}if(t==="FAIL"||t==="DEGRADING"){const m=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const m=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:m}}if(t==="MARGINAL"){const m=[...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:m}}if(t==="EMERGING"){const m=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:m}}const h=c.length>0?` Passing: ${c.map(m=>m.criterion).join(", ")}.`:"",g=d.length>0?` Needs improvement: ${d.map(m=>m.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const Ey={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function jC(t){return Object.hasOwn(Ey,t)}function SC(t){return jC(t)?Ey[t]:t}function kC(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=p.useState([]),[u,d]=p.useState([]),[h,g]=p.useState(!0),[m,y]=p.useState(null),[v,b]=p.useState(new Set),[S,k]=p.useState({}),[w,C]=p.useState(null),[N,R]=p.useState(""),[L,B]=p.useState(!1),[D,F]=p.useState(""),[E,H]=p.useState(""),z=p.useCallback(async()=>{g(!0),y(null);try{const[$,M]=await Promise.all([Ce.getCredentials(r,s),Ce.getParams(r,s)]);c($.credentials),d(M.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{g(!1)}},[r,s]);p.useEffect(()=>{z()},[z]);const I=p.useCallback(async($,M)=>{B(!0),y(null);try{await Ce.setCredential(r,s,$,M),C(null),R(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to save ${$}`)}finally{B(!1)}},[r,s,z]),U=p.useCallback(async()=>{const $=D.trim().toUpperCase(),M=E.trim();if(!(!$||!M)){B(!0),y(null);try{await Ce.setCredential(r,s,$,M),F(""),H(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to add ${$}`)}finally{B(!1)}}},[r,s,D,E,z]),q=p.useCallback(async $=>{if(v.has($)){b(M=>{const _=new Set(M);return _.delete($),_}),k(M=>{const _={...M};return delete _[$],_});return}try{const _=(await Ce.getParamsRevealed(r,s,$)).params.find(O=>O.name===$);_!=null&&_.value&&(k(O=>({...O,[$]:_.value})),b(O=>new Set(O).add($)))}catch{}},[r,s,v]),X=new Set(o.map($=>$.name)),J=[...o.map($=>{const M=u.find(_=>_.name===$.name);return{name:$.name,status:$.status,maskedValue:(M==null?void 0:M.maskedValue)??""}}),...u.filter($=>!X.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return a.jsxs("div",{className:"py-2 px-3",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),m&&a.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:m}),h&&J.length===0&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&J.length===0&&!m&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),J.map($=>a.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&a.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has($.name)?S[$.name]??$.maskedValue:$.maskedValue||"***",a.jsx("button",{onClick:()=>q($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:v.has($.name)?"hide":"show"})]}),w===$.name?a.jsxs("div",{className:"flex gap-1",children:[a.jsx("input",{value:N,onChange:M=>R(M.target.value),onKeyDown:M=>{M.key==="Enter"&&N.trim()&&I($.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),a.jsx("button",{onClick:()=>I($.name,N),disabled:L||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),a.jsx("button",{onClick:()=>{C(null),R("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):a.jsx("button",{onClick:()=>{C($.name),R("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),a.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:D,onChange:$=>F($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),a.jsx("input",{value:E,onChange:$=>H($.target.value),onKeyDown:$=>{$.key==="Enter"&&D.trim()&&E.trim()&&U()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),a.jsx("button",{onClick:U,disabled:L||!D.trim()||!E.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:L?"not-allowed":"pointer"},children:"Add"})]})]})]})}function wC(t,r,s){const[o,c]=p.useState(null),[u,d]=p.useState(!1),h=p.useRef("");p.useEffect(()=>{const m=`${t}/${r}/${s}`;h.current!==m&&(h.current=m,d(!0),Ce.getCaseHistory(t,r,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,r,s]);const g=p.useCallback(()=>{d(!0),h.current="",Ce.getCaseHistory(t,r,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,r,s]);return{entries:o,loading:u,refetch:g}}function CC(t,r,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(m=>m.id===t)).filter(Boolean);if(u.length>=2){const m=u.filter(y=>y.pass).length/u.length;m>=.3&&m<=.7&&(o.flaky=!0)}const d=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(d&&h){const g=d.assertions.find(y=>y.id===t),m=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(m!=null&&m.pass)&&(o.nonDiscriminating=!0)}if(r&&!r.pass&&s.length>=1){const m=s[0].assertions.find(y=>y.id===t);m!=null&&m.pass&&(o.regression=!0)}return o}function EC(){var O;const{state:t,dispatch:r,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:g}=An(),{evals:m,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:w,generateEvalsError:C}=t,N=p.useMemo(()=>{for(const V of S.values())if(V.status==="running"||V.status==="queued")return!0;return!1},[S]),[R,L]=p.useState(!1),[B,D]=p.useState("all"),F={skill_name:t.skill,evals:[]},E=m??F,H=E.evals,z=p.useMemo(()=>B==="all"?H:H.filter(V=>Nl(V)===B),[B,H]),I=z.find(V=>V.id===v)??null;p.useEffect(()=>{v!==null&&!z.find(V=>V.id===v)&&r({type:"SELECT_CASE",caseId:z.length>0?z[0].id:null})},[z,v,r]);const[U,q]=p.useState([]),X=p.useMemo(()=>H.some(V=>Nl(V)==="integration"),[H]);p.useEffect(()=>{X&&Ce.getCredentials(t.plugin,t.skill).then(V=>q(V.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const J=p.useMemo(()=>new Set(U.filter(V=>V.status==="missing").map(V=>V.name)),[U]),[$,M]=p.useState(!1),_=p.useCallback(V=>{M(!1),h(V?{testType:V}:void 0)},[h]);return!m||H.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M9 11l3 3L22 4"}),a.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),a.jsx("div",{className:"text-center",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),a.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),a.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>L(!0),disabled:g,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),a.jsxs("div",{style:{position:"relative"},children:[a.jsxs("div",{className:"flex",children:[a.jsx("button",{onClick:()=>_("unit"),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),a.jsx("button",{onClick:()=>M(!$),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$&&a.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:a.jsx("button",{onClick:()=>_("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.background="var(--surface-2)"},onMouseLeave:V=>{V.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&w.length>0&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(ni,{entries:w,isRunning:!0})}),C&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(Zo,{error:C,onRetry:()=>_()})}),R&&a.jsx(Ug,{evals:E,onSave:V=>{s(V),L(!1)},onCancel:()=>L(!1)})]}):a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[a.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",z.length,")"]}),a.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?a.jsx("button",{onClick:d,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>c("benchmark"),disabled:z.length===0||g,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),a.jsx("button",{onClick:()=>c("comparison"),disabled:z.length===0||g,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),a.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(V=>a.jsx("button",{onClick:()=>D(V),style:{padding:"2px 8px",fontSize:10,fontWeight:B===V?600:400,background:B===V?"var(--accent-muted)":"transparent",color:B===V?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:V==="all"?`All (${H.length})`:V==="unit"?`Unit (${H.filter(se=>Nl(se)==="unit").length})`:`Integration (${H.filter(se=>Nl(se)==="integration").length})`},V))}),a.jsxs("div",{className:"py-1",children:[z.length===0&&H.length>0&&a.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",B==="all"?"":B+" ","tests yet"]}),z.map(V=>{var W;const se=b.get(V.id),A=v===V.id,Y=Nl(V);return a.jsxs("button",{onClick:()=>r({type:"SELECT_CASE",caseId:V.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:A?"var(--accent-muted)":"transparent",borderLeft:A?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:te=>{A||(te.currentTarget.style.background="var(--surface-2)")},onMouseLeave:te=>{A||(te.currentTarget.style.background="transparent")},children:[a.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[a.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:A?"var(--text-primary)":"var(--text-secondary)"},children:["#",V.id," ",V.name,a.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:Y==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:Y==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:Y==="unit"?"U":"I"}),Y==="integration"&&((W=V.requiredCredentials)==null?void 0:W.some(te=>J.has(te)))&&a.jsx("span",{title:"Configure credentials to run",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),a.jsx(Ny,{result:se})]}),a.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[V.assertions.length," assertion",V.assertions.length!==1?"s":"",(se==null?void 0:se.passRate)!=null&&a.jsx(RC,{passRate:se.passRate})]})]},V.id)})]}),a.jsx("div",{className:"px-3 py-2",children:!g&&a.jsx("button",{onClick:()=>L(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--accent)",V.currentTarget.style.color="var(--accent)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-default)",V.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(kC,{})})]}),a.jsx("div",{className:"overflow-auto",children:I?a.jsx(NC,{evalCase:I,result:b.get(I.id),evals:m,caseStatus:((O=S.get(I.id))==null?void 0:O.status)??"idle",onSaveEvals:s,onRun:V=>o(V,"benchmark"),onCompare:V=>o(V,"comparison"),onCancel:V=>u(V),onImprove:V=>r({type:"OPEN_IMPROVE",evalId:V})}):a.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),R&&a.jsx(Ug,{evals:E,onSave:V=>{s(V),L(!1)},onCancel:()=>L(!1)})]})}function NC({evalCase:t,result:r,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:g}){const{state:m,isReadOnly:y}=An(),{plugin:v,skill:b}=m,{entries:S,loading:k}=wC(v,b,t.id),[w,C]=p.useState(!1),[N,R]=p.useState(t.prompt),[L,B]=p.useState(!1),[D,F]=p.useState(t.expected_output);p.useState(()=>{R(t.prompt),F(t.expected_output)});const E=p.useCallback(V=>{c({...s,evals:s.evals.map(se=>se.id===V.id?V:se)})},[s,c]),H=p.useCallback(()=>{E({...t,prompt:N}),C(!1)},[t,N,E]),z=p.useCallback(()=>{E({...t,expected_output:D}),B(!1)},[t,D,E]),I=p.useCallback(()=>{E({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,E]),U=p.useCallback((V,se)=>{E({...t,assertions:t.assertions.map(A=>A.id===V?{...A,text:se}:A)})},[t,E]),q=p.useCallback(V=>{E({...t,assertions:t.assertions.filter(se=>se.id!==V)})},[t,E]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(V=>V.id!==t.id)})},[s,t.id,c]),J=r&&r.assertions.length>0&&r.assertions.every(V=>V.pass),$=r&&r.assertions.some(V=>!V.pass),M=Nl(t),_=t.requiredCredentials??[],O=M==="integration"&&_.length>0;return a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[a.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[a.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?a.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)"},children:M==="unit"?"Unit":"Integration"}):a.jsx("button",{onClick:()=>{if((M==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:se,requirements:A,cleanup:Y,...W}=t;E({...W,testType:"unit"})}else E({...t,testType:"integration"})},title:`Click to switch to ${M==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:M==="unit"?"Unit":"Integration"}),a.jsx(Ny,{result:r})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?a.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),a.jsx("button",{onClick:()=>d(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),$&&!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.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"})]})})]})]}),y&&M==="integration"&&a.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),a.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),a.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),J&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),O&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:_.map(V=>a.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),!y&&M==="integration"&&a.jsx(LC,{evalCase:t,onUpdate:E}),a.jsx(jo,{title:"Prompt",children:w?a.jsxs("div",{children:[a.jsx("textarea",{value:N,onChange:V=>R(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:H,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{R(t.prompt),C(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||C(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||a.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),a.jsx(jo,{title:"Expected Output",children:L?a.jsxs("div",{children:[a.jsx("textarea",{value:D,onChange:V=>F(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:z,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{F(t.expected_output),B(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||B(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||a.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),a.jsx(jo,{title:`Assertions (${t.assertions.length})`,action:y?void 0:a.jsx("button",{onClick:I,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?a.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):a.jsx("div",{className:"space-y-2",children:t.assertions.map(V=>{const se=r==null?void 0:r.assertions.find(Y=>Y.assertion_id===V.id),A=CC(V.id,se,S);return a.jsx(TC,{assertion:V,result:se,badges:A,isReadOnly:y,onUpdate:Y=>U(V.id,Y),onDelete:()=>q(V.id)},V.id)})})}),(r==null?void 0:r.output)&&a.jsx(AC,{output:r.output,durationMs:r.durationMs,tokens:r.tokens}),r&&r.passRate!=null&&r.passRate<.2&&(()=>{const V=Cy("INEFFECTIVE",r.passRate);return V.recommendations&&V.recommendations.length>0?a.jsx(jo,{title:"Recommendations",children:a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),a.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((se,A)=>a.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),se]},A))})]})}):null})(),a.jsx(MC,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function TC({assertion:t,result:r,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[g,m]=p.useState(t.text),[y,v]=p.useState(!1),b=()=>{c(g),h(!1)};return a.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsxs("div",{className:"flex items-start gap-2",children:[r?a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&a.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&a.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&a.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),d?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:g,onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),a.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(m(t.text),h(!0))},children:t.text}),(r==null?void 0:r.reasoning)&&a.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(r==null?void 0:r.reasoning)&&a.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:r.reasoning})]}),!o&&a.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function jo({title:t,action:r,children:s}){return a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),r]}),s]})}function Ny({result:t}){const[r,s]=p.useState(!1);if(!t||t.status==null)return a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,d=Cy(o?"PASS":"FAIL",c);return a.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":r?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,r&&a.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:d.explanation})]})}function RC({passRate:t}){const r=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:a.jsx("div",{className:"h-full rounded-full",style:{width:`${r}%`,background:r>=80?"var(--green)":r>=50?"var(--yellow)":"var(--red)"}})})})}function AC({output:t,durationMs:r,tokens:s}){const[o,c]=p.useState(!1);return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",r!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",(r/1e3).toFixed(1),"s)"]}),s!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&a.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Md(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Ld({entry:t}){return a.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:Sy(t.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:t.type==="benchmark"?"var(--accent-muted)":t.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:t.type==="benchmark"?"var(--accent)":t.type==="comparison"?"var(--purple)":"var(--orange)"},children:t.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ll(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[t.durationMs!=null&&a.jsx("span",{children:ky(t.durationMs)}),t.tokens!=null&&a.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const r=t.pass_rate-t.baselinePassRate,s=r>.001?"skill":r<-.001?"baseline":"tie",o=r>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:r>=0?"var(--green)":"var(--red)"},children:[o,(r*100).toFixed(1),"%"]}),a.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),a.jsx("div",{className:"space-y-0.5",children:t.assertions.map(r=>a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:r.text})]},r.id))})]})}function MC({evalId:t,sharedEntries:r,sharedLoading:s}){const{state:o,dispatch:c}=An(),{plugin:u,skill:d}=o,[h,g]=p.useState(!0),m=r??null,y=s??!1,v=p.useCallback(()=>{g(w=>!w)},[]),b=m?m.slice(0,10):[],S=b.some(w=>{const C=Md(w.type);return C==="left"||C==="full"}),k=b.some(w=>{const C=Md(w.type);return C==="right"||C==="full"});return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",m&&m.length>0&&a.jsxs("span",{style:{fontWeight:400},children:["(",m.length," run",m.length!==1?"s":"",")"]})]}),h&&a.jsx("div",{className:"animate-fade-in",children:y?a.jsxs("div",{className:"flex items-center gap-2 py-3",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!m||m.length===0?a.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):a.jsxs("div",{children:[b.length>=2&&a.jsx("div",{className:"mb-2",children:a.jsx(wy,{entries:b})}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&a.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&a.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((w,C)=>{const N=Md(w.type);return N==="full"?a.jsx("div",{style:{gridColumn:"1 / -1"},children:a.jsx(Ld,{entry:w})},C):N==="left"?a.jsxs(p.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"},children:a.jsx(Ld,{entry:w})}),a.jsx("div",{style:{gridColumn:"2"}})]},C):a.jsxs(p.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"}}),a.jsx("div",{style:{gridColumn:"2"},children:a.jsx(Ld,{entry:w})})]},C)})]}),a.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:w=>{w.currentTarget.style.textDecoration="underline"},onMouseLeave:w=>{w.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function Ug({evals:t,onSave:r,onCancel:s}){const[o,c]=p.useState(""),[u,d]=p.useState(""),[h,g]=p.useState(""),[m,y]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=p.useState("unit"),[S,k]=p.useState(""),[w,C]=p.useState([]),[N,R]=p.useState(""),[L,B]=p.useState(""),D=Math.max(0,...t.evals.map(z=>z.id))+1,F=z=>{b(z),z==="unit"&&(C([]),k(""),R(""),B(""))},E=()=>{const z=S.trim().toUpperCase();z&&!w.includes(z)&&C([...w,z]),k("")},H=()=>{if(!o.trim()||!u.trim())return;const z={id:D,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter(I=>I.text.trim()),...v==="integration"?{testType:"integration",...w.length>0?{requiredCredentials:w}:{},...N||L?{requirements:{...N?{platform:N}:{},...L?{chromeProfile:L}:{}}}:{}}:{}};r({...t,evals:[...t.evals,z]})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-overlay-in",style:{background:"rgba(0,0,0,0.6)"},children:a.jsxs("div",{className:"w-full max-w-lg rounded-xl p-6 animate-modal-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",maxHeight:"85vh",overflowY:"auto"},children:[a.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),a.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(z=>a.jsx("button",{onClick:()=>F(z),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===z?z==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===z?z==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:z},z))})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),a.jsx("input",{value:o,onChange:z=>c(z.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),a.jsx("textarea",{value:u,onChange:z=>d(z.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),a.jsx("textarea",{value:h,onChange:z=>g(z.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),m.map((z,I)=>a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:z.text,onChange:U=>y(m.map((q,X)=>X===I?{...q,text:U.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&a.jsx("button",{onClick:()=>y(m.filter((U,q)=>q!==I)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z.id)),a.jsx("button",{onClick:()=>y([...m,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:w.map(z=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[z,a.jsx("button",{onClick:()=>C(w.filter(I=>I!==z)),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:S,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),E())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),a.jsx("button",{onClick:E,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:N,onChange:z=>R(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("label",{className:"block",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:L,onChange:z=>B(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsx("button",{onClick:H,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function LC({evalCase:t,onUpdate:r}){var d,h;const[s,o]=p.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&r({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const m=(t.requiredCredentials??[]).filter(y=>y!==g);r({...t,requiredCredentials:m.length>0?m:void 0})};return a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,a.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),a.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:g=>r({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>r({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Rn(t,r){return r==="free"?"Free":r==="subscription"&&t==null?"Included":t==null?"N/A":t>=1?`$${t.toFixed(2)}`:t===0?"$0.00":t>=.001?`$${t.toFixed(4)}`:`$${t.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function Ty(t,r){return t==null||r==null?"N/A":`${t.toLocaleString("en-US")} in / ${r.toLocaleString("en-US")} out`}function zC(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function DC(t,r){let s="";if(r){const c=new Date(r);isNaN(c.getTime())||(s=c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}))}return[t,s].filter(Boolean).join(" · ")}function _C(t,r,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*r);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function $g(t,r){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(r)}}function OC(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function BC(t,r){const s=t+r,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const IC={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function HC(t,r){if(!t)return null;const s=IC[t];if(s==null||s===0)return null;const o=s*r*.5,c=s*r*2;return`${Rn(o)}–${Rn(c)}`}function UC(){const{state:t,runCase:r,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=An(),{evals:d,caseRunStates:h,bulkRunActive:g,latestBenchmark:m,inlineResults:y}=t,{config:v}=Ur(),b=(d==null?void 0:d.evals)??[],S=p.useMemo(()=>{for(const E of h.values())if(E.status==="running"||E.status==="queued")return!0;return!1},[h]),k=b.filter(E=>{const H=h.get(E.id);return H&&(H.status==="complete"||H.status==="error"||H.status==="cancelled")}).length,w=b.filter(E=>{const H=h.get(E.id);return H&&(H.status==="running"||H.status==="queued")}).length,C=p.useRef(null),[N,R]=p.useState(0);p.useEffect(()=>{if(S&&!C.current&&(C.current=Date.now()),!S){C.current=null,R(0);return}const E=setInterval(()=>{C.current&&R(Math.round((Date.now()-C.current)/1e3))},1e3);return()=>clearInterval(E)},[S]);const L=b.reduce((E,H)=>E+H.assertions.length,0),B=b.length+L,D=p.useMemo(()=>BC(b.length,L),[b.length,L]),F=p.useMemo(()=>HC((v==null?void 0:v.provider)??null,B),[v==null?void 0:v.provider,B]);return a.jsxs("div",{className:"p-5",children:[u&&a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),a.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&a.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[w," running"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),a.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),a.jsx("button",{onClick:()=>s("benchmark"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),a.jsx("button",{onClick:()=>s("baseline"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&b.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("span",{children:["Est. duration: ",D]}),F&&a.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&a.jsx("span",{children:"Cost: Included"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&a.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),a.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),a.jsx("div",{className:"space-y-3 stagger-children",children:b.map(E=>{const H=y.get(E.id),z=h.get(E.id),I=(z==null?void 0:z.status)??"idle",U=m==null?void 0:m.cases.find(q=>q.eval_id===E.id);return a.jsx(VC,{name:E.name,evalId:E.id,result:H,caseCost:U==null?void 0:U.cost,caseBillingMode:U==null?void 0:U.billingMode,caseInputTokens:U==null?void 0:U.inputTokens,caseOutputTokens:U==null?void 0:U.outputTokens,caseStatus:I,runMode:(z==null?void 0:z.mode)??null,comparisonDetail:U==null?void 0:U.comparisonDetail,isReadOnly:u,onRun:q=>r(q,"benchmark"),onBaseline:q=>r(q,"baseline"),onCompare:q=>r(q,"comparison"),onCancel:q=>o(q)},E.id)})}),!S&&m&&m.cases.length>0&&a.jsxs("div",{className:"mt-5",children:[a.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:zC(m.type)}),a.jsx("span",{className:"text-[20px] font-bold",style:{color:(m.overall_pass_rate??0)>=.8?"var(--green)":(m.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:m.overall_pass_rate!=null?`${Math.round(m.overall_pass_rate*100)}%`:"--"})]}),m.totalDurationMs!=null&&a.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(m.totalDurationMs/1e3).toFixed(1),"s",m.model&&` | Model: ${m.model}`,m.totalInputTokens!=null&&m.totalOutputTokens!=null&&` | Tokens: ${Ty(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${Rn(m.totalCost)}`]}),m.overall_pass_rate>=.9999&&!m.comparison&&a.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||u,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:b.length===0?.5:1},children:"Run Final A/B Comparison"})]}),m.comparison&&a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const E=DC(m.model,m.timestamp);return E?a.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:E}):a.jsx("div",{className:"mb-3"})})(),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Vg,{label:"Skill",value:m.comparison.skillPassRate,color:"var(--accent)"}),a.jsx(Vg,{label:"Baseline",value:m.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),a.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:m.comparison.delta>0?"var(--green)":m.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",m.comparison.delta>0?"+":"",(m.comparison.delta*100).toFixed(1),"%",m.verdict&&` | ${SC(m.verdict)}`]}),(()=>{const E=m.cases.reduce((z,I)=>z+I.assertions.length,0),H=_C(m.comparison.delta,E,m.cases.length);return a.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:H})})()]})]})]})}const $C={benchmark:{label:"Skill",bg:"var(--accent-muted)",color:"var(--accent)"},baseline:{label:"Baseline",bg:"var(--surface-3)",color:"var(--text-tertiary)"},comparison:{label:"Compare",bg:"var(--purple-muted)",color:"var(--purple)"}};function VC({name:t,evalId:r,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:g,comparisonDetail:m,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:k}){const[w,C]=p.useState(!1),N=h==="running"||h==="queued",R=h==="complete"||h==="error";return a.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&a.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&a.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),a.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",r," ",t]}),g&&(N||R)&&(()=>{const L=$C[g];return L?a.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:L.bg,color:L.color,padding:"1px 6px"},children:L.label}):null})()]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N?a.jsx("button",{onClick:()=>k(r),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>S(r),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),a.jsx("button",{onClick:()=>v(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),a.jsx("button",{onClick:()=>b(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&a.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&d!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Ty(u,d)}),o!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Rn(o,c)}),h==="cancelled"&&a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"space-y-1",children:s.assertions.map(L=>a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsx("span",{style:{color:L.pass?"var(--green)":"var(--red)"},children:L.pass?"PASS":"FAIL"}),a.jsx("span",{style:{color:"var(--text-secondary)"},children:L.text})]},L.assertion_id))}),s.output&&a.jsx("button",{onClick:()=>C(!w),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:w?"Hide output":"Show output"}),w&&s.output&&a.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),m&&a.jsx("div",{className:"px-4 pb-3",children:a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const L=$g(m.skillContentScore,m.baselineContentScore),B=$g(m.skillStructureScore,m.baselineStructureScore),D=OC(m.winner);return a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",L.skill,"% / Baseline ",L.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsx("span",{style:{color:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&a.jsx(PC,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const zd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function PC({errorMessage:t,classifiedError:r}){const[s,o]=p.useState(!1),c=(r==null?void 0:r.title)??"Error",u=r==null?void 0:r.hint,d=r?zd[r.category]??zd.unknown:zd.unknown;return a.jsx("div",{className:"px-4 pb-3",children:a.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[a.jsx("span",{style:{fontSize:12},children:d}),a.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),a.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&a.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&a.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Vg({label:t,value:r,color:s}){return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(r*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r*100}%`,background:s}})})]})}const Pg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function FC(){var _;const{state:t,dispatch:r,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=An(),{plugin:u,skill:d,activationPrompts:h,activationResults:g,activationSummary:m,activationRunning:y,activationError:v,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:w,activationHistory:C}=t,{state:N}=ea(),R=((_=N.skills.find(O=>O.plugin===u&&O.skill===d))==null?void 0:_.version)??null,[L,B]=p.useState(h),[D,F]=p.useState(null),[E,H]=p.useState(!1);p.useEffect(()=>{h&&h!==L&&B(h)},[h]),p.useEffect(()=>{r({type:"SET_ACTIVATION_PROMPTS",prompts:L})},[L,r]),p.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(O=>O.json()).then(O=>F(O.rawContent||O.description||null)).catch(()=>F(null))},[u,d]);function z(){s(L)}function I(){c(8)}const U=L.trim().split(`
81
- `).filter(Boolean).length,q=g.filter(O=>O.classification==="TP"||O.classification==="TN"),X=g.filter(O=>O.classification==="FP"||O.classification==="FN"),J=(D==null?void 0:D.replace(/^---[\s\S]*?---\s*/,"").trim())??null,$=L.trim().length>0,M=J?Xo(J):"";return a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),a.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),a.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[a.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),a.jsx("div",{className:"flex gap-1.5",children:a.jsx("button",{onClick:I,disabled:k||!J||y,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:J?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:J?1:.5,cursor:J?"pointer":"not-allowed"},title:J?void 0:"No skill description available",onMouseEnter:O=>{J&&!k&&(O.currentTarget.style.background="var(--surface-3)")},onMouseLeave:O=>{k||(O.currentTarget.style.background="var(--surface-2)")},children:k?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),$?"Regenerate":"Generate"," Test Prompts"]})})})]}),!J&&!y&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),w&&a.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:w}),a.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:L,onChange:O=>B(O.target.value),placeholder:`How do I write a unit test?
77
+ `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?d[y][v]=d[y-1][v-1]+1:d[y][v]=Math.max(d[y-1][v],d[y][v-1]);const h=[];let g=c,p=u;for(;g>0||p>0;)g>0&&p>0&&s[g-1]===o[p-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,p--):p>0&&(g===0||d[g][p-1]>=d[g-1][p])?(h.push({type:"added",content:o[p-1]}),p--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function Jw(t,r){if(r&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return a.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return a.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ni({entries:t,isRunning:r}){const[s,o]=m.useState(!1),c=m.useRef(null);return m.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!r?null:a.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[a.jsxs("span",{className:"flex items-center gap-2",children:[r&&a.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&a.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,d)=>{const h=d===t.length-1&&r,g=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return a.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[Jw(u.phase,h),a.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),a.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&a.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const zg={rate_limit:{icon:"⏱",color:"var(--amber, #f59e0b)"},context_window:{icon:"⚠",color:"var(--amber, #f59e0b)"},auth:{icon:"🔒",color:"var(--red, #ef4444)"},timeout:{icon:"⌛",color:"var(--amber, #f59e0b)"},model_not_found:{icon:"🔍",color:"var(--red, #ef4444)"},provider_unavailable:{icon:"⚡",color:"var(--red, #ef4444)"},parse_error:{icon:"❓",color:"var(--amber, #f59e0b)"},unknown:{icon:"❌",color:"var(--red, #ef4444)"}};function Zo({error:t,onRetry:r,onDismiss:s}){const[o,c]=m.useState(null),u=m.useRef(null);m.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),m.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=zg[t.category]||zg.unknown,h=o!=null&&o>0;return a.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${d.color} 30%, transparent)`,background:`color-mix(in srgb, ${d.color} 6%, var(--surface-1))`},children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{fontSize:14},children:d.icon}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&a.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-3.5 pb-3",children:[a.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),a.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(r||o!=null)&&a.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:r&&a.jsx("button",{onClick:r,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function eC({plugin:t,skill:r,skillContent:s,onApplied:o}){const[c,u]=m.useState("closed"),{config:d}=Hr(),[h,g]=m.useState("claude-cli"),[p,y]=m.useState("opus"),[v,b]=m.useState([]),[S,k]=m.useState(""),[E,C]=m.useState(""),[N,T]=m.useState(null),[A,B]=m.useState(null),[D,F]=m.useState([]),[w,O]=m.useState(!1),z=m.useRef(null);m.useEffect(()=>{if(!d)return;d.providers.find(_=>_.id==="claude-cli"&&_.available)&&(g("claude-cli"),y("opus"))},[d]),m.useEffect(()=>()=>{var L;(L=z.current)==null||L.abort()},[]);function U(){return d==null?void 0:d.providers.find(L=>L.id===h&&L.available)}const H=m.useCallback(()=>{var L;(L=z.current)==null||L.abort(),u("open")},[]);async function q(){u("loading"),T(null),B(null),F([]);const L=new AbortController;z.current=L;try{const _=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(r)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:p}),signal:L.signal});if(!_.ok||!_.body){let Y=`HTTP ${_.status}`;try{const W=await _.json();W.error&&(Y=W.error)}catch{}throw new Error(Y)}const I=_.body.getReader(),V=new TextDecoder;let se="",M="";for(;;){const{done:Y,value:W}=await I.read();if(Y)break;se+=V.decode(W,{stream:!0});const te=se.split(`
78
+ `);se=te.pop()||"";for(const fe of te)if(fe.startsWith("event: "))M=fe.slice(7).trim();else if(fe.startsWith("data: ")){try{const ie=JSON.parse(fe.slice(6));M==="progress"?F(ye=>[...ye,{phase:ie.phase,message:ie.message,timestamp:Date.now()}]):M==="done"||M==="complete"?(k(ie.improved),C(ie.reasoning||""),b(Qo(ie.original||s,ie.improved)),u("diff_shown")):M==="error"&&(T(ie.message||ie.description||"Unknown error"),ie.category&&B(ie),u("open"))}catch{}M=""}}}catch(_){_.name!=="AbortError"&&(T(_.message),u("open"))}finally{z.current=null}}async function X(){O(!0);try{await Ce.applyImprovement(t,r,S),o(S),u("closed")}catch(L){T(L.message)}finally{O(!1)}}function J(){u("closed"),b([]),k(""),C(""),T(null)}if(c==="closed")return a.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=U();return a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),a.jsx("button",{onClick:J,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:L=>{L.currentTarget.style.background="var(--surface-3)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:L=>{g(L.target.value);const _=d==null?void 0:d.providers.find(I=>I.id===L.target.value);_!=null&&_.models[0]&&y(_.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(L=>L.available).map(L=>a.jsx("option",{value:L.id,children:L.label},L.id))})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:p,onChange:L=>y(L.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(L=>a.jsx("option",{value:L.id,children:L.label},L.id))})]}),c==="loading"?a.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):a.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&a.jsx("div",{className:"mt-3",children:a.jsx(ni,{entries:D,isRunning:!0})})]}),N&&a.jsx("div",{className:"mb-4",children:A?a.jsx(Zo,{error:A,onRetry:q,onDismiss:()=>{T(null),B(null)}}):a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&a.jsxs(a.Fragment,{children:[E&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),E]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((L,_)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:L.type==="added"?"rgba(34,197,94,0.1)":L.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:L.type==="added"?"var(--green)":L.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:L.type==="added"?"3px solid var(--green)":L.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:L.type==="added"?"+":L.type==="removed"?"-":" "}),L.content]},_))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:X,disabled:w,className:"btn btn-primary",children:w?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),a.jsx("button",{onClick:J,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const Dg={remove:{bg:"var(--red-muted)",color:"var(--red)",label:"REMOVE"},modify:{bg:"rgba(251,191,36,0.15)",color:"#fbbf24",label:"MODIFY"},add:{bg:"var(--green-muted)",color:"var(--green)",label:"ADD"}},tC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function nC({change:t,index:r,selected:s,onToggle:o,originalEval:c}){var v;const[u,d]=m.useState(!1),h=Dg[t.action]??Dg.add,g=tC[t.action]??"var(--border-subtle)",p=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=m.useCallback(()=>o(r),[o,r]);return a.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),a.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),a.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:p}),a.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),a.jsx("button",{onClick:()=>d(!u),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-3)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:u?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&a.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&a.jsx(aC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&a.jsx(rC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&a.jsx(lC,{evalCase:c})]})]})}function aC({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[a.jsx(lf,{label:"Prompt",value:t.prompt}),a.jsx(lf,{label:"Expected",value:t.expected_output}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>a.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function rC({original:t,proposed:r}){const s=[];t.name!==r.name&&s.push({label:"Name",old:t.name,new:r.name}),t.prompt!==r.prompt&&s.push({label:"Prompt",old:t.prompt,new:r.prompt}),t.expected_output!==r.expected_output&&s.push({label:"Expected",old:t.expected_output,new:r.expected_output});const o=t.assertions??[],c=r.assertions??[],u=new Set(o.map(p=>p.text)),d=new Set(c.map(p=>p.text)),h=c.filter(p=>!u.has(p.text)),g=o.filter(p=>!d.has(p.text));return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(p=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:p.label}),a.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[a.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",sf(p.old,120)]}),a.jsxs("div",{style:{color:"var(--green)"},children:["+ ",sf(p.new,120)]})]})]},p.label)),(h.length>0||g.length>0)&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),a.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(p=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",p.text]},p.id)),h.map(p=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",p.text]},p.id))]})]}),s.length===0&&h.length===0&&g.length===0&&a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function lC({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[a.jsx(lf,{label:"Prompt",value:t.prompt}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>a.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function lf({label:t,value:r}){return a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a.jsx("div",{className:"mt-0.5 text-[11px] p-2 rounded font-mono",style:{background:"var(--surface-1)",color:"var(--text-secondary)",whiteSpace:"pre-wrap"},children:sf(r,300)})]})}function sf(t,r){return t.length>r?t.slice(0,r)+"...":t}const _g={remove:0,modify:1,add:2};function sC({changes:t,selections:r,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((g,p)=>({change:g,originalIndex:p}));d.sort((g,p)=>(_g[g.change.action]??2)-(_g[p.change.action]??2));const h=Array.from(r.values()).filter(Boolean).length;return a.jsxs("div",{className:"mt-3 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),a.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),a.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:g,originalIndex:p})=>a.jsx(nC,{change:g,index:p,selected:r.get(p)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},p))})]})}function iC(){var L;const{state:t,dispatch:r,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:p}=An(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:E,aiEditEvalSelections:C,aiEditEvalsRetry:N}=t,[T,A]=m.useState(""),{config:B}=Hr(),[D,F]=m.useState("claude-cli"),[w,O]=m.useState("opus"),z=m.useRef(null);m.useEffect(()=>{var _;(_=z.current)==null||_.focus()},[]),m.useEffect(()=>{if(!B)return;B.providers.find(I=>I.id==="claude-cli"&&I.available)&&(F("claude-cli"),O("opus"))},[B]);const U=B==null?void 0:B.providers.find(_=>_.id===D&&_.available),H=m.useCallback(()=>{const _=T.trim();!_||y||s(_,D,w)},[T,y,s,D,w]),q=m.useCallback(_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),H()),_.key==="Escape"&&(_.preventDefault(),y?u():c())},[H,y,u,c]),X=m.useCallback(()=>{r({type:"CLOSE_AI_EDIT"}),r({type:"OPEN_AI_EDIT"})},[r]),J=v?Qo(t.skillContent,v.improved):[],$=((L=t.evals)==null?void 0:L.evals)??[];return a.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),a.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--surface-3)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-4 py-3",children:[!v&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{ref:z,value:T,onChange:_=>A(_.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),a.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:D,onChange:_=>{F(_.target.value);const I=B==null?void 0:B.providers.find(V=>V.id===_.target.value);I!=null&&I.models[0]&&O(I.models[0].id)},disabled:y,style:{width:"100%"},children:B==null?void 0:B.providers.filter(_=>_.available).map(_=>a.jsx("option",{value:_.id,children:_.label},_.id))})]}),a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:w,onChange:_=>O(_.target.value),disabled:y,style:{width:"100%"},children:U==null?void 0:U.models.map(_=>a.jsx("option",{value:_.id,children:_.label},_.id))})]}),a.jsx("div",{className:"flex-1"}),y?a.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):a.jsx("button",{onClick:H,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&a.jsx("div",{className:"mt-2.5",children:a.jsx(ni,{entries:k,isRunning:!0})})]}),b&&a.jsx("div",{className:"mt-3",children:S?a.jsx(Zo,{error:S,onRetry:X,onDismiss:c}):a.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),v&&a.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&a.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),a.jsx("div",{className:"mb-1",children:a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:J.map((_,I)=>a.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:_.type==="added"?"rgba(34,197,94,0.1)":_.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:_.type==="added"?"var(--green)":_.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:_.type==="added"?"3px solid var(--green)":_.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:_.type==="added"?"+":_.type==="removed"?"-":" "}),_.content]},I))}),a.jsx(sC,{changes:E,selections:C,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:g}),N&&a.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[a.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),a.jsx("button",{onClick:p,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),a.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function oC(t,r){const[s,o]=m.useState([]),[c,u]=m.useState("SKILL.md"),[d,h]=m.useState(null),[g,p]=m.useState(!1),[y,v]=m.useState(null),b=m.useCallback(async()=>{try{const E=await Ce.getSkillFiles(t,r);o(E.files)}catch{o([])}},[t,r]);m.useEffect(()=>{u("SKILL.md"),h(null),v(null),b()},[t,r,b]);const S=m.useCallback(async E=>{if(u(E),E==="SKILL.md"){h(null),v(null);return}p(!0),v(null);try{const C=await Ce.getSkillFile(t,r,E);h(C)}catch(C){v(`Unable to open file: ${C.message}`),h(null)}finally{p(!1)}},[t,r]),k=m.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function cC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function uC(t){const r=[],s=new Map;for(const o of t){const c=o.path.split("/"),d={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,d)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&r.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(o.path);d&&h&&d.children.push(h)}}return r}function by({expanded:t}){return a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function jy(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.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"})})}function dC(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function fC(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"23 4 23 10 17 10"}),a.jsx("polyline",{points:"1 20 1 14 7 14"}),a.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function Sy({node:t,depth:r,activeFile:s,onSelect:o}){const[c,u]=m.useState(!0),d=t.path===s;return t.type==="dir"?a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[a.jsx(by,{expanded:c}),a.jsx(jy,{}),a.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>a.jsx(Sy,{node:h,depth:r+1,activeFile:s,onSelect:o},h.path))]}):a.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:d?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:d?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[a.jsx("span",{style:{width:10}}),a.jsx(dC,{}),a.jsx("span",{style:{flex:1},children:t.name}),a.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:cC(t.size)})]})}function pC({files:t,activeFile:r,onSelect:s,onRefresh:o}){const[c,u]=m.useState(!1),d=m.useMemo(()=>uC(t),[t]);return a.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[a.jsx(by,{expanded:c}),a.jsx(jy,{}),a.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),a.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:a.jsx(fC,{})})]}),c&&a.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>a.jsx(Sy,{node:h,depth:0,activeFile:r,onSelect:s},h.path))})]})}function bo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function mC(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function hC(t){const r=t.toLowerCase();return r.endsWith(".json")?"json":r.endsWith(".md")?"md":"other"}function Og({content:t}){return a.jsx("textarea",{readOnly:!0,value:t,style:{flex:1,width:"100%",resize:"none",background:"var(--surface-1)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}})}function Bg({content:t,fileType:r}){if(r==="json"){const s=mC(t);return a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s})}return r==="md"?a.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 20px",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:13,lineHeight:1.6},dangerouslySetInnerHTML:{__html:Xo(t)}}):a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function Ig(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function xC({file:t,loading:r,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[g,p]=m.useState(o),[y,v]=m.useState(!1),[b,S]=m.useState(""),[k,E]=m.useState(!1),[C,N]=m.useState(null),T=o!==g?o:g;m.useEffect(()=>{h==null||h(y)},[y,h]);const A=m.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),B=m.useCallback(()=>{v(!1)},[]),D=m.useCallback(async()=>{if(!(!c||!u||!t)){E(!0);try{await Ce.saveSkillFile(c,u,t.path,b),N("Saved"),v(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{E(!1)}}},[c,u,t,b,d]);if(m.useEffect(()=>{if(!y)return;const O=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),D())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[y,D]),r)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:a.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[a.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),a.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return a.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",bo(t.size),") — cannot be displayed"]});const F=t.content??"",w=hC(t.path);return a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&a.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",bo(512*1024)," — ",bo(t.size)," total"]}),a.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(w==="md"||w==="json")&&["raw","split","preview"].map(O=>a.jsx("button",{onClick:()=>p(O),style:{padding:"2px 8px",fontSize:11,background:T===O?"var(--accent-muted)":"none",color:T===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),a.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[bo(t.size),c&&u&&!t.binary&&!y&&a.jsx("button",{onClick:A,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:D,disabled:k,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),a.jsx("button",{onClick:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&a.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[a.jsx("textarea",{value:b,onChange:O=>S(O.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),a.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),a.jsx("button",{onClick:D,disabled:k,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),a.jsx("button",{onClick:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&w!=="other"?a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:a.jsx(Og,{content:F})}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ig(F)}}):a.jsx(Bg,{content:F,fileType:w})})]}):T==="preview"&&w!=="other"?w==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ig(F)}}):a.jsx(Bg,{content:F,fileType:w}):a.jsx(Og,{content:F})})]})}function gC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function vC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),a.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function yC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function bC({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}function Ad({size:t=15}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function jC(){const{state:t,dispatch:r,saveContent:s,isReadOnly:o}=An(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:g,aiEditOpen:p}=t,[y,v]=m.useState("split"),[b,S]=m.useState(!1),k=m.useRef(null),[E,C]=m.useState(!1),[N,T]=m.useState(""),[A,B]=m.useState(!1),[D,F]=m.useState(null),[w,O]=m.useState([]),[z,U]=m.useState([]),[H,q]=m.useState(null),X=m.useRef(null),{config:J}=Hr(),{files:$,activeFile:L,secondaryContent:_,loading:I,error:V,selectFile:se,refresh:M,isSkillMd:Y}=oC(c??"",u??""),[W,te]=m.useState(!1),fe=m.useCallback(be=>{W&&!window.confirm("You have unsaved changes. Discard?")||se(be)},[W,se]);m.useEffect(()=>()=>{var be;(be=X.current)==null||be.abort()},[]);const{metadata:ie,body:ye}=Qw(d),de=ie["allowed-tools"],Se=Array.isArray(de)?de:typeof de=="string"?[de]:[],Ae=ie.name,_e=ie.description,re=ie.metadata,he=typeof re=="object"&&!Array.isArray(re)?re:null,pe=ie.version||(he==null?void 0:he.version),ge=ie.tags||(he==null?void 0:he.tags),je=Array.isArray(ge)?ge:typeof ge=="string"?ge.split(",").map(be=>be.trim()).filter(Boolean):[],Be=new Set(["name","description","metadata","allowed-tools","version","tags"]),Oe=Object.entries(ie).filter(([be])=>!Be.has(be)),rt=m.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),Nt=m.useCallback(be=>{(be.ctrlKey||be.metaKey)&&be.key==="s"&&(be.preventDefault(),be.stopPropagation(),h&&rt()),(be.ctrlKey||be.metaKey)&&be.key==="k"&&(be.preventDefault(),be.stopPropagation(),r({type:p?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,rt,p,r]),ht=m.useCallback(async()=>{var pt,Ct;if(!N.trim())return;(pt=X.current)==null||pt.abort();const be=new AbortController;X.current=be,B(!0),q(null),U([]),F(null),O([]);try{const Yt=(J==null?void 0:J.provider)||"claude-cli",un=(J==null?void 0:J.model)||"sonnet",Gt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Yt,model:un}),signal:be.signal});if(!Gt.ok||!Gt.body){let gt=`HTTP ${Gt.status}`;try{const da=await Gt.json();da.error&&(gt=da.error)}catch{}throw new Error(gt)}const an=Gt.body.getReader(),Mn=new TextDecoder;let Mt="",xt="";for(;;){const{done:gt,value:da}=await an.read();if(gt)break;Mt+=Mn.decode(da,{stream:!0});const za=Mt.split(`
79
+ `);Mt=za.pop()||"";for(const Wn of za)if(Wn.startsWith("event: "))xt=Wn.slice(7).trim();else if(Wn.startsWith("data: ")){try{const Et=JSON.parse(Wn.slice(6));if(xt==="progress")U(oe=>[...oe,{phase:Et.phase,message:Et.message,timestamp:Date.now()}]);else if(xt==="done"||xt==="complete"){const oe=["---"];Et.name&&oe.push(`name: ${Et.name}`),Et.description&&oe.push(`description: "${Et.description.replace(/"/g,'\\"')}"`),Et.model&&oe.push(`model: ${Et.model}`),(Ct=Et.allowedTools)!=null&&Ct.trim()&&oe.push(`allowed-tools: ${Et.allowedTools.trim()}`),oe.push("---","",Et.body||"");const xe=oe.join(`
80
+ `);F(xe),O(Qo(d,xe)),B(!1)}else xt==="error"&&(q(Et.message||Et.description||"Generation failed"),B(!1))}catch{}xt=""}}}catch(Yt){Yt.name!=="AbortError"&&q(Yt.message)}finally{B(!1),X.current=null}},[N,J,d]),Dt=m.useCallback(()=>{D&&r({type:"SET_CONTENT",content:D}),C(!1),F(null),O([]),T(""),U([])},[D,r]),Tt=m.useCallback(()=>{C(!1),F(null),O([]),T(""),U([]),q(null)},[]),Qe=m.useCallback(()=>{var be;E?((be=X.current)==null||be.abort(),Tt()):(p&&r({type:"CLOSE_AI_EDIT"}),C(!0))},[E,p,r,Tt]),tt=[{mode:"raw",icon:a.jsx(gC,{}),label:"Editor"},{mode:"split",icon:a.jsx(vC,{}),label:"Split"},{mode:"preview",icon:a.jsx(yC,{}),label:"Preview"}];return a.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Nt,tabIndex:-1,children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:tt.map(({mode:be,icon:pt,label:Ct})=>a.jsxs("button",{onClick:()=>v(be),title:Ct,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===be?"var(--surface-4)":"transparent",color:y===be?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===be?600:400,border:"none",cursor:"pointer"},children:[pt,a.jsx("span",{style:{letterSpacing:"0.01em"},children:Ct})]},be))}),Y?o?a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>{p?r({type:"CLOSE_AI_EDIT"}):(E&&Tt(),r({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:p?600:400,border:"none",cursor:"pointer",color:p?"var(--purple)":"var(--text-tertiary)",background:p?"var(--purple-muted)":"transparent"},children:[a.jsx(bC,{size:13}),a.jsx("span",{children:"AI Edit"})]}),a.jsxs("button",{onClick:Qe,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:E?600:400,border:"none",cursor:"pointer",color:E?"var(--purple)":"var(--text-tertiary)",background:E?"var(--purple-muted)":"transparent"},children:[a.jsx(Ad,{size:13}),a.jsx("span",{children:"Regenerate"})]}),a.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&a.jsx("button",{onClick:()=>r({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),a.jsx("button",{onClick:rt,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&a.jsx(pC,{files:$,activeFile:L,onSelect:fe,onRefresh:M}),!Y&&a.jsx(xC,{file:_,loading:I,error:V,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{se(L),M()},onDirtyChange:te}),Y&&a.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&a.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:a.jsx("textarea",{ref:k,value:d,onChange:be=>{o||r({type:"SET_CONTENT",content:be.target.value})},onKeyDown:Nt,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&a.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:a.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Ae||pe||_e)&&a.jsxs("div",{style:{marginBottom:20},children:[a.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Ae&&a.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Ae}),pe&&a.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",pe]})]}),_e&&a.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:_e})]}),je.length>0&&a.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:je.map(be=>a.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:be},be))}),Se.length>0&&a.jsx("div",{style:{marginBottom:16},children:a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),Se.map(be=>a.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:be},be))]})}),Oe.length>0&&a.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Oe.map(([be,pt],Ct)=>{const Yt=Array.isArray(pt)?pt.join(", "):typeof pt=="object"?Object.entries(pt).map(([un,Gt])=>`${un}: ${Array.isArray(Gt)?Gt.join(", "):Gt}`).join(" | "):pt;return a.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Ct>0?"1px solid var(--border-subtle)":"none"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:be}),a.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Yt})]},be)})}),(Ae||_e||je.length>0||Se.length>0||Oe.length>0)&&ye&&a.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ye&&a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Xo(ye)}})]})})]}),Y&&p&&a.jsx(iC,{}),Y&&E&&a.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:a.jsxs("div",{className:"px-4 py-3",children:[!D&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ad,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),a.jsx("div",{className:"flex gap-2 mb-2",children:a.jsx("textarea",{value:N,onChange:be=>T(be.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:A,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:A?.5:1},onKeyDown:be=>{be.key==="Enter"&&(be.ctrlKey||be.metaKey)&&N.trim()&&!A&&(be.preventDefault(),ht())}})}),a.jsxs("div",{className:"flex items-center gap-2",children:[A?a.jsx("button",{onClick:()=>{var be;(be=X.current)==null||be.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):a.jsx("button",{onClick:ht,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),a.jsx("button",{onClick:Tt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),A&&z.length>0&&a.jsx("div",{className:"mt-2",children:a.jsx(ni,{entries:z,isRunning:!0})}),H&&a.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,a.jsx("button",{onClick:ht,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),D&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ad,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:w.map((be,pt)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:be.type==="added"?"var(--green-muted)":be.type==="removed"?"var(--red-muted)":"transparent",color:be.type==="added"?"var(--green)":be.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:be.type==="added"?"3px solid var(--green)":be.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:be.type==="added"?"+":be.type==="removed"?"-":" "}),be.content]},pt))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:Dt,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:Tt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&g!==null&&c&&u&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(eC,{plugin:c,skill:u,skillContent:d,onApplied:be=>{r({type:"SET_CONTENT",content:be}),r({type:"CONTENT_SAVED"}),r({type:"CLOSE_IMPROVE"})}})})]})}function Nl(t){return t.testType==="integration"?"integration":"unit"}function Ll(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function ky(t){const r=new Date(t);return r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function wy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const SC=new Set(["benchmark","comparison","baseline"]);function Ug(t,r,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(r-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function Cy({entries:t}){const r=t.filter(v=>SC.has(v.type)).slice().reverse(),s=r.map((v,b,S)=>({rate:v.pass_rate,idx:b,total:S.length})).filter((v,b)=>{const S=r[b].type;return S==="benchmark"||S==="comparison"}),o=r.flatMap((v,b)=>v.type==="baseline"?[{rate:v.pass_rate,idx:b,total:r.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:b,total:r.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Ug(s,c,u,d):[],g=o.length>=2?Ug(o,c,u,d):[],p=h[h.length-1],y=g[g.length-1];return a.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&a.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&a.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&a.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),p&&a.jsx("circle",{cx:parseFloat(p.split(",")[0]),cy:parseFloat(p.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Ey(t,r,s){const o=isNaN(r)?0:r,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const p=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${p}`}}if(t==="FAIL"||t==="DEGRADING"){const p=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${p}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const p=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:p}}if(t==="MARGINAL"){const p=[...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:p}}if(t==="EMERGING"){const p=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:p}}const h=c.length>0?` Passing: ${c.map(p=>p.criterion).join(", ")}.`:"",g=d.length>0?` Needs improvement: ${d.map(p=>p.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const Ny={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function kC(t){return Object.hasOwn(Ny,t)}function wC(t){return kC(t)?Ny[t]:t}function CC(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=m.useState([]),[u,d]=m.useState([]),[h,g]=m.useState(!0),[p,y]=m.useState(null),[v,b]=m.useState(new Set),[S,k]=m.useState({}),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState(!1),[D,F]=m.useState(""),[w,O]=m.useState(""),z=m.useCallback(async()=>{g(!0),y(null);try{const[$,L]=await Promise.all([Ce.getCredentials(r,s),Ce.getParams(r,s)]);c($.credentials),d(L.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{g(!1)}},[r,s]);m.useEffect(()=>{z()},[z]);const U=m.useCallback(async($,L)=>{B(!0),y(null);try{await Ce.setCredential(r,s,$,L),C(null),T(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to save ${$}`)}finally{B(!1)}},[r,s,z]),H=m.useCallback(async()=>{const $=D.trim().toUpperCase(),L=w.trim();if(!(!$||!L)){B(!0),y(null);try{await Ce.setCredential(r,s,$,L),F(""),O(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to add ${$}`)}finally{B(!1)}}},[r,s,D,w,z]),q=m.useCallback(async $=>{if(v.has($)){b(L=>{const _=new Set(L);return _.delete($),_}),k(L=>{const _={...L};return delete _[$],_});return}try{const _=(await Ce.getParamsRevealed(r,s,$)).params.find(I=>I.name===$);_!=null&&_.value&&(k(I=>({...I,[$]:_.value})),b(I=>new Set(I).add($)))}catch{}},[r,s,v]),X=new Set(o.map($=>$.name)),J=[...o.map($=>{const L=u.find(_=>_.name===$.name);return{name:$.name,status:$.status,maskedValue:(L==null?void 0:L.maskedValue)??""}}),...u.filter($=>!X.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return a.jsxs("div",{className:"py-2 px-3",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),p&&a.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:p}),h&&J.length===0&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&J.length===0&&!p&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),J.map($=>a.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&a.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has($.name)?S[$.name]??$.maskedValue:$.maskedValue||"***",a.jsx("button",{onClick:()=>q($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:v.has($.name)?"hide":"show"})]}),E===$.name?a.jsxs("div",{className:"flex gap-1",children:[a.jsx("input",{value:N,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&N.trim()&&U($.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),a.jsx("button",{onClick:()=>U($.name,N),disabled:A||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),a.jsx("button",{onClick:()=>{C(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):a.jsx("button",{onClick:()=>{C($.name),T("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),a.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:D,onChange:$=>F($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),a.jsx("input",{value:w,onChange:$=>O($.target.value),onKeyDown:$=>{$.key==="Enter"&&D.trim()&&w.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),a.jsx("button",{onClick:H,disabled:A||!D.trim()||!w.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:A?"not-allowed":"pointer"},children:"Add"})]})]})]})}function EC(t,r,s){const[o,c]=m.useState(null),[u,d]=m.useState(!1),h=m.useRef("");m.useEffect(()=>{const p=`${t}/${r}/${s}`;h.current!==p&&(h.current=p,d(!0),Ce.getCaseHistory(t,r,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,r,s]);const g=m.useCallback(()=>{d(!0),h.current="",Ce.getCaseHistory(t,r,s).then(p=>c(p)).catch(()=>c([])).finally(()=>d(!1))},[t,r,s]);return{entries:o,loading:u,refetch:g}}function NC(t,r,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(p=>p.id===t)).filter(Boolean);if(u.length>=2){const p=u.filter(y=>y.pass).length/u.length;p>=.3&&p<=.7&&(o.flaky=!0)}const d=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(d&&h){const g=d.assertions.find(y=>y.id===t),p=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(p!=null&&p.pass)&&(o.nonDiscriminating=!0)}if(r&&!r.pass&&s.length>=1){const p=s[0].assertions.find(y=>y.id===t);p!=null&&p.pass&&(o.regression=!0)}return o}function TC(){var I;const{state:t,dispatch:r,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:g}=An(),{evals:p,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:E,generateEvalsError:C}=t,N=m.useMemo(()=>{for(const V of S.values())if(V.status==="running"||V.status==="queued")return!0;return!1},[S]),[T,A]=m.useState(!1),[B,D]=m.useState("all"),F={skill_name:t.skill,evals:[]},w=p??F,O=w.evals,z=m.useMemo(()=>B==="all"?O:O.filter(V=>Nl(V)===B),[B,O]),U=z.find(V=>V.id===v)??null;m.useEffect(()=>{v!==null&&!z.find(V=>V.id===v)&&r({type:"SELECT_CASE",caseId:z.length>0?z[0].id:null})},[z,v,r]);const[H,q]=m.useState([]),X=m.useMemo(()=>O.some(V=>Nl(V)==="integration"),[O]);m.useEffect(()=>{X&&Ce.getCredentials(t.plugin,t.skill).then(V=>q(V.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const J=m.useMemo(()=>new Set(H.filter(V=>V.status==="missing").map(V=>V.name)),[H]),[$,L]=m.useState(!1),_=m.useCallback(V=>{L(!1),h(V?{testType:V}:void 0)},[h]);return!p||O.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M9 11l3 3L22 4"}),a.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),a.jsx("div",{className:"text-center",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),a.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),a.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>A(!0),disabled:g,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),a.jsxs("div",{style:{position:"relative"},children:[a.jsxs("div",{className:"flex",children:[a.jsx("button",{onClick:()=>_("unit"),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),a.jsx("button",{onClick:()=>L(!$),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$&&a.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:a.jsx("button",{onClick:()=>_("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.background="var(--surface-2)"},onMouseLeave:V=>{V.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&E.length>0&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(ni,{entries:E,isRunning:!0})}),C&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(Zo,{error:C,onRetry:()=>_()})}),T&&a.jsx(Hg,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]}):a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[a.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",z.length,")"]}),a.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?a.jsx("button",{onClick:d,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>c("benchmark"),disabled:z.length===0||g,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),a.jsx("button",{onClick:()=>c("comparison"),disabled:z.length===0||g,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),a.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(V=>a.jsx("button",{onClick:()=>D(V),style:{padding:"2px 8px",fontSize:10,fontWeight:B===V?600:400,background:B===V?"var(--accent-muted)":"transparent",color:B===V?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:V==="all"?`All (${O.length})`:V==="unit"?`Unit (${O.filter(se=>Nl(se)==="unit").length})`:`Integration (${O.filter(se=>Nl(se)==="integration").length})`},V))}),a.jsxs("div",{className:"py-1",children:[z.length===0&&O.length>0&&a.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",B==="all"?"":B+" ","tests yet"]}),z.map(V=>{var W;const se=b.get(V.id),M=v===V.id,Y=Nl(V);return a.jsxs("button",{onClick:()=>r({type:"SELECT_CASE",caseId:V.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:M?"var(--accent-muted)":"transparent",borderLeft:M?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:te=>{M||(te.currentTarget.style.background="var(--surface-2)")},onMouseLeave:te=>{M||(te.currentTarget.style.background="transparent")},children:[a.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[a.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:M?"var(--text-primary)":"var(--text-secondary)"},children:["#",V.id," ",V.name,a.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:Y==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:Y==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:Y==="unit"?"U":"I"}),Y==="integration"&&((W=V.requiredCredentials)==null?void 0:W.some(te=>J.has(te)))&&a.jsx("span",{title:"Configure credentials to run",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),a.jsx(Ty,{result:se})]}),a.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[V.assertions.length," assertion",V.assertions.length!==1?"s":"",(se==null?void 0:se.passRate)!=null&&a.jsx(MC,{passRate:se.passRate})]})]},V.id)})]}),a.jsx("div",{className:"px-3 py-2",children:!g&&a.jsx("button",{onClick:()=>A(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--accent)",V.currentTarget.style.color="var(--accent)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-default)",V.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(CC,{})})]}),a.jsx("div",{className:"overflow-auto",children:U?a.jsx(RC,{evalCase:U,result:b.get(U.id),evals:p,caseStatus:((I=S.get(U.id))==null?void 0:I.status)??"idle",onSaveEvals:s,onRun:V=>o(V,"benchmark"),onCompare:V=>o(V,"comparison"),onCancel:V=>u(V),onImprove:V=>r({type:"OPEN_IMPROVE",evalId:V})}):a.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),T&&a.jsx(Hg,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]})}function RC({evalCase:t,result:r,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:g}){const{state:p,isReadOnly:y}=An(),{plugin:v,skill:b}=p,{entries:S,loading:k}=EC(v,b,t.id),[E,C]=m.useState(!1),[N,T]=m.useState(t.prompt),[A,B]=m.useState(!1),[D,F]=m.useState(t.expected_output);m.useState(()=>{T(t.prompt),F(t.expected_output)});const w=m.useCallback(V=>{c({...s,evals:s.evals.map(se=>se.id===V.id?V:se)})},[s,c]),O=m.useCallback(()=>{w({...t,prompt:N}),C(!1)},[t,N,w]),z=m.useCallback(()=>{w({...t,expected_output:D}),B(!1)},[t,D,w]),U=m.useCallback(()=>{w({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,w]),H=m.useCallback((V,se)=>{w({...t,assertions:t.assertions.map(M=>M.id===V?{...M,text:se}:M)})},[t,w]),q=m.useCallback(V=>{w({...t,assertions:t.assertions.filter(se=>se.id!==V)})},[t,w]),X=m.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(V=>V.id!==t.id)})},[s,t.id,c]),J=r&&r.assertions.length>0&&r.assertions.every(V=>V.pass),$=r&&r.assertions.some(V=>!V.pass),L=Nl(t),_=t.requiredCredentials??[],I=L==="integration"&&_.length>0;return a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[a.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[a.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?a.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)"},children:L==="unit"?"Unit":"Integration"}):a.jsx("button",{onClick:()=>{if((L==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:se,requirements:M,cleanup:Y,...W}=t;w({...W,testType:"unit"})}else w({...t,testType:"integration"})},title:`Click to switch to ${L==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:L==="unit"?"Unit":"Integration"}),a.jsx(Ty,{result:r})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?a.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),a.jsx("button",{onClick:()=>d(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),$&&!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.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"})]})})]})]}),y&&L==="integration"&&a.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),a.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),a.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),J&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),I&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:_.map(V=>a.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),!y&&L==="integration"&&a.jsx(DC,{evalCase:t,onUpdate:w}),a.jsx(jo,{title:"Prompt",children:E?a.jsxs("div",{children:[a.jsx("textarea",{value:N,onChange:V=>T(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{T(t.prompt),C(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||C(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||a.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),a.jsx(jo,{title:"Expected Output",children:A?a.jsxs("div",{children:[a.jsx("textarea",{value:D,onChange:V=>F(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:z,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{F(t.expected_output),B(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||B(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||a.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),a.jsx(jo,{title:`Assertions (${t.assertions.length})`,action:y?void 0:a.jsx("button",{onClick:U,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?a.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):a.jsx("div",{className:"space-y-2",children:t.assertions.map(V=>{const se=r==null?void 0:r.assertions.find(Y=>Y.assertion_id===V.id),M=NC(V.id,se,S);return a.jsx(AC,{assertion:V,result:se,badges:M,isReadOnly:y,onUpdate:Y=>H(V.id,Y),onDelete:()=>q(V.id)},V.id)})})}),(r==null?void 0:r.output)&&a.jsx(LC,{output:r.output,durationMs:r.durationMs,tokens:r.tokens}),r&&r.passRate!=null&&r.passRate<.2&&(()=>{const V=Ey("INEFFECTIVE",r.passRate);return V.recommendations&&V.recommendations.length>0?a.jsx(jo,{title:"Recommendations",children:a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),a.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((se,M)=>a.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),se]},M))})]})}):null})(),a.jsx(zC,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function AC({assertion:t,result:r,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=m.useState(!1),[g,p]=m.useState(t.text),[y,v]=m.useState(!1),b=()=>{c(g),h(!1)};return a.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsxs("div",{className:"flex items-start gap-2",children:[r?a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&a.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&a.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&a.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),d?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:g,onChange:S=>p(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),a.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(p(t.text),h(!0))},children:t.text}),(r==null?void 0:r.reasoning)&&a.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(r==null?void 0:r.reasoning)&&a.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:r.reasoning})]}),!o&&a.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function jo({title:t,action:r,children:s}){return a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),r]}),s]})}function Ty({result:t}){const[r,s]=m.useState(!1);if(!t||t.status==null)return a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,d=Ey(o?"PASS":"FAIL",c);return a.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":r?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,r&&a.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:d.explanation})]})}function MC({passRate:t}){const r=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:a.jsx("div",{className:"h-full rounded-full",style:{width:`${r}%`,background:r>=80?"var(--green)":r>=50?"var(--yellow)":"var(--red)"}})})})}function LC({output:t,durationMs:r,tokens:s}){const[o,c]=m.useState(!1);return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",r!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",(r/1e3).toFixed(1),"s)"]}),s!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&a.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Md(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Ld({entry:t}){return a.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:ky(t.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:t.type==="benchmark"?"var(--accent-muted)":t.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:t.type==="benchmark"?"var(--accent)":t.type==="comparison"?"var(--purple)":"var(--orange)"},children:t.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ll(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[t.durationMs!=null&&a.jsx("span",{children:wy(t.durationMs)}),t.tokens!=null&&a.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const r=t.pass_rate-t.baselinePassRate,s=r>.001?"skill":r<-.001?"baseline":"tie",o=r>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:r>=0?"var(--green)":"var(--red)"},children:[o,(r*100).toFixed(1),"%"]}),a.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),a.jsx("div",{className:"space-y-0.5",children:t.assertions.map(r=>a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:r.text})]},r.id))})]})}function zC({evalId:t,sharedEntries:r,sharedLoading:s}){const{state:o,dispatch:c}=An(),{plugin:u,skill:d}=o,[h,g]=m.useState(!0),p=r??null,y=s??!1,v=m.useCallback(()=>{g(E=>!E)},[]),b=p?p.slice(0,10):[],S=b.some(E=>{const C=Md(E.type);return C==="left"||C==="full"}),k=b.some(E=>{const C=Md(E.type);return C==="right"||C==="full"});return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",p&&p.length>0&&a.jsxs("span",{style:{fontWeight:400},children:["(",p.length," run",p.length!==1?"s":"",")"]})]}),h&&a.jsx("div",{className:"animate-fade-in",children:y?a.jsxs("div",{className:"flex items-center gap-2 py-3",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!p||p.length===0?a.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):a.jsxs("div",{children:[b.length>=2&&a.jsx("div",{className:"mb-2",children:a.jsx(Cy,{entries:b})}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&a.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&a.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((E,C)=>{const N=Md(E.type);return N==="full"?a.jsx("div",{style:{gridColumn:"1 / -1"},children:a.jsx(Ld,{entry:E})},C):N==="left"?a.jsxs(m.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"},children:a.jsx(Ld,{entry:E})}),a.jsx("div",{style:{gridColumn:"2"}})]},C):a.jsxs(m.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"}}),a.jsx("div",{style:{gridColumn:"2"},children:a.jsx(Ld,{entry:E})})]},C)})]}),a.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:E=>{E.currentTarget.style.textDecoration="underline"},onMouseLeave:E=>{E.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function Hg({evals:t,onSave:r,onCancel:s}){const[o,c]=m.useState(""),[u,d]=m.useState(""),[h,g]=m.useState(""),[p,y]=m.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=m.useState("unit"),[S,k]=m.useState(""),[E,C]=m.useState([]),[N,T]=m.useState(""),[A,B]=m.useState(""),D=Math.max(0,...t.evals.map(z=>z.id))+1,F=z=>{b(z),z==="unit"&&(C([]),k(""),T(""),B(""))},w=()=>{const z=S.trim().toUpperCase();z&&!E.includes(z)&&C([...E,z]),k("")},O=()=>{if(!o.trim()||!u.trim())return;const z={id:D,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:p.filter(U=>U.text.trim()),...v==="integration"?{testType:"integration",...E.length>0?{requiredCredentials:E}:{},...N||A?{requirements:{...N?{platform:N}:{},...A?{chromeProfile:A}:{}}}:{}}:{}};r({...t,evals:[...t.evals,z]})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-overlay-in",style:{background:"rgba(0,0,0,0.6)"},children:a.jsxs("div",{className:"w-full max-w-lg rounded-xl p-6 animate-modal-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",maxHeight:"85vh",overflowY:"auto"},children:[a.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),a.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(z=>a.jsx("button",{onClick:()=>F(z),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===z?z==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===z?z==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:z},z))})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),a.jsx("input",{value:o,onChange:z=>c(z.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),a.jsx("textarea",{value:u,onChange:z=>d(z.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),a.jsx("textarea",{value:h,onChange:z=>g(z.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),p.map((z,U)=>a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:z.text,onChange:H=>y(p.map((q,X)=>X===U?{...q,text:H.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),p.length>1&&a.jsx("button",{onClick:()=>y(p.filter((H,q)=>q!==U)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z.id)),a.jsx("button",{onClick:()=>y([...p,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:E.map(z=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[z,a.jsx("button",{onClick:()=>C(E.filter(U=>U!==z)),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:S,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),w())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),a.jsx("button",{onClick:w,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:N,onChange:z=>T(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("label",{className:"block",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:A,onChange:z=>B(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function DC({evalCase:t,onUpdate:r}){var d,h;const[s,o]=m.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&r({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const p=(t.requiredCredentials??[]).filter(y=>y!==g);r({...t,requiredCredentials:p.length>0?p:void 0})};return a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,a.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),a.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:g=>r({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>r({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Rn(t,r){return r==="free"?"Free":r==="subscription"&&t==null?"Included":t==null?"N/A":t>=1?`$${t.toFixed(2)}`:t===0?"$0.00":t>=.001?`$${t.toFixed(4)}`:`$${t.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function Ry(t,r){return t==null||r==null?"N/A":`${t.toLocaleString("en-US")} in / ${r.toLocaleString("en-US")} out`}function _C(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function OC(t,r){let s="";if(r){const c=new Date(r);isNaN(c.getTime())||(s=c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}))}return[t,s].filter(Boolean).join(" · ")}function BC(t,r,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*r);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function $g(t,r){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(r)}}function IC(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function UC(t,r){const s=t+r,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const HC={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function $C(t,r){if(!t)return null;const s=HC[t];if(s==null||s===0)return null;const o=s*r*.5,c=s*r*2;return`${Rn(o)}–${Rn(c)}`}function VC(){const{state:t,runCase:r,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=An(),{evals:d,caseRunStates:h,bulkRunActive:g,latestBenchmark:p,inlineResults:y}=t,{config:v}=Hr(),b=(d==null?void 0:d.evals)??[],S=m.useMemo(()=>{for(const w of h.values())if(w.status==="running"||w.status==="queued")return!0;return!1},[h]),k=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,E=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="running"||O.status==="queued")}).length,C=m.useRef(null),[N,T]=m.useState(0);m.useEffect(()=>{if(S&&!C.current&&(C.current=Date.now()),!S){C.current=null,T(0);return}const w=setInterval(()=>{C.current&&T(Math.round((Date.now()-C.current)/1e3))},1e3);return()=>clearInterval(w)},[S]);const A=b.reduce((w,O)=>w+O.assertions.length,0),B=b.length+A,D=m.useMemo(()=>UC(b.length,A),[b.length,A]),F=m.useMemo(()=>$C((v==null?void 0:v.provider)??null,B),[v==null?void 0:v.provider,B]);return a.jsxs("div",{className:"p-5",children:[u&&a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),a.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&a.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[E," running"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),a.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),a.jsx("button",{onClick:()=>s("benchmark"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),a.jsx("button",{onClick:()=>s("baseline"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&b.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("span",{children:["Est. duration: ",D]}),F&&a.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&a.jsx("span",{children:"Cost: Included"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&a.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),a.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),a.jsx("div",{className:"space-y-3 stagger-children",children:b.map(w=>{const O=y.get(w.id),z=h.get(w.id),U=(z==null?void 0:z.status)??"idle",H=p==null?void 0:p.cases.find(q=>q.eval_id===w.id);return a.jsx(FC,{name:w.name,evalId:w.id,result:O,caseCost:H==null?void 0:H.cost,caseBillingMode:H==null?void 0:H.billingMode,caseInputTokens:H==null?void 0:H.inputTokens,caseOutputTokens:H==null?void 0:H.outputTokens,caseStatus:U,runMode:(z==null?void 0:z.mode)??null,comparisonDetail:H==null?void 0:H.comparisonDetail,isReadOnly:u,onRun:q=>r(q,"benchmark"),onBaseline:q=>r(q,"baseline"),onCompare:q=>r(q,"comparison"),onCancel:q=>o(q)},w.id)})}),!S&&p&&p.cases.length>0&&a.jsxs("div",{className:"mt-5",children:[a.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:_C(p.type)}),a.jsx("span",{className:"text-[20px] font-bold",style:{color:(p.overall_pass_rate??0)>=.8?"var(--green)":(p.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:p.overall_pass_rate!=null?`${Math.round(p.overall_pass_rate*100)}%`:"--"})]}),p.totalDurationMs!=null&&a.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(p.totalDurationMs/1e3).toFixed(1),"s",p.model&&` | Model: ${p.model}`,p.totalInputTokens!=null&&p.totalOutputTokens!=null&&` | Tokens: ${Ry(p.totalInputTokens,p.totalOutputTokens)}`,p.totalCost!=null&&` | Cost: ${Rn(p.totalCost)}`]}),p.overall_pass_rate>=.9999&&!p.comparison&&a.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||u,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:b.length===0?.5:1},children:"Run Final A/B Comparison"})]}),p.comparison&&a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const w=OC(p.model,p.timestamp);return w?a.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:w}):a.jsx("div",{className:"mb-3"})})(),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Vg,{label:"Skill",value:p.comparison.skillPassRate,color:"var(--accent)"}),a.jsx(Vg,{label:"Baseline",value:p.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),a.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:p.comparison.delta>0?"var(--green)":p.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",p.comparison.delta>0?"+":"",(p.comparison.delta*100).toFixed(1),"%",p.verdict&&` | ${wC(p.verdict)}`]}),(()=>{const w=p.cases.reduce((z,U)=>z+U.assertions.length,0),O=BC(p.comparison.delta,w,p.cases.length);return a.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const PC={benchmark:{label:"Skill",bg:"var(--accent-muted)",color:"var(--accent)"},baseline:{label:"Baseline",bg:"var(--surface-3)",color:"var(--text-tertiary)"},comparison:{label:"Compare",bg:"var(--purple-muted)",color:"var(--purple)"}};function FC({name:t,evalId:r,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:g,comparisonDetail:p,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:k}){const[E,C]=m.useState(!1),N=h==="running"||h==="queued",T=h==="complete"||h==="error";return a.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&a.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&a.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),a.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",r," ",t]}),g&&(N||T)&&(()=>{const A=PC[g];return A?a.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:A.bg,color:A.color,padding:"1px 6px"},children:A.label}):null})()]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N?a.jsx("button",{onClick:()=>k(r),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>S(r),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),a.jsx("button",{onClick:()=>v(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),a.jsx("button",{onClick:()=>b(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&a.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&d!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Ry(u,d)}),o!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Rn(o,c)}),h==="cancelled"&&a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"space-y-1",children:s.assertions.map(A=>a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsx("span",{style:{color:A.pass?"var(--green)":"var(--red)"},children:A.pass?"PASS":"FAIL"}),a.jsx("span",{style:{color:"var(--text-secondary)"},children:A.text})]},A.assertion_id))}),s.output&&a.jsx("button",{onClick:()=>C(!E),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:E?"Hide output":"Show output"}),E&&s.output&&a.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),p&&a.jsx("div",{className:"px-4 pb-3",children:a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const A=$g(p.skillContentScore,p.baselineContentScore),B=$g(p.skillStructureScore,p.baselineStructureScore),D=IC(p.winner);return a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",A.skill,"% / Baseline ",A.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsx("span",{style:{color:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&a.jsx(GC,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const zd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function GC({errorMessage:t,classifiedError:r}){const[s,o]=m.useState(!1),c=(r==null?void 0:r.title)??"Error",u=r==null?void 0:r.hint,d=r?zd[r.category]??zd.unknown:zd.unknown;return a.jsx("div",{className:"px-4 pb-3",children:a.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[a.jsx("span",{style:{fontSize:12},children:d}),a.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),a.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&a.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&a.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Vg({label:t,value:r,color:s}){return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(r*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r*100}%`,background:s}})})]})}const Pg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function WC(){var _;const{state:t,dispatch:r,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=An(),{plugin:u,skill:d,activationPrompts:h,activationResults:g,activationSummary:p,activationRunning:y,activationError:v,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:E,activationHistory:C}=t,{state:N}=ea(),T=((_=N.skills.find(I=>I.plugin===u&&I.skill===d))==null?void 0:_.version)??null,[A,B]=m.useState(h),[D,F]=m.useState(null),[w,O]=m.useState(!1);m.useEffect(()=>{h&&h!==A&&B(h)},[h]),m.useEffect(()=>{r({type:"SET_ACTIVATION_PROMPTS",prompts:A})},[A,r]),m.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(I=>I.json()).then(I=>F(I.rawContent||I.description||null)).catch(()=>F(null))},[u,d]);function z(){s(A)}function U(){c(8)}const H=A.trim().split(`
81
+ `).filter(Boolean).length,q=g.filter(I=>I.classification==="TP"||I.classification==="TN"),X=g.filter(I=>I.classification==="FP"||I.classification==="FN"),J=(D==null?void 0:D.replace(/^---[\s\S]*?---\s*/,"").trim())??null,$=A.trim().length>0,L=J?Xo(J):"";return a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),a.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),a.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[a.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),a.jsx("div",{className:"flex gap-1.5",children:a.jsx("button",{onClick:U,disabled:k||!J||y,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:J?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:J?1:.5,cursor:J?"pointer":"not-allowed"},title:J?void 0:"No skill description available",onMouseEnter:I=>{J&&!k&&(I.currentTarget.style.background="var(--surface-3)")},onMouseLeave:I=>{k||(I.currentTarget.style.background="var(--surface-2)")},children:k?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),$?"Regenerate":"Generate"," Test Prompts"]})})})]}),!J&&!y&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),E&&a.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:E}),a.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:A,onChange:I=>B(I.target.value),placeholder:`How do I write a unit test?
82
82
  What edge cases should I test?
83
83
  +Deploy this to production
84
84
  !What's the weather like today?
85
- !Write me a poem about flowers`}),a.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:"One prompt per line"}),a.jsx(So,{}),a.jsx("span",{children:"No prefix = auto-classify"}),a.jsx(So,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),a.jsx(So,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),a.jsx(So,{}),a.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[U," prompt",U!==1?"s":""]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:z,disabled:y||!L.trim(),className:"btn btn-primary",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("circle",{cx:"12",cy:"12",r:"6"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${U} prompts tested`,b&&a.jsx(YC,{startedAt:b})]})]})]})]}),a.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:J?a.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:M}}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&a.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[a.jsx("div",{className:"spinner-lg mx-auto mb-4"}),a.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&a.jsxs("div",{className:"space-y-5",children:[X.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),a.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((O,V)=>a.jsx(Fg,{result:O},`incorrect-${V}`))})]}),q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"16 10 11 15 8 12"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((O,V)=>a.jsx(Fg,{result:O},`correct-${V}`))})]})]}),m&&a.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),m.autoClassifiedCount!=null&&m.autoClassifiedCount>0&&a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[m.autoClassifiedCount," of ",m.total," prompts auto-classified from skill name and tags"]}),a.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[a.jsx(Dd,{label:"Precision",value:m.precision,description:"Of all activations, how many were correct?",detail:`${m.tp} true / ${m.tp+m.fp} total activations`}),a.jsx(Dd,{label:"Recall",value:m.recall,description:"Of expected activations, how many fired?",detail:`${m.tp} activated / ${m.tp+m.fn} expected`}),a.jsx(Dd,{label:"Reliability",value:m.reliability,description:"Overall correct classification rate",detail:`${m.tp+m.tn} correct / ${m.total} total`})]}),a.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[a.jsx(ko,{label:"True Positive",abbr:"TP",count:m.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),a.jsx(ko,{label:"False Positive",abbr:"FP",count:m.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),a.jsx(ko,{label:"False Negative",abbr:"FN",count:m.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),a.jsx(ko,{label:"True Negative",abbr:"TN",count:m.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),a.jsx(GC,{history:C,expanded:E,onToggle:()=>H(!E),skillVersion:R})]})}function GC({history:t,expanded:r,onToggle:s,skillVersion:o}){return t===null?null:a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:s,children:[a.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&a.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&a.jsx("div",{className:"px-4 py-3",children:t.length===0?a.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):a.jsx("div",{className:"space-y-2",children:t.map(c=>a.jsx(WC,{run:c,skillVersion:o},c.id))})})]})}function WC({run:t,skillVersion:r}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:qC(t.timestamp)}),a.jsx(ei,{version:r??null,size:"sm","data-testid":"activation-row-version"}),a.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),a.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function qC(t){const r=Date.now(),s=new Date(t).getTime(),o=Math.floor((r-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function So(){return a.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Fg({result:t}){const r=Pg[t.classification]||Pg.FN,s=t.classification==="TP"||t.classification==="TN";return a.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:r.bg,border:"1px solid transparent"},children:[a.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${r.text} 20%, transparent)`},children:s?a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),a.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[a.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:r.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),a.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&a.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&a.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Dd({label:t,value:r,description:s,detail:o}){const c=Math.round(r*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),a.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),a.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),a.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function ko({abbr:t,count:r,bg:s,color:o,description:c}){return a.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[a.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:r}),a.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),a.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function YC({startedAt:t}){const[r,s]=p.useState(0);return p.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),a.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}const _d={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Gg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},of=600,cf=180,sn=40,Od=of-sn*2,rr=cf-sn*2,KC=[25,50,75,100];function Wg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function XC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function QC({entries:t,onPointClick:r}){const[s,o]=p.useState(null),c=p.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((m,y)=>{const v=sn+y/(u-1)*Od,b=m.passRate*100,S=sn+rr-b/100*rr;return{x:v,y:S,pct:b,entry:m}}),h=d.map(m=>`${m.x},${m.y}`).join(" "),g=Array.from(new Set(c.map(m=>m.type)));return a.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[a.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),a.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(m=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:_d[m]??"var(--text-tertiary)"}}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Gg[m]??m})]},m))}),a.jsxs("svg",{width:of,height:cf,viewBox:`0 0 ${of} ${cf}`,style:{display:"block",overflow:"visible"},children:[KC.map(m=>{const y=sn+rr-m/100*rr;return a.jsxs("g",{children:[a.jsx("line",{x1:sn,y1:y,x2:sn+Od,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),a.jsxs("text",{x:sn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),a.jsx("line",{x1:sn,y1:sn+rr,x2:sn+Od,y2:sn+rr,stroke:"var(--border-subtle)",strokeWidth:1}),a.jsx("text",{x:sn-8,y:sn+rr+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),a.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((m,y)=>a.jsx("circle",{cx:m.x,cy:m.y,r:5,fill:_d[m.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>r==null?void 0:r(m.entry)},y)),ZC(u).map(m=>a.jsx("text",{x:d[m].x,y:sn+rr+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Wg(c[m].timestamp)},m))]}),s&&a.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Wg(s.entry.timestamp)}),a.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:_d[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Gg[s.entry.type]??s.entry.type}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),a.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:XC(s.entry.totalDurationMs)}),a.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function ZC(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const r=Math.ceil(t/10),s=[0];for(let o=r;o<t-1;o+=r)s.push(o);return s.push(t-1),s}const _s=new Map;let on=null,zo=null,wo=1e3,Tl=0;function Ry(){if(on)return;on=new EventSource("/api/events");const t=r=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=_s.get(r);if(c)for(const u of c)u(o)};on.addEventListener("benchmark:complete",t("benchmark:complete")),on.addEventListener("history:written",t("history:written")),on.addEventListener("leaderboard:updated",t("leaderboard:updated")),on.onerror=()=>{on==null||on.close(),on=null,Tl>0&&(zo=setTimeout(()=>{wo=Math.min(wo*2,3e4),Ry()},wo))},on.onopen=()=>{wo=1e3}}function JC(){zo!=null&&(clearTimeout(zo),zo=null),on==null||on.close(),on=null}function eE(t,r){return _s.has(t)||_s.set(t,new Set),_s.get(t).add(r),Tl++,Ry(),()=>{var s;(s=_s.get(t))==null||s.delete(r),Tl--,Tl<=0&&(Tl=0,queueMicrotask(()=>{Tl<=0&&JC()}))}}function Ho(t,r){const s=p.useRef(r);s.current=r,p.useEffect(()=>eE(t,c=>s.current(c)),[t])}function Uo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function tE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function nE({rate:t,label:r}){const s=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:Uo(t)},children:[s,"%"]})]}),a.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:Uo(t)}})})]})})}function aE({points:t}){if(t.length<2)return null;const r=200,s=48,o=4,c=t.length,u=t.map((g,m)=>{const y=o+m/(c-1)*(r-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,m)=>`${m===0?"M":"L"} ${g.x},${g.y}`).join(" ");return a.jsxs("svg",{width:r,height:s,style:{display:"block"},children:[a.jsx("path",{d,fill:"var(--accent-muted)"}),a.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),a.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function rE({plugin:t,skill:r}){const s=`stats/${t}/${r}`,o=p.useCallback(()=>Ce.getStats(t,r),[t,r]),{data:c,loading:u}=ti(s,o),d=p.useCallback(()=>Tn(s),[s]);if(Ho("benchmark:complete",d),Ho("history:written",d),u)return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"skeleton h-24 rounded-xl"}),a.jsx("div",{className:"skeleton h-48 rounded-xl"}),a.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),a.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,m=h-g,y=c.assertionStats.slice(0,10);return a.jsxs("div",{className:"space-y-4 stagger-children",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:Uo(h)},children:[Math.round(h*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:m>=0?"var(--green)":"var(--red)"},children:[m>=0?"+":"",Math.round(m*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.totalCost)})]}),c.costPerRun!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),a.jsx(aE,{points:c.trendPoints})]}),c.modelStats.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),a.jsx("tbody",{children:c.modelStats.map(v=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),a.jsx("td",{style:{padding:"8px",textAlign:"center"},children:a.jsxs("span",{className:"font-semibold",style:{color:Uo(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:tE(v.avgDurationMs)}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Rn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),a.jsx("div",{className:"space-y-3",children:y.map(v=>a.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),a.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),a.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),a.jsx(nE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function lE({plugin:t,skill:r}){const[s,o]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState({}),[g,m]=p.useState({});p.useEffect(()=>{Ce.getEvals(t,r).then(o).catch(()=>o(null))},[t,r]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){m(b=>({...b,[v]:!0}));try{const b=await Ce.getCaseHistory(t,r,v);h(S=>({...S,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{m(b=>({...b,[v]:!1}))}}}return s?a.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],S=c===v.id,k=g[v.id],w=b.length>0?b[0].pass_rate:null;return a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:C=>{S||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{S||(C.currentTarget.style.background="transparent")},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),a.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),a.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&a.jsx(wy,{entries:b}),w!=null&&a.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Ll(w)},children:[Math.round(w*100),"%"]}),b.length>0&&a.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&a.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?a.jsxs("div",{className:"p-4 flex items-center gap-2",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):a.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,N)=>a.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:Sy(C.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ll(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&a.jsx("span",{children:ky(C.durationMs)}),C.tokens!=null&&a.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),a.jsx("div",{className:"space-y-1",children:C.assertions.map(R=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:R.pass?"var(--green)":"var(--red)"},children:a.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:R.pass?a.jsx("polyline",{points:"20 6 9 17 4 12"}):a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:R.text}),R.reasoning&&a.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:R.reasoning})]})]},R.id))})]},N))})})]},v.id)})}):a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function sE(){const{state:t,dispatch:r}=An(),{plugin:s,skill:o}=t,{state:c}=ea(),u=c.skills.find(O=>O.plugin===s&&O.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=p.useState("timeline"),[m,y]=p.useState(""),[v,b]=p.useState(""),[S,k]=p.useState(!1),[w,C]=p.useState([]),[N,R]=p.useState(null),[L,B]=p.useState(!1),[D,F]=p.useState(null),[E,H]=p.useState(!1),z=`history/${s}/${o}?model=${m}&type=${v}`,I=p.useCallback(()=>Ce.getHistory(s,o,{model:m||void 0,type:v||void 0}),[s,o,m,v]),{data:U,loading:q}=ti(z,I),X=U??[];p.useEffect(()=>{!U||U.length<2||Ce.compareRuns(s,o,U[0].timestamp,U[1].timestamp).then(O=>{const V=O.regressions.filter(se=>se.change==="regression");r({type:"SET_REGRESSIONS",regressions:V})}).catch(()=>{})},[U,s,o,r]);const J=p.useCallback(()=>Tn(z),[z]);Ho("history:written",J);const $=p.useCallback(async O=>{if(S){C(V=>V.includes(O)?V.filter(se=>se!==O):V.length>=2?[V[1],O]:[...V,O]);return}H(!0);try{const V=await Ce.getHistoryEntry(s,o,O);F(V)}catch{}finally{H(!1)}},[s,o,S]),M=p.useCallback(async()=>{if(w.length===2){B(!0);try{const O=await Ce.compareRuns(s,o,w[0],w[1]);R(O)}catch{}finally{B(!1)}}},[s,o,w]),_=[...new Set(X.map(O=>O.model))];return q?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"skeleton h-12 rounded-lg"}),a.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(O=>a.jsx("button",{onClick:()=>g(O),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===O?"var(--accent-muted)":"transparent",color:h===O?"var(--accent)":"var(--text-tertiary)"},children:O==="timeline"?"Timeline":O==="per-eval"?"Per Eval":"Statistics"},O))}),h==="timeline"&&a.jsxs("div",{children:[X.length>0&&a.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:a.jsx(QC,{entries:X,onPointClick:O=>$(O.timestamp)})}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("select",{value:m,onChange:O=>y(O.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Models"}),_.map(O=>a.jsx("option",{value:O,children:O},O))]}),a.jsxs("select",{value:v,onChange:O=>b(O.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Types"}),a.jsx("option",{value:"benchmark",children:"Benchmark"}),a.jsx("option",{value:"comparison",children:"Comparison"}),a.jsx("option",{value:"baseline",children:"Baseline"}),a.jsx("option",{value:"model-compare",children:"Model Compare"}),a.jsx("option",{value:"improve",children:"AI Improve"}),a.jsx("option",{value:"instruct",children:"AI Edit"}),a.jsx("option",{value:"ai-generate",children:"AI Generate"}),a.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{onClick:()=>{k(!S),C([]),R(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&w.length===2&&a.jsx("button",{onClick:M,disabled:L,className:"btn btn-primary text-[12px]",children:L?"Comparing...":"Compare"})]}),a.jsx("div",{className:"space-y-2",children:X.length===0?a.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(O=>{const V=w.includes(O.timestamp);return a.jsx("button",{onClick:()=>$(O.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:V?"var(--accent-muted)":"var(--surface-1)",border:V?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:se=>{V||(se.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:se=>{V||(se.currentTarget.style.borderColor="var(--border-subtle)")},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:V?"var(--accent)":"var(--border-default)",background:V?"var(--accent)":"transparent"},children:V&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(O.timestamp).toLocaleString()}),a.jsx("span",{className:"pill text-[9px]",style:{background:O.type==="comparison"?"var(--purple-muted)":O.type==="baseline"?"var(--surface-3)":O.type==="model-compare"?"var(--accent-muted)":O.type==="improve"||O.type==="instruct"?"var(--purple-muted)":O.type==="ai-generate"?"var(--green-muted)":O.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:O.type==="comparison"?"var(--purple)":O.type==="baseline"?"var(--text-tertiary)":O.type==="model-compare"?"var(--accent)":O.type==="improve"||O.type==="instruct"?"var(--purple)":O.type==="ai-generate"?"var(--green)":O.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:O.type==="model-compare"?"model compare":O.type==="improve"?"ai improve":O.type==="instruct"?"ai edit":O.type==="ai-generate"?"ai generate":O.type==="eval-generate"?"eval generate":O.type})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ei,{version:d,size:"sm","data-testid":"history-row-version"}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:O.model}),O.totalCost!=null&&O.totalCost>0&&a.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(O.totalCost)}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:O.passRate>=.8?"var(--green)":O.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(O.passRate*100),"%"]})]})]})},O.timestamp)})}),N&&a.jsx(iE,{result:N}),D&&!S&&a.jsx(oE,{run:D,onClose:()=>F(null)})]}),h==="per-eval"&&a.jsx(lE,{plugin:s,skill:o}),h==="statistics"&&a.jsx(rE,{plugin:s,skill:o})]})}function iE({result:t}){const r=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[a.jsxs("span",{children:["Run A cost: ",Rn(t.runA.totalCost??null)]}),a.jsxs("span",{children:["Run B cost: ",Rn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&a.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Rn(t.runB.totalCost-t.runA.totalCost)]})]}),r.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),a.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:a.jsxs("table",{className:"w-full text-[12px]",children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"var(--surface-2)"},children:[a.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),a.jsx("tbody",{children:t.caseDiffs.map(o=>a.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function oE({run:t,onClose:r}){return(t.type==="improve"||t.type==="instruct")&&t.improve?a.jsx(cE,{run:t,onClose:r}):a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),a.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Rn(t.totalCost)}`]}),a.jsx("div",{className:"space-y-2",children:t.cases.map(s=>a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&a.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(s.cost)}),a.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function cE({run:t,onClose:r}){var u;const s=p.useMemo(()=>t.improve?Qo(t.improve.original,t.improve.improved):[],[t.improve]),o=p.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=p.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return a.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),a.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),a.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&a.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:c.map((d,h)=>a.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function Ay({data:t}){if(t.length<2)return a.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=r.length,g=Math.min(...r),y=Math.max(...r)-g||1,v=r.map((k,w)=>{const C=c+w/(h-1)*u,N=c+d-(k-g)/y*d;return`${C.toFixed(1)},${N.toFixed(1)}`}),b=r[r.length-1],S=Ll(b);return a.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[a.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,w]=v[v.length-1].split(",");return a.jsx("circle",{cx:k,cy:w,r:2.5,fill:S})})()]})}function uE(){return a.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function dE({pct:t}){const r=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return a.jsxs("span",{className:"pill",style:{background:s,color:r,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function fE({score:t,rating:r}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[r]??s.minimal,c=t>=0?"+":"";return a.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),a.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function pE({warning:t}){return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10.29 3.86L1.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"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function mE({active:t,onChange:r,hasBaseline:s}){return a.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[a.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),a.jsx("button",{onClick:()=>r("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function hE(t){var o,c,u;if(t.length===0)return[];const r=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;r.has(g)||r.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const m=r.get(g);m.passRates.push(h.passRate.mean),m.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,m.lastDuration=h.duration.mean,m.lastCost=((c=h.cost)==null?void 0:c.total)??null,m.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(m.lastBaselinePassRate=h.baselinePassRate.mean,m.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,m.lastAmplificationPct=h.amplificationPct,m.hasBaseline=!0)}const s=[];for(const[d,h]of r){const[g,...m]=d.split("/");s.push({rank:0,model:m.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const My=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function xE({entries:t}){return a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>a.jsx("th",{style:My(r==="#"?"center":"left"),children:r},r))})}),a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&a.jsx(uE,{})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ll(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ay,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function gE({entries:t}){const r=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return r.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",a.jsx("code",{children:"--baseline"})," flag."]})})}):a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>a.jsx("th",{style:My(s==="#"?"center":"left"),children:s},s))})}),a.jsx("tbody",{children:r.map((s,o)=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ll(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?a.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?a.jsx(dE,{pct:s.amplificationPct}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ay,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function vE(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=p.useState("rankings"),u=`leaderboard/${r}/${s}`,d=p.useCallback(()=>Ce.getLeaderboard(r,s),[r,s]),{data:h,loading:g}=ti(u,d),m=(h==null?void 0:h.entries)??[];p.useEffect(()=>{c("rankings")},[r,s]);const y=p.useCallback(()=>Tn(u),[u]);Ho("leaderboard:updated",y);const v=p.useMemo(()=>hE(m),[m]),b=v.some(w=>w.hasBaseline),S=m[0],k=S==null?void 0:S.judgeBiasWarning;return g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),a.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),a.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),a.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",a.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),a.jsx(mE,{active:o,onChange:c,hasBaseline:b})]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[m.length," sweep",m.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&a.jsx(pE,{warning:k}),o==="rankings"?a.jsx(xE,{entries:v}):a.jsx(gE,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&a.jsx(fE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function yE({plugin:t,skill:r}){const[s,o]=p.useState([]),[c,u]=p.useState([]),[d,h]=p.useState(!0),[g,m]=p.useState(null);p.useEffect(()=>{Ce.getDependencies(t,r).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,r]);async function y(v,b){try{await navigator.clipboard.writeText(b),m(v),setTimeout(()=>m(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?a.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),a.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>a.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),a.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),a.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>a.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),a.jsx("div",{className:"space-y-1.5",children:c.map(v=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function qg({plugin:t,skill:r}){const[s,o]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[g,m]=p.useState(""),[y,v]=p.useState(!1),[b,S]=p.useState(null),[k,w]=p.useState(""),[C,N]=p.useState(""),[R,L]=p.useState(!1),[B,D]=p.useState(new Set),F=p.useCallback(async()=>{u(!0);try{const[I,U]=await Promise.all([Ce.getCredentials(t,r).catch(()=>({credentials:[]})),Ce.getParams(t,r).catch(()=>({params:[]}))]),q=new Map(U.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of I.credentials){X.add($.name);const M=q.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:M==null?void 0:M.maskedValue})}for(const $ of U.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});o(J)}finally{u(!1)}},[t,r]);p.useEffect(()=>{F()},[F]);const E=p.useCallback(async I=>{if(B.has(I)){D(U=>{const q=new Set(U);return q.delete(I),q}),o(U=>U.map(q=>q.name===I?{...q,revealedValue:void 0}:q));return}try{const q=(await Ce.getParamsRevealed(t,r,I)).params.find(X=>X.name===I);q&&(o(X=>X.map(J=>J.name===I?{...J,revealedValue:q.value}:J)),D(X=>new Set(X).add(I)))}catch{}},[t,r,B]),H=async(I,U)=>{if(!(!I.trim()||!U.trim())){v(!0),S(null);try{await Ce.setCredential(t,r,I,U),h(null),m(""),D(new Set),F()}catch(q){S(q.message)}finally{v(!1)}}},z=async()=>{if(!(!k.trim()||!C.trim())){v(!0),S(null);try{await Ce.setCredential(t,r,k.trim().toUpperCase(),C),w(""),N(""),L(!1),F()}catch(I){S(I.message)}finally{v(!1)}}};return c?a.jsxs("div",{className:"mt-6",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):a.jsxs("div",{className:"mt-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("button",{onClick:()=>L(!R),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&a.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!R?a.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):a.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(I=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:I.name}),I.maskedValue&&a.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(I.name)&&I.revealedValue!=null?I.revealedValue:I.maskedValue}),I.maskedValue&&a.jsx("button",{onClick:()=>E(I.name),className:"btn btn-ghost px-1",title:B.has(I.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(I.name)?a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),a.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:I.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:I.status==="ready"?"var(--green)":"var(--orange)"},children:I.status==="ready"?"ready":"missing"}),I.source&&a.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:I.source}),d===I.name?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("input",{value:g,onChange:U=>m(U.target.value),onKeyDown:U=>{U.key==="Enter"&&H(I.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),a.jsx("button",{onClick:()=>H(I.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),a.jsx("button",{onClick:()=>{h(null),m("")},className:"btn btn-ghost text-[10px] px-1",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):a.jsx("button",{onClick:()=>{h(I.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},I.name))}),R&&a.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:k,onChange:I=>w(I.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),a.jsx("input",{value:C,onChange:I=>N(I.target.value),onKeyDown:I=>{I.key==="Enter"&&z()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx("button",{onClick:()=>{L(!1),w(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),a.jsx("button",{onClick:z,disabled:y||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function bE(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{Ce.getDependencies(r,s).then(c).catch(()=>{}).finally(()=>d(!1))},[r,s]),u?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx(yE,{plugin:r,skill:s}),a.jsx(qg,{plugin:r,skill:s})]}):a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),a.jsx(qg,{plugin:r,skill:s})]})}function jE(t){const r={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(r.targetAgents=t.targetAgents),r}function SE(t){var c;const r=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:r?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function uf(t,r=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(s=s.replace(/^-+|-+$/g,"")),s}function kE(t,r,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function wE({onCreated:t,resolveAiConfigOverride:r,forceLayout:s}){const[o,c]=p.useState("ai"),[u,d]=p.useState(null),[h,g]=p.useState(!0),{config:m}=Ur(),[y,v]=p.useState(""),[b,S]=p.useState(s??3),[k,w]=p.useState(""),[C,N]=p.useState(""),[R,L]=p.useState(""),[B,D]=p.useState(""),[F,E]=p.useState(""),[H,z]=p.useState(""),[I,U]=p.useState("write"),[q,X]=p.useState([]),[J,$]=p.useState(!1),[M,_]=p.useState(null),[O,V]=p.useState(null),[se,A]=p.useState("vskill"),[Y,W]=p.useState("1.0.0"),[te,fe]=p.useState(!0),ie=p.useCallback(async()=>{try{const ve=await Ce.detectEngines();V(ve),A(Re=>Re!=="vskill"?Re:ve.vskillSkillBuilder?"vskill":ve.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{V({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{ie()},[ie]);const[ye,de]=p.useState(""),[Se,Ae]=p.useState(!1),[_e,re]=p.useState(!1),[he,pe]=p.useState(null),[xe,je]=p.useState(null),[Be,Oe]=p.useState([]),rt=p.useRef(null),Nt=p.useRef(null),ht=p.useRef(null),Dt=p.useRef(null),Tt=p.useRef(null),[Qe,tt]=p.useState(!1),[be,pt]=p.useState(!1),Ct=p.useRef(y),Yt=p.useRef(k),un=p.useRef(C);p.useEffect(()=>{Ct.current=y},[y]),p.useEffect(()=>{Yt.current=k},[k]),p.useEffect(()=>{un.current=C},[C]),p.useEffect(()=>{Ce.getProjectLayout().then(ve=>{if(d(ve),s)return;S(ve.suggestedLayout);const Re=ve.detectedLayouts.find(dn=>dn.layout===ve.suggestedLayout);Re!=null&&Re.existingPlugins.length&&w(Re.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),p.useEffect(()=>{var ve;o==="ai"&&((ve=rt.current)==null||ve.focus())},[o]),p.useEffect(()=>()=>{var ve;(ve=Nt.current)==null||ve.abort()},[]);const Gt=p.useMemo(()=>{var ve;return u?((ve=u.detectedLayouts.find(Re=>Re.layout===b))==null?void 0:ve.existingPlugins)||[]:[]},[u,b]),an=k==="__new__"?C:k,Mn=u?kE(u.root,b,an||"{plugin}",y||"{skill}"):"",Mt=p.useMemo(()=>u?u.detectedLayouts.filter(ve=>ve.layout!==4):[],[u]),xt=p.useMemo(()=>{if(!u)return null;const ve=u.detectedLayouts.find(fn=>fn.layout===2&&fn.existingPlugins.length>0),Re=u.detectedLayouts.find(fn=>fn.layout===1&&fn.existingPlugins.length>0),dn=ve||Re;return dn?{layout:dn.layout,plugins:dn.existingPlugins}:null},[u]),gt=p.useCallback(()=>{if(r)return r();if(!m)return{provider:"claude-cli",model:"sonnet"};const ve=m.provider||"claude-cli",Re=m.model||"sonnet";return{provider:ve,model:Re}},[m,r]),da=p.useCallback(()=>{var ve;(ve=Nt.current)==null||ve.abort(),Ae(!1)},[]),za=p.useCallback(()=>{pe(null),je(null)},[]),Wn=p.useCallback(async()=>{var fn,ai;if(pe(null),je(null),Oe([]),ht.current=null,Dt.current=null,!ye.trim()){pe("Describe what your skill should do");return}Ae(!0);const ve=new AbortController;Nt.current=ve;const{provider:Re,model:dn}=gt();try{const qn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(jE({prompt:ye.trim(),provider:Re,model:dn,targetAgents:q})),signal:ve.signal});if(!qn.ok||!qn.body){let pr=`HTTP ${qn.status}`;try{const mr=await qn.json();mr.error&&(pr=mr.error)}catch{}throw new Error(pr)}const Bl=qn.body.getReader(),fr=new TextDecoder;let Il="",ta="";for(;;){const{done:pr,value:mr}=await Bl.read();if(pr)break;Il+=fr.decode(mr,{stream:!0});const Pr=Il.split(`
86
- `);Il=Pr.pop()||"";for(const Da of Pr)if(Da.startsWith("event: "))ta=Da.slice(7).trim();else if(Da.startsWith("data: ")){try{const it=JSON.parse(Da.slice(6));if(ta==="progress")Oe(hr=>[...hr,{phase:it.phase,message:it.message,timestamp:Date.now()}]);else if(ta==="provenance")Dt.current={resolvedModelId:typeof it.resolvedModelId=="string"?it.resolvedModelId:null,snapshotDate:typeof it.snapshotDate=="string"?it.snapshotDate:null};else if(ta==="done"||ta==="complete"){const hr={prompt:ye.trim(),provider:gt().provider,model:gt().model,resolvedModelId:((fn=Dt.current)==null?void 0:fn.resolvedModelId)??null,snapshotDate:((ai=Dt.current)==null?void 0:ai.snapshotDate)??null,reasoning:it.reasoning||""},rn=SE({userName:Ct.current,userPlugin:Yt.current,userNewPlugin:un.current,aiName:it.name,aiSuggestedPlugin:it.suggestedPlugin&&it.suggestedPlugin.plugin?{plugin:it.suggestedPlugin.plugin,layout:it.suggestedPlugin.layout}:null,forceLayout:s});if(rn.applyName!==null&&v(rn.applyName),L(it.description),D(it.model||""),E(it.allowedTools||""),z(it.body),re(!0),ht.current=hr,c("manual"),s===3)S(3),w(""),N("");else if(rn.applySuggestedPlugin&&rn.suggestedPluginValue){const ot=rn.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(na=>na.existingPlugins))??[]).includes(ot.plugin))if(w(ot.plugin),ot.layout&&(ot.layout===1||ot.layout===2))S(ot.layout);else{const na=u==null?void 0:u.detectedLayouts.find(Jo=>Jo.existingPlugins.includes(ot.plugin));na&&(na.layout===1||na.layout===2)&&S(na.layout)}else w("__new__"),N(ot.plugin)}else!rn.applySuggestedPlugin&&Yt.current.trim().length===0&&un.current.trim().length===0&&b===3&&xt&&pt(!0);const Ut={name:it.name,plugin:an||"",layout:b,description:it.description,model:it.model||void 0,allowedTools:it.allowedTools||void 0,body:it.body,aiMeta:hr};Ce.saveDraft(Ut).then(ot=>{tt(!0),ot!=null&&ot.dir&&(Tt.current=ot.dir)}).catch(()=>{})}else ta==="error"&&(pe(it.message||it.description||"Unknown error"),it.category&&je(it))}catch{}ta=""}}}catch(qn){qn.name!=="AbortError"&&pe(qn.message)}finally{Ae(!1),Nt.current=null}},[ye,gt,b,xt,an,u,q,s]),Et=p.useCallback(async()=>{if(_(null),!y.trim()){_("Skill name is required");return}if(!R.trim()){_("Description is required");return}if(b!==3&&!an.trim()){_("Plugin name is required");return}if(!te){_("Version is not valid semver");return}$(!0);try{const ve=await Ce.createSkill({name:uf(y),plugin:an||"",layout:b,description:R,model:B||void 0,allowedTools:F||void 0,body:H,aiMeta:ht.current||void 0,draftDir:Tt.current||void 0,version:Y.trim()||void 0,engine:se});Tt.current=null,t(ve.plugin,ve.skill)}catch(ve){_(ve.message)}finally{$(!1)}},[y,R,b,an,B,F,H,Y,te,se,t]),ce=p.useCallback(()=>{xt&&(S(xt.layout),w(xt.plugins[0]),pt(!1))},[xt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Mt,availablePlugins:Gt,pathPreview:Mn,plugin:k,setPlugin:w,newPlugin:C,setNewPlugin:N,effectivePlugin:an,name:y,setName:v,description:R,setDescription:L,model:B,setModel:D,allowedTools:F,setAllowedTools:E,body:H,setBody:z,bodyViewMode:I,setBodyViewMode:U,aiPrompt:ye,setAiPrompt:de,generating:Se,aiGenerated:_e,aiError:he,aiClassifiedError:xe,aiProgress:Be,promptRef:rt,handleGenerate:Wn,handleCancelGenerate:da,clearAiError:za,targetAgents:q,setTargetAgents:X,draftSaved:Qe,showPluginRecommendation:be,setShowPluginRecommendation:pt,pluginLayoutInfo:xt,applyPluginRecommendation:ce,creating:J,error:M,handleCreate:Et,engineDetection:O,refreshEngineDetection:ie,engine:se,setEngine:A,version:Y,setVersion:W,versionValid:te,setVersionValid:fe,standaloneLocked:s===3}}function Ly(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.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"})})}function CE(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function zy({node:t,depth:r=0}){var s;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?a.jsx(Ly,{}):a.jsx(CE,{}),a.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>a.jsx(zy,{node:o,depth:r+1},o.name))]})}function EE(t,r,s){const o=[];r&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function NE({skillName:t,hasEvals:r,isDraft:s}){const o=EE(t,r,s);return a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsx(Ly,{})}),"Skill Structure"]}),a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:a.jsx(zy,{node:o})})]})}const lr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Bd({size:t=14,color:r="currentColor"}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function TE({onCreated:t,onCancel:r}){const s=wE({onCreated:t});return a.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[a.jsxs("div",{className:"mb-5",children:[a.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),a.jsx("div",{className:"flex items-center justify-between mt-2",children:a.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Bd,{size:12}),"AI-Assisted"]})}),a.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsx(Bd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),a.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
85
+ !Write me a poem about flowers`}),a.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:"One prompt per line"}),a.jsx(So,{}),a.jsx("span",{children:"No prefix = auto-classify"}),a.jsx(So,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),a.jsx(So,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),a.jsx(So,{}),a.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[H," prompt",H!==1?"s":""]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:z,disabled:y||!A.trim(),className:"btn btn-primary",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("circle",{cx:"12",cy:"12",r:"6"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${H} prompts tested`,b&&a.jsx(XC,{startedAt:b})]})]})]})]}),a.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:J?a.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:L}}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&a.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[a.jsx("div",{className:"spinner-lg mx-auto mb-4"}),a.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&a.jsxs("div",{className:"space-y-5",children:[X.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),a.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((I,V)=>a.jsx(Fg,{result:I},`incorrect-${V}`))})]}),q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"16 10 11 15 8 12"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((I,V)=>a.jsx(Fg,{result:I},`correct-${V}`))})]})]}),p&&a.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),p.autoClassifiedCount!=null&&p.autoClassifiedCount>0&&a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[p.autoClassifiedCount," of ",p.total," prompts auto-classified from skill name and tags"]}),a.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[a.jsx(Dd,{label:"Precision",value:p.precision,description:"Of all activations, how many were correct?",detail:`${p.tp} true / ${p.tp+p.fp} total activations`}),a.jsx(Dd,{label:"Recall",value:p.recall,description:"Of expected activations, how many fired?",detail:`${p.tp} activated / ${p.tp+p.fn} expected`}),a.jsx(Dd,{label:"Reliability",value:p.reliability,description:"Overall correct classification rate",detail:`${p.tp+p.tn} correct / ${p.total} total`})]}),a.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[a.jsx(ko,{label:"True Positive",abbr:"TP",count:p.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),a.jsx(ko,{label:"False Positive",abbr:"FP",count:p.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),a.jsx(ko,{label:"False Negative",abbr:"FN",count:p.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),a.jsx(ko,{label:"True Negative",abbr:"TN",count:p.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),a.jsx(qC,{history:C,expanded:w,onToggle:()=>O(!w),skillVersion:T})]})}function qC({history:t,expanded:r,onToggle:s,skillVersion:o}){return t===null?null:a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:s,children:[a.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&a.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&a.jsx("div",{className:"px-4 py-3",children:t.length===0?a.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):a.jsx("div",{className:"space-y-2",children:t.map(c=>a.jsx(YC,{run:c,skillVersion:o},c.id))})})]})}function YC({run:t,skillVersion:r}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:KC(t.timestamp)}),a.jsx(ei,{version:r??null,size:"sm","data-testid":"activation-row-version"}),a.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),a.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function KC(t){const r=Date.now(),s=new Date(t).getTime(),o=Math.floor((r-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function So(){return a.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Fg({result:t}){const r=Pg[t.classification]||Pg.FN,s=t.classification==="TP"||t.classification==="TN";return a.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:r.bg,border:"1px solid transparent"},children:[a.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${r.text} 20%, transparent)`},children:s?a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),a.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[a.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:r.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),a.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&a.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&a.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Dd({label:t,value:r,description:s,detail:o}){const c=Math.round(r*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),a.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),a.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),a.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function ko({abbr:t,count:r,bg:s,color:o,description:c}){return a.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[a.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:r}),a.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),a.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function XC({startedAt:t}){const[r,s]=m.useState(0);return m.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),a.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}const _d={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Gg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},of=600,cf=180,sn=40,Od=of-sn*2,rr=cf-sn*2,QC=[25,50,75,100];function Wg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ZC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function JC({entries:t,onPointClick:r}){const[s,o]=m.useState(null),c=m.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((p,y)=>{const v=sn+y/(u-1)*Od,b=p.passRate*100,S=sn+rr-b/100*rr;return{x:v,y:S,pct:b,entry:p}}),h=d.map(p=>`${p.x},${p.y}`).join(" "),g=Array.from(new Set(c.map(p=>p.type)));return a.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[a.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),a.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(p=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:_d[p]??"var(--text-tertiary)"}}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Gg[p]??p})]},p))}),a.jsxs("svg",{width:of,height:cf,viewBox:`0 0 ${of} ${cf}`,style:{display:"block",overflow:"visible"},children:[QC.map(p=>{const y=sn+rr-p/100*rr;return a.jsxs("g",{children:[a.jsx("line",{x1:sn,y1:y,x2:sn+Od,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),a.jsxs("text",{x:sn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[p,"%"]})]},p)}),a.jsx("line",{x1:sn,y1:sn+rr,x2:sn+Od,y2:sn+rr,stroke:"var(--border-subtle)",strokeWidth:1}),a.jsx("text",{x:sn-8,y:sn+rr+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),a.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((p,y)=>a.jsx("circle",{cx:p.x,cy:p.y,r:5,fill:_d[p.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:p.x,y:p.y,entry:p.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>r==null?void 0:r(p.entry)},y)),eE(u).map(p=>a.jsx("text",{x:d[p].x,y:sn+rr+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Wg(c[p].timestamp)},p))]}),s&&a.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Wg(s.entry.timestamp)}),a.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:_d[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Gg[s.entry.type]??s.entry.type}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),a.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:ZC(s.entry.totalDurationMs)}),a.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function eE(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const r=Math.ceil(t/10),s=[0];for(let o=r;o<t-1;o+=r)s.push(o);return s.push(t-1),s}const _s=new Map;let on=null,zo=null,wo=1e3,Tl=0;function Ay(){if(on)return;on=new EventSource("/api/events");const t=r=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=_s.get(r);if(c)for(const u of c)u(o)};on.addEventListener("benchmark:complete",t("benchmark:complete")),on.addEventListener("history:written",t("history:written")),on.addEventListener("leaderboard:updated",t("leaderboard:updated")),on.onerror=()=>{on==null||on.close(),on=null,Tl>0&&(zo=setTimeout(()=>{wo=Math.min(wo*2,3e4),Ay()},wo))},on.onopen=()=>{wo=1e3}}function tE(){zo!=null&&(clearTimeout(zo),zo=null),on==null||on.close(),on=null}function nE(t,r){return _s.has(t)||_s.set(t,new Set),_s.get(t).add(r),Tl++,Ay(),()=>{var s;(s=_s.get(t))==null||s.delete(r),Tl--,Tl<=0&&(Tl=0,queueMicrotask(()=>{Tl<=0&&tE()}))}}function Uo(t,r){const s=m.useRef(r);s.current=r,m.useEffect(()=>nE(t,c=>s.current(c)),[t])}function Ho(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function aE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function rE({rate:t,label:r}){const s=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:Ho(t)},children:[s,"%"]})]}),a.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:Ho(t)}})})]})})}function lE({points:t}){if(t.length<2)return null;const r=200,s=48,o=4,c=t.length,u=t.map((g,p)=>{const y=o+p/(c-1)*(r-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,p)=>`${p===0?"M":"L"} ${g.x},${g.y}`).join(" ");return a.jsxs("svg",{width:r,height:s,style:{display:"block"},children:[a.jsx("path",{d,fill:"var(--accent-muted)"}),a.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),a.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function sE({plugin:t,skill:r}){const s=`stats/${t}/${r}`,o=m.useCallback(()=>Ce.getStats(t,r),[t,r]),{data:c,loading:u}=ti(s,o),d=m.useCallback(()=>Tn(s),[s]);if(Uo("benchmark:complete",d),Uo("history:written",d),u)return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"skeleton h-24 rounded-xl"}),a.jsx("div",{className:"skeleton h-48 rounded-xl"}),a.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),a.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,p=h-g,y=c.assertionStats.slice(0,10);return a.jsxs("div",{className:"space-y-4 stagger-children",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:Ho(h)},children:[Math.round(h*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:p>=0?"var(--green)":"var(--red)"},children:[p>=0?"+":"",Math.round(p*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.totalCost)})]}),c.costPerRun!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),a.jsx(lE,{points:c.trendPoints})]}),c.modelStats.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),a.jsx("tbody",{children:c.modelStats.map(v=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),a.jsx("td",{style:{padding:"8px",textAlign:"center"},children:a.jsxs("span",{className:"font-semibold",style:{color:Ho(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:aE(v.avgDurationMs)}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Rn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),a.jsx("div",{className:"space-y-3",children:y.map(v=>a.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),a.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),a.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),a.jsx(rE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function iE({plugin:t,skill:r}){const[s,o]=m.useState(null),[c,u]=m.useState(null),[d,h]=m.useState({}),[g,p]=m.useState({});m.useEffect(()=>{Ce.getEvals(t,r).then(o).catch(()=>o(null))},[t,r]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){p(b=>({...b,[v]:!0}));try{const b=await Ce.getCaseHistory(t,r,v);h(S=>({...S,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{p(b=>({...b,[v]:!1}))}}}return s?a.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],S=c===v.id,k=g[v.id],E=b.length>0?b[0].pass_rate:null;return a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:C=>{S||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{S||(C.currentTarget.style.background="transparent")},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),a.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),a.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&a.jsx(Cy,{entries:b}),E!=null&&a.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Ll(E)},children:[Math.round(E*100),"%"]}),b.length>0&&a.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&a.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?a.jsxs("div",{className:"p-4 flex items-center gap-2",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):a.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,N)=>a.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:ky(C.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ll(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&a.jsx("span",{children:wy(C.durationMs)}),C.tokens!=null&&a.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),a.jsx("div",{className:"space-y-1",children:C.assertions.map(T=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:T.pass?"var(--green)":"var(--red)"},children:a.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:T.pass?a.jsx("polyline",{points:"20 6 9 17 4 12"}):a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:T.text}),T.reasoning&&a.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:T.reasoning})]})]},T.id))})]},N))})})]},v.id)})}):a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function oE(){const{state:t,dispatch:r}=An(),{plugin:s,skill:o}=t,{state:c}=ea(),u=c.skills.find(I=>I.plugin===s&&I.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=m.useState("timeline"),[p,y]=m.useState(""),[v,b]=m.useState(""),[S,k]=m.useState(!1),[E,C]=m.useState([]),[N,T]=m.useState(null),[A,B]=m.useState(!1),[D,F]=m.useState(null),[w,O]=m.useState(!1),z=`history/${s}/${o}?model=${p}&type=${v}`,U=m.useCallback(()=>Ce.getHistory(s,o,{model:p||void 0,type:v||void 0}),[s,o,p,v]),{data:H,loading:q}=ti(z,U),X=H??[];m.useEffect(()=>{!H||H.length<2||Ce.compareRuns(s,o,H[0].timestamp,H[1].timestamp).then(I=>{const V=I.regressions.filter(se=>se.change==="regression");r({type:"SET_REGRESSIONS",regressions:V})}).catch(()=>{})},[H,s,o,r]);const J=m.useCallback(()=>Tn(z),[z]);Uo("history:written",J);const $=m.useCallback(async I=>{if(S){C(V=>V.includes(I)?V.filter(se=>se!==I):V.length>=2?[V[1],I]:[...V,I]);return}O(!0);try{const V=await Ce.getHistoryEntry(s,o,I);F(V)}catch{}finally{O(!1)}},[s,o,S]),L=m.useCallback(async()=>{if(E.length===2){B(!0);try{const I=await Ce.compareRuns(s,o,E[0],E[1]);T(I)}catch{}finally{B(!1)}}},[s,o,E]),_=[...new Set(X.map(I=>I.model))];return q?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"skeleton h-12 rounded-lg"}),a.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(I=>a.jsx("button",{onClick:()=>g(I),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===I?"var(--accent-muted)":"transparent",color:h===I?"var(--accent)":"var(--text-tertiary)"},children:I==="timeline"?"Timeline":I==="per-eval"?"Per Eval":"Statistics"},I))}),h==="timeline"&&a.jsxs("div",{children:[X.length>0&&a.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:a.jsx(JC,{entries:X,onPointClick:I=>$(I.timestamp)})}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("select",{value:p,onChange:I=>y(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Models"}),_.map(I=>a.jsx("option",{value:I,children:I},I))]}),a.jsxs("select",{value:v,onChange:I=>b(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Types"}),a.jsx("option",{value:"benchmark",children:"Benchmark"}),a.jsx("option",{value:"comparison",children:"Comparison"}),a.jsx("option",{value:"baseline",children:"Baseline"}),a.jsx("option",{value:"model-compare",children:"Model Compare"}),a.jsx("option",{value:"improve",children:"AI Improve"}),a.jsx("option",{value:"instruct",children:"AI Edit"}),a.jsx("option",{value:"ai-generate",children:"AI Generate"}),a.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{onClick:()=>{k(!S),C([]),T(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&E.length===2&&a.jsx("button",{onClick:L,disabled:A,className:"btn btn-primary text-[12px]",children:A?"Comparing...":"Compare"})]}),a.jsx("div",{className:"space-y-2",children:X.length===0?a.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(I=>{const V=E.includes(I.timestamp);return a.jsx("button",{onClick:()=>$(I.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:V?"var(--accent-muted)":"var(--surface-1)",border:V?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:se=>{V||(se.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:se=>{V||(se.currentTarget.style.borderColor="var(--border-subtle)")},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:V?"var(--accent)":"var(--border-default)",background:V?"var(--accent)":"transparent"},children:V&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(I.timestamp).toLocaleString()}),a.jsx("span",{className:"pill text-[9px]",style:{background:I.type==="comparison"?"var(--purple-muted)":I.type==="baseline"?"var(--surface-3)":I.type==="model-compare"?"var(--accent-muted)":I.type==="improve"||I.type==="instruct"?"var(--purple-muted)":I.type==="ai-generate"?"var(--green-muted)":I.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:I.type==="comparison"?"var(--purple)":I.type==="baseline"?"var(--text-tertiary)":I.type==="model-compare"?"var(--accent)":I.type==="improve"||I.type==="instruct"?"var(--purple)":I.type==="ai-generate"?"var(--green)":I.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:I.type==="model-compare"?"model compare":I.type==="improve"?"ai improve":I.type==="instruct"?"ai edit":I.type==="ai-generate"?"ai generate":I.type==="eval-generate"?"eval generate":I.type})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ei,{version:d,size:"sm","data-testid":"history-row-version"}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:I.model}),I.totalCost!=null&&I.totalCost>0&&a.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(I.totalCost)}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:I.passRate>=.8?"var(--green)":I.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(I.passRate*100),"%"]})]})]})},I.timestamp)})}),N&&a.jsx(cE,{result:N}),D&&!S&&a.jsx(uE,{run:D,onClose:()=>F(null)})]}),h==="per-eval"&&a.jsx(iE,{plugin:s,skill:o}),h==="statistics"&&a.jsx(sE,{plugin:s,skill:o})]})}function cE({result:t}){const r=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[a.jsxs("span",{children:["Run A cost: ",Rn(t.runA.totalCost??null)]}),a.jsxs("span",{children:["Run B cost: ",Rn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&a.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Rn(t.runB.totalCost-t.runA.totalCost)]})]}),r.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),a.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:a.jsxs("table",{className:"w-full text-[12px]",children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"var(--surface-2)"},children:[a.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),a.jsx("tbody",{children:t.caseDiffs.map(o=>a.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function uE({run:t,onClose:r}){return(t.type==="improve"||t.type==="instruct")&&t.improve?a.jsx(dE,{run:t,onClose:r}):a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),a.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Rn(t.totalCost)}`]}),a.jsx("div",{className:"space-y-2",children:t.cases.map(s=>a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&a.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(s.cost)}),a.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function dE({run:t,onClose:r}){var u;const s=m.useMemo(()=>t.improve?Qo(t.improve.original,t.improve.improved):[],[t.improve]),o=m.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=m.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return a.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),a.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),a.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&a.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:c.map((d,h)=>a.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function My({data:t}){if(t.length<2)return a.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=r.length,g=Math.min(...r),y=Math.max(...r)-g||1,v=r.map((k,E)=>{const C=c+E/(h-1)*u,N=c+d-(k-g)/y*d;return`${C.toFixed(1)},${N.toFixed(1)}`}),b=r[r.length-1],S=Ll(b);return a.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[a.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,E]=v[v.length-1].split(",");return a.jsx("circle",{cx:k,cy:E,r:2.5,fill:S})})()]})}function fE(){return a.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function pE({pct:t}){const r=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return a.jsxs("span",{className:"pill",style:{background:s,color:r,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function mE({score:t,rating:r}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[r]??s.minimal,c=t>=0?"+":"";return a.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),a.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function hE({warning:t}){return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10.29 3.86L1.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"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function xE({active:t,onChange:r,hasBaseline:s}){return a.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[a.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),a.jsx("button",{onClick:()=>r("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function gE(t){var o,c,u;if(t.length===0)return[];const r=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;r.has(g)||r.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const p=r.get(g);p.passRates.push(h.passRate.mean),p.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,p.lastDuration=h.duration.mean,p.lastCost=((c=h.cost)==null?void 0:c.total)??null,p.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(p.lastBaselinePassRate=h.baselinePassRate.mean,p.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,p.lastAmplificationPct=h.amplificationPct,p.hasBaseline=!0)}const s=[];for(const[d,h]of r){const[g,...p]=d.split("/");s.push({rank:0,model:p.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Ly=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function vE({entries:t}){return a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>a.jsx("th",{style:Ly(r==="#"?"center":"left"),children:r},r))})}),a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&a.jsx(fE,{})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ll(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(My,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function yE({entries:t}){const r=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return r.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",a.jsx("code",{children:"--baseline"})," flag."]})})}):a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>a.jsx("th",{style:Ly(s==="#"?"center":"left"),children:s},s))})}),a.jsx("tbody",{children:r.map((s,o)=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ll(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?a.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?a.jsx(pE,{pct:s.amplificationPct}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(My,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function bE(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=m.useState("rankings"),u=`leaderboard/${r}/${s}`,d=m.useCallback(()=>Ce.getLeaderboard(r,s),[r,s]),{data:h,loading:g}=ti(u,d),p=(h==null?void 0:h.entries)??[];m.useEffect(()=>{c("rankings")},[r,s]);const y=m.useCallback(()=>Tn(u),[u]);Uo("leaderboard:updated",y);const v=m.useMemo(()=>gE(p),[p]),b=v.some(E=>E.hasBaseline),S=p[0],k=S==null?void 0:S.judgeBiasWarning;return g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),a.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),a.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),a.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",a.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),a.jsx(xE,{active:o,onChange:c,hasBaseline:b})]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&a.jsx(hE,{warning:k}),o==="rankings"?a.jsx(vE,{entries:v}):a.jsx(yE,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&a.jsx(mE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function jE({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState([]),[d,h]=m.useState(!0),[g,p]=m.useState(null);m.useEffect(()=>{Ce.getDependencies(t,r).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,r]);async function y(v,b){try{await navigator.clipboard.writeText(b),p(v),setTimeout(()=>p(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?a.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),a.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>a.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),a.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),a.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>a.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),a.jsx("div",{className:"space-y-1.5",children:c.map(v=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function qg({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState(!0),[d,h]=m.useState(null),[g,p]=m.useState(""),[y,v]=m.useState(!1),[b,S]=m.useState(null),[k,E]=m.useState(""),[C,N]=m.useState(""),[T,A]=m.useState(!1),[B,D]=m.useState(new Set),F=m.useCallback(async()=>{u(!0);try{const[U,H]=await Promise.all([Ce.getCredentials(t,r).catch(()=>({credentials:[]})),Ce.getParams(t,r).catch(()=>({params:[]}))]),q=new Map(H.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of U.credentials){X.add($.name);const L=q.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:L==null?void 0:L.maskedValue})}for(const $ of H.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});o(J)}finally{u(!1)}},[t,r]);m.useEffect(()=>{F()},[F]);const w=m.useCallback(async U=>{if(B.has(U)){D(H=>{const q=new Set(H);return q.delete(U),q}),o(H=>H.map(q=>q.name===U?{...q,revealedValue:void 0}:q));return}try{const q=(await Ce.getParamsRevealed(t,r,U)).params.find(X=>X.name===U);q&&(o(X=>X.map(J=>J.name===U?{...J,revealedValue:q.value}:J)),D(X=>new Set(X).add(U)))}catch{}},[t,r,B]),O=async(U,H)=>{if(!(!U.trim()||!H.trim())){v(!0),S(null);try{await Ce.setCredential(t,r,U,H),h(null),p(""),D(new Set),F()}catch(q){S(q.message)}finally{v(!1)}}},z=async()=>{if(!(!k.trim()||!C.trim())){v(!0),S(null);try{await Ce.setCredential(t,r,k.trim().toUpperCase(),C),E(""),N(""),A(!1),F()}catch(U){S(U.message)}finally{v(!1)}}};return c?a.jsxs("div",{className:"mt-6",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):a.jsxs("div",{className:"mt-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("button",{onClick:()=>A(!T),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&a.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!T?a.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):a.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(U=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:U.name}),U.maskedValue&&a.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(U.name)&&U.revealedValue!=null?U.revealedValue:U.maskedValue}),U.maskedValue&&a.jsx("button",{onClick:()=>w(U.name),className:"btn btn-ghost px-1",title:B.has(U.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(U.name)?a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),a.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:U.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:U.status==="ready"?"var(--green)":"var(--orange)"},children:U.status==="ready"?"ready":"missing"}),U.source&&a.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:U.source}),d===U.name?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("input",{value:g,onChange:H=>p(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(U.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),a.jsx("button",{onClick:()=>O(U.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),a.jsx("button",{onClick:()=>{h(null),p("")},className:"btn btn-ghost text-[10px] px-1",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):a.jsx("button",{onClick:()=>{h(U.name),p("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},U.name))}),T&&a.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:k,onChange:U=>E(U.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),a.jsx("input",{value:C,onChange:U=>N(U.target.value),onKeyDown:U=>{U.key==="Enter"&&z()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx("button",{onClick:()=>{A(!1),E(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),a.jsx("button",{onClick:z,disabled:y||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function SE(){const{state:t}=An(),{plugin:r,skill:s}=t,[o,c]=m.useState(null),[u,d]=m.useState(!0);return m.useEffect(()=>{Ce.getDependencies(r,s).then(c).catch(()=>{}).finally(()=>d(!1))},[r,s]),u?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx(jE,{plugin:r,skill:s}),a.jsx(qg,{plugin:r,skill:s})]}):a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),a.jsx(qg,{plugin:r,skill:s})]})}function kE(t){const r={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(r.targetAgents=t.targetAgents),r}function wE(t){var c;const r=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:r?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function uf(t,r=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(s=s.replace(/^-+|-+$/g,"")),s}function CE(t,r,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function EE({onCreated:t,resolveAiConfigOverride:r,forceLayout:s}){const[o,c]=m.useState("ai"),[u,d]=m.useState(null),[h,g]=m.useState(!0),{config:p}=Hr(),[y,v]=m.useState(""),[b,S]=m.useState(s??3),[k,E]=m.useState(""),[C,N]=m.useState(""),[T,A]=m.useState(""),[B,D]=m.useState(""),[F,w]=m.useState(""),[O,z]=m.useState(""),[U,H]=m.useState("write"),[q,X]=m.useState([]),[J,$]=m.useState(!1),[L,_]=m.useState(null),[I,V]=m.useState(null),[se,M]=m.useState("vskill"),[Y,W]=m.useState("1.0.0"),[te,fe]=m.useState(!0),ie=m.useCallback(async()=>{try{const xe=await Ce.detectEngines();V(xe),M(Ee=>Ee!=="vskill"?Ee:xe.vskillSkillBuilder?"vskill":xe.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{V({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);m.useEffect(()=>{ie()},[ie]);const[ye,de]=m.useState(""),[Se,Ae]=m.useState(!1),[_e,re]=m.useState(!1),[he,pe]=m.useState(null),[ge,je]=m.useState(null),[Be,Oe]=m.useState([]),rt=m.useRef(null),Nt=m.useRef(null),ht=m.useRef(null),Dt=m.useRef(null),Tt=m.useRef(null),[Qe,tt]=m.useState(!1),[be,pt]=m.useState(!1),Ct=m.useRef(y),Yt=m.useRef(k),un=m.useRef(C);m.useEffect(()=>{Ct.current=y},[y]),m.useEffect(()=>{Yt.current=k},[k]),m.useEffect(()=>{un.current=C},[C]),m.useEffect(()=>{Ce.getProjectLayout().then(xe=>{if(d(xe),s)return;S(xe.suggestedLayout);const Ee=xe.detectedLayouts.find(dn=>dn.layout===xe.suggestedLayout);Ee!=null&&Ee.existingPlugins.length&&E(Ee.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),m.useEffect(()=>{var xe;o==="ai"&&((xe=rt.current)==null||xe.focus())},[o]),m.useEffect(()=>()=>{var xe;(xe=Nt.current)==null||xe.abort()},[]);const Gt=m.useMemo(()=>{var xe;return u?((xe=u.detectedLayouts.find(Ee=>Ee.layout===b))==null?void 0:xe.existingPlugins)||[]:[]},[u,b]),an=k==="__new__"?C:k,Mn=u?CE(u.root,b,an||"{plugin}",y||"{skill}"):"",Mt=m.useMemo(()=>u?u.detectedLayouts.filter(xe=>xe.layout!==4):[],[u]),xt=m.useMemo(()=>{if(!u)return null;const xe=u.detectedLayouts.find(fn=>fn.layout===2&&fn.existingPlugins.length>0),Ee=u.detectedLayouts.find(fn=>fn.layout===1&&fn.existingPlugins.length>0),dn=xe||Ee;return dn?{layout:dn.layout,plugins:dn.existingPlugins}:null},[u]),gt=m.useCallback(()=>{if(r)return r();if(!p)return{provider:"claude-cli",model:"sonnet"};const xe=p.provider||"claude-cli",Ee=p.model||"sonnet";return{provider:xe,model:Ee}},[p,r]),da=m.useCallback(()=>{var xe;(xe=Nt.current)==null||xe.abort(),Ae(!1)},[]),za=m.useCallback(()=>{pe(null),je(null)},[]),Wn=m.useCallback(async()=>{var fn,ai;if(pe(null),je(null),Oe([]),ht.current=null,Dt.current=null,!ye.trim()){pe("Describe what your skill should do");return}Ae(!0);const xe=new AbortController;Nt.current=xe;const{provider:Ee,model:dn}=gt();try{const qn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(kE({prompt:ye.trim(),provider:Ee,model:dn,targetAgents:q})),signal:xe.signal});if(!qn.ok||!qn.body){let pr=`HTTP ${qn.status}`;try{const mr=await qn.json();mr.error&&(pr=mr.error)}catch{}throw new Error(pr)}const Bl=qn.body.getReader(),fr=new TextDecoder;let Il="",ta="";for(;;){const{done:pr,value:mr}=await Bl.read();if(pr)break;Il+=fr.decode(mr,{stream:!0});const Pr=Il.split(`
86
+ `);Il=Pr.pop()||"";for(const Da of Pr)if(Da.startsWith("event: "))ta=Da.slice(7).trim();else if(Da.startsWith("data: ")){try{const it=JSON.parse(Da.slice(6));if(ta==="progress")Oe(hr=>[...hr,{phase:it.phase,message:it.message,timestamp:Date.now()}]);else if(ta==="provenance")Dt.current={resolvedModelId:typeof it.resolvedModelId=="string"?it.resolvedModelId:null,snapshotDate:typeof it.snapshotDate=="string"?it.snapshotDate:null};else if(ta==="done"||ta==="complete"){const hr={prompt:ye.trim(),provider:gt().provider,model:gt().model,resolvedModelId:((fn=Dt.current)==null?void 0:fn.resolvedModelId)??null,snapshotDate:((ai=Dt.current)==null?void 0:ai.snapshotDate)??null,reasoning:it.reasoning||""},rn=wE({userName:Ct.current,userPlugin:Yt.current,userNewPlugin:un.current,aiName:it.name,aiSuggestedPlugin:it.suggestedPlugin&&it.suggestedPlugin.plugin?{plugin:it.suggestedPlugin.plugin,layout:it.suggestedPlugin.layout}:null,forceLayout:s});if(rn.applyName!==null&&v(rn.applyName),A(it.description),D(it.model||""),w(it.allowedTools||""),z(it.body),re(!0),ht.current=hr,c("manual"),s===3)S(3),E(""),N("");else if(rn.applySuggestedPlugin&&rn.suggestedPluginValue){const ot=rn.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(na=>na.existingPlugins))??[]).includes(ot.plugin))if(E(ot.plugin),ot.layout&&(ot.layout===1||ot.layout===2))S(ot.layout);else{const na=u==null?void 0:u.detectedLayouts.find(Jo=>Jo.existingPlugins.includes(ot.plugin));na&&(na.layout===1||na.layout===2)&&S(na.layout)}else E("__new__"),N(ot.plugin)}else!rn.applySuggestedPlugin&&Yt.current.trim().length===0&&un.current.trim().length===0&&b===3&&xt&&pt(!0);const Ht={name:it.name,plugin:an||"",layout:b,description:it.description,model:it.model||void 0,allowedTools:it.allowedTools||void 0,body:it.body,aiMeta:hr};Ce.saveDraft(Ht).then(ot=>{tt(!0),ot!=null&&ot.dir&&(Tt.current=ot.dir)}).catch(()=>{})}else ta==="error"&&(pe(it.message||it.description||"Unknown error"),it.category&&je(it))}catch{}ta=""}}}catch(qn){qn.name!=="AbortError"&&pe(qn.message)}finally{Ae(!1),Nt.current=null}},[ye,gt,b,xt,an,u,q,s]),Et=m.useCallback(async()=>{if(_(null),!y.trim()){_("Skill name is required");return}if(!T.trim()){_("Description is required");return}if(b!==3&&!an.trim()){_("Plugin name is required");return}if(!te){_("Version is not valid semver");return}$(!0);try{const xe=await Ce.createSkill({name:uf(y),plugin:an||"",layout:b,description:T,model:B||void 0,allowedTools:F||void 0,body:O,aiMeta:ht.current||void 0,draftDir:Tt.current||void 0,version:Y.trim()||void 0,engine:se});Tt.current=null,t(xe.plugin,xe.skill)}catch(xe){_(xe.message)}finally{$(!1)}},[y,T,b,an,B,F,O,Y,te,se,t]),oe=m.useCallback(()=>{xt&&(S(xt.layout),E(xt.plugins[0]),pt(!1))},[xt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Mt,availablePlugins:Gt,pathPreview:Mn,plugin:k,setPlugin:E,newPlugin:C,setNewPlugin:N,effectivePlugin:an,name:y,setName:v,description:T,setDescription:A,model:B,setModel:D,allowedTools:F,setAllowedTools:w,body:O,setBody:z,bodyViewMode:U,setBodyViewMode:H,aiPrompt:ye,setAiPrompt:de,generating:Se,aiGenerated:_e,aiError:he,aiClassifiedError:ge,aiProgress:Be,promptRef:rt,handleGenerate:Wn,handleCancelGenerate:da,clearAiError:za,targetAgents:q,setTargetAgents:X,draftSaved:Qe,showPluginRecommendation:be,setShowPluginRecommendation:pt,pluginLayoutInfo:xt,applyPluginRecommendation:oe,creating:J,error:L,handleCreate:Et,engineDetection:I,refreshEngineDetection:ie,engine:se,setEngine:M,version:Y,setVersion:W,versionValid:te,setVersionValid:fe,standaloneLocked:s===3}}function zy(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.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"})})}function NE(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Dy({node:t,depth:r=0}){var s;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?a.jsx(zy,{}):a.jsx(NE,{}),a.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>a.jsx(Dy,{node:o,depth:r+1},o.name))]})}function TE(t,r,s){const o=[];r&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function RE({skillName:t,hasEvals:r,isDraft:s}){const o=TE(t,r,s);return a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsx(zy,{})}),"Skill Structure"]}),a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:a.jsx(Dy,{node:o})})]})}const lr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Bd({size:t=14,color:r="currentColor"}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function AE({onCreated:t,onCancel:r}){const s=EE({onCreated:t});return a.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[a.jsxs("div",{className:"mb-5",children:[a.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),a.jsx("div",{className:"flex items-center justify-between mt-2",children:a.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Bd,{size:12}),"AI-Assisted"]})}),a.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsx(Bd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),a.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
87
87
 
88
88
  Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...lr,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),a.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&a.jsx(ni,{entries:s.aiProgress,isRunning:!0}),s.aiError&&a.jsx("div",{children:s.aiClassifiedError?a.jsx(Zo,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):a.jsxs("div",{children:[a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),a.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?a.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):a.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[a.jsx(Bd,{size:14}),"Generate"]}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",a.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),a.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>a.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),a.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr,children:[s.availablePlugins.map(o=>a.jsx("option",{value:o,children:o},o)),a.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&a.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(uf(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:lr})]}),a.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&a.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),a.jsxs("span",{children:["Plugins detected (",a.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),a.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(uf(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr})]}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...lr,minHeight:"72px"}})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"opus",children:"Opus"}),a.jsx("option",{value:"sonnet",children:"Sonnet"}),a.jsx("option",{value:"haiku",children:"Haiku"})]})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),a.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr})]})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),a.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>a.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]}):a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?a.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
89
89
 
90
90
  You are an expert at...
91
- `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...lr,minHeight:"150px"}}):s.body.trim()?a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Xo(s.body)}}):a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),a.jsx(NE,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function RE(){return a.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),a.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),a.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function Do({variant:t,message:r,onRetry:s}){const{setMode:o,setSearch:c}=ea(),[u,d]=p.useState(!1);return t==="no-selection"?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[a.jsx("div",{className:"mb-5",children:u?a.jsx(RE,{}):a.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),a.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?a.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[a.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:a.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),a.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),a.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",a.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),a.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?a.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:a.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[a.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:r||"Failed to load skill data"}),s&&a.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):a.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[a.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),a.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function AE(t,r){const[s,o]=t.split(".").map(Number),[c,u]=r.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const ME={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function Dy(){const[t,r]=p.useState([]),[s,o]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[g,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[k,w]=p.useState(null),[C,N]=p.useState(null),[R,L]=p.useState(!1),B=p.useCallback(async()=>{o(!0);try{const U=await Ce.getSkillUpdates();r(U.filter(q=>q.updateAvailable))}catch{r([])}finally{o(!1)}},[]);p.useEffect(()=>{B()},[B]);const D=p.useMemo(()=>t.filter(U=>!U.pinned),[t]),F=p.useCallback(U=>{u(q=>{const X=new Set(q);return X.has(U)?X.delete(U):X.add(U),X})},[]),E=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(U=>U.name)))},[c,D]),H=p.useCallback(()=>{const U=[...c];if(!U.length)return;m(!0),h(new Map(U.map(X=>[X,{skill:X,status:"pending"}])));const q=Ce.startBatchUpdate(U);q.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),q.addEventListener("done",X=>{q.close(),m(!1);try{const J=JSON.parse(X.data);w(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>w(null),5e3)}catch{}B()}),q.addEventListener("error",()=>{q.close(),m(!1),w("Batch update failed"),setTimeout(()=>w(null),5e3)})},[c,B]),z=p.useCallback(async U=>{const q=U.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];v($=>new Set($).add(U.name)),S($=>{const M=new Map($);return M.delete(U.name),M});try{const $=await Ce.postSkillUpdate(X,J);if($.ok)B();else{const M=`Update failed (HTTP ${$.status}): ${$.body}`;S(_=>new Map(_).set(U.name,M)),w(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>w(null),5e3)}}catch($){const M=$ instanceof Error?$.message:"Network error";S(_=>new Map(_).set(U.name,M)),w(`Couldn't update ${J} — ${M}`),setTimeout(()=>w(null),5e3)}finally{v($=>{const M=new Set($);return M.delete(U.name),M})}},[B]),I=p.useCallback(async U=>{if(!U.latest)return;const q=U.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];L(!0);try{const $=await Ce.getVersionDiff(X,J,U.installed,U.latest);N({skill:U,diff:$})}catch{N(null)}finally{L(!1)}},[]);return s?a.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[a.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-16 rounded-lg"}),a.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?a.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),a.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),a.jsx("button",{onClick:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):a.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&a.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),a.jsxs("div",{className:"flex items-center justify-between mb-5",children:[a.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),a.jsx("button",{onClick:H,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),a.jsx("div",{className:"flex items-center gap-2 mb-3",children:a.jsxs("button",{onClick:E,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.length>0&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),a.jsx("div",{className:"space-y-2",children:t.map(U=>{const q=U.name.split("/").pop()||U.name,X=U.latest?AE(U.installed,U.latest):"patch",J=ME[X],$=!!U.pinned,M=y.has(U.name),_=d.get(U.name),O=c.has(U.name);return a.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>!$&&F(U.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:O?"var(--accent)":"var(--border-default)",background:O?"var(--accent)":"transparent",opacity:$?.4:1},children:O&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),$&&a.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),a.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:J.bg,color:J.text},children:X})]}),a.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[U.installed," → ",U.latest||"?",$&&` (pinned at ${U.pinnedVersion||U.installed})`]})]}),_&&a.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.status==="done"?"var(--green-muted)":_.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:_.status==="done"?"var(--green)":_.status==="error"?"var(--red)":"var(--yellow)"},children:[_.status,_.error&&`: ${_.error}`]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>I(U),className:"btn btn-ghost text-[11px]",disabled:R,children:"View Changes"}),a.jsx("button",{onClick:()=>z(U),disabled:$||M||g,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:M?a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(_==null?void 0:_.status)==="done"?a.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},U.name)})}),C&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:a.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:U=>U.stopPropagation(),children:[a.jsx("div",{className:"mb-2 flex justify-end",children:a.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),a.jsx(zf,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const LE=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Dy},Symbol.toStringTag,{value:"Module"}));function zE(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function DE(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function _E(t){if(!t||typeof t!="string")return null;const r=t.trim();if(!r)return null;if(!r.includes("://")){const[s]=r.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(r),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function _y(t){const{author:r,repoUrl:s}=t,o=_E(s??null),c=r&&r.trim()!==""?r:o??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?a.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!r||r.trim()===""?a.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function OE(t){let r=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return r=r.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),r}function BE(t,r){const s=OE(t),o=(r??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Yg(t){if(!t)return"source";const r=t.replace(/\/+$/,""),s=r.lastIndexOf("/");return s===-1?r:r.slice(s+1)}function Oy(t){const{repoUrl:r,skillPath:s,absolutePath:o}=t,[c,u]=p.useState(!1),d=typeof r=="string"&&r.trim()!==""&&/^https?:\/\//.test(r.trim()),h=s?Yg(s):o?Yg(o):"source",g=p.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const y=BE(r,s);return a.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return a.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const m=o??s??"";return a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Kg(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function By(t){return t.skill?HE({skill:t.skill}):$E({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function IE(t,r=48){if(t.length<=r)return t;const s=t.slice(0,12),o=t.slice(t.length-(r-12-1));return`${s}…${o}`}function HE({skill:t}){const[r,s]=p.useState(!1),o=p.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Kg(ne.toasts.pathCopied,"info")}catch{Kg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[a.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[a.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[a.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),a.jsx("span",{"data-testid":"detail-header-version",children:a.jsx(ei,{version:t.version??null})})]}),a.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(_y,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),a.jsx(Oy,{repoUrl:t.repoUrl??t.homepage??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),a.jsx(UE,{skill:t}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:IE(t.dir||"—")}),a.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),r?"Copied":"Copy"]})]})]})}function UE({skill:t}){const r=t.installMethod,s=t.symlinkTarget;if(!r)return null;let o="";switch(r){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return a.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[a.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),a.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function $E({state:t,isReadOnly:r,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:g,regressions:m,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,R)=>N+R.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,w=zE(b),C=DE(b);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[a.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),a.jsx(VE,{}),a.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),r&&a.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&a.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&a.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!r&&s&&a.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:o,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:a.jsx(PE,{})}),m.length>0&&a.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("path",{d:"M10.29 3.86L1.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"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),y>0&&a.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),a.jsx("span",{className:"pill",style:{background:C,color:w},children:b!=null?`${Math.round(b*100)}%`:"--"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function VE(){return a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function PE(){return a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.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"}),a.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),a.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sr(t){const{title:r,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:g}=t,m=r??s??"",y=typeof g=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g==null||g())};return a.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:m}):null,a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?a.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?a.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const FE="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function GE(t){const{onNavigate:r}=t,[s,o]=p.useState(t.open??!1),c=p.useCallback(()=>o(!1),[]);p.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{r==null||r(d),o(!1)},[r]);return a.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&a.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[a.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:FE}),a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Id,children:"Tests →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Id,children:"Run →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Id,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Id={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function WE(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const r=t/1024;if(r<1024)return r>=10?`${Math.round(r)} KB`:`${r.toFixed(1).replace(/\.0$/,"")} KB`;const s=r/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function zs(t){if(!t)return"—";const r=new Date(t);if(Number.isNaN(r.getTime()))return t;const s=Date.now()-r.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function qE(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function YE(t){const r=t.installMethod;if(!r)return null;const s=r==="authored"?"Authored":r==="copied"?"Copied":"Symlinked";return a.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function KE(t){var y,v;const{skill:r,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(XE(r.homepage)?r.homepage??null:null),g=((y=r.mcpDeps)==null?void 0:y.length)??0,m=((v=r.deps)==null?void 0:v.length)??0;return a.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[a.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[a.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:r.skill}),a.jsx(ei,{version:r.version??null}),YE(r)]}),a.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(_y,{author:r.author??null,repoUrl:h}),r.category?a.jsxs("span",{children:["· ",r.category]}):null,a.jsx(Oy,{repoUrl:h,skillPath:d??null,absolutePath:r.dir}),r.lastModified?a.jsxs("span",{title:r.lastModified,children:["· Updated ",zs(r.lastModified)]}):null]})]}),a.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[a.jsx(sr,{title:"Benchmark",value:qE(r),subtitle:r.lastBenchmark?zs(r.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:a.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:a.jsx(GE,{onNavigate:s})})}),a.jsx(sr,{title:"Tests",value:r.evalCount??0,subtitle:`${r.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),a.jsx(sr,{title:"Activations",value:o,subtitle:c?`Last: ${zs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),a.jsx(sr,{title:"Last run",value:zs(c??r.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),a.jsx(sr,{title:"MCP deps",value:g,subtitle:g>0&&r.mcpDeps?r.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(sr,{title:"Skill deps",value:m,subtitle:m>0&&r.deps?r.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(sr,{title:"Size",value:WE(r.sizeBytes),"data-testid":"metric-size"}),a.jsx(sr,{title:"Last modified",value:zs(r.lastModified),subtitle:r.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function XE(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}const Xg=p.memo(function({message:r,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return a.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:r})});function QE({toast:t,onDismiss:r}){const[s,o]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return a.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&a.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),r(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),a.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function ZE({toasts:t,onDismiss:r,liveMessage:s,liveAssertiveMessage:o}){return a.jsxs(a.Fragment,{children:[a.jsx(Xg,{politeness:"polite",message:s}),a.jsx(Xg,{politeness:"assertive",message:o}),t.length>0&&a.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>a.jsx("div",{style:{pointerEvents:"auto"},children:a.jsx(QE,{toast:c,onDismiss:r})},c.id))})]})}const Iy=p.createContext(null);function Df(){const t=p.useContext(Iy);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function JE({children:t,maxVisible:r=4,defaultDurationMs:s=4e3}){const[o,c]=p.useState([]),[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(C=>{const N=m.current.get(C);N&&(clearTimeout(N),m.current.delete(C)),c(R=>R.filter(L=>L.id!==C))},[]),v=p.useCallback((C,N)=>{if(N<=0)return;const R=setTimeout(()=>{y(C)},N);m.current.set(C,R)},[y]),b=p.useCallback(C=>{const N=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,R={id:N,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(L=>[...L,R]),R.severity==="error"?g(R.message):d(R.message),v(N,R.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear(),c([])},[]);p.useEffect(()=>{function C(N){N.key==="Escape"&&c(R=>{if(R.length===0)return R;const L=R.slice(0,r),B=L[L.length-1],D=m.current.get(B.id);return D&&(clearTimeout(D),m.current.delete(B.id)),R.filter(F=>F.id!==B.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r]),p.useEffect(()=>()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear()},[]);const k=o.slice(0,r),w=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return a.jsxs(Iy.Provider,{value:w,children:[t,a.jsx(ZE,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function eN({skill:t}){const{refreshUpdates:r,dismissPushUpdate:s}=ea(),{toast:o}=Df(),[c,u]=p.useState("idle"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),[b,S]=p.useState(!1),k=p.useRef(null),w=p.useCallback(async()=>{if(!t||c==="updating")return;const L=new AbortController;k.current=L,u("updating"),h(null);try{const B=await Ce.postSkillUpdate(t.plugin,t.skill,L.signal);if(B.ok)u("done"),r(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const D=`Update failed (HTTP ${B.status}): ${B.body}`;u("idle"),h(D),o({message:`Couldn't update ${t.skill} — HTTP ${B.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{w()}}})}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const D=B instanceof Error?B.message:"Network error";u("idle"),h(D),o({message:`Couldn't update ${t.skill} — ${D}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{w()}}})}finally{k.current===L&&(k.current=null)}},[t,c,r,s,o]);if(p.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let L=!1;return S(!0),Ce.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(B=>{L||v(B)}).catch(()=>{L||v(null)}).finally(()=>{L||S(!1)}),()=>{L=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),p.useEffect(()=>()=>{var L;(L=k.current)==null||L.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,N=c==="updating"?"Updating…":C?`Update to ${C}`:"Update",R=c==="updating";return a.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{w()},disabled:R,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:R?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:N}),a.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>m(L=>!L),disabled:R||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),c==="updating"&&a.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),d&&c!=="updating"&&a.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:d}),g&&C&&a.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[b&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!b&&y&&a.jsx(zf,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!b&&!y&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const tN=3e4;function nN({plugin:t,skill:r,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=ea(),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[,m]=p.useState(0),y=p.useRef(null),v=p.useRef(null),b=`${t}/${r}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const w=setInterval(()=>m(C=>(C+1)%1e6),250);return()=>clearInterval(w)},[u]),p.useEffect(()=>{if(!u||!S)return;const w=v.current??0;S.receivedAt<w||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),g(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),g(!0),y.current=null,v.current=null},tN);try{await Ce.rescanSkill(t,r)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&a.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&a.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const Hy=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],aN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function rN(t){return typeof t=="string"&&Hy.includes(t)}function lN(){if(typeof window>"u")return"overview";const r=new URLSearchParams(window.location.search).get("panel");return rN(r)?r:"overview"}function Hd(){const{state:t,setMobileView:r}=ea();return t.isMobile?a.jsxs("button",{onClick:()=>r("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function sN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return iN(t);const{state:r,selectSkill:s,setMode:o,refreshSkills:c}=ea(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const m=()=>d(window.location.hash);return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]),u==="#/updates")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Hd,{}),a.jsx(Dy,{})]});if(r.mode==="create")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Hd,{}),a.jsx(TE,{onCreated:(m,y)=>{o("browse"),c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!r.selectedSkill)return r.skillsError?a.jsx(Do,{variant:"error",message:r.skillsError,onRetry:c}):!r.skillsLoading&&r.skills.length===0?a.jsx(Do,{variant:"no-skills"}):a.jsx(Do,{variant:"no-selection"});const h=r.selectedSkill,g=r.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Hd,{}),a.jsx(oN,{skillInfo:g,allSkills:r.skills,onSelectSkill:m=>s(m)})]})}function iN(t){const r=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(r==null)return uN();if(t.loadError)return dN(r,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Uy(r,s,t.onDetailTabChange,o)}function oN({skillInfo:t,allSkills:r,onSelectSkill:s}){const[o,c]=p.useState(lN());p.useEffect(()=>{if(typeof window>"u")return;const d=new URLSearchParams(window.location.search);o==="overview"?d.delete("panel"):d.set("panel",o);const h=d.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=p.useMemo(()=>t?Uy(t,o,c,{}):a.jsx(Do,{variant:"no-selection"}),[t,o,r,s]);return a.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function cN(t,r){return a.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:Hy.map(s=>{const o=s===t;return a.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>r==null?void 0:r(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:aN[s]},s)})})}function uN(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function dN(t,r){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[By({skill:t}),a.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[a.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:r})]})]})}function fN({active:t}){return t==="editor"?a.jsx(yC,{}):t==="tests"?a.jsx(EC,{}):t==="run"?a.jsx(UC,{}):t==="activation"?a.jsx(FC,{}):t==="history"?a.jsx(sE,{}):t==="leaderboard"?a.jsx(vE,{}):t==="deps"?a.jsx(bE,{}):t==="versions"?a.jsx(Yw,{}):null}function pN({active:t}){const{state:r,dispatch:s}=An();return p.useEffect(()=>{t!=="overview"&&r.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,r.activePanel,s]),null}function Uy(t,r,s,o){const c=h=>{s==null||s(h)},u=a.jsx(KE,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?a.jsxs(Pw,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[a.jsx(pN,{active:r}),a.jsx(fN,{active:r})]},`${t.plugin}/${t.skill}`):a.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",r," view."]});return a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[a.jsx("div",{style:{padding:16,paddingBottom:12},children:By({skill:t})}),a.jsx(eN,{skill:t}),t.origin==="installed"&&a.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:a.jsx(nN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),cN(r,s),a.jsx("div",{role:"tabpanel",id:`detail-panel-${r}`,"aria-labelledby":`detail-tab-${r}`,"data-testid":`detail-panel-${r}`,style:{flex:1,minHeight:0,overflow:"auto"},children:r==="overview"?u:d})]})}function mN(){const{updateCount:t,state:r,dismissUpdateNotification:s}=ea(),o=t>0&&!r.updateNotificationDismissed;return p.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?a.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[a.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),a.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),a.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const hN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function xN({open:t,onClose:r,groups:s=hN,title:o=ne.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var g;if(h.key==="Escape"){h.preventDefault(),r();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,r]),t?a.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&r()},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[a.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),a.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:r,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>a.jsxs("section",{style:{marginBottom:12},children:[a.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),a.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>a.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[a.jsx("span",{children:h.label}),a.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function gN(t){const r=ne.actions,s=[{action:"open",label:r.open},{action:"copy-path",label:r.copyPath},{action:"reveal",label:r.revealInEditor},{action:"run-benchmark",label:r.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:r.edit},{action:"duplicate",label:r.duplicate},{action:"delete",label:r.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:r.update}),o.push({action:"uninstall",label:r.uninstall}),o.push({action:"delete",label:r.delete,disabled:!0,title:r.deletePluginTooltip}),o}function vN({state:t,onClose:r,onAction:s,itemsOverride:o}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),g=p.useMemo(()=>t.skill?o??gN(t.skill):[],[t.skill,o]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+g.length*28;let k=t.x,w=t.y;return k+b+v>window.innerWidth&&(k=Math.max(v,t.x-b)),w+S+v>window.innerHeight&&(w=Math.max(v,t.y-S)),{left:k,top:w}},[t.x,t.y,g.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=p.useCallback(()=>{if(!t.skill)return;const v=g[d];!v||v.disabled||(s(v.action,t.skill),r())},[g,d,t.skill,s,r]);return p.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),r();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||r())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,r,g.length,y]),!t.open||!t.skill?null:a.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:m.left,top:m.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,b)=>a.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),r())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}function yN({open:t,title:r,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const g=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=m.current)==null||k.focus()}),()=>{var k,w;(w=(k=y.current)==null?void 0:k.focus)==null||w.call(k),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function k(w){if(w.key==="Escape"){w.preventDefault(),h();return}if(w.key==="Tab"&&g.current){const C=g.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const N=C[0],R=C[C.length-1];w.shiftKey&&document.activeElement===N?(w.preventDefault(),R.focus()):!w.shiftKey&&document.activeElement===R&&(w.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return a.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:a.jsxs("div",{ref:g,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[a.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:r}),a.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[a.jsx("button",{ref:m,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),a.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:o})]})]})})}function bN(t){const r=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return r.includes("mac")?"system Trash":r.includes("win")?"Recycle Bin":"Trash"}const Qg=t=>`${t.plugin}/${t.skill}`;function jN(t){const r=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,o=t==null?void 0:t.onFailure,c=p.useRef(s),u=p.useRef(o);c.current=s,u.current=o;const d=p.useRef(new Map),[,h]=p.useState(0),g=p.useCallback(()=>h(k=>k+1),[]),m=p.useCallback(async k=>{var w,C;try{await Ce.deleteSkill(k.skill.plugin,k.skill.skill),(w=c.current)==null||w.call(c,k.skill)}catch(N){(C=u.current)==null||C.call(u,k.skill,N)}finally{d.current.delete(Qg(k.skill)),g()}},[g]),y=p.useCallback(k=>{const w=Qg(k),C=d.current.get(w);C!=null&&C.timeoutId&&clearTimeout(C.timeoutId);const N={skill:k,timeoutId:null};N.timeoutId=setTimeout(()=>{N.timeoutId=null,m(N)},r),d.current.set(w,N),g()},[r,m,g]),v=p.useCallback(k=>{const w=d.current.get(k);w&&(w.timeoutId&&clearTimeout(w.timeoutId),d.current.delete(k),g())},[g]),b=p.useCallback(async()=>{const k=Array.from(d.current.values());for(const w of k)w.timeoutId&&(clearTimeout(w.timeoutId),w.timeoutId=null);await Promise.all(k.map(w=>m(w)))},[m]),S=p.useCallback(k=>d.current.has(k),[]);return p.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),p.useEffect(()=>{const k=d.current;return()=>{for(const w of k.values())w.timeoutId&&clearTimeout(w.timeoutId);k.clear()}},[]),{enqueueDelete:y,cancelDelete:v,flushPending:b,isPending:S}}const SN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function kN(t){return t?SN[t]??null:null}function wN({open:t,providerKey:r,onClose:s}){const o=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.useEffect(()=>{if(!t)return;const d=o.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=kN(r),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Fo.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),a.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsx(CN,{title:u,onClose:s}),a.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?a.jsx(EN,{content:c}):a.jsx(NN,{})}),a.jsx("style",{children:`@keyframes vskillDrawerIn {
91
+ `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...lr,minHeight:"150px"}}):s.body.trim()?a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Xo(s.body)}}):a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),a.jsx(RE,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function ME(){return a.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),a.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),a.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function Do({variant:t,message:r,onRetry:s}){const{setMode:o,setSearch:c}=ea(),[u,d]=m.useState(!1);return t==="no-selection"?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[a.jsx("div",{className:"mb-5",children:u?a.jsx(ME,{}):a.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),a.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?a.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[a.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:a.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),a.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),a.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",a.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),a.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?a.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:a.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[a.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:r||"Failed to load skill data"}),s&&a.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):a.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[a.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),a.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function LE(t,r){const[s,o]=t.split(".").map(Number),[c,u]=r.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const zE={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function _y(){const[t,r]=m.useState([]),[s,o]=m.useState(!0),[c,u]=m.useState(new Set),[d,h]=m.useState(new Map),[g,p]=m.useState(!1),[y,v]=m.useState(new Set),[b,S]=m.useState(new Map),[k,E]=m.useState(null),[C,N]=m.useState(null),[T,A]=m.useState(!1),B=m.useCallback(async()=>{o(!0);try{const H=await Ce.getSkillUpdates();r(H.filter(q=>q.updateAvailable))}catch{r([])}finally{o(!1)}},[]);m.useEffect(()=>{B()},[B]);const D=m.useMemo(()=>t.filter(H=>!H.pinned),[t]),F=m.useCallback(H=>{u(q=>{const X=new Set(q);return X.has(H)?X.delete(H):X.add(H),X})},[]),w=m.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(H=>H.name)))},[c,D]),O=m.useCallback(()=>{const H=[...c];if(!H.length)return;p(!0),h(new Map(H.map(X=>[X,{skill:X,status:"pending"}])));const q=Ce.startBatchUpdate(H);q.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),q.addEventListener("done",X=>{q.close(),p(!1);try{const J=JSON.parse(X.data);E(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>E(null),5e3)}catch{}B()}),q.addEventListener("error",()=>{q.close(),p(!1),E("Batch update failed"),setTimeout(()=>E(null),5e3)})},[c,B]),z=m.useCallback(async H=>{const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];v($=>new Set($).add(H.name)),S($=>{const L=new Map($);return L.delete(H.name),L});try{const $=await Ce.postSkillUpdate(X,J);if($.ok)B();else{const L=`Update failed (HTTP ${$.status}): ${$.body}`;S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>E(null),5e3)}}catch($){const L=$ instanceof Error?$.message:"Network error";S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — ${L}`),setTimeout(()=>E(null),5e3)}finally{v($=>{const L=new Set($);return L.delete(H.name),L})}},[B]),U=m.useCallback(async H=>{if(!H.latest)return;const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];A(!0);try{const $=await Ce.getVersionDiff(X,J,H.installed,H.latest);N({skill:H,diff:$})}catch{N(null)}finally{A(!1)}},[]);return s?a.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[a.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-16 rounded-lg"}),a.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?a.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),a.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),a.jsx("button",{onClick:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):a.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&a.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),a.jsxs("div",{className:"flex items-center justify-between mb-5",children:[a.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),a.jsx("button",{onClick:O,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),a.jsx("div",{className:"flex items-center gap-2 mb-3",children:a.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.length>0&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),a.jsx("div",{className:"space-y-2",children:t.map(H=>{const q=H.name.split("/").pop()||H.name,X=H.latest?LE(H.installed,H.latest):"patch",J=zE[X],$=!!H.pinned,L=y.has(H.name),_=d.get(H.name),I=c.has(H.name);return a.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>!$&&F(H.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:I?"var(--accent)":"var(--border-default)",background:I?"var(--accent)":"transparent",opacity:$?.4:1},children:I&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),$&&a.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),a.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:J.bg,color:J.text},children:X})]}),a.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",$&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),_&&a.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.status==="done"?"var(--green-muted)":_.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:_.status==="done"?"var(--green)":_.status==="error"?"var(--red)":"var(--yellow)"},children:[_.status,_.error&&`: ${_.error}`]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>U(H),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),a.jsx("button",{onClick:()=>z(H),disabled:$||L||g,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:L?a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(_==null?void 0:_.status)==="done"?a.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.name)})}),C&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:a.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[a.jsx("div",{className:"mb-2 flex justify-end",children:a.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),a.jsx(zf,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const DE=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:_y},Symbol.toStringTag,{value:"Module"}));function _E(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function OE(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function BE(t){if(!t||typeof t!="string")return null;const r=t.trim();if(!r)return null;if(!r.includes("://")){const[s]=r.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(r),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function Oy(t){const{author:r,repoUrl:s}=t,o=BE(s??null),c=r&&r.trim()!==""?r:o??"—",[u,d]=m.useState(!1),h=m.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?a.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!r||r.trim()===""?a.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function IE(t){let r=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return r=r.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),r}function UE(t,r){const s=IE(t),o=(r??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Yg(t){if(!t)return"source";const r=t.replace(/\/+$/,""),s=r.lastIndexOf("/");return s===-1?r:r.slice(s+1)}function By(t){const{repoUrl:r,skillPath:s,absolutePath:o}=t,[c,u]=m.useState(!1),d=typeof r=="string"&&r.trim()!==""&&/^https?:\/\//.test(r.trim()),h=s?Yg(s):o?Yg(o):"source",g=m.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const y=UE(r,s);return a.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return a.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const p=o??s??"";return a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${p}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Kg(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function Iy(t){return t.skill?$E({skill:t.skill}):PE({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function HE(t,r=48){if(t.length<=r)return t;const s=t.slice(0,12),o=t.slice(t.length-(r-12-1));return`${s}…${o}`}function $E({skill:t}){const[r,s]=m.useState(!1),o=m.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Kg(ne.toasts.pathCopied,"info")}catch{Kg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[a.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[a.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[a.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),a.jsx("span",{"data-testid":"detail-header-version",children:a.jsx(ei,{version:t.version??null})})]}),a.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(Oy,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),a.jsx(By,{repoUrl:t.repoUrl??t.homepage??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),a.jsx(VE,{skill:t}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:HE(t.dir||"—")}),a.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),r?"Copied":"Copy"]})]})]})}function VE({skill:t}){const r=t.installMethod,s=t.symlinkTarget;if(!r)return null;let o="";switch(r){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return a.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[a.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),a.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function PE({state:t,isReadOnly:r,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:g,regressions:p,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,E=_E(b),C=OE(b);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[a.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),a.jsx(FE,{}),a.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),r&&a.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&a.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&a.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!r&&s&&a.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:o,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:a.jsx(GE,{})}),p.length>0&&a.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("path",{d:"M10.29 3.86L1.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"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),p.length," regression",p.length>1?"s":""]}),y>0&&a.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),a.jsx("span",{className:"pill",style:{background:C,color:E},children:b!=null?`${Math.round(b*100)}%`:"--"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function FE(){return a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function GE(){return a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.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"}),a.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),a.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sr(t){const{title:r,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:g}=t,p=r??s??"",y=typeof g=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g==null||g())};return a.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[p?a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:p}):null,a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?a.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?a.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const WE="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function qE(t){const{onNavigate:r}=t,[s,o]=m.useState(t.open??!1),c=m.useCallback(()=>o(!1),[]);m.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=m.useCallback(d=>{r==null||r(d),o(!1)},[r]);return a.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&a.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[a.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:WE}),a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Id,children:"Tests →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Id,children:"Run →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Id,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Id={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function YE(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const r=t/1024;if(r<1024)return r>=10?`${Math.round(r)} KB`:`${r.toFixed(1).replace(/\.0$/,"")} KB`;const s=r/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function zs(t){if(!t)return"—";const r=new Date(t);if(Number.isNaN(r.getTime()))return t;const s=Date.now()-r.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function KE(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function XE(t){const r=t.installMethod;if(!r)return null;const s=r==="authored"?"Authored":r==="copied"?"Copied":"Symlinked";return a.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function QE(t){var y,v;const{skill:r,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(ZE(r.homepage)?r.homepage??null:null),g=((y=r.mcpDeps)==null?void 0:y.length)??0,p=((v=r.deps)==null?void 0:v.length)??0;return a.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[a.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[a.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:r.skill}),a.jsx(ei,{version:r.version??null}),XE(r)]}),a.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(Oy,{author:r.author??null,repoUrl:h}),r.category?a.jsxs("span",{children:["· ",r.category]}):null,a.jsx(By,{repoUrl:h,skillPath:d??null,absolutePath:r.dir}),r.lastModified?a.jsxs("span",{title:r.lastModified,children:["· Updated ",zs(r.lastModified)]}):null]})]}),a.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[a.jsx(sr,{title:"Benchmark",value:KE(r),subtitle:r.lastBenchmark?zs(r.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:a.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:a.jsx(qE,{onNavigate:s})})}),a.jsx(sr,{title:"Tests",value:r.evalCount??0,subtitle:`${r.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),a.jsx(sr,{title:"Activations",value:o,subtitle:c?`Last: ${zs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),a.jsx(sr,{title:"Last run",value:zs(c??r.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),a.jsx(sr,{title:"MCP deps",value:g,subtitle:g>0&&r.mcpDeps?r.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(sr,{title:"Skill deps",value:p,subtitle:p>0&&r.deps?r.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(sr,{title:"Size",value:YE(r.sizeBytes),"data-testid":"metric-size"}),a.jsx(sr,{title:"Last modified",value:zs(r.lastModified),subtitle:r.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function ZE(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}const Xg=m.memo(function({message:r,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return a.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:r})});function JE({toast:t,onDismiss:r}){const[s,o]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return a.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&a.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),r(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),a.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function eN({toasts:t,onDismiss:r,liveMessage:s,liveAssertiveMessage:o}){return a.jsxs(a.Fragment,{children:[a.jsx(Xg,{politeness:"polite",message:s}),a.jsx(Xg,{politeness:"assertive",message:o}),t.length>0&&a.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>a.jsx("div",{style:{pointerEvents:"auto"},children:a.jsx(JE,{toast:c,onDismiss:r})},c.id))})]})}const Uy=m.createContext(null);function Df(){const t=m.useContext(Uy);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function tN({children:t,maxVisible:r=4,defaultDurationMs:s=4e3}){const[o,c]=m.useState([]),[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(new Map),y=m.useCallback(C=>{const N=p.current.get(C);N&&(clearTimeout(N),p.current.delete(C)),c(T=>T.filter(A=>A.id!==C))},[]),v=m.useCallback((C,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(C)},N);p.current.set(C,T)},[y]),b=m.useCallback(C=>{const N=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(A=>[...A,T]),T.severity==="error"?g(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=m.useCallback(()=>{for(const C of p.current.values())clearTimeout(C);p.current.clear(),c([])},[]);m.useEffect(()=>{function C(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,r),B=A[A.length-1],D=p.current.get(B.id);return D&&(clearTimeout(D),p.current.delete(B.id)),T.filter(F=>F.id!==B.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r]),m.useEffect(()=>()=>{for(const C of p.current.values())clearTimeout(C);p.current.clear()},[]);const k=o.slice(0,r),E=m.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return a.jsxs(Uy.Provider,{value:E,children:[t,a.jsx(eN,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function nN({skill:t}){const{refreshUpdates:r,dismissPushUpdate:s}=ea(),{toast:o}=Df(),[c,u]=m.useState("idle"),[d,h]=m.useState(null),[g,p]=m.useState(!1),[y,v]=m.useState(null),[b,S]=m.useState(!1),k=m.useRef(null),E=m.useCallback(async()=>{if(!t||c==="updating")return;const A=new AbortController;k.current=A,u("updating"),h(null);try{const B=await Ce.postSkillUpdate(t.plugin,t.skill,A.signal);if(B.ok)u("done"),r(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const D=`Update failed (HTTP ${B.status}): ${B.body}`;u("idle"),h(D),o({message:`Couldn't update ${t.skill} — HTTP ${B.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const D=B instanceof Error?B.message:"Network error";u("idle"),h(D),o({message:`Couldn't update ${t.skill} — ${D}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{k.current===A&&(k.current=null)}},[t,c,r,s,o]);if(m.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let A=!1;return S(!0),Ce.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(B=>{A||v(B)}).catch(()=>{A||v(null)}).finally(()=>{A||S(!1)}),()=>{A=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),m.useEffect(()=>()=>{var A;(A=k.current)==null||A.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,N=c==="updating"?"Updating…":C?`Update to ${C}`:"Update",T=c==="updating";return a.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:N}),a.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>p(A=>!A),disabled:T||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),c==="updating"&&a.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),d&&c!=="updating"&&a.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:d}),g&&C&&a.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[b&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!b&&y&&a.jsx(zf,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!b&&!y&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const aN=3e4;function rN({plugin:t,skill:r,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=ea(),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[,p]=m.useState(0),y=m.useRef(null),v=m.useRef(null),b=`${t}/${r}`,S=c.updatesById.get(b);if(m.useEffect(()=>{if(!u)return;const E=setInterval(()=>p(C=>(C+1)%1e6),250);return()=>clearInterval(E)},[u]),m.useEffect(()=>{if(!u||!S)return;const E=v.current??0;S.receivedAt<E||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),g(!1),v.current=null)},[u,S]),m.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),g(!0),y.current=null,v.current=null},aN);try{await Ce.rescanSkill(t,r)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&a.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&a.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const Hy=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],lN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function sN(t){return typeof t=="string"&&Hy.includes(t)}function iN(){if(typeof window>"u")return"overview";const r=new URLSearchParams(window.location.search).get("panel");return sN(r)?r:"overview"}function Ud(){const{state:t,setMobileView:r}=ea();return t.isMobile?a.jsxs("button",{onClick:()=>r("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function oN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return cN(t);const{state:r,selectSkill:s,setMode:o,refreshSkills:c}=ea(),[u,d]=m.useState(typeof window<"u"?window.location.hash:"");if(m.useEffect(()=>{const p=()=>d(window.location.hash);return window.addEventListener("hashchange",p),()=>window.removeEventListener("hashchange",p)},[]),u==="#/updates")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Ud,{}),a.jsx(_y,{})]});if(r.mode==="create")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Ud,{}),a.jsx(AE,{onCreated:(p,y)=>{o("browse"),c(),s({plugin:p,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!r.selectedSkill)return r.skillsError?a.jsx(Do,{variant:"error",message:r.skillsError,onRetry:c}):!r.skillsLoading&&r.skills.length===0?a.jsx(Do,{variant:"no-skills"}):a.jsx(Do,{variant:"no-selection"});const h=r.selectedSkill,g=r.skills.find(p=>p.plugin===h.plugin&&p.skill===h.skill)??null;return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Ud,{}),a.jsx(uN,{skillInfo:g,allSkills:r.skills,onSelectSkill:p=>s(p)})]})}function cN(t){const r=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(r==null)return fN();if(t.loadError)return pN(r,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return $y(r,s,t.onDetailTabChange,o)}function uN({skillInfo:t,allSkills:r,onSelectSkill:s}){const[o,c]=m.useState(iN());m.useEffect(()=>{if(typeof window>"u")return;const d=new URLSearchParams(window.location.search);o==="overview"?d.delete("panel"):d.set("panel",o);const h=d.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=m.useMemo(()=>t?$y(t,o,c,{}):a.jsx(Do,{variant:"no-selection"}),[t,o,r,s]);return a.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function dN(t,r){return a.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:Hy.map(s=>{const o=s===t;return a.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>r==null?void 0:r(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:lN[s]},s)})})}function fN(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function pN(t,r){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Iy({skill:t}),a.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[a.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:r})]})]})}function mN({active:t}){return t==="editor"?a.jsx(jC,{}):t==="tests"?a.jsx(TC,{}):t==="run"?a.jsx(VC,{}):t==="activation"?a.jsx(WC,{}):t==="history"?a.jsx(oE,{}):t==="leaderboard"?a.jsx(bE,{}):t==="deps"?a.jsx(SE,{}):t==="versions"?a.jsx(Xw,{}):null}function hN({active:t}){const{state:r,dispatch:s}=An();return m.useEffect(()=>{t!=="overview"&&r.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,r.activePanel,s]),null}function $y(t,r,s,o){const c=h=>{s==null||s(h)},u=a.jsx(QE,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?a.jsxs(Gw,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[a.jsx(hN,{active:r}),a.jsx(mN,{active:r})]},`${t.plugin}/${t.skill}`):a.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",r," view."]});return a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[a.jsx("div",{style:{padding:16,paddingBottom:12},children:Iy({skill:t})}),a.jsx(nN,{skill:t}),t.origin==="installed"&&a.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:a.jsx(rN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),dN(r,s),a.jsx("div",{role:"tabpanel",id:`detail-panel-${r}`,"aria-labelledby":`detail-tab-${r}`,"data-testid":`detail-panel-${r}`,style:{flex:1,minHeight:0,overflow:"auto"},children:r==="overview"?u:d})]})}function xN(){const{updateCount:t,state:r,dismissUpdateNotification:s}=ea(),o=t>0&&!r.updateNotificationDismissed;return m.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?a.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[a.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),a.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),a.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const gN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function vN({open:t,onClose:r,groups:s=gN,title:o=ne.shortcuts.title}){const c=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),m.useEffect(()=>{if(!t)return;function d(h){var g;if(h.key==="Escape"){h.preventDefault(),r();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,r]),t?a.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&r()},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[a.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),a.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:r,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>a.jsxs("section",{style:{marginBottom:12},children:[a.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),a.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>a.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[a.jsx("span",{children:h.label}),a.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function yN(t){const r=ne.actions,s=[{action:"open",label:r.open},{action:"copy-path",label:r.copyPath},{action:"reveal",label:r.revealInEditor},{action:"run-benchmark",label:r.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:r.edit},{action:"duplicate",label:r.duplicate},{action:"delete",label:r.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:r.update}),o.push({action:"uninstall",label:r.uninstall}),o.push({action:"delete",label:r.delete,disabled:!0,title:r.deletePluginTooltip}),o}function bN({state:t,onClose:r,onAction:s,itemsOverride:o}){const c=m.useRef(null),u=m.useRef(null),[d,h]=m.useState(0),g=m.useMemo(()=>t.skill?o??yN(t.skill):[],[t.skill,o]),p=m.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+g.length*28;let k=t.x,E=t.y;return k+b+v>window.innerWidth&&(k=Math.max(v,t.x-b)),E+S+v>window.innerHeight&&(E=Math.max(v,t.y-S)),{left:k,top:E}},[t.x,t.y,g.length]);m.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=m.useCallback(()=>{if(!t.skill)return;const v=g[d];!v||v.disabled||(s(v.action,t.skill),r())},[g,d,t.skill,s,r]);return m.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),r();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||r())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,r,g.length,y]),!t.open||!t.skill?null:a.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:p.left,top:p.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,b)=>a.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),r())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}function jN({open:t,title:r,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const g=m.useRef(null),p=m.useRef(null),y=m.useRef(null);if(m.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=p.current)==null||k.focus()}),()=>{var k,E;(E=(k=y.current)==null?void 0:k.focus)==null||E.call(k),y.current=null}},[t]),m.useEffect(()=>{if(!t)return;function k(E){if(E.key==="Escape"){E.preventDefault(),h();return}if(E.key==="Tab"&&g.current){const C=g.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const N=C[0],T=C[C.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return a.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:a.jsxs("div",{ref:g,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[a.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:r}),a.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[a.jsx("button",{ref:p,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),a.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:o})]})]})})}function SN(t){const r=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return r.includes("mac")?"system Trash":r.includes("win")?"Recycle Bin":"Trash"}const Qg=t=>`${t.plugin}/${t.skill}`;function kN(t){const r=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,o=t==null?void 0:t.onFailure,c=m.useRef(s),u=m.useRef(o);c.current=s,u.current=o;const d=m.useRef(new Map),[,h]=m.useState(0),g=m.useCallback(()=>h(k=>k+1),[]),p=m.useCallback(async k=>{var E,C;try{await Ce.deleteSkill(k.skill.plugin,k.skill.skill),(E=c.current)==null||E.call(c,k.skill)}catch(N){(C=u.current)==null||C.call(u,k.skill,N)}finally{d.current.delete(Qg(k.skill)),g()}},[g]),y=m.useCallback(k=>{const E=Qg(k),C=d.current.get(E);C!=null&&C.timeoutId&&clearTimeout(C.timeoutId);const N={skill:k,timeoutId:null};N.timeoutId=setTimeout(()=>{N.timeoutId=null,p(N)},r),d.current.set(E,N),g()},[r,p,g]),v=m.useCallback(k=>{const E=d.current.get(k);E&&(E.timeoutId&&clearTimeout(E.timeoutId),d.current.delete(k),g())},[g]),b=m.useCallback(async()=>{const k=Array.from(d.current.values());for(const E of k)E.timeoutId&&(clearTimeout(E.timeoutId),E.timeoutId=null);await Promise.all(k.map(E=>p(E)))},[p]),S=m.useCallback(k=>d.current.has(k),[]);return m.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),m.useEffect(()=>{const k=d.current;return()=>{for(const E of k.values())E.timeoutId&&clearTimeout(E.timeoutId);k.clear()}},[]),{enqueueDelete:y,cancelDelete:v,flushPending:b,isPending:S}}const wN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function CN(t){return t?wN[t]??null:null}function EN({open:t,providerKey:r,onClose:s}){const o=m.useRef(null);if(m.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),m.useEffect(()=>{if(!t)return;const d=o.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=CN(r),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Fo.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),a.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsx(NN,{title:u,onClose:s}),a.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?a.jsx(TN,{content:c}):a.jsx(RN,{})}),a.jsx("style",{children:`@keyframes vskillDrawerIn {
92
92
  from { transform: translateX(100%); }
93
93
  to { transform: translateX(0); }
94
94
  }
95
95
  @keyframes vskillDrawerBackdropIn {
96
96
  from { opacity: 0; }
97
97
  to { opacity: 1; }
98
- }`})]})]}),document.body)}function CN({title:t,onClose:r}){return a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),a.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:r,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function EN({content:t}){var r,s;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>a.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>a.jsx("li",{children:a.jsx(TN,{name:o})},o))})]}),t.keyUrl&&a.jsx(RN,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(r=t.install)==null?void 0:r.map((o,c)=>a.jsx(Ud,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>a.jsx(Ud,{code:o},`start-${c}`)),t.pullExample&&a.jsx(Ud,{code:t.pullExample})]})]}),a.jsx("footer",{style:{marginTop:8},children:a.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function NN(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[a.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),a.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function TN({name:t}){const r=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),a.jsx("button",{type:"button",onClick:r,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function Ud({code:t}){return a.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function RN({href:t,label:r,testId:s}){return a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer","data-testid":s,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[r," →"]})}function AN(){const[t,r]=p.useState(!1),[s,o]=p.useState(null),c=p.useRef(null),u=p.useCallback((h,g)=>{var m;c.current=typeof document<"u"?document.activeElement:null,(m=g==null?void 0:g.beforeOpen)==null||m.call(g),o(h),r(!0)},[]),d=p.useCallback(()=>{r(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return p.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function MN(t){const r=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const d=t.filter(h=>c.sharedFolderGroup.includes(h.id));r.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,g)=>h+g.globalCount,0)});continue}r.push({kind:"individual",key:c.id,agent:c})}return{detected:r,notDetected:s}}function LN({agents:t,activeAgentId:r,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=p.useRef(null);p.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),p.useEffect(()=>{const y=b=>{h.current&&!h.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const g=p.useMemo(()=>MN(t),[t]),m=t.find(y=>y.id===s)??t.find(y=>y.id===r)??t[0];return typeof document>"u"?null:Fo.createPortal(a.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[a.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&a.jsx(Zg,{}),g.detected.map(y=>y.kind==="aggregate"?a.jsx(DN,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??r??"")}},y.key):a.jsx(zN,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===r,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>a.jsx(_N,{agent:y.agent},y.key))]})]}),a.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:m?a.jsx(ON,{agent:m,activeAgentId:r,onSwitch:()=>c(m.id)}):a.jsx(Zg,{})})]}),a.jsx("style",{children:`@keyframes scopePickerFadeIn {
98
+ }`})]})]}),document.body)}function NN({title:t,onClose:r}){return a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),a.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:r,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function TN({content:t}){var r,s;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>a.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>a.jsx("li",{children:a.jsx(AN,{name:o})},o))})]}),t.keyUrl&&a.jsx(MN,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(r=t.install)==null?void 0:r.map((o,c)=>a.jsx(Hd,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>a.jsx(Hd,{code:o},`start-${c}`)),t.pullExample&&a.jsx(Hd,{code:t.pullExample})]})]}),a.jsx("footer",{style:{marginTop:8},children:a.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function RN(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[a.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),a.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function AN({name:t}){const r=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),a.jsx("button",{type:"button",onClick:r,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function Hd({code:t}){return a.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function MN({href:t,label:r,testId:s}){return a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer","data-testid":s,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[r," →"]})}function LN(){const[t,r]=m.useState(!1),[s,o]=m.useState(null),c=m.useRef(null),u=m.useCallback((h,g)=>{var p;c.current=typeof document<"u"?document.activeElement:null,(p=g==null?void 0:g.beforeOpen)==null||p.call(g),o(h),r(!0)},[]),d=m.useCallback(()=>{r(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return m.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function zN(t){const r=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const d=t.filter(h=>c.sharedFolderGroup.includes(h.id));r.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,g)=>h+g.globalCount,0)});continue}r.push({kind:"individual",key:c.id,agent:c})}return{detected:r,notDetected:s}}function DN({agents:t,activeAgentId:r,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=m.useRef(null);m.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),m.useEffect(()=>{const y=b=>{h.current&&!h.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const g=m.useMemo(()=>zN(t),[t]),p=t.find(y=>y.id===s)??t.find(y=>y.id===r)??t[0];return typeof document>"u"?null:Fo.createPortal(a.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[a.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&a.jsx(Zg,{}),g.detected.map(y=>y.kind==="aggregate"?a.jsx(ON,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??r??"")}},y.key):a.jsx(_N,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===r,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>a.jsx(BN,{agent:y.agent},y.key))]})]}),a.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:p?a.jsx(IN,{agent:p,activeAgentId:r,onSwitch:()=>c(p.id)}):a.jsx(Zg,{})})]}),a.jsx("style",{children:`@keyframes scopePickerFadeIn {
99
99
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
100
100
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
101
- }`})]}),document.body)}function zN({agent:t,focused:r,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return a.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),a.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function DN({row:t,onFocus:r}){return a.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),a.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function _N({agent:t}){const r=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return a.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),a.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&a.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function ON({agent:t,activeAgentId:r,onSwitch:s}){const o=t.id===r,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":IN(t.health)})]}),a.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[a.jsx($d,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),a.jsx($d,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),a.jsx($d,{label:ne.scopePicker.statsLastSync,value:t.lastSync?BN(t.lastSync):"—"})]}),a.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function $d({label:t,value:r}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function Zg(){return a.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function BN(t){try{const r=new Date(t).getTime(),s=Date.now()-r;if(Number.isNaN(r))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function IN(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function HN(t){const r=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)r.set(o,s);return t.agents.map(s=>{const o=r.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function UN({agents:t,activeAgentId:r,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useMemo(()=>t.find(S=>S.id===r)??t[0]??null,[t,r]),y=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),v=p.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),a.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.displayName)??"Select agent"}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(m==null?void 0:m.installedCount)??0," · ",(m==null?void 0:m.globalCount)??0,")"]}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&a.jsx(LN,{agents:t,activeAgentId:r,focusedAgentId:d??r,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const $y="vskill-ccode-banner-dismissed",$N=new Set(["claude-cli","claude-code"]);function VN(){try{return sessionStorage.getItem($y)==="true"}catch{return!1}}function PN(){try{sessionStorage.setItem($y,"true")}catch{}}function FN({activeAgentId:t}){const[r,s]=p.useState(()=>VN()),o=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{PN(),s(!0)},[]);return!t||!$N.has(t)||r?null:a.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function GN(){const[t,r]=p.useState(null),[s,o]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Ce.getAgents();r(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return p.useEffect(()=>{d()},[d]),p.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Co="workspace",WN=["skills","agents"];async function qN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function YN(t){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${r.status}`)}return await r.json()}async function KN(t){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function XN(t){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${r.status}`)}return await r.json()}function Vd(){for(const t of WN)Tn(t)}function QN(){const{data:t,loading:r,error:s,revalidate:o}=ti(Co,qN),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await YN(m),Tn(Co),Vd()},[]),h=p.useCallback(async m=>{await KN(m),Tn(Co),Vd()},[]),g=p.useCallback(async m=>{await XN(m),Tn(Co),Vd()},[]);return{workspace:c,activeProject:u,loading:r,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function ZN({workspace:t,onSwitch:r,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(""),[v,b]=p.useState(null),[S,k]=p.useState(null),[w,C]=p.useState(null),[N,R]=p.useState(!1),L=p.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function z(I){L.current&&!L.current.contains(I.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=m.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(I){const U=I instanceof Error?I.message:String(I);/does not exist/i.test(U)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(U)?b("That project is already registered."):b(U)}}async function E(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function H(z){if(z.length<=50)return z;const I=z.split("/");return I.length<=4?z:`${I.slice(0,3).join("/")}/…/${I.slice(-2).join("/")}`}return a.jsxs("div",{ref:L,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[a.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),a.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&a.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[B.length===0&&a.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&a.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const I=c?c(z.path):!1,U=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return a.jsxs("li",{role:"menuitem","data-stale":I?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!I){if(U){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:I?"not-allowed":"pointer",background:q&&!I?"var(--surface-2, rgba(0,0,0,0.04))":U?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:I?.5:1,transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:U?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:U?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),U&&a.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),a.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H(z.path)}),I&&a.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),a.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"}),a.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),a.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&a.jsxs("button",{type:"button",onClick:()=>void E(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("input",{type:"text",value:m,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),w&&a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[a.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),a.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",w.name]}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),a.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${w.path}" && npx vskill@latest studio`}),a.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${w.path}" && npx vskill@latest studio`),R(!0),setTimeout(()=>R(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),a.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function JN(t,r){const s=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function eT({open:t,projects:r,onSwitch:s,onClose:o}){const[c,u]=p.useState(""),[d,h]=p.useState(0),g=p.useMemo(()=>JN(r,c),[r,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const m=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?a.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[a.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),a.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[a.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:m,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),a.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&a.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>a.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[a.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),a.jsxs("span",{className:"flex-1",children:[a.jsx("span",{className:"vskill-palette-name",children:y.name}),a.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const Jg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function tT({open:t,onClose:r,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[g,m]=p.useState(s),[y,v]=p.useState(""),[b,S]=p.useState(""),[k,w]=p.useState(""),[C,N]=p.useState([]),[R,L]=p.useState(!1),[B,D]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),v(""),S(""),w(""),D(null))},[t,s]),p.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(M=>M.json()).then(M=>{$&&N(M.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),p.useEffect(()=>{if(!t)return;function $(M){M.key==="Escape"&&(M.preventDefault(),r())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,r]),!t)return null;const F=C.length>0,E=o&&F,H=o,z=Jg.test(y),I=g==="existing-plugin"?b.length>0:Jg.test(b),U=!R&&z&&(g==="standalone"||I),q=nT(c,g,b,y);async function X(){D(null),L(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const O=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await O.json();if(!O.ok){D(V.error??`Check failed: ${O.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{L(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const M=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=M),r()}async function J(){D(null),L(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),M=await $.json();if(!$.ok||!M.ok){D(M.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:M.pluginName??null,skillMdPath:M.skillMdPath}),r()}catch($){D($ instanceof Error?$.message:String($))}finally{L(!1)}}return a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),a.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[a.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&a.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx(Pd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>m("standalone")}),a.jsx(Pd,{title:"Add to existing plugin",subtitle:E?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!E,selected:g==="existing-plugin",onClick:()=>E&&m("existing-plugin")}),a.jsx(Pd,{title:"New plugin",subtitle:H?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!H,selected:g==="new-plugin",onClick:()=>H&&m("new-plugin")})]}),d==="details"&&a.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&a.jsx(Eo,{label:"Plugin name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:No(!b||I)})}),g==="existing-plugin"&&a.jsx(Eo,{label:"Plugin",children:a.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...No(!0),fontFamily:"var(--font-mono)"},children:[a.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>a.jsx("option",{value:$.name,children:$.name},$.path))]})}),a.jsx(Eo,{label:"Skill name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:No(!y||z)})}),a.jsx(Eo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:a.jsx("textarea",{value:k,onChange:$=>w($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...No(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&a.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,M)=>a.jsx("div",{children:$},M))]}),B&&a.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[a.jsx("button",{type:"button",onClick:r,style:Fd,children:"Cancel"}),d==="destination"&&a.jsx("button",{type:"button",onClick:()=>h("details"),style:ev,children:"Continue →"}),d==="details"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>h("destination"),style:Fd,children:"← Back"}),a.jsx("button",{type:"button",onClick:()=>void X(),disabled:!U,style:{...Fd,opacity:U?1:.5,cursor:U?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),a.jsx("button",{type:"button",onClick:()=>void J(),disabled:!U,style:{...ev,opacity:U?1:.5,cursor:U?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:R?"Creating…":"Create empty scaffold"})]})]})]})]})}function Pd({title:t,subtitle:r,description:s,icon:o,selected:c,disabled:u,onClick:d}){return a.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Eo({label:t,hint:r,children:s}){return a.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),r&&a.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),s]})}function No(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const ev={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},Fd={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function nT(t,r,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return r==="standalone"?[`${d}/skills/${c}/SKILL.md`]:r==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:r==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function aT({open:t,onClose:r,onInstall:s,installedNames:o}){const[c,u]=p.useState([]),[d,h]=p.useState(null),[g,m]=p.useState(null),[y,v]=p.useState(!1),[b,S]=p.useState(null);return p.useEffect(()=>{t&&(v(!0),S(null),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);u(k.marketplaces??[])}).catch(k=>S(k instanceof Error?k.message:String(k))).finally(()=>v(!1)))},[t]),p.useEffect(()=>{if(!d){m(null);return}v(!0),S(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(d)}`).then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);m(k)}).catch(k=>S(k instanceof Error?k.message:String(k))).finally(()=>v(!1))},[d]),p.useEffect(()=>{if(!t)return;function k(w){w.key==="Escape"&&r()}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[t,r]),t?a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),a.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[d&&a.jsx("button",{type:"button",onClick:()=>h(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),a.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:d?(g==null?void 0:g.name)??d:"Browse plugins"}),a.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[y&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),b&&a.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:b}),!d&&!y&&c.length===0&&!b&&a.jsx(rT,{}),!d&&c.map(k=>a.jsxs("button",{type:"button",onClick:()=>h(k.name),style:sT,onMouseEnter:w=>{w.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:k.name}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.source})]},k.name)),d&&g&&a.jsxs(a.Fragment,{children:[g.description&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:g.description}),g.plugins.length===0&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),g.plugins.map(k=>{const w=o.has(k.name);return a.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:a.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[k.name,k.version&&a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:k.version}),k.category&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:k.category})]}),k.description&&a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:k.description})]}),a.jsx("button",{type:"button",disabled:w,onClick:()=>s(k.name,d),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:w?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:w?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:w?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:w?"default":"pointer",fontFamily:"inherit",boxShadow:w?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:w?"Installed":"Install"})]})},k.name)})]})]}),!d&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:a.jsx(lT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>u(k.marketplaces??[]))}})})]})]}):null}function rT(){return a.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",a.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[a.jsx("li",{children:a.jsx("code",{children:"anthropics/claude-plugins-official"})}),a.jsx("li",{children:a.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function lT({onAdded:t}){const[r,s]=p.useState(""),[o,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const g=r.trim();if(g){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await m.json().catch(()=>({}));if(!m.ok||!y.ok){d(y.error??`Add failed (${m.status})`);return}s(""),t()}catch(m){d(m instanceof Error?m.message:String(m))}finally{c(!1)}}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{type:"text",value:r,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!r.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!r.trim()?"not-allowed":"pointer",opacity:o||!r.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const sT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Gd=12;function iT({job:t,onDone:r}){const[s,o]=p.useState([]),[c,u]=p.useState("running"),[d,h]=p.useState(!1);if(p.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),r({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const w=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:R,done:L}=await w.read();if(L)break;N+=C.decode(R,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const E=JSON.parse(F[1]);E.type==="stdout"&&E.line?(b=[...b,E.line].slice(-Gd),o(b)):E.type==="stderr"&&E.line?(b=[...b,`⚠ ${E.line}`].slice(-Gd),o(b)):E.type==="done"?(S=E.ok?"ok":"failed",u(S),Lv(),Tn("skills"),r({ok:E.ok??!1,code:E.code??null,lines:b})):E.type==="error"&&E.error&&(b=[...b,`✘ ${E.error}`].slice(-Gd),o(b))}catch{}}}S==="running"&&r({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),r({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",m=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return a.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[a.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?a.jsx(oT,{}):m}),a.jsxs("span",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&a.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&a.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
- `)})]})}function oT(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const cT=3e3,uT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function tv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function dT(){const{toast:t}=Df(),r=p.useRef(new Map),s=p.useCallback(o=>{if(!tv(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<cT)return;r.current.set(o.provider,c);const d=uT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return p.useEffect(()=>{function o(c){const u=c.detail;!u||!tv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Vy="vskill.studio.prefs";function Py(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Fy(){const t=Py();if(!t)return{};try{const r=t.getItem(Vy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function fT(t,r){const s=Py();if(s)try{const c={...Fy(),[t]:r};s.setItem(Vy,JSON.stringify(c))}catch{}}function pT(t,r){const o=Fy()[t];return o===void 0?r:o}const nv={open:!1,x:0,y:0,skill:null};function mT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function _r(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function hT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function xT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{_r(ne.toasts.permissionDenied,"error");return}_r(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_r(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_r(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_r(ne.toasts.skillDuplicated,"info");return;case"update":_r(ne.toasts.skillUpdated,"info");return;case"uninstall":_r(ne.actions.editPlaceholder,"info");return;case"delete":hT(r);return;default:return}}function gT(t){return t.startsWith("#/create")}function vT(t){return t.startsWith("#/updates")}function Gy(t){const[r,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),r}function yT(){return Gy(gT)}function bT(){return Gy(vT)}const jT=p.lazy(()=>Xs(()=>import("./CommandPalette-BoXvLUq1.js"),__vite__mapDeps([2,1]))),ST=p.lazy(()=>Xs(()=>import("./CreateSkillPage-9cOfboMo.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),kT=p.lazy(()=>Xs(()=>Promise.resolve().then(()=>LE),void 0).then(t=>({default:t.UpdatesPanel})));function wT(){return a.jsx(mS,{children:a.jsx(dS,{children:a.jsxs(JE,{children:[a.jsx(CT,{}),a.jsx(mN,{})]})})})}function CT(){var Wn,Et;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ea(),{config:h}=Ur(),{mode:g,resolvedTheme:m,setTheme:y}=Mv(),{toast:v}=Df(),[b,S]=p.useState(()=>Dw()),[k]=p.useState(!0),[w,C]=p.useState(!1),[N,R]=p.useState(!1),[L,B]=p.useState(!1),[D,F]=p.useState("overview"),[E,H]=p.useState(nv),z=p.useCallback((ce,ve)=>{H(mT(ce,ve))},[]),I=GN(),[U,q]=p.useState(()=>pT("activeAgent",null)),X=p.useCallback(ce=>{q(ce),fT("activeAgent",ce),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ce}}))},[]);p.useEffect(()=>{var ce;!U&&((ce=I.response)!=null&&ce.suggested)&&X(I.response.suggested)},[U,(Wn=I.response)==null?void 0:Wn.suggested,X]);const J=p.useMemo(()=>I.response?HN(I.response):[],[I.response]),{workspace:$,switchProject:M,addProject:_,removeProject:O,activeProject:V}=QN(),[se,A]=p.useState(!1),[Y,W]=p.useState(!1),[te,fe]=p.useState("standalone"),ie=p.useCallback((ce="standalone")=>{fe(ce),W(!0)},[]);p.useEffect(()=>{function ce(ve){if(!(ve instanceof CustomEvent))return;const Re=ve.detail;ie((Re==null?void 0:Re.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ce),()=>window.removeEventListener("studio:request-create-skill",ce)},[ie]);const[ye,de]=p.useState(!1),[Se,Ae]=p.useState(null);p.useEffect(()=>{function ce(){de(!0)}return window.addEventListener("studio:open-marketplace",ce),()=>window.removeEventListener("studio:open-marketplace",ce)},[]);const _e=p.useMemo(()=>{const ce=new Set;for(const ve of t.skills)ve.source==="plugin"&&ve.pluginName&&ce.add(ve.pluginName);return ce},[t.skills]);af([{key:"p",meta:!0,handler:ce=>{var Re;const ve=typeof document<"u"?document.activeElement:null;ve&&ve.tagName==="INPUT"||((Re=ce==null?void 0:ce.preventDefault)==null||Re.call(ce),A(dn=>!dn))}}],{enabled:!0});const re=AN(),he=re.open;p.useEffect(()=>{function ce(ve){if(!(ve instanceof CustomEvent))return;const Re=ve.detail;Re!=null&&Re.provider&&he(Re.provider)}return window.addEventListener("studio:open-setup-drawer",ce),()=>window.removeEventListener("studio:open-setup-drawer",ce)},[he]);const pe=p.useCallback(()=>{H(nv)},[]);p.useEffect(()=>{function ce(ve){if(!(ve instanceof CustomEvent))return;const Re=ve.detail;Re!=null&&Re.message&&v({message:Re.message,severity:Re.severity??"info"})}return window.addEventListener("studio:toast",ce),()=>window.removeEventListener("studio:toast",ce)},[v]),dT();const[xe,je]=p.useState(!1),[Be,Oe]=p.useState(void 0);p.useEffect(()=>{function ce(ve){if(!(ve instanceof CustomEvent))return;const Re=ve.detail;Oe(Re==null?void 0:Re.provider),je(!0)}return window.addEventListener("studio:open-settings",ce),()=>window.removeEventListener("studio:open-settings",ce)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[rt,Nt]=p.useState(null),[ht,Dt]=p.useState(()=>new Set),Tt=p.useRef(!1),Qe=p.useMemo(()=>bN(),[]),tt=p.useCallback(ce=>`${ce.plugin}/${ce.skill}`,[]),be=p.useCallback(ce=>{Dt(ve=>{const Re=new Set(ve);return Re.add(tt(ce)),Re})},[tt]),pt=p.useCallback(ce=>{Dt(ve=>{const Re=new Set(ve);return Re.delete(tt(ce)),Re})},[tt]),Ct=jN({delayMs:1e4,onCommit:ce=>{o(),pt(ce)},onFailure:(ce,ve)=>{pt(ce),v({message:`Couldn't delete ${ce.skill}: ${ve.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(ce),Ct.enqueueDelete(ce)}}})}});p.useEffect(()=>{function ce(ve){if(!(ve instanceof CustomEvent))return;const Re=ve.detail;Re!=null&&Re.skill&&Nt(Re.skill)}return window.addEventListener("studio:request-delete",ce),()=>window.removeEventListener("studio:request-delete",ce)},[]);const Yt=p.useCallback(()=>{const ce=rt;if(Nt(null),!ce)return;const ve={plugin:ce.plugin,skill:ce.skill};be(ve),Ct.enqueueDelete(ve);const Re=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Re}Deleted ${ce.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(ve)),pt(ve)}}})},[rt,be,pt,Ct,v,Qe,tt]),un=p.useCallback(()=>{Nt(null)},[]),Gt=p.useMemo(()=>t.skills.filter(ce=>!ht.has(tt(ce))),[t.skills,ht,tt]),an=p.useMemo(()=>t.selectedSkill?t.skills.find(ce=>ce.plugin===t.selectedSkill.plugin&&ce.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=p.useCallback(ce=>{r({plugin:ce.plugin,skill:ce.skill,origin:ce.origin})},[r]),Mt=p.useMemo(()=>{if(!t.selectedSkill)return"";const ce=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ce})`},[t.selectedSkill]),xt=p.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(ce=>!ce)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>R(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(ce=>!ce)},{key:"ctrl+k",handler:()=>C(ce=>!ce)},{key:"?",handler:()=>R(ce=>!ce)},{key:"cmd+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(ce=>!ce)},{key:"ctrl+b",handler:()=>B(ce=>!ce)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=yT(),za=bT()?a.jsx(p.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(kT,{})}):gt?a.jsx(p.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(ST,{})}):a.jsx(sN,{selectedSkillInfo:an,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return a.jsxs(a.Fragment,{children:[a.jsx(hS,{sidebarWidth:b,sidebarHidden:L||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Bw,{connected:k}),liveMessage:Mt,topRail:a.jsx(p2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?a.jsx(ZN,{workspace:$,onSwitch:M,onAdd:_,onRemove:O}):void 0}),sidebar:a.jsx(Ew,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:U,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:I.status==="ready"&&J.length>0?a.jsxs(a.Fragment,{children:[a.jsx(UN,{agents:J,activeAgentId:U,onActiveAgentChange:X,onOpenSetup:ce=>re.open(ce)}),a.jsx(FN,{activeAgentId:U})]}):null}),resizeHandle:a.jsx(Ow,{initialWidth:b??Hs,onChange:S}),main:za,statusBar:a.jsx(w2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(ce=>{const ve=ce.id;return{id:ve,label:ce.label,available:ce.available,kind:ve==="ollama"||ve==="lm-studio"?"start-service":ve==="anthropic"||ve==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(xN,{open:N,onClose:()=>R(!1)}),a.jsx(wN,{open:re.isOpen,providerKey:re.providerKey,onClose:re.close}),a.jsx(vN,{state:E,onClose:pe,onAction:(ce,ve)=>xT(ce,ve)}),w&&a.jsx(p.Suspense,{fallback:null,children:a.jsx(jT,{open:w,onClose:()=>C(!1),commands:xt})}),a.jsx(eT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:ce=>{M(ce)},onClose:()=>A(!1)}),a.jsx(tT,{open:Y,onClose:()=>W(!1),initialMode:te,isClaudeCode:U==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:ce=>{o(),setTimeout(()=>{u(ce.pluginName??"",ce.skillName)},500)}}),a.jsx(aT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(ce,ve)=>{Ae({plugin:ce,marketplace:ve,ref:`${ce}@${ve}`}),de(!1)}}),a.jsx(Tv,{open:xe,onClose:()=>je(!1),initialProvider:Be,onToast:ce=>v({message:ce,severity:"info"})}),a.jsx(iT,{job:Se,onDone:ce=>{ce.ok&&setTimeout(()=>Ae(null),3e3)}}),a.jsx(yN,{open:rt!==null,title:rt?`Delete "${rt.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const av="vskill.migrations.scope-rename.v1",ET={own:"authoring-project",installed:"available-project",global:"available-personal"},NT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function TT(t){if(t.getItem(av)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(NT);if(!c)continue;const[,u,d]=c,h=ET[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(av,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{TT(window.localStorage)}catch{}u0.createRoot(document.getElementById("root")).render(a.jsx(p.StrictMode,{children:a.jsx(Mj,{children:a.jsx(y2,{children:a.jsx(wT,{})})})}));export{Zo as E,Sv as L,ni as P,Ne as R,NE as S,Ur as a,Fy as b,wE as c,Xo as d,pT as g,a as j,p as r,ne as s,uf as t,W0 as u,fT as w};
101
+ }`})]}),document.body)}function _N({agent:t,focused:r,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return a.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),a.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function ON({row:t,onFocus:r}){return a.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),a.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function BN({agent:t}){const r=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return a.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),a.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&a.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function IN({agent:t,activeAgentId:r,onSwitch:s}){const o=t.id===r,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":HN(t.health)})]}),a.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[a.jsx($d,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),a.jsx($d,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),a.jsx($d,{label:ne.scopePicker.statsLastSync,value:t.lastSync?UN(t.lastSync):"—"})]}),a.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function $d({label:t,value:r}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function Zg(){return a.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function UN(t){try{const r=new Date(t).getTime(),s=Date.now()-r;if(Number.isNaN(r))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function HN(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function $N(t){const r=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)r.set(o,s);return t.agents.map(s=>{const o=r.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function VN({agents:t,activeAgentId:r,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useMemo(()=>t.find(S=>S.id===r)??t[0]??null,[t,r]),y=m.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=m.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),a.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&a.jsx(DN,{agents:t,activeAgentId:r,focusedAgentId:d??r,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Vy="vskill-ccode-banner-dismissed",PN=new Set(["claude-cli","claude-code"]);function FN(){try{return sessionStorage.getItem(Vy)==="true"}catch{return!1}}function GN(){try{sessionStorage.setItem(Vy,"true")}catch{}}function WN({activeAgentId:t}){const[r,s]=m.useState(()=>FN()),o=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{GN(),s(!0)},[]);return!t||!PN.has(t)||r?null:a.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function qN(){const[t,r]=m.useState(null),[s,o]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const h=await Ce.getAgents();r(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Co="workspace",YN=["skills","agents"];async function KN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function XN(t){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${r.status}`)}return await r.json()}async function QN(t){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function ZN(t){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${r.status}`)}return await r.json()}function Vd(){for(const t of YN)Tn(t)}function JN(){const{data:t,loading:r,error:s,revalidate:o}=ti(Co,KN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),d=m.useCallback(async p=>{await XN(p),Tn(Co),Vd()},[]),h=m.useCallback(async p=>{await QN(p),Tn(Co),Vd()},[]),g=m.useCallback(async p=>{await ZN(p),Tn(Co),Vd()},[]);return{workspace:c,activeProject:u,loading:r,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function eT({workspace:t,onSwitch:r,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(""),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=p.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function O(z){if(z.length<=50)return z;const U=z.split("/");return U.length<=4?z:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return a.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[a.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),a.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&a.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[B.length===0&&a.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&a.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const U=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return a.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&a.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),a.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),U&&a.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),a.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"}),a.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),a.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&a.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("input",{type:"text",value:p,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[a.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),a.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),a.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),a.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),a.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function tT(t,r){const s=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function nT({open:t,projects:r,onSwitch:s,onClose:o}){const[c,u]=m.useState(""),[d,h]=m.useState(0),g=m.useMemo(()=>tT(r,c),[r,c]);m.useEffect(()=>{t||(u(""),h(0))},[t]),m.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?a.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[a.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),a.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[a.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),a.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&a.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>a.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[a.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),a.jsxs("span",{className:"flex-1",children:[a.jsx("span",{className:"vskill-palette-name",children:y.name}),a.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const Jg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function aT({open:t,onClose:r,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=m.useState("destination"),[g,p]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[k,E]=m.useState(""),[C,N]=m.useState([]),[T,A]=m.useState(!1),[B,D]=m.useState(null);if(m.useEffect(()=>{t&&(h("destination"),p(s),v(""),S(""),E(""),D(null))},[t,s]),m.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),m.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),r())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,r]),!t)return null;const F=C.length>0,w=o&&F,O=o,z=Jg.test(y),U=g==="existing-plugin"?b.length>0:Jg.test(b),H=!T&&z&&(g==="standalone"||U),q=rT(c,g,b,y);async function X(){D(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){D(V.error??`Check failed: ${I.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),r()}async function J(){D(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){D(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),r()}catch($){D($ instanceof Error?$.message:String($))}finally{A(!1)}}return a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),a.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[a.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&a.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx(Pd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),a.jsx(Pd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&p("existing-plugin")}),a.jsx(Pd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),d==="details"&&a.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&a.jsx(Eo,{label:"Plugin name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:No(!b||U)})}),g==="existing-plugin"&&a.jsx(Eo,{label:"Plugin",children:a.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...No(!0),fontFamily:"var(--font-mono)"},children:[a.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>a.jsx("option",{value:$.name,children:$.name},$.path))]})}),a.jsx(Eo,{label:"Skill name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:No(!y||z)})}),a.jsx(Eo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:a.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...No(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&a.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>a.jsx("div",{children:$},L))]}),B&&a.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[a.jsx("button",{type:"button",onClick:r,style:Fd,children:"Cancel"}),d==="destination"&&a.jsx("button",{type:"button",onClick:()=>h("details"),style:ev,children:"Continue →"}),d==="details"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>h("destination"),style:Fd,children:"← Back"}),a.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...Fd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),a.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...ev,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Pd({title:t,subtitle:r,description:s,icon:o,selected:c,disabled:u,onClick:d}){return a.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Eo({label:t,hint:r,children:s}){return a.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),r&&a.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),s]})}function No(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const ev={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},Fd={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function rT(t,r,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return r==="standalone"?[`${d}/skills/${c}/SKILL.md`]:r==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:r==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Py(t){return t.trim().toLowerCase()}function lT(t,r){const s=Py(r);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function sT(t,r){const s=Py(r);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function iT({open:t,onClose:r,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=m.useState(null),[h,g]=m.useState([]),[p,y]=m.useState(null),[v,b]=m.useState(null),[S,k]=m.useState(!1),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{p?T(""):B("")},[p]);const D=m.useMemo(()=>lT(h,N),[h,N]),F=m.useMemo(()=>sT((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),m.useEffect(()=>{if(!p){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[p]),m.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&r()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,r]),t?a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),a.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[p&&a.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),a.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:p?(v==null?void 0:v.name)??p:"Browse plugins"}),a.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&a.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!p&&!S&&h.length===0&&!E&&a.jsx(oT,{}),!p&&h.length>0&&a.jsx(tv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&h.length>0&&D.length===0&&a.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!p&&D.map(w=>a.jsxs("button",{type:"button",onClick:()=>y(w.name),style:uT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),p&&v&&a.jsxs(a.Fragment,{children:[v.description&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&a.jsx(tv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&a.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return a.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:a.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?a.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):a.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,p),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!p&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:a.jsx(cT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function tv({value:t,onChange:r,placeholder:s,ariaLabel:o,testId:c}){return a.jsx("div",{style:{padding:"0 4px 10px"},children:a.jsx("input",{type:"search",value:t,onChange:u=>r(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function oT(){return a.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",a.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[a.jsx("li",{children:a.jsx("code",{children:"anthropics/claude-plugins-official"})}),a.jsx("li",{children:a.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function cT({onAdded:t}){const[r,s]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null);async function h(){const g=r.trim();if(g){c(!0),d(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){d(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){d(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{type:"text",value:r,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!r.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!r.trim()?"not-allowed":"pointer",opacity:o||!r.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const uT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Gd=12;function dT({job:t,onDone:r}){const[s,o]=m.useState([]),[c,u]=m.useState("running"),[d,h]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),r({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Gd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Gd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),zv(),Tn("skills"),r({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Gd),o(b))}catch{}}}S==="running"&&r({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),r({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return a.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[a.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?a.jsx(fT,{}):p}),a.jsxs("span",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&a.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&a.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
+ `)})]})}function fT(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const pT=3e3,mT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function nv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function hT(){const{toast:t}=Df(),r=m.useRef(new Map),s=m.useCallback(o=>{if(!nv(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<pT)return;r.current.set(o.provider,c);const d=mT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!nv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Fy="vskill.studio.prefs";function Gy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Wy(){const t=Gy();if(!t)return{};try{const r=t.getItem(Fy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function xT(t,r){const s=Gy();if(s)try{const c={...Wy(),[t]:r};s.setItem(Fy,JSON.stringify(c))}catch{}}function gT(t,r){const o=Wy()[t];return o===void 0?r:o}const av={open:!1,x:0,y:0,skill:null};function vT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function _r(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function yT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function bT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{_r(ne.toasts.permissionDenied,"error");return}_r(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_r(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_r(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_r(ne.toasts.skillDuplicated,"info");return;case"update":_r(ne.toasts.skillUpdated,"info");return;case"uninstall":_r(ne.actions.editPlaceholder,"info");return;case"delete":yT(r);return;default:return}}function jT(t){return t.startsWith("#/create")}function ST(t){return t.startsWith("#/updates")}function qy(t){const[r,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),r}function kT(){return qy(jT)}function wT(){return qy(ST)}const CT=m.lazy(()=>Xs(()=>import("./CommandPalette-BZekSSlW.js"),__vite__mapDeps([2,1]))),ET=m.lazy(()=>Xs(()=>import("./CreateSkillPage-CJCr7_2R.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),NT=m.lazy(()=>Xs(()=>Promise.resolve().then(()=>DE),void 0).then(t=>({default:t.UpdatesPanel})));function TT(){return a.jsx(xS,{children:a.jsx(pS,{children:a.jsxs(tN,{children:[a.jsx(RT,{}),a.jsx(xN,{})]})})})}function RT(){var Wn,Et;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ea(),{config:h}=Hr(),{mode:g,resolvedTheme:p,setTheme:y}=Lv(),{toast:v}=Df(),[b,S]=m.useState(()=>Ow()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(vT(oe,xe))},[]),U=qN(),[H,q]=m.useState(()=>gT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),xT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?$N(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=JN(),[se,M]=m.useState(!1),[Y,W]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),W(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const re=LN(),he=re.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),hT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[rt,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>SN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=kN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=rt;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[rt,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),an=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{r({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[r]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=kT(),za=wT()?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(NT,{})}):gt?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(ET,{})}):a.jsx(oN,{selectedSkillInfo:an,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return a.jsxs(a.Fragment,{children:[a.jsx(gS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Uw,{connected:k}),liveMessage:Mt,topRail:a.jsx(h2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?a.jsx(eT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:a.jsx(Tw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?a.jsxs(a.Fragment,{children:[a.jsx(VN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>re.open(oe)}),a.jsx(WN,{activeAgentId:H})]}):null}),resizeHandle:a.jsx(Iw,{initialWidth:b??Us,onChange:S}),main:za,statusBar:a.jsx(E2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(vN,{open:N,onClose:()=>T(!1)}),a.jsx(EN,{open:re.isOpen,providerKey:re.providerKey,onClose:re.close}),a.jsx(bN,{state:w,onClose:pe,onAction:(oe,xe)=>bT(oe,xe)}),E&&a.jsx(m.Suspense,{fallback:null,children:a.jsx(CT,{open:E,onClose:()=>C(!1),commands:xt})}),a.jsx(nT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),a.jsx(aT,{open:Y,onClose:()=>W(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),a.jsx(iT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),a.jsx(Rv,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),a.jsx(dT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),a.jsx(jN,{open:rt!==null,title:rt?`Delete "${rt.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const rv="vskill.migrations.scope-rename.v1",AT={own:"authoring-project",installed:"available-project",global:"available-personal"},MT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function LT(t){if(t.getItem(rv)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(MT);if(!c)continue;const[,u,d]=c,h=AT[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(rv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{LT(window.localStorage)}catch{}f0.createRoot(document.getElementById("root")).render(a.jsx(m.StrictMode,{children:a.jsx(zj,{children:a.jsx(j2,{children:a.jsx(TT,{})})})}));export{Zo as E,kv as L,ni as P,Te as R,RE as S,Hr as a,Wy as b,EE as c,Xo as d,gT as g,a as j,m as r,ne as s,uf as t,Y0 as u,xT as w};