vskill 0.5.138 → 0.5.140
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.
- package/README.md +16 -16
- package/agents.json +1 -1
- package/dist/commands/stamp-versions.d.ts +25 -0
- package/dist/commands/stamp-versions.js +153 -0
- package/dist/commands/stamp-versions.js.map +1 -0
- package/dist/eval-server/api-routes.js +13 -5
- package/dist/eval-server/api-routes.js.map +1 -1
- package/dist/eval-server/skill-dir-registry.d.ts +15 -0
- package/dist/eval-server/skill-dir-registry.js +34 -0
- package/dist/eval-server/skill-dir-registry.js.map +1 -1
- package/dist/eval-server/skill-resolver.js +6 -1
- package/dist/eval-server/skill-resolver.js.map +1 -1
- package/dist/eval-ui/assets/{CommandPalette-DWl6kb7K.js → CommandPalette-DeEo1aM2.js} +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-IndkXdwH.js → CreateSkillPage-BGi_wZ1y.js} +1 -1
- package/dist/eval-ui/assets/{FindSkillsPalette-Br5cToMQ.js → FindSkillsPalette-BbJJSef2.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-usZJoJGb.js → SearchPaletteCore-BK0cFJb6.js} +1 -1
- package/dist/eval-ui/assets/{SkillDetailPanel-ZGSkm510.js → SkillDetailPanel-DxidXsNP.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-Borwxx95.js → UpdateDropdown-CcaDVKoz.js} +1 -1
- package/dist/eval-ui/assets/index-ByzTygib.css +1 -0
- package/dist/eval-ui/assets/index-C12VKBb6.js +110 -0
- package/dist/eval-ui/index.html +2 -2
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/eval-ui/assets/index-BOR1gyX9.js +0 -102
- package/dist/eval-ui/assets/index-C8DXCPPg.css +0 -1
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-Borwxx95.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-DWl6kb7K.js","assets/FindSkillsPalette-Br5cToMQ.js","assets/SkillDetailPanel-ZGSkm510.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-IndkXdwH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
/* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.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 pv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ud={exports:{}},As={};/**
|
|
3
|
-
* @license React
|
|
4
|
-
* react-jsx-runtime.production.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var Rx;function h0(){if(Rx)return As;Rx=1;var t=Symbol.for("react.transitional.element"),a=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 As.Fragment=a,As.jsx=s,As.jsxs=s,As}var Ax;function x0(){return Ax||(Ax=1,ud.exports=h0()),ud.exports}var r=x0(),dd={exports:{}},He={};/**
|
|
11
|
-
* @license React
|
|
12
|
-
* react.production.js
|
|
13
|
-
*
|
|
14
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the MIT license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var Mx;function g0(){if(Mx)return He;Mx=1;var t=Symbol.for("react.transitional.element"),a=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"),x=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function S(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,w={};function T(z,W,te){this.props=z,this.context=W,this.refs=w,this.updater=te||C}T.prototype.isReactComponent={},T.prototype.setState=function(z,W){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,W,"setState")},T.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function N(){}N.prototype=T.prototype;function L(z,W,te){this.props=z,this.context=W,this.refs=w,this.updater=te||C}var _=L.prototype=new N;_.constructor=L,k(_,T.prototype),_.isPureReactComponent=!0;var D=Array.isArray;function F(){}var E={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(z,W,te){var q=te.ref;return{$$typeof:t,type:z,key:W,ref:q!==void 0?q:null,props:te}}function U(z,W){return M(z.type,W,z.props)}function $(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function Y(z){var W={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(te){return W[te]})}var X=/\/+/g;function ee(z,W){return typeof z=="object"&&z!==null&&z.key!=null?Y(""+z.key):W.toString(36)}function I(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(F,F):(z.status="pending",z.then(function(W){z.status==="pending"&&(z.status="fulfilled",z.value=W)},function(W){z.status==="pending"&&(z.status="rejected",z.reason=W)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function A(z,W,te,q,oe){var le=typeof z;(le==="undefined"||le==="boolean")&&(z=null);var ve=!1;if(z===null)ve=!0;else switch(le){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(z.$$typeof){case t:case a:ve=!0;break;case v:return ve=z._init,A(ve(z._payload),W,te,q,oe)}}if(ve)return oe=oe(z),ve=q===""?"."+ee(z,0):q,D(oe)?(te="",ve!=null&&(te=ve.replace(X,"$&/")+"/"),A(oe,W,te,"",function(Re){return Re})):oe!=null&&($(oe)&&(oe=U(oe,te+(oe.key==null||z&&z.key===oe.key?"":(""+oe.key).replace(X,"$&/")+"/")+ve)),W.push(oe)),1;ve=0;var ce=q===""?".":q+":";if(D(z))for(var be=0;be<z.length;be++)q=z[be],le=ce+ee(q,be),ve+=A(q,W,te,le,oe);else if(be=S(z),typeof be=="function")for(z=be.call(z),be=0;!(q=z.next()).done;)q=q.value,le=ce+ee(q,be++),ve+=A(q,W,te,le,oe);else if(le==="object"){if(typeof z.then=="function")return A(I(z),W,te,q,oe);throw W=String(z),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ve}function B(z,W,te){if(z==null)return z;var q=[],oe=0;return A(z,q,"","",function(le){return W.call(te,le,oe++)}),q}function V(z){if(z._status===-1){var W=z._result;W=W(),W.then(function(te){(z._status===0||z._status===-1)&&(z._status=1,z._result=te)},function(te){(z._status===0||z._status===-1)&&(z._status=2,z._result=te)}),z._status===-1&&(z._status=0,z._result=W)}if(z._status===1)return z._result.default;throw z._result}var H=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},re={map:B,forEach:function(z,W,te){B(z,function(){W.apply(this,arguments)},te)},count:function(z){var W=0;return B(z,function(){W++}),W},toArray:function(z){return B(z,function(W){return W})||[]},only:function(z){if(!$(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return He.Activity=y,He.Children=re,He.Component=T,He.Fragment=s,He.Profiler=c,He.PureComponent=L,He.StrictMode=o,He.Suspense=x,He.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,He.__COMPILER_RUNTIME={__proto__:null,c:function(z){return E.H.useMemoCache(z)}},He.cache=function(z){return function(){return z.apply(null,arguments)}},He.cacheSignal=function(){return null},He.cloneElement=function(z,W,te){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var q=k({},z.props),oe=z.key;if(W!=null)for(le in W.key!==void 0&&(oe=""+W.key),W)!O.call(W,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&W.ref===void 0||(q[le]=W[le]);var le=arguments.length-2;if(le===1)q.children=te;else if(1<le){for(var ve=Array(le),ce=0;ce<le;ce++)ve[ce]=arguments[ce+2];q.children=ve}return M(z.type,oe,q)},He.createContext=function(z){return z={$$typeof:d,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:u,_context:z},z},He.createElement=function(z,W,te){var q,oe={},le=null;if(W!=null)for(q in W.key!==void 0&&(le=""+W.key),W)O.call(W,q)&&q!=="key"&&q!=="__self"&&q!=="__source"&&(oe[q]=W[q]);var ve=arguments.length-2;if(ve===1)oe.children=te;else if(1<ve){for(var ce=Array(ve),be=0;be<ve;be++)ce[be]=arguments[be+2];oe.children=ce}if(z&&z.defaultProps)for(q in ve=z.defaultProps,ve)oe[q]===void 0&&(oe[q]=ve[q]);return M(z,le,oe)},He.createRef=function(){return{current:null}},He.forwardRef=function(z){return{$$typeof:h,render:z}},He.isValidElement=$,He.lazy=function(z){return{$$typeof:v,_payload:{_status:-1,_result:z},_init:V}},He.memo=function(z,W){return{$$typeof:m,type:z,compare:W===void 0?null:W}},He.startTransition=function(z){var W=E.T,te={};E.T=te;try{var q=z(),oe=E.S;oe!==null&&oe(te,q),typeof q=="object"&&q!==null&&typeof q.then=="function"&&q.then(F,H)}catch(le){H(le)}finally{W!==null&&te.types!==null&&(W.types=te.types),E.T=W}},He.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},He.use=function(z){return E.H.use(z)},He.useActionState=function(z,W,te){return E.H.useActionState(z,W,te)},He.useCallback=function(z,W){return E.H.useCallback(z,W)},He.useContext=function(z){return E.H.useContext(z)},He.useDebugValue=function(){},He.useDeferredValue=function(z,W){return E.H.useDeferredValue(z,W)},He.useEffect=function(z,W){return E.H.useEffect(z,W)},He.useEffectEvent=function(z){return E.H.useEffectEvent(z)},He.useId=function(){return E.H.useId()},He.useImperativeHandle=function(z,W,te){return E.H.useImperativeHandle(z,W,te)},He.useInsertionEffect=function(z,W){return E.H.useInsertionEffect(z,W)},He.useLayoutEffect=function(z,W){return E.H.useLayoutEffect(z,W)},He.useMemo=function(z,W){return E.H.useMemo(z,W)},He.useOptimistic=function(z,W){return E.H.useOptimistic(z,W)},He.useReducer=function(z,W,te){return E.H.useReducer(z,W,te)},He.useRef=function(z){return E.H.useRef(z)},He.useState=function(z){return E.H.useState(z)},He.useSyncExternalStore=function(z,W,te){return E.H.useSyncExternalStore(z,W,te)},He.useTransition=function(){return E.H.useTransition()},He.version="19.2.4",He}var Lx;function xf(){return Lx||(Lx=1,dd.exports=g0()),dd.exports}var p=xf();const Ne=pv(p);var fd={exports:{}},Ms={},pd={exports:{}},md={};/**
|
|
19
|
-
* @license React
|
|
20
|
-
* scheduler.production.js
|
|
21
|
-
*
|
|
22
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the MIT license found in the
|
|
25
|
-
* LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var zx;function v0(){return zx||(zx=1,(function(t){function a(A,B){var V=A.length;A.push(B);e:for(;0<V;){var H=V-1>>>1,re=A[H];if(0<c(re,B))A[H]=B,A[V]=re,V=H;else break e}}function s(A){return A.length===0?null:A[0]}function o(A){if(A.length===0)return null;var B=A[0],V=A.pop();if(V!==B){A[0]=V;e:for(var H=0,re=A.length,z=re>>>1;H<z;){var W=2*(H+1)-1,te=A[W],q=W+1,oe=A[q];if(0>c(te,V))q<re&&0>c(oe,te)?(A[H]=oe,A[q]=V,H=q):(A[H]=te,A[W]=V,H=W);else if(q<re&&0>c(oe,V))A[H]=oe,A[q]=V,H=q;else break e}}return B}function c(A,B){var V=A.sortIndex-B.sortIndex;return V!==0?V:A.id-B.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 x=[],m=[],v=1,y=null,b=3,S=!1,C=!1,k=!1,w=!1,T=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function _(A){for(var B=s(m);B!==null;){if(B.callback===null)o(m);else if(B.startTime<=A)o(m),B.sortIndex=B.expirationTime,a(x,B);else break;B=s(m)}}function D(A){if(k=!1,_(A),!C)if(s(x)!==null)C=!0,F||(F=!0,Y());else{var B=s(m);B!==null&&I(D,B.startTime-A)}}var F=!1,E=-1,O=5,M=-1;function U(){return w?!0:!(t.unstable_now()-M<O)}function $(){if(w=!1,F){var A=t.unstable_now();M=A;var B=!0;try{e:{C=!1,k&&(k=!1,N(E),E=-1),S=!0;var V=b;try{t:{for(_(A),y=s(x);y!==null&&!(y.expirationTime>A&&U());){var H=y.callback;if(typeof H=="function"){y.callback=null,b=y.priorityLevel;var re=H(y.expirationTime<=A);if(A=t.unstable_now(),typeof re=="function"){y.callback=re,_(A),B=!0;break t}y===s(x)&&o(x),_(A)}else o(x);y=s(x)}if(y!==null)B=!0;else{var z=s(m);z!==null&&I(D,z.startTime-A),B=!1}}break e}finally{y=null,b=V,S=!1}B=void 0}}finally{B?Y():F=!1}}}var Y;if(typeof L=="function")Y=function(){L($)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,ee=X.port2;X.port1.onmessage=$,Y=function(){ee.postMessage(null)}}else Y=function(){T($,0)};function I(A,B){E=T(function(){A(t.unstable_now())},B)}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(A){A.callback=null},t.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<A?Math.floor(1e3/A):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(A){switch(b){case 1:case 2:case 3:var B=3;break;default:B=b}var V=b;b=B;try{return A()}finally{b=V}},t.unstable_requestPaint=function(){w=!0},t.unstable_runWithPriority=function(A,B){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var V=b;b=A;try{return B()}finally{b=V}},t.unstable_scheduleCallback=function(A,B,V){var H=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?H+V:H):V=H,A){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=V+re,A={id:v++,callback:B,priorityLevel:A,startTime:V,expirationTime:re,sortIndex:-1},V>H?(A.sortIndex=V,a(m,A),s(x)===null&&A===s(m)&&(k?(N(E),E=-1):k=!0,I(D,V-H))):(A.sortIndex=re,a(x,A),C||S||(C=!0,F||(F=!0,Y()))),A},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(A){var B=b;return function(){var V=b;b=B;try{return A.apply(this,arguments)}finally{b=V}}}})(md)),md}var Dx;function y0(){return Dx||(Dx=1,pd.exports=v0()),pd.exports}var hd={exports:{}},rn={};/**
|
|
27
|
-
* @license React
|
|
28
|
-
* react-dom.production.js
|
|
29
|
-
*
|
|
30
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
31
|
-
*
|
|
32
|
-
* This source code is licensed under the MIT license found in the
|
|
33
|
-
* LICENSE file in the root directory of this source tree.
|
|
34
|
-
*/var _x;function b0(){if(_x)return rn;_x=1;var t=xf();function a(x){var m="https://react.dev/errors/"+x;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)m+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+x+"; 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(a(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(x,m,v){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:y==null?null:""+y,children:x,containerInfo:m,implementation:v}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(x,m){if(x==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,rn.createPortal=function(x,m){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(a(299));return u(x,m,null,v)},rn.flushSync=function(x){var m=d.T,v=o.p;try{if(d.T=null,o.p=2,x)return x()}finally{d.T=m,o.p=v,o.d.f()}},rn.preconnect=function(x,m){typeof x=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,o.d.C(x,m))},rn.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},rn.preinit=function(x,m){if(typeof x=="string"&&m&&typeof m.as=="string"){var v=m.as,y=h(v,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;v==="style"?o.d.S(x,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:y,integrity:b,fetchPriority:S}):v==="script"&&o.d.X(x,{crossOrigin:y,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},rn.preinitModule=function(x,m){if(typeof x=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var v=h(m.as,m.crossOrigin);o.d.M(x,{crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&o.d.M(x)},rn.preload=function(x,m){if(typeof x=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var v=m.as,y=h(v,m.crossOrigin);o.d.L(x,v,{crossOrigin:y,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})}},rn.preloadModule=function(x,m){if(typeof x=="string")if(m){var v=h(m.as,m.crossOrigin);o.d.m(x,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else o.d.m(x)},rn.requestFormReset=function(x){o.d.r(x)},rn.unstable_batchedUpdates=function(x,m){return x(m)},rn.useFormState=function(x,m,v){return d.H.useFormState(x,m,v)},rn.useFormStatus=function(){return d.H.useHostTransitionStatus()},rn.version="19.2.4",rn}var Ox;function mv(){if(Ox)return hd.exports;Ox=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(a){console.error(a)}}return t(),hd.exports=b0(),hd.exports}/**
|
|
35
|
-
* @license React
|
|
36
|
-
* react-dom-client.production.js
|
|
37
|
-
*
|
|
38
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the MIT license found in the
|
|
41
|
-
* LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/var Bx;function j0(){if(Bx)return Ms;Bx=1;var t=y0(),a=xf(),s=mv();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 x(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 g=f.alternate;if(g===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return x(f),e;if(g===i)return x(f),n;g=g.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=g;else{for(var j=!1,R=f.child;R;){if(R===l){j=!0,l=f,i=g;break}if(R===i){j=!0,i=f,l=g;break}R=R.sibling}if(!j){for(R=g.child;R;){if(R===l){j=!0,l=g,i=f;break}if(R===i){j=!0,i=g,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 v(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=v(e),n!==null)return n;e=e.sibling}return null}var y=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),L=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function Y(e){return e===null||typeof e!="object"?null:(e=$&&e[$]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function ee(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 k:return"Fragment";case T:return"Profiler";case w:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case M:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case L:return e.displayName||"Context";case N:return(e._context.displayName||"Context")+".Consumer";case _: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:ee(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return ee(e(n))}catch{}}return null}var I=Array.isArray,A=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},H=[],re=-1;function z(e){return{current:e}}function W(e){0>re||(e.current=H[re],H[re]=null,re--)}function te(e,n){re++,H[re]=e.current,e.current=n}var q=z(null),oe=z(null),le=z(null),ve=z(null);function ce(e,n){switch(te(le,n),te(oe,e),te(q,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Zh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Zh(n),e=Jh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}W(q),te(q,e)}function be(){W(q),W(oe),W(le)}function Re(e){e.memoizedState!==null&&te(ve,e);var n=q.current,l=Jh(n,e.type);n!==l&&(te(oe,e),te(q,l))}function Ae(e){oe.current===e&&(W(q),W(oe)),ve.current===e&&(W(ve),Es._currentValue=V)}var se,he;function pe(e){if(se===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);se=n&&n[1]||"",he=-1<l.stack.indexOf(`
|
|
43
|
-
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
-
`+se+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 de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(ae){var J=ae}Reflect.construct(e,[],de)}else{try{de.call()}catch(ae){J=ae}e.call(de.prototype)}}else{try{throw Error()}catch(ae){J=ae}(de=e())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(ae){if(ae&&J&&typeof ae.stack=="string")return[ae.stack,J.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 g=i.DetermineComponentFrameRoot(),j=g[0],R=g[1];if(j&&R){var P=j.split(`
|
|
45
|
-
`),Z=R.split(`
|
|
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 ie=`
|
|
47
|
-
`+P[i].replace(" at new "," at ");return e.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",e.displayName)),ie}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 Ue(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
|
|
48
|
-
Error generating stack: `+i.message+`
|
|
49
|
-
`+i.stack}}var gt=Object.prototype.hasOwnProperty,Lt=t.unstable_scheduleCallback,st=t.unstable_cancelCallback,Et=t.unstable_shouldYield,Yt=t.unstable_requestPaint,Ye=t.unstable_now,vt=t.unstable_getCurrentPriorityLevel,bn=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,ht=t.unstable_NormalPriority,zt=t.unstable_LowPriority,Ot=t.unstable_IdlePriority,Dn=t.log,Nt=t.unstable_setDisableYieldValue,_n=null,Pt=null;function Tt(e){if(typeof Dn=="function"&&Nt(e),Pt&&typeof Pt.setStrictMode=="function")try{Pt.setStrictMode(_n,e)}catch{}}var it=Math.clz32?Math.clz32:hr,rr=Math.log,ar=Math.LN2;function hr(e){return e>>>=0,e===0?32:31-(rr(e)/ar|0)|0}var pn=256,Rt=262144,De=4194304;function ot(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 sn(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,g=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~g,i!==0?f=ot(i):(j&=R,j!==0?f=ot(j):l||(l=R&~e,l!==0&&(f=ot(l))))):(R=i&~g,R!==0?f=ot(R):j!==0?f=ot(j):l||(l=i&~e,l!==0&&(f=ot(l)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:f}function Zt(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function fe(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 Ce(){var e=De;return De<<=1,(De&62914560)===0&&(De=4194304),e}function ze(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function jn(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ha(e,n,l,i,f,g){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 ie=31-it(l),de=1<<ie;R[ie]=0,P[ie]=-1;var J=Z[ie];if(J!==null)for(Z[ie]=null,ie=0;ie<J.length;ie++){var ae=J[ie];ae!==null&&(ae.lane&=-536870913)}l&=~de}i!==0&&lr(e,i,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(j&~n))}function lr(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-it(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function xa(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-it(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function ga(e,n){var l=n&-n;return l=(l&42)!==0?1:qa(l),(l&(e.suspendedLanes|n))!==0?0:l}function qa(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 Br(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ct(){var e=B.p;return e!==0?e:(e=window.event,e===void 0?32:Sx(e.type))}function va(e,n){var l=B.p;try{return B.p=e,n()}finally{B.p=l}}var on=Math.random().toString(36).slice(2),Vt="__reactFiber$"+on,ut="__reactProps$"+on,ya="__reactContainer$"+on,sr="__reactEvents$"+on,tc="__reactListeners$"+on,lb="__reactHandles$"+on,Uf="__reactResources$"+on,$l="__reactMarker$"+on;function nc(e){delete e[Vt],delete e[ut],delete e[sr],delete e[tc],delete e[lb]}function Ya(e){var n=e[Vt];if(n)return n;for(var l=e.parentNode;l;){if(n=l[ya]||l[Vt]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=sx(e);e!==null;){if(l=e[Vt])return l;e=sx(e)}return n}e=l,l=e.parentNode}return null}function Ka(e){if(e=e[Vt]||e[ya]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Pl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Xa(e){var n=e[Uf];return n||(n=e[Uf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(e){e[$l]=!0}var Hf=new Set,$f={};function ba(e,n){Qa(e,n),Qa(e+"Capture",n)}function Qa(e,n){for($f[e]=n,e=0;e<n.length;e++)Hf.add(n[e])}var sb=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]*$"),Pf={},Vf={};function ib(e){return gt.call(Vf,e)?!0:gt.call(Pf,e)?!1:sb.test(e)?Vf[e]=!0:(Pf[e]=!0,!1)}function li(e,n,l){if(ib(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 si(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 xr(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 On(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ff(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function ob(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,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,g.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 rc(e){if(!e._valueTracker){var n=Ff(e)?"checked":"value";e._valueTracker=ob(e,n,""+e[n])}}function Gf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=Ff(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function ii(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 cb=/[\n"\\]/g;function Bn(e){return e.replace(cb,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function ac(e,n,l,i,f,g,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=""+On(n)):e.value!==""+On(n)&&(e.value=""+On(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?lc(e,j,On(n)):l!=null?lc(e,j,On(l)):i!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+On(R):e.removeAttribute("name")}function Wf(e,n,l,i,f,g,j,R){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){rc(e);return}l=l!=null?""+On(l):"",n=n!=null?""+On(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),rc(e)}function lc(e,n,l){n==="number"&&ii(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Za(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=""+On(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 qf(e,n,l){if(n!=null&&(n=""+On(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+On(l):""}function Yf(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if(I(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=On(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),rc(e)}function Ja(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var ub=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 Kf(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||ub.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function Xf(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&&Kf(e,f,i)}else for(var g in n)n.hasOwnProperty(g)&&Kf(e,g,n[g])}function sc(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 db=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"]]),fb=/^[\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 oi(e){return fb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function gr(){}var ic=null;function oc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var el=null,tl=null;function Qf(e){var n=Ka(e);if(n&&(e=n.stateNode)){var l=e[ut]||null;e:switch(e=n.stateNode,n.type){case"input":if(ac(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="'+Bn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ut]||null;if(!f)throw Error(o(90));ac(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&&Gf(i)}break e;case"textarea":qf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Za(e,!!l.multiple,n,!1)}}}var cc=!1;function Zf(e,n,l){if(cc)return e(n,l);cc=!0;try{var i=e(n);return i}finally{if(cc=!1,(el!==null||tl!==null)&&(Ki(),el&&(n=el,e=tl,tl=el=null,Qf(n),e)))for(n=0;n<e.length;n++)Qf(e[n])}}function Vl(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ut]||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 vr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uc=!1;if(vr)try{var Fl={};Object.defineProperty(Fl,"passive",{get:function(){uc=!0}}),window.addEventListener("test",Fl,Fl),window.removeEventListener("test",Fl,Fl)}catch{uc=!1}var Ir=null,dc=null,ci=null;function Jf(){if(ci)return ci;var e,n=dc,l=n.length,i,f="value"in Ir?Ir.value:Ir.textContent,g=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[g-i];i++);return ci=f.slice(e,1<i?1-i:void 0)}function ui(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 di(){return!0}function ep(){return!1}function mn(e){function n(l,i,f,g,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(g):g[R]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?di:ep,this.isPropagationStopped=ep,this}return y(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=di)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=di)},persist:function(){},isPersistent:di}),n}var ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fi=mn(ja),Gl=y({},ja,{view:0,detail:0}),pb=mn(Gl),fc,pc,Wl,pi=y({},Gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hc,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!==Wl&&(Wl&&e.type==="mousemove"?(fc=e.screenX-Wl.screenX,pc=e.screenY-Wl.screenY):pc=fc=0,Wl=e),fc)},movementY:function(e){return"movementY"in e?e.movementY:pc}}),tp=mn(pi),mb=y({},pi,{dataTransfer:0}),hb=mn(mb),xb=y({},Gl,{relatedTarget:0}),mc=mn(xb),gb=y({},ja,{animationName:0,elapsedTime:0,pseudoElement:0}),vb=mn(gb),yb=y({},ja,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),bb=mn(yb),jb=y({},ja,{data:0}),np=mn(jb),Sb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kb={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"},wb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Cb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=wb[e])?!!n[e]:!1}function hc(){return Cb}var Eb=y({},Gl,{key:function(e){if(e.key){var n=Sb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?kb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hc,charCode:function(e){return e.type==="keypress"?ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Nb=mn(Eb),Tb=y({},pi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),rp=mn(Tb),Rb=y({},Gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hc}),Ab=mn(Rb),Mb=y({},ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lb=mn(Mb),zb=y({},pi,{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}),Db=mn(zb),_b=y({},ja,{newState:0,oldState:0}),Ob=mn(_b),Bb=[9,13,27,32],xc=vr&&"CompositionEvent"in window,ql=null;vr&&"documentMode"in document&&(ql=document.documentMode);var Ib=vr&&"TextEvent"in window&&!ql,ap=vr&&(!xc||ql&&8<ql&&11>=ql),lp=" ",sp=!1;function ip(e,n){switch(e){case"keyup":return Bb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function op(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var nl=!1;function Ub(e,n){switch(e){case"compositionend":return op(n);case"keypress":return n.which!==32?null:(sp=!0,lp);case"textInput":return e=n.data,e===lp&&sp?null:e;default:return null}}function Hb(e,n){if(nl)return e==="compositionend"||!xc&&ip(e,n)?(e=Jf(),ci=dc=Ir=null,nl=!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 ap&&n.locale!=="ko"?null:n.data;default:return null}}var $b={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 cp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!$b[e.type]:n==="textarea"}function up(e,n,l,i){el?tl?tl.push(i):tl=[i]:el=i,n=no(n,"onChange"),0<n.length&&(l=new fi("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Yl=null,Kl=null;function Pb(e){Wh(e,0)}function mi(e){var n=Pl(e);if(Gf(n))return e}function dp(e,n){if(e==="change")return n}var fp=!1;if(vr){var gc;if(vr){var vc="oninput"in document;if(!vc){var pp=document.createElement("div");pp.setAttribute("oninput","return;"),vc=typeof pp.oninput=="function"}gc=vc}else gc=!1;fp=gc&&(!document.documentMode||9<document.documentMode)}function mp(){Yl&&(Yl.detachEvent("onpropertychange",hp),Kl=Yl=null)}function hp(e){if(e.propertyName==="value"&&mi(Kl)){var n=[];up(n,Kl,e,oc(e)),Zf(Pb,n)}}function Vb(e,n,l){e==="focusin"?(mp(),Yl=n,Kl=l,Yl.attachEvent("onpropertychange",hp)):e==="focusout"&&mp()}function Fb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return mi(Kl)}function Gb(e,n){if(e==="click")return mi(n)}function Wb(e,n){if(e==="input"||e==="change")return mi(n)}function qb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Sn=typeof Object.is=="function"?Object.is:qb;function Xl(e,n){if(Sn(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(!gt.call(n,f)||!Sn(e[f],n[f]))return!1}return!0}function xp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function gp(e,n){var l=xp(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=xp(l)}}function vp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?vp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function yp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=ii(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=ii(e.document)}return n}function yc(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 Yb=vr&&"documentMode"in document&&11>=document.documentMode,rl=null,bc=null,Ql=null,jc=!1;function bp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;jc||rl==null||rl!==ii(i)||(i=rl,"selectionStart"in i&&yc(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}),Ql&&Xl(Ql,i)||(Ql=i,i=no(bc,"onSelect"),0<i.length&&(n=new fi("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=rl)))}function Sa(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var al={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionrun:Sa("Transition","TransitionRun"),transitionstart:Sa("Transition","TransitionStart"),transitioncancel:Sa("Transition","TransitionCancel"),transitionend:Sa("Transition","TransitionEnd")},Sc={},jp={};vr&&(jp=document.createElement("div").style,"AnimationEvent"in window||(delete al.animationend.animation,delete al.animationiteration.animation,delete al.animationstart.animation),"TransitionEvent"in window||delete al.transitionend.transition);function ka(e){if(Sc[e])return Sc[e];if(!al[e])return e;var n=al[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in jp)return Sc[e]=n[l];return e}var Sp=ka("animationend"),kp=ka("animationiteration"),wp=ka("animationstart"),Kb=ka("transitionrun"),Xb=ka("transitionstart"),Qb=ka("transitioncancel"),Cp=ka("transitionend"),Ep=new Map,kc="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(" ");kc.push("scrollEnd");function Xn(e,n){Ep.set(e,n),ba(n,[e])}var hi=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)},In=[],ll=0,wc=0;function xi(){for(var e=ll,n=wc=ll=0;n<e;){var l=In[n];In[n++]=null;var i=In[n];In[n++]=null;var f=In[n];In[n++]=null;var g=In[n];if(In[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}g!==0&&Np(l,f,g)}}function gi(e,n,l,i){In[ll++]=e,In[ll++]=n,In[ll++]=l,In[ll++]=i,wc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function Cc(e,n,l,i){return gi(e,n,l,i),vi(e)}function wa(e,n){return gi(e,null,null,n),vi(e)}function Np(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,g=e.return;g!==null;)g.childLanes|=l,i=g.alternate,i!==null&&(i.childLanes|=l),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-it(l),e=g.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),g):null}function vi(e){if(50<ys)throw ys=0,Du=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var sl={};function Zb(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 kn(e,n,l,i){return new Zb(e,n,l,i)}function Ec(e){return e=e.prototype,!(!e||!e.isReactComponent)}function yr(e,n){var l=e.alternate;return l===null?(l=kn(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 Tp(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 yi(e,n,l,i,f,g){var j=0;if(i=e,typeof e=="function")Ec(e)&&(j=1);else if(typeof e=="string")j=r0(e,l,q.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case M:return e=kn(31,l,n,f),e.elementType=M,e.lanes=g,e;case k:return Ca(l.children,f,g,n);case w:j=8,f|=24;break;case T:return e=kn(12,l,n,f|2),e.elementType=T,e.lanes=g,e;case D:return e=kn(13,l,n,f),e.elementType=D,e.lanes=g,e;case F:return e=kn(19,l,n,f),e.elementType=F,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L:j=10;break e;case N:j=9;break e;case _:j=11;break e;case E: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=kn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=g,n}function Ca(e,n,l,i){return e=kn(7,e,i,n),e.lanes=l,e}function Nc(e,n,l){return e=kn(6,e,null,n),e.lanes=l,e}function Rp(e){var n=kn(18,null,null,0);return n.stateNode=e,n}function Tc(e,n,l){return n=kn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Ap=new WeakMap;function Un(e,n){if(typeof e=="object"&&e!==null){var l=Ap.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Ue(n)},Ap.set(e,n),n)}return{value:e,source:n,stack:Ue(n)}}var il=[],ol=0,bi=null,Zl=0,Hn=[],$n=0,Ur=null,ir=1,or="";function br(e,n){il[ol++]=Zl,il[ol++]=bi,bi=e,Zl=n}function Mp(e,n,l){Hn[$n++]=ir,Hn[$n++]=or,Hn[$n++]=Ur,Ur=e;var i=ir;e=or;var f=32-it(i)-1;i&=~(1<<f),l+=1;var g=32-it(n)+f;if(30<g){var j=f-f%5;g=(i&(1<<j)-1).toString(32),i>>=j,f-=j,ir=1<<32-it(n)+f|l<<f|i,or=g+e}else ir=1<<g|l<<f|i,or=e}function Rc(e){e.return!==null&&(br(e,1),Mp(e,1,0))}function Ac(e){for(;e===bi;)bi=il[--ol],il[ol]=null,Zl=il[--ol],il[ol]=null;for(;e===Ur;)Ur=Hn[--$n],Hn[$n]=null,or=Hn[--$n],Hn[$n]=null,ir=Hn[--$n],Hn[$n]=null}function Lp(e,n){Hn[$n++]=ir,Hn[$n++]=or,Hn[$n++]=Ur,ir=n.id,or=n.overflow,Ur=e}var Jt=null,yt=null,Qe=!1,Hr=null,Pn=!1,Mc=Error(o(519));function $r(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jl(Un(n,e)),Mc}function zp(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[Vt]=e,n[ut]=i,l){case"dialog":qe("cancel",n),qe("close",n);break;case"iframe":case"object":case"embed":qe("load",n);break;case"video":case"audio":for(l=0;l<js.length;l++)qe(js[l],n);break;case"source":qe("error",n);break;case"img":case"image":case"link":qe("error",n),qe("load",n);break;case"details":qe("toggle",n);break;case"input":qe("invalid",n),Wf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":qe("invalid",n);break;case"textarea":qe("invalid",n),Yf(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||Xh(n.textContent,l)?(i.popover!=null&&(qe("beforetoggle",n),qe("toggle",n)),i.onScroll!=null&&qe("scroll",n),i.onScrollEnd!=null&&qe("scrollend",n),i.onClick!=null&&(n.onclick=gr),n=!0):n=!1,n||$r(e,!0)}function Dp(e){for(Jt=e.return;Jt;)switch(Jt.tag){case 5:case 31:case 13:Pn=!1;return;case 27:case 3:Pn=!0;return;default:Jt=Jt.return}}function cl(e){if(e!==Jt)return!1;if(!Qe)return Dp(e),Qe=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Ku(e.type,e.memoizedProps)),l=!l),l&&yt&&$r(e),Dp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=lx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=lx(e)}else n===27?(n=yt,ta(e.type)?(e=ed,ed=null,yt=e):yt=n):yt=Jt?Fn(e.stateNode.nextSibling):null;return!0}function Ea(){yt=Jt=null,Qe=!1}function Lc(){var e=Hr;return e!==null&&(vn===null?vn=e:vn.push.apply(vn,e),Hr=null),e}function Jl(e){Hr===null?Hr=[e]:Hr.push(e)}var zc=z(null),Na=null,jr=null;function Pr(e,n,l){te(zc,n._currentValue),n._currentValue=l}function Sr(e){e._currentValue=zc.current,W(zc)}function Dc(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 _c(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var j=f.child;g=g.firstContext;e:for(;g!==null;){var R=g;g=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){g.lanes|=l,R=g.alternate,R!==null&&(R.lanes|=l),Dc(g.return,l,e),i||(j=null);break e}g=R.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,g=j.alternate,g!==null&&(g.lanes|=l),Dc(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 ul(e,n,l,i){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!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;Sn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===ve.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Es):e=[Es])}f=f.return}e!==null&&_c(n,e,l,i),n.flags|=262144}function ji(e){for(e=e.firstContext;e!==null;){if(!Sn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ta(e){Na=e,jr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function en(e){return _p(Na,e)}function Si(e,n){return Na===null&&Ta(e),_p(e,n)}function _p(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},jr===null){if(e===null)throw Error(o(308));jr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else jr=jr.next=n;return l}var Jb=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()})}},e1=t.unstable_scheduleCallback,t1=t.unstable_NormalPriority,Bt={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oc(){return{controller:new Jb,data:new Map,refCount:0}}function es(e){e.refCount--,e.refCount===0&&e1(t1,function(){e.controller.abort()})}var ts=null,Bc=0,dl=0,fl=null;function n1(e,n){if(ts===null){var l=ts=[];Bc=0,dl=Hu(),fl={status:"pending",value:void 0,then:function(i){l.push(i)}}}return Bc++,n.then(Op,Op),n}function Op(){if(--Bc===0&&ts!==null){fl!==null&&(fl.status="fulfilled");var e=ts;ts=null,dl=0,fl=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function r1(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 Bp=A.S;A.S=function(e,n){bh=Ye(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&n1(e,n),Bp!==null&&Bp(e,n)};var Ra=z(null);function Ic(){var e=Ra.current;return e!==null?e:xt.pooledCache}function ki(e,n){n===null?te(Ra,Ra.current):te(Ra,n.pool)}function Ip(){var e=Ic();return e===null?null:{parent:Bt._currentValue,pool:e}}var pl=Error(o(460)),Uc=Error(o(474)),wi=Error(o(542)),Ci={then:function(){}};function Up(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Hp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(gr,gr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Pp(e),e;default:if(typeof n.status=="string")n.then(gr,gr);else{if(e=xt,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,Pp(e),e}throw Ma=n,pl}}function Aa(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ma=l,pl):l}}var Ma=null;function $p(){if(Ma===null)throw Error(o(459));var e=Ma;return Ma=null,e}function Pp(e){if(e===pl||e===wi)throw Error(o(483))}var ml=null,ns=0;function Ei(e){var n=ns;return ns+=1,ml===null&&(ml=[]),Hp(ml,e,n)}function rs(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ni(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 Vp(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=yr(K,G),K.index=0,K.sibling=null,K}function g(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,ue){return G===null||G.tag!==6?(G=Nc(Q,K.mode,ue),G.return=K,G):(G=f(G,Q),G.return=K,G)}function P(K,G,Q,ue){var Me=Q.type;return Me===k?ie(K,G,Q.props.children,ue,Q.key):G!==null&&(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Aa(Me)===G.type)?(G=f(G,Q.props),rs(G,Q),G.return=K,G):(G=yi(Q.type,Q.key,Q.props,null,K.mode,ue),rs(G,Q),G.return=K,G)}function Z(K,G,Q,ue){return G===null||G.tag!==4||G.stateNode.containerInfo!==Q.containerInfo||G.stateNode.implementation!==Q.implementation?(G=Tc(Q,K.mode,ue),G.return=K,G):(G=f(G,Q.children||[]),G.return=K,G)}function ie(K,G,Q,ue,Me){return G===null||G.tag!==7?(G=Ca(Q,K.mode,ue,Me),G.return=K,G):(G=f(G,Q),G.return=K,G)}function de(K,G,Q){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Nc(""+G,K.mode,Q),G.return=K,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return Q=yi(G.type,G.key,G.props,null,K.mode,Q),rs(Q,G),Q.return=K,Q;case C:return G=Tc(G,K.mode,Q),G.return=K,G;case O:return G=Aa(G),de(K,G,Q)}if(I(G)||Y(G))return G=Ca(G,K.mode,Q,null),G.return=K,G;if(typeof G.then=="function")return de(K,Ei(G),Q);if(G.$$typeof===L)return de(K,Si(K,G),Q);Ni(K,G)}return null}function J(K,G,Q,ue){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,ue);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Me?P(K,G,Q,ue):null;case C:return Q.key===Me?Z(K,G,Q,ue):null;case O:return Q=Aa(Q),J(K,G,Q,ue)}if(I(Q)||Y(Q))return Me!==null?null:ie(K,G,Q,ue,null);if(typeof Q.then=="function")return J(K,G,Ei(Q),ue);if(Q.$$typeof===L)return J(K,G,Si(K,Q),ue);Ni(K,Q)}return null}function ae(K,G,Q,ue,Me){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return K=K.get(Q)||null,R(G,K,""+ue,Me);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case S:return K=K.get(ue.key===null?Q:ue.key)||null,P(G,K,ue,Me);case C:return K=K.get(ue.key===null?Q:ue.key)||null,Z(G,K,ue,Me);case O:return ue=Aa(ue),ae(K,G,Q,ue,Me)}if(I(ue)||Y(ue))return K=K.get(Q)||null,ie(G,K,ue,Me,null);if(typeof ue.then=="function")return ae(K,G,Q,Ei(ue),Me);if(ue.$$typeof===L)return ae(K,G,Q,Si(G,ue),Me);Ni(G,ue)}return null}function we(K,G,Q,ue){for(var Me=null,Je=null,Ee=G,Ve=G=0,Xe=null;Ee!==null&&Ve<Q.length;Ve++){Ee.index>Ve?(Xe=Ee,Ee=null):Xe=Ee.sibling;var et=J(K,Ee,Q[Ve],ue);if(et===null){Ee===null&&(Ee=Xe);break}e&&Ee&&et.alternate===null&&n(K,Ee),G=g(et,G,Ve),Je===null?Me=et:Je.sibling=et,Je=et,Ee=Xe}if(Ve===Q.length)return l(K,Ee),Qe&&br(K,Ve),Me;if(Ee===null){for(;Ve<Q.length;Ve++)Ee=de(K,Q[Ve],ue),Ee!==null&&(G=g(Ee,G,Ve),Je===null?Me=Ee:Je.sibling=Ee,Je=Ee);return Qe&&br(K,Ve),Me}for(Ee=i(Ee);Ve<Q.length;Ve++)Xe=ae(Ee,K,Ve,Q[Ve],ue),Xe!==null&&(e&&Xe.alternate!==null&&Ee.delete(Xe.key===null?Ve:Xe.key),G=g(Xe,G,Ve),Je===null?Me=Xe:Je.sibling=Xe,Je=Xe);return e&&Ee.forEach(function(sa){return n(K,sa)}),Qe&&br(K,Ve),Me}function Le(K,G,Q,ue){if(Q==null)throw Error(o(151));for(var Me=null,Je=null,Ee=G,Ve=G=0,Xe=null,et=Q.next();Ee!==null&&!et.done;Ve++,et=Q.next()){Ee.index>Ve?(Xe=Ee,Ee=null):Xe=Ee.sibling;var sa=J(K,Ee,et.value,ue);if(sa===null){Ee===null&&(Ee=Xe);break}e&&Ee&&sa.alternate===null&&n(K,Ee),G=g(sa,G,Ve),Je===null?Me=sa:Je.sibling=sa,Je=sa,Ee=Xe}if(et.done)return l(K,Ee),Qe&&br(K,Ve),Me;if(Ee===null){for(;!et.done;Ve++,et=Q.next())et=de(K,et.value,ue),et!==null&&(G=g(et,G,Ve),Je===null?Me=et:Je.sibling=et,Je=et);return Qe&&br(K,Ve),Me}for(Ee=i(Ee);!et.done;Ve++,et=Q.next())et=ae(Ee,K,Ve,et.value,ue),et!==null&&(e&&et.alternate!==null&&Ee.delete(et.key===null?Ve:et.key),G=g(et,G,Ve),Je===null?Me=et:Je.sibling=et,Je=et);return e&&Ee.forEach(function(m0){return n(K,m0)}),Qe&&br(K,Ve),Me}function pt(K,G,Q,ue){if(typeof Q=="object"&&Q!==null&&Q.type===k&&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===k){if(G.tag===7){l(K,G.sibling),ue=f(G,Q.props.children),ue.return=K,K=ue;break e}}else if(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Aa(Me)===G.type){l(K,G.sibling),ue=f(G,Q.props),rs(ue,Q),ue.return=K,K=ue;break e}l(K,G);break}else n(K,G);G=G.sibling}Q.type===k?(ue=Ca(Q.props.children,K.mode,ue,Q.key),ue.return=K,K=ue):(ue=yi(Q.type,Q.key,Q.props,null,K.mode,ue),rs(ue,Q),ue.return=K,K=ue)}return j(K);case C: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),ue=f(G,Q.children||[]),ue.return=K,K=ue;break e}else{l(K,G);break}else n(K,G);G=G.sibling}ue=Tc(Q,K.mode,ue),ue.return=K,K=ue}return j(K);case O:return Q=Aa(Q),pt(K,G,Q,ue)}if(I(Q))return we(K,G,Q,ue);if(Y(Q)){if(Me=Y(Q),typeof Me!="function")throw Error(o(150));return Q=Me.call(Q),Le(K,G,Q,ue)}if(typeof Q.then=="function")return pt(K,G,Ei(Q),ue);if(Q.$$typeof===L)return pt(K,G,Si(K,Q),ue);Ni(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,G!==null&&G.tag===6?(l(K,G.sibling),ue=f(G,Q),ue.return=K,K=ue):(l(K,G),ue=Nc(Q,K.mode,ue),ue.return=K,K=ue),j(K)):l(K,G)}return function(K,G,Q,ue){try{ns=0;var Me=pt(K,G,Q,ue);return ml=null,Me}catch(Ee){if(Ee===pl||Ee===wi)throw Ee;var Je=kn(29,Ee,null,K.mode);return Je.lanes=ue,Je.return=K,Je}finally{}}}var La=Vp(!0),Fp=Vp(!1),Vr=!1;function Hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $c(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 Fr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Gr(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=vi(e),Np(e,null,l),n}return gi(e,i,n,l),vi(e)}function as(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,xa(e,l)}}function Pc(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?f=g=j:g=g.next=j,l=l.next}while(l!==null);g===null?f=g=n:g=g.next=n}else f=g=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:g,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 Vc=!1;function ls(){if(Vc){var e=fl;if(e!==null)throw e}}function ss(e,n,l,i){Vc=!1;var f=e.updateQueue;Vr=!1;var g=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?g=Z:j.next=Z,j=P;var ie=e.alternate;ie!==null&&(ie=ie.updateQueue,R=ie.lastBaseUpdate,R!==j&&(R===null?ie.firstBaseUpdate=Z:R.next=Z,ie.lastBaseUpdate=P))}if(g!==null){var de=f.baseState;j=0,ie=Z=P=null,R=g;do{var J=R.lane&-536870913,ae=J!==R.lane;if(ae?(Ke&J)===J:(i&J)===J){J!==0&&J===dl&&(Vc=!0),ie!==null&&(ie=ie.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=e,Le=R;J=n;var pt=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){de=we.call(pt,de,J);break e}de=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,J=typeof we=="function"?we.call(pt,de,J):we,J==null)break e;de=y({},de,J);break e;case 2:Vr=!0}}J=R.callback,J!==null&&(e.flags|=64,ae&&(e.flags|=8192),ae=f.callbacks,ae===null?f.callbacks=[J]:ae.push(J))}else ae={lane:J,tag:R.tag,payload:R.payload,callback:R.callback,next:null},ie===null?(Z=ie=ae,P=de):ie=ie.next=ae,j|=J;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);ie===null&&(P=de),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=ie,g===null&&(f.shared.lanes=0),Xr|=j,e.lanes=j,e.memoizedState=de}}function Gp(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Wp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Gp(l[e],n)}var hl=z(null),Ti=z(0);function qp(e,n){e=Mr,te(Ti,e),te(hl,n),Mr=e|n.baseLanes}function Fc(){te(Ti,Mr),te(hl,hl.current)}function Gc(){Mr=Ti.current,W(hl),W(Ti)}var wn=z(null),Vn=null;function Wr(e){var n=e.alternate;te(Dt,Dt.current&1),te(wn,e),Vn===null&&(n===null||hl.current!==null||n.memoizedState!==null)&&(Vn=e)}function Wc(e){te(Dt,Dt.current),te(wn,e),Vn===null&&(Vn=e)}function Yp(e){e.tag===22?(te(Dt,Dt.current),te(wn,e),Vn===null&&(Vn=e)):qr()}function qr(){te(Dt,Dt.current),te(wn,wn.current)}function Cn(e){W(wn),Vn===e&&(Vn=null),W(Dt)}var Dt=z(0);function Ri(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Zu(l)||Ju(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 kr=0,Pe=null,dt=null,It=null,Ai=!1,xl=!1,za=!1,Mi=0,is=0,gl=null,a1=0;function At(){throw Error(o(321))}function qc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!Sn(e[l],n[l]))return!1;return!0}function Yc(e,n,l,i,f,g){return kr=g,Pe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,A.H=e===null||e.memoizedState===null?Mm:cu,za=!1,g=l(i,f),za=!1,xl&&(g=Xp(n,l,i,f)),Kp(e),g}function Kp(e){A.H=us;var n=dt!==null&&dt.next!==null;if(kr=0,It=dt=Pe=null,Ai=!1,is=0,gl=null,n)throw Error(o(300));e===null||Ut||(e=e.dependencies,e!==null&&ji(e)&&(Ut=!0))}function Xp(e,n,l,i){Pe=e;var f=0;do{if(xl&&(gl=null),is=0,xl=!1,25<=f)throw Error(o(301));if(f+=1,It=dt=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}A.H=Lm,g=n(l,i)}while(xl);return g}function l1(){var e=A.H,n=e.useState()[0];return n=typeof n.then=="function"?os(n):n,e=e.useState()[0],(dt!==null?dt.memoizedState:null)!==e&&(Pe.flags|=1024),n}function Kc(){var e=Mi!==0;return Mi=0,e}function Xc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Qc(e){if(Ai){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ai=!1}kr=0,It=dt=Pe=null,xl=!1,is=Mi=0,gl=null}function cn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return It===null?Pe.memoizedState=It=e:It=It.next=e,It}function _t(){if(dt===null){var e=Pe.alternate;e=e!==null?e.memoizedState:null}else e=dt.next;var n=It===null?Pe.memoizedState:It.next;if(n!==null)It=n,dt=e;else{if(e===null)throw Pe.alternate===null?Error(o(467)):Error(o(310));dt=e,e={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},It===null?Pe.memoizedState=It=e:It=It.next=e}return It}function Li(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function os(e){var n=is;return is+=1,gl===null&&(gl=[]),e=Hp(gl,e,n),n=Pe,(It===null?n.memoizedState:It.next)===null&&(n=n.alternate,A.H=n===null||n.memoizedState===null?Mm:cu),e}function zi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return os(e);if(e.$$typeof===L)return en(e)}throw Error(o(438,String(e)))}function Zc(e){var n=null,l=Pe.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=Pe.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=Li(),Pe.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 wr(e,n){return typeof n=="function"?n(e):n}function Di(e){var n=_t();return Jc(n,dt,e)}function Jc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,g=i.pending;if(g!==null){if(f!==null){var j=f.next;f.next=g.next,g.next=j}n.baseQueue=f=g,i.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var R=j=null,P=null,Z=n,ie=!1;do{var de=Z.lane&-536870913;if(de!==Z.lane?(Ke&de)===de:(kr&de)===de){var J=Z.revertLane;if(J===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),de===dl&&(ie=!0);else if((kr&J)===J){Z=Z.next,J===dl&&(ie=!0);continue}else de={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=de,j=g):P=P.next=de,Pe.lanes|=J,Xr|=J;de=Z.action,za&&l(g,de),g=Z.hasEagerState?Z.eagerState:l(g,de)}else J={lane:de,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=J,j=g):P=P.next=J,Pe.lanes|=de,Xr|=de;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=g:P.next=R,!Sn(g,e.memoizedState)&&(Ut=!0,ie&&(l=fl,l!==null)))throw l;e.memoizedState=g,e.baseState=j,e.baseQueue=P,i.lastRenderedState=g}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function eu(e){var n=_t(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,g=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do g=e(g,j.action),j=j.next;while(j!==f);Sn(g,n.memoizedState)||(Ut=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,i]}function Qp(e,n,l){var i=Pe,f=_t(),g=Qe;if(g){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!Sn((dt||f).memoizedState,l);if(j&&(f.memoizedState=l,Ut=!0),f=f.queue,ru(em.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||It!==null&&It.memoizedState.tag&1){if(i.flags|=2048,vl(9,{destroy:void 0},Jp.bind(null,i,f,l,n),null),xt===null)throw Error(o(349));g||(kr&127)!==0||Zp(i,n,l)}return l}function Zp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Pe.updateQueue,n===null?(n=Li(),Pe.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Jp(e,n,l,i){n.value=l,n.getSnapshot=i,tm(n)&&nm(e)}function em(e,n,l){return l(function(){tm(n)&&nm(e)})}function tm(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!Sn(e,l)}catch{return!0}}function nm(e){var n=wa(e,2);n!==null&&yn(n,e,2)}function tu(e){var n=cn();if(typeof e=="function"){var l=e;if(e=l(),za){Tt(!0);try{l()}finally{Tt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:e},n}function rm(e,n,l,i){return e.baseState=l,Jc(e,dt,typeof i=="function"?i:wr)}function s1(e,n,l,i,f){if(Bi(e))throw Error(o(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){g.listeners.push(j)}};A.T!==null?l(!0):g.isTransition=!1,i(g),l=n.pending,l===null?(g.next=n.pending=g,am(n,g)):(g.next=l.next,n.pending=l.next=g)}}function am(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var g=A.T,j={};A.T=j;try{var R=l(f,i),P=A.S;P!==null&&P(j,R),lm(e,n,R)}catch(Z){nu(e,n,Z)}finally{g!==null&&j.types!==null&&(g.types=j.types),A.T=g}}else try{g=l(f,i),lm(e,n,g)}catch(Z){nu(e,n,Z)}}function lm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){sm(e,n,i)},function(i){return nu(e,n,i)}):sm(e,n,l)}function sm(e,n,l){n.status="fulfilled",n.value=l,im(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,am(e,l)))}function nu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,im(n),n=n.next;while(n!==i)}e.action=null}function im(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function om(e,n){return n}function cm(e,n){if(Qe){var l=xt.formState;if(l!==null){e:{var i=Pe;if(Qe){if(yt){t:{for(var f=yt,g=Pn;f.nodeType!==8;){if(!g){f=null;break t}if(f=Fn(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){yt=Fn(f.nextSibling),i=f.data==="F!";break e}}$r(i)}i=!1}i&&(n=l[0])}}return l=cn(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:om,lastRenderedState:n},l.queue=i,l=Tm.bind(null,Pe,i),i.dispatch=l,i=tu(!1),g=ou.bind(null,Pe,!1,i.queue),i=cn(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=s1.bind(null,Pe,f,g,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function um(e){var n=_t();return dm(n,dt,e)}function dm(e,n,l){if(n=Jc(e,n,om)[0],e=Di(wr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=os(n)}catch(j){throw j===pl?wi:j}else i=n;n=_t();var f=n.queue,g=f.dispatch;return l!==n.memoizedState&&(Pe.flags|=2048,vl(9,{destroy:void 0},i1.bind(null,f,l),null)),[i,g,e]}function i1(e,n){e.action=n}function fm(e){var n=_t(),l=dt;if(l!==null)return dm(n,l,e);_t(),n=n.memoizedState,l=_t();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function vl(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=Pe.updateQueue,n===null&&(n=Li(),Pe.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 pm(){return _t().memoizedState}function _i(e,n,l,i){var f=cn();Pe.flags|=e,f.memoizedState=vl(1|n,{destroy:void 0},l,i===void 0?null:i)}function Oi(e,n,l,i){var f=_t();i=i===void 0?null:i;var g=f.memoizedState.inst;dt!==null&&i!==null&&qc(i,dt.memoizedState.deps)?f.memoizedState=vl(n,g,l,i):(Pe.flags|=e,f.memoizedState=vl(1|n,g,l,i))}function mm(e,n){_i(8390656,8,e,n)}function ru(e,n){Oi(2048,8,e,n)}function o1(e){Pe.flags|=4;var n=Pe.updateQueue;if(n===null)n=Li(),Pe.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function hm(e){var n=_t().memoizedState;return o1({ref:n,nextImpl:e}),function(){if((nt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function xm(e,n){return Oi(4,2,e,n)}function gm(e,n){return Oi(4,4,e,n)}function vm(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 ym(e,n,l){l=l!=null?l.concat([e]):null,Oi(4,4,vm.bind(null,n,e),l)}function au(){}function bm(e,n){var l=_t();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&qc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function jm(e,n){var l=_t();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&qc(n,i[1]))return i[0];if(i=e(),za){Tt(!0);try{e()}finally{Tt(!1)}}return l.memoizedState=[i,n],i}function lu(e,n,l){return l===void 0||(kr&1073741824)!==0&&(Ke&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=Sh(),Pe.lanes|=e,Xr|=e,l)}function Sm(e,n,l,i){return Sn(l,n)?l:hl.current!==null?(e=lu(e,l,i),Sn(e,n)||(Ut=!0),e):(kr&42)===0||(kr&1073741824)!==0&&(Ke&261930)===0?(Ut=!0,e.memoizedState=l):(e=Sh(),Pe.lanes|=e,Xr|=e,n)}function km(e,n,l,i,f){var g=B.p;B.p=g!==0&&8>g?g:8;var j=A.T,R={};A.T=R,ou(e,!1,n,l);try{var P=f(),Z=A.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var ie=r1(P,i);cs(e,n,ie,Tn(e))}else cs(e,n,i,Tn(e))}catch(de){cs(e,n,{then:function(){},status:"rejected",reason:de},Tn())}finally{B.p=g,j!==null&&R.types!==null&&(j.types=R.types),A.T=j}}function c1(){}function su(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=wm(e).queue;km(e,f,n,V,l===null?c1:function(){return Cm(e),l(i)})}function wm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:V},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Cm(e){var n=wm(e);n.next===null&&(n=e.alternate.memoizedState),cs(e,n.next.queue,{},Tn())}function iu(){return en(Es)}function Em(){return _t().memoizedState}function Nm(){return _t().memoizedState}function u1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Tn();e=Fr(l);var i=Gr(n,e,l);i!==null&&(yn(i,n,l),as(i,n,l)),n={cache:Oc()},e.payload=n;return}n=n.return}}function d1(e,n,l){var i=Tn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bi(e)?Rm(n,l):(l=Cc(e,n,l,i),l!==null&&(yn(l,e,i),Am(l,n,i)))}function Tm(e,n,l){var i=Tn();cs(e,n,l,i)}function cs(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))Rm(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var j=n.lastRenderedState,R=g(j,l);if(f.hasEagerState=!0,f.eagerState=R,Sn(R,j))return gi(e,n,f,0),xt===null&&xi(),!1}catch{}finally{}if(l=Cc(e,n,f,i),l!==null)return yn(l,e,i),Am(l,n,i),!0}return!1}function ou(e,n,l,i){if(i={lane:2,revertLane:Hu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(n)throw Error(o(479))}else n=Cc(e,l,i,2),n!==null&&yn(n,e,2)}function Bi(e){var n=e.alternate;return e===Pe||n!==null&&n===Pe}function Rm(e,n){xl=Ai=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Am(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,xa(e,l)}}var us={readContext:en,use:zi,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};us.useEffectEvent=At;var Mm={readContext:en,use:zi,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:mm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,_i(4194308,4,vm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return _i(4194308,4,e,n)},useInsertionEffect:function(e,n){_i(4,2,e,n)},useMemo:function(e,n){var l=cn();n=n===void 0?null:n;var i=e();if(za){Tt(!0);try{e()}finally{Tt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=cn();if(l!==void 0){var f=l(n);if(za){Tt(!0);try{l(n)}finally{Tt(!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=d1.bind(null,Pe,e),[i.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:function(e){e=tu(e);var n=e.queue,l=Tm.bind(null,Pe,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:au,useDeferredValue:function(e,n){var l=cn();return lu(l,e,n)},useTransition:function(){var e=tu(!1);return e=km.bind(null,Pe,e.queue,!0,!1),cn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=Pe,f=cn();if(Qe){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),xt===null)throw Error(o(349));(Ke&127)!==0||Zp(i,n,l)}f.memoizedState=l;var g={value:l,getSnapshot:n};return f.queue=g,mm(em.bind(null,i,g,e),[e]),i.flags|=2048,vl(9,{destroy:void 0},Jp.bind(null,i,g,l,n),null),l},useId:function(){var e=cn(),n=xt.identifierPrefix;if(Qe){var l=or,i=ir;l=(i&~(1<<32-it(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Mi++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=a1++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:iu,useFormState:cm,useActionState:cm,useOptimistic:function(e){var n=cn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=ou.bind(null,Pe,!0,l),l.dispatch=n,[e,n]},useMemoCache:Zc,useCacheRefresh:function(){return cn().memoizedState=u1.bind(null,Pe)},useEffectEvent:function(e){var n=cn(),l={impl:e};return n.memoizedState=l,function(){if((nt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},cu={readContext:en,use:zi,useCallback:bm,useContext:en,useEffect:ru,useImperativeHandle:ym,useInsertionEffect:xm,useLayoutEffect:gm,useMemo:jm,useReducer:Di,useRef:pm,useState:function(){return Di(wr)},useDebugValue:au,useDeferredValue:function(e,n){var l=_t();return Sm(l,dt.memoizedState,e,n)},useTransition:function(){var e=Di(wr)[0],n=_t().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Qp,useId:Em,useHostTransitionStatus:iu,useFormState:um,useActionState:um,useOptimistic:function(e,n){var l=_t();return rm(l,dt,e,n)},useMemoCache:Zc,useCacheRefresh:Nm};cu.useEffectEvent=hm;var Lm={readContext:en,use:zi,useCallback:bm,useContext:en,useEffect:ru,useImperativeHandle:ym,useInsertionEffect:xm,useLayoutEffect:gm,useMemo:jm,useReducer:eu,useRef:pm,useState:function(){return eu(wr)},useDebugValue:au,useDeferredValue:function(e,n){var l=_t();return dt===null?lu(l,e,n):Sm(l,dt.memoizedState,e,n)},useTransition:function(){var e=eu(wr)[0],n=_t().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Qp,useId:Em,useHostTransitionStatus:iu,useFormState:fm,useActionState:fm,useOptimistic:function(e,n){var l=_t();return dt!==null?rm(l,dt,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Zc,useCacheRefresh:Nm};Lm.useEffectEvent=hm;function uu(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:y({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var du={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Tn(),f=Fr(i);f.payload=n,l!=null&&(f.callback=l),n=Gr(e,f,i),n!==null&&(yn(n,e,i),as(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Tn(),f=Fr(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Gr(e,f,i),n!==null&&(yn(n,e,i),as(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Tn(),i=Fr(l);i.tag=2,n!=null&&(i.callback=n),n=Gr(e,i,l),n!==null&&(yn(n,e,l),as(n,e,l))}};function zm(e,n,l,i,f,g,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,g,j):n.prototype&&n.prototype.isPureReactComponent?!Xl(l,i)||!Xl(f,g):!0}function Dm(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&&du.enqueueReplaceState(n,n.state,null)}function Da(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=y({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function _m(e){hi(e)}function Om(e){console.error(e)}function Bm(e){hi(e)}function Ii(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function Im(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 fu(e,n,l){return l=Fr(l),l.tag=3,l.payload={element:null},l.callback=function(){Ii(e,n)},l}function Um(e){return e=Fr(e),e.tag=3,e}function Hm(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var g=i.value;e.payload=function(){return f(g)},e.callback=function(){Im(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){Im(n,l,i),typeof f!="function"&&(Qr===null?Qr=new Set([this]):Qr.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function f1(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&ul(n,l,f,!0),l=wn.current,l!==null){switch(l.tag){case 31:case 13:return Vn===null?Xi():l.alternate===null&&Mt===0&&(Mt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),Bu(e,i,f)),!1;case 22:return l.flags|=65536,i===Ci?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)),Bu(e,i,f)),!1}throw Error(o(435,l.tag))}return Bu(e,i,f),Xi(),!1}if(Qe)return n=wn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Mc&&(e=Error(o(422),{cause:i}),Jl(Un(e,l)))):(i!==Mc&&(n=Error(o(423),{cause:i}),Jl(Un(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=Un(i,l),f=fu(e.stateNode,i,f),Pc(e,f),Mt!==4&&(Mt=2)),!1;var g=Error(o(520),{cause:i});if(g=Un(g,l),vs===null?vs=[g]:vs.push(g),Mt!==4&&(Mt=2),n===null)return!0;i=Un(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=fu(l.stateNode,i,e),Pc(l,e),!1;case 1:if(n=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Qr===null||!Qr.has(g))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Um(f),Hm(f,e,l,i),Pc(l,f),!1}l=l.return}while(l!==null);return!1}var pu=Error(o(461)),Ut=!1;function tn(e,n,l,i){n.child=e===null?Fp(n,null,l,i):La(n,e.child,l,i)}function $m(e,n,l,i,f){l=l.render;var g=n.ref;if("ref"in i){var j={};for(var R in i)R!=="ref"&&(j[R]=i[R])}else j=i;return Ta(n),i=Yc(e,n,l,j,g,f),R=Kc(),e!==null&&!Ut?(Xc(e,n,f),Cr(e,n,f)):(Qe&&R&&Rc(n),n.flags|=1,tn(e,n,i,f),n.child)}function Pm(e,n,l,i,f){if(e===null){var g=l.type;return typeof g=="function"&&!Ec(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,Vm(e,n,g,i,f)):(e=yi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!ju(e,f)){var j=g.memoizedProps;if(l=l.compare,l=l!==null?l:Xl,l(j,i)&&e.ref===n.ref)return Cr(e,n,f)}return n.flags|=1,e=yr(g,i),e.ref=n.ref,e.return=n,n.child=e}function Vm(e,n,l,i,f){if(e!==null){var g=e.memoizedProps;if(Xl(g,i)&&e.ref===n.ref)if(Ut=!1,n.pendingProps=i=g,ju(e,f))(e.flags&131072)!==0&&(Ut=!0);else return n.lanes=e.lanes,Cr(e,n,f)}return mu(e,n,l,i,f)}function Fm(e,n,l,i){var f=i.children,g=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(g=g!==null?g.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&~g}else i=0,n.child=null;return Gm(e,n,g,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ki(n,g!==null?g.cachePool:null),g!==null?qp(n,g):Fc(),Yp(n);else return i=n.lanes=536870912,Gm(e,n,g!==null?g.baseLanes|l:l,l,i)}else g!==null?(ki(n,g.cachePool),qp(n,g),qr(),n.memoizedState=null):(e!==null&&ki(n,null),Fc(),qr());return tn(e,n,f,l),n.child}function ds(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Gm(e,n,l,i,f){var g=Ic();return g=g===null?null:{parent:Bt._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&ki(n,null),Fc(),Yp(n),e!==null&&ul(e,n,i,!0),n.childLanes=f,null}function Ui(e,n){return n=$i({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Wm(e,n,l){return La(n,e.child,null,l),e=Ui(n,n.pendingProps),e.flags|=2,Cn(n),n.memoizedState=null,e}function p1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Qe){if(i.mode==="hidden")return e=Ui(n,i),n.lanes=536870912,ds(null,e);if(Wc(n),(e=yt)?(e=ax(e,Pn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ur!==null?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},l=Rp(e),l.return=n,n.child=l,Jt=n,yt=null)):e=null,e===null)throw $r(n);return n.lanes=536870912,null}return Ui(n,i)}var g=e.memoizedState;if(g!==null){var j=g.dehydrated;if(Wc(n),f)if(n.flags&256)n.flags&=-257,n=Wm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(Ut||ul(e,n,l,!1),f=(l&e.childLanes)!==0,Ut||f){if(i=xt,i!==null&&(j=ga(i,l),j!==0&&j!==g.retryLane))throw g.retryLane=j,wa(e,j),yn(i,e,j),pu;Xi(),n=Wm(e,n,l)}else e=g.treeContext,yt=Fn(j.nextSibling),Jt=n,Qe=!0,Hr=null,Pn=!1,e!==null&&Lp(n,e),n=Ui(n,i),n.flags|=4096;return n}return e=yr(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 mu(e,n,l,i,f){return Ta(n),l=Yc(e,n,l,i,void 0,f),i=Kc(),e!==null&&!Ut?(Xc(e,n,f),Cr(e,n,f)):(Qe&&i&&Rc(n),n.flags|=1,tn(e,n,l,f),n.child)}function qm(e,n,l,i,f,g){return Ta(n),n.updateQueue=null,l=Xp(n,i,l,f),Kp(e),i=Kc(),e!==null&&!Ut?(Xc(e,n,g),Cr(e,n,g)):(Qe&&i&&Rc(n),n.flags|=1,tn(e,n,l,g),n.child)}function Ym(e,n,l,i,f){if(Ta(n),n.stateNode===null){var g=sl,j=l.contextType;typeof j=="object"&&j!==null&&(g=en(j)),g=new l(i,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=du,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=i,g.state=n.memoizedState,g.refs={},Hc(n),j=l.contextType,g.context=typeof j=="object"&&j!==null?en(j):sl,g.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(uu(n,l,j,i),g.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(j=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),j!==g.state&&du.enqueueReplaceState(g,g.state,null),ss(n,i,g,f),ls(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){g=n.stateNode;var R=n.memoizedProps,P=Da(l,R);g.props=P;var Z=g.context,ie=l.contextType;j=sl,typeof ie=="object"&&ie!==null&&(j=en(ie));var de=l.getDerivedStateFromProps;ie=typeof de=="function"||typeof g.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,ie||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(R||Z!==j)&&Dm(n,g,i,j),Vr=!1;var J=n.memoizedState;g.state=J,ss(n,i,g,f),ls(),Z=n.memoizedState,R||J!==Z||Vr?(typeof de=="function"&&(uu(n,l,de,i),Z=n.memoizedState),(P=Vr||zm(n,l,P,i,J,Z,j))?(ie||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),g.props=i,g.state=Z,g.context=j,i=P):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{g=n.stateNode,$c(e,n),j=n.memoizedProps,ie=Da(l,j),g.props=ie,de=n.pendingProps,J=g.context,Z=l.contextType,P=sl,typeof Z=="object"&&Z!==null&&(P=en(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(j!==de||J!==P)&&Dm(n,g,i,P),Vr=!1,J=n.memoizedState,g.state=J,ss(n,i,g,f),ls();var ae=n.memoizedState;j!==de||J!==ae||Vr||e!==null&&e.dependencies!==null&&ji(e.dependencies)?(typeof R=="function"&&(uu(n,l,R,i),ae=n.memoizedState),(ie=Vr||zm(n,l,ie,i,J,ae,P)||e!==null&&e.dependencies!==null&&ji(e.dependencies))?(Z||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(i,ae,P),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(i,ae,P)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=ae),g.props=i,g.state=ae,g.context=P,i=ie):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=1024),i=!1)}return g=i,Hi(e,n),i=(n.flags&128)!==0,g||i?(g=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&i?(n.child=La(n,e.child,null,f),n.child=La(n,null,l,f)):tn(e,n,l,f),n.memoizedState=g.state,e=n.child):e=Cr(e,n,f),e}function Km(e,n,l,i){return Ea(),n.flags|=256,tn(e,n,l,i),n.child}var hu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function xu(e){return{baseLanes:e,cachePool:Ip()}}function gu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=Nn),e}function Xm(e,n,l){var i=n.pendingProps,f=!1,g=(n.flags&128)!==0,j;if((j=g)||(j=e!==null&&e.memoizedState===null?!1:(Dt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Qe){if(f?Wr(n):qr(),(e=yt)?(e=ax(e,Pn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ur!==null?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},l=Rp(e),l.return=n,n.child=l,Jt=n,yt=null)):e=null,e===null)throw $r(n);return Ju(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,f?(qr(),f=n.mode,R=$i({mode:"hidden",children:R},f),i=Ca(i,f,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=xu(l),i.childLanes=gu(e,j,l),n.memoizedState=hu,ds(null,i)):(Wr(n),vu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(g)n.flags&256?(Wr(n),n.flags&=-257,n=yu(e,n,l)):n.memoizedState!==null?(qr(),n.child=e.child,n.flags|=128,n=null):(qr(),R=i.fallback,f=n.mode,i=$i({mode:"visible",children:i.children},f),R=Ca(R,f,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,La(n,e.child,null,l),i=n.child,i.memoizedState=xu(l),i.childLanes=gu(e,j,l),n.memoizedState=hu,n=ds(null,i));else if(Wr(n),Ju(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Jl({value:i,source:null,stack:null}),n=yu(e,n,l)}else if(Ut||ul(e,n,l,!1),j=(l&e.childLanes)!==0,Ut||j){if(j=xt,j!==null&&(i=ga(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,wa(e,i),yn(j,e,i),pu;Zu(R)||Xi(),n=yu(e,n,l)}else Zu(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,yt=Fn(R.nextSibling),Jt=n,Qe=!0,Hr=null,Pn=!1,e!==null&&Lp(n,e),n=vu(n,i.children),n.flags|=4096);return n}return f?(qr(),R=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=yr(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=yr(Z,R):(R=Ca(R,f,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,ds(null,i),i=n.child,R=e.child.memoizedState,R===null?R=xu(l):(f=R.cachePool,f!==null?(P=Bt._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=Ip(),R={baseLanes:R.baseLanes|l,cachePool:f}),i.memoizedState=R,i.childLanes=gu(e,j,l),n.memoizedState=hu,ds(e.child,i)):(Wr(n),l=e.child,e=l.sibling,l=yr(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 vu(e,n){return n=$i({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function $i(e,n){return e=kn(22,e,null,n),e.lanes=0,e}function yu(e,n,l){return La(n,e.child,null,l),e=vu(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),Dc(e.return,n,l)}function bu(e,n,l,i,f,g){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:g}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=g)}function Zm(e,n,l){var i=n.pendingProps,f=i.revealOrder,g=i.tail;i=i.children;var j=Dt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,te(Dt,j),tn(e,n,i,l),i=Qe?Zl: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&&Ri(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),bu(n,!1,f,l,g,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&&Ri(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}bu(n,!0,l,null,g,i);break;case"together":bu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function Cr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),Xr|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(ul(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=yr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=yr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function ju(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&ji(e)))}function m1(e,n,l){switch(n.tag){case 3:ce(n,n.stateNode.containerInfo),Pr(n,Bt,e.memoizedState.cache),Ea();break;case 27:case 5:Re(n);break;case 4:ce(n,n.stateNode.containerInfo);break;case 10:Pr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Wc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Wr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?Xm(e,n,l):(Wr(n),e=Cr(e,n,l),e!==null?e.sibling:null);Wr(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(ul(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Zm(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),te(Dt,Dt.current),i)break;return null;case 22:return n.lanes=0,Fm(e,n,l,n.pendingProps);case 24:Pr(n,Bt,e.memoizedState.cache)}return Cr(e,n,l)}function Jm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ut=!0;else{if(!ju(e,l)&&(n.flags&128)===0)return Ut=!1,m1(e,n,l);Ut=(e.flags&131072)!==0}else Ut=!1,Qe&&(n.flags&1048576)!==0&&Mp(n,Zl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Aa(n.elementType),n.type=e,typeof e=="function")Ec(e)?(i=Da(e,i),n.tag=1,n=Ym(null,n,e,i,l)):(n.tag=0,n=mu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===_){n.tag=11,n=$m(null,n,e,i,l);break e}else if(f===E){n.tag=14,n=Pm(null,n,e,i,l);break e}}throw n=ee(e)||e,Error(o(306,n,""))}}return n;case 0:return mu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Da(i,n.pendingProps),Ym(e,n,i,f,l);case 3:e:{if(ce(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var g=n.memoizedState;f=g.element,$c(e,n),ss(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Pr(n,Bt,i),i!==g.cache&&_c(n,[Bt],l,!0),ls(),i=j.element,g.isDehydrated)if(g={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=Km(e,n,i,l);break e}else if(i!==f){f=Un(Error(o(424)),n),Jl(f),n=Km(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(yt=Fn(e.firstChild),Jt=n,Qe=!0,Hr=null,Pn=!0,l=Fp(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Ea(),i===f){n=Cr(e,n,l);break e}tn(e,n,i,l)}n=n.child}return n;case 26:return Hi(e,n),e===null?(l=ux(n.type,null,n.pendingProps,null))?n.memoizedState=l:Qe||(l=n.type,e=n.pendingProps,i=ro(le.current).createElement(l),i[Vt]=n,i[ut]=e,nn(i,l,e),Kt(i),n.stateNode=i):n.memoizedState=ux(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Re(n),e===null&&Qe&&(i=n.stateNode=ix(n.type,n.pendingProps,le.current),Jt=n,Pn=!0,f=yt,ta(n.type)?(ed=f,yt=Fn(i.firstChild)):yt=f),tn(e,n,n.pendingProps.children,l),Hi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Qe&&((f=i=yt)&&(i=F1(i,n.type,n.pendingProps,Pn),i!==null?(n.stateNode=i,Jt=n,yt=Fn(i.firstChild),Pn=!1,f=!0):f=!1),f||$r(n)),Re(n),f=n.type,g=n.pendingProps,j=e!==null?e.memoizedProps:null,i=g.children,Ku(f,g)?i=null:j!==null&&Ku(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=Yc(e,n,l1,null,null,l),Es._currentValue=f),Hi(e,n),tn(e,n,i,l),n.child;case 6:return e===null&&Qe&&((e=l=yt)&&(l=G1(l,n.pendingProps,Pn),l!==null?(n.stateNode=l,Jt=n,yt=null,e=!0):e=!1),e||$r(n)),null;case 13:return Xm(e,n,l);case 4:return ce(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=La(n,null,i,l):tn(e,n,i,l),n.child;case 11:return $m(e,n,n.type,n.pendingProps,l);case 7:return tn(e,n,n.pendingProps,l),n.child;case 8:return tn(e,n,n.pendingProps.children,l),n.child;case 12:return tn(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Pr(n,n.type,i.value),tn(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Ta(n),f=en(f),i=i(f),n.flags|=1,tn(e,n,i,l),n.child;case 14:return Pm(e,n,n.type,n.pendingProps,l);case 15:return Vm(e,n,n.type,n.pendingProps,l);case 19:return Zm(e,n,l);case 31:return p1(e,n,l);case 22:return Fm(e,n,l,n.pendingProps);case 24:return Ta(n),i=en(Bt),e===null?(f=Ic(),f===null&&(f=xt,g=Oc(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=l),f=g),n.memoizedState={parent:i,cache:f},Hc(n),Pr(n,Bt,f)):((e.lanes&l)!==0&&($c(e,n),ss(n,null,null,l),ls()),f=e.memoizedState,g=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Pr(n,Bt,i)):(i=g.cache,Pr(n,Bt,i),i!==f.cache&&_c(n,[Bt],l,!0))),tn(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Er(e){e.flags|=4}function Su(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(Eh())e.flags|=8192;else throw Ma=Ci,Uc}else e.flags&=-16777217}function eh(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!hx(n))if(Eh())e.flags|=8192;else throw Ma=Ci,Uc}function Pi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?Ce():536870912,e.lanes|=n,Sl|=n)}function fs(e,n){if(!Qe)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 bt(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 h1(e,n,l){var i=n.pendingProps;switch(Ac(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bt(n),null;case 1:return bt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),Sr(Bt),be(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(cl(n)?Er(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Lc())),bt(n),null;case 26:var f=n.type,g=n.memoizedState;return e===null?(Er(n),g!==null?(bt(n),eh(n,g)):(bt(n),Su(n,f,null,i,l))):g?g!==e.memoizedState?(Er(n),bt(n),eh(n,g)):(bt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Er(n),bt(n),Su(n,f,e,i,l)),null;case 27:if(Ae(n),l=le.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Er(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}e=q.current,cl(n)?zp(n):(e=ix(f,i,l),n.stateNode=e,Er(n))}return bt(n),null;case 5:if(Ae(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Er(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}if(g=q.current,cl(n))zp(n);else{var j=ro(le.current);switch(g){case 1:g=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:g=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":g=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":g=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":g=j.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?g.multiple=!0:i.size&&(g.size=i.size);break;default:g=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}g[Vt]=n,g[ut]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)g.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=g;e:switch(nn(g,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&&Er(n)}}return bt(n),Su(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Er(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=le.current,cl(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Jt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[Vt]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Xh(e.nodeValue,l)),e||$r(n,!0)}else e=ro(e).createTextNode(i),e[Vt]=n,n.stateNode=e}return bt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=cl(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[Vt]=n}else Ea(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),e=!1}else l=Lc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Cn(n),n):(Cn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return bt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=cl(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[Vt]=n}else Ea(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),f=!1}else f=Lc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Cn(n),n):(Cn(n),null)}return Cn(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),g=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(g=i.memoizedState.cachePool.pool),g!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Pi(n,n.updateQueue),bt(n),null);case 4:return be(),e===null&&Fu(n.stateNode.containerInfo),bt(n),null;case 10:return Sr(n.type),bt(n),null;case 19:if(W(Dt),i=n.memoizedState,i===null)return bt(n),null;if(f=(n.flags&128)!==0,g=i.rendering,g===null)if(f)fs(i,!1);else{if(Mt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Ri(e),g!==null){for(n.flags|=128,fs(i,!1),e=g.updateQueue,n.updateQueue=e,Pi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Tp(l,e),l=l.sibling;return te(Dt,Dt.current&1|2),Qe&&br(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Ye()>qi&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ri(g),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Pi(n,e),fs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!g.alternate&&!Qe)return bt(n),null}else 2*Ye()-i.renderingStartTime>qi&&l!==536870912&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304);i.isBackwards?(g.sibling=n.child,n.child=g):(e=i.last,e!==null?e.sibling=g:n.child=g,i.last=g)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Ye(),e.sibling=null,l=Dt.current,te(Dt,f?l&1|2:l&1),Qe&&br(n,i.treeForkCount),e):(bt(n),null);case 22:case 23:return Cn(n),Gc(),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&&(bt(n),n.subtreeFlags&6&&(n.flags|=8192)):bt(n),l=n.updateQueue,l!==null&&Pi(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&&W(Ra),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Sr(Bt),bt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function x1(e,n){switch(Ac(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Sr(Bt),be(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Ae(n),null;case 31:if(n.memoizedState!==null){if(Cn(n),n.alternate===null)throw Error(o(340));Ea()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Cn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Ea()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return W(Dt),null;case 4:return be(),null;case 10:return Sr(n.type),null;case 22:case 23:return Cn(n),Gc(),e!==null&&W(Ra),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return Sr(Bt),null;case 25:return null;default:return null}}function th(e,n){switch(Ac(n),n.tag){case 3:Sr(Bt),be();break;case 26:case 27:case 5:Ae(n);break;case 4:be();break;case 31:n.memoizedState!==null&&Cn(n);break;case 13:Cn(n);break;case 19:W(Dt);break;case 10:Sr(n.type);break;case 22:case 23:Cn(n),Gc(),e!==null&&W(Ra);break;case 24:Sr(Bt)}}function ps(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 g=l.create,j=l.inst;i=g(),j.destroy=i}l=l.next}while(l!==f)}}catch(R){lt(n,n.return,R)}}function Yr(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var g=f.next;i=g;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(ie){lt(f,P,ie)}}}i=i.next}while(i!==g)}}catch(ie){lt(n,n.return,ie)}}function nh(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Wp(n,l)}catch(i){lt(e,e.return,i)}}}function rh(e,n,l){l.props=Da(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){lt(e,n,i)}}function ms(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){lt(e,n,f)}}function cr(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){lt(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){lt(e,n,f)}else l.current=null}function ah(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){lt(e,e.return,f)}}function ku(e,n,l){try{var i=e.stateNode;I1(i,e.type,l,n),i[ut]=n}catch(f){lt(e,e.return,f)}}function lh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ta(e.type)||e.tag===4}function wu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||lh(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&&ta(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 Cu(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=gr));else if(i!==4&&(i===27&&ta(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Cu(e,n,l),e=e.sibling;e!==null;)Cu(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&&ta(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 sh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);nn(n,i,l),n[Vt]=e,n[ut]=l}catch(g){lt(e,e.return,g)}}var Nr=!1,Ht=!1,Eu=!1,ih=typeof WeakSet=="function"?WeakSet:Set,Xt=null;function g1(e,n){if(e=e.containerInfo,qu=uo,e=yp(e),yc(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,g=i.focusNode;i=i.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var j=0,R=-1,P=-1,Z=0,ie=0,de=e,J=null;t:for(;;){for(var ae;de!==l||f!==0&&de.nodeType!==3||(R=j+f),de!==g||i!==0&&de.nodeType!==3||(P=j+i),de.nodeType===3&&(j+=de.nodeValue.length),(ae=de.firstChild)!==null;)J=de,de=ae;for(;;){if(de===e)break t;if(J===l&&++Z===f&&(R=j),J===g&&++ie===i&&(P=j),(ae=de.nextSibling)!==null)break;de=J,J=de.parentNode}de=ae}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(Yu={focusedElem:e,selectionRange:l},uo=!1,Xt=n;Xt!==null;)if(n=Xt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Xt=e;else for(;Xt!==null;){switch(n=Xt,g=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&&g!==null){e=void 0,l=n,f=g.memoizedProps,g=g.memoizedState,i=l.stateNode;try{var we=Da(l.type,f);e=i.getSnapshotBeforeUpdate(we,g),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){lt(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Qu(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Qu(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,Xt=e;break}Xt=n.return}}function oh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Rr(e,l),i&4&&ps(5,l);break;case 1:if(Rr(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){lt(l,l.return,j)}else{var f=Da(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){lt(l,l.return,j)}}i&64&&nh(l),i&512&&ms(l,l.return);break;case 3:if(Rr(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{Wp(e,n)}catch(j){lt(l,l.return,j)}}break;case 27:n===null&&i&4&&sh(l);case 26:case 5:Rr(e,l),n===null&&i&4&&ah(l),i&512&&ms(l,l.return);break;case 12:Rr(e,l);break;case 31:Rr(e,l),i&4&&dh(e,l);break;case 13:Rr(e,l),i&4&&fh(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=E1.bind(null,l),W1(e,l))));break;case 22:if(i=l.memoizedState!==null||Nr,!i){n=n!==null&&n.memoizedState!==null||Ht,f=Nr;var g=Ht;Nr=i,(Ht=n)&&!g?Ar(e,l,(l.subtreeFlags&8772)!==0):Rr(e,l),Nr=f,Ht=g}break;case 30:break;default:Rr(e,l)}}function ch(e){var n=e.alternate;n!==null&&(e.alternate=null,ch(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&nc(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 kt=null,hn=!1;function Tr(e,n,l){for(l=l.child;l!==null;)uh(e,n,l),l=l.sibling}function uh(e,n,l){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(_n,l)}catch{}switch(l.tag){case 26:Ht||cr(l,n),Tr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Ht||cr(l,n);var i=kt,f=hn;ta(l.type)&&(kt=l.stateNode,hn=!1),Tr(e,n,l),ks(l.stateNode),kt=i,hn=f;break;case 5:Ht||cr(l,n);case 6:if(i=kt,f=hn,kt=null,Tr(e,n,l),kt=i,hn=f,kt!==null)if(hn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(l.stateNode)}catch(g){lt(l,n,g)}else try{kt.removeChild(l.stateNode)}catch(g){lt(l,n,g)}break;case 18:kt!==null&&(hn?(e=kt,nx(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Al(e)):nx(kt,l.stateNode));break;case 4:i=kt,f=hn,kt=l.stateNode.containerInfo,hn=!0,Tr(e,n,l),kt=i,hn=f;break;case 0:case 11:case 14:case 15:Yr(2,l,n),Ht||Yr(4,l,n),Tr(e,n,l);break;case 1:Ht||(cr(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&rh(l,n,i)),Tr(e,n,l);break;case 21:Tr(e,n,l);break;case 22:Ht=(i=Ht)||l.memoizedState!==null,Tr(e,n,l),Ht=i;break;default:Tr(e,n,l)}}function dh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Al(e)}catch(l){lt(n,n.return,l)}}}function fh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Al(e)}catch(l){lt(n,n.return,l)}}function v1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ih),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ih),n;default:throw Error(o(435,e.tag))}}function Fi(e,n){var l=v1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=N1.bind(null,e,i);i.then(f,f)}})}function xn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],g=e,j=n,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(ta(R.type)){kt=R.stateNode,hn=!1;break e}break;case 5:kt=R.stateNode,hn=!1;break e;case 3:case 4:kt=R.stateNode.containerInfo,hn=!0;break e}R=R.return}if(kt===null)throw Error(o(160));uh(g,j,f),kt=null,hn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)ph(n,e),n=n.sibling}var Qn=null;function ph(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:xn(n,e),gn(e),i&4&&(Yr(3,e,e.return),ps(3,e),Yr(5,e,e.return));break;case 1:xn(n,e),gn(e),i&512&&(Ht||l===null||cr(l,l.return)),i&64&&Nr&&(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=Qn;if(xn(n,e),gn(e),i&512&&(Ht||l===null||cr(l,l.return)),i&4){var g=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":g=f.getElementsByTagName("title")[0],(!g||g[$l]||g[Vt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(i),f.head.insertBefore(g,f.querySelector("head > title"))),nn(g,i,l),g[Vt]=e,Kt(g),i=g;break e;case"link":var j=px("link","href",f).get(i+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(g=j[R],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(R,1);break t}}g=f.createElement(i),nn(g,i,l),f.head.appendChild(g);break;case"meta":if(j=px("meta","content",f).get(i+(l.content||""))){for(R=0;R<j.length;R++)if(g=j[R],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(R,1);break t}}g=f.createElement(i),nn(g,i,l),f.head.appendChild(g);break;default:throw Error(o(468,i))}g[Vt]=e,Kt(g),i=g}e.stateNode=i}else mx(f,e.type,e.stateNode);else e.stateNode=fx(f,i,e.memoizedProps);else g!==i?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,i===null?mx(f,e.type,e.stateNode):fx(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&ku(e,e.memoizedProps,l.memoizedProps)}break;case 27:xn(n,e),gn(e),i&512&&(Ht||l===null||cr(l,l.return)),l!==null&&i&4&&ku(e,e.memoizedProps,l.memoizedProps);break;case 5:if(xn(n,e),gn(e),i&512&&(Ht||l===null||cr(l,l.return)),e.flags&32){f=e.stateNode;try{Ja(f,"")}catch(we){lt(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,ku(e,f,l!==null?l.memoizedProps:f)),i&1024&&(Eu=!0);break;case 6:if(xn(n,e),gn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){lt(e,e.return,we)}}break;case 3:if(so=null,f=Qn,Qn=ao(n.containerInfo),xn(n,e),Qn=f,gn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{Al(n.containerInfo)}catch(we){lt(e,e.return,we)}Eu&&(Eu=!1,mh(e));break;case 4:i=Qn,Qn=ao(e.stateNode.containerInfo),xn(n,e),gn(e),Qn=i;break;case 12:xn(n,e),gn(e);break;case 31:xn(n,e),gn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 13:xn(n,e),gn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Wi=Ye()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=Nr,ie=Ht;if(Nr=Z||f,Ht=ie||P,xn(n,e),Ht=ie,Nr=Z,gn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||Nr||Ht||_a(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(g=P.stateNode,f)j=g.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var de=P.memoizedProps.style,J=de!=null&&de.hasOwnProperty("display")?de.display:null;R.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(we){lt(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){lt(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var ae=P.stateNode;f?rx(ae,!0):rx(P.stateNode,!1)}catch(we){lt(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,Fi(e,l))));break;case 19:xn(n,e),gn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 30:break;case 21:break;default:xn(n,e),gn(e)}}function gn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(lh(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,g=wu(e);Vi(e,g,f);break;case 5:var j=l.stateNode;l.flags&32&&(Ja(j,""),l.flags&=-33);var R=wu(e);Vi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=wu(e);Cu(e,Z,P);break;default:throw Error(o(161))}}catch(ie){lt(e,e.return,ie)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function mh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;mh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Rr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)oh(e,n.alternate,n),n=n.sibling}function _a(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Yr(4,n,n.return),_a(n);break;case 1:cr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&rh(n,n.return,l),_a(n);break;case 27:ks(n.stateNode);case 26:case 5:cr(n,n.return),_a(n);break;case 22:n.memoizedState===null&&_a(n);break;case 30:_a(n);break;default:_a(n)}e=e.sibling}}function Ar(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,g=n,j=g.flags;switch(g.tag){case 0:case 11:case 15:Ar(f,g,l),ps(4,g);break;case 1:if(Ar(f,g,l),i=g,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){lt(i,i.return,Z)}if(i=g,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++)Gp(P[f],R)}catch(Z){lt(i,i.return,Z)}}l&&j&64&&nh(g),ms(g,g.return);break;case 27:sh(g);case 26:case 5:Ar(f,g,l),l&&i===null&&j&4&&ah(g),ms(g,g.return);break;case 12:Ar(f,g,l);break;case 31:Ar(f,g,l),l&&j&4&&dh(f,g);break;case 13:Ar(f,g,l),l&&j&4&&fh(f,g);break;case 22:g.memoizedState===null&&Ar(f,g,l),ms(g,g.return);break;case 30:break;default:Ar(f,g,l)}n=n.sibling}}function Nu(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&&es(l))}function Tu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&es(e))}function Zn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)hh(e,n,l,i),n=n.sibling}function hh(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Zn(e,n,l,i),f&2048&&ps(9,n);break;case 1:Zn(e,n,l,i);break;case 3:Zn(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&&es(e)));break;case 12:if(f&2048){Zn(e,n,l,i),e=n.stateNode;try{var g=n.memoizedProps,j=g.id,R=g.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){lt(n,n.return,P)}}else Zn(e,n,l,i);break;case 31:Zn(e,n,l,i);break;case 13:Zn(e,n,l,i);break;case 23:break;case 22:g=n.stateNode,j=n.alternate,n.memoizedState!==null?g._visibility&2?Zn(e,n,l,i):hs(e,n):g._visibility&2?Zn(e,n,l,i):(g._visibility|=2,yl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Nu(j,n);break;case 24:Zn(e,n,l,i),f&2048&&Tu(n.alternate,n);break;default:Zn(e,n,l,i)}}function yl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,j=n,R=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:yl(g,j,R,P,f),ps(8,j);break;case 23:break;case 22:var ie=j.stateNode;j.memoizedState!==null?ie._visibility&2?yl(g,j,R,P,f):hs(g,j):(ie._visibility|=2,yl(g,j,R,P,f)),f&&Z&2048&&Nu(j.alternate,j);break;case 24:yl(g,j,R,P,f),f&&Z&2048&&Tu(j.alternate,j);break;default:yl(g,j,R,P,f)}n=n.sibling}}function hs(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:hs(l,i),f&2048&&Nu(i.alternate,i);break;case 24:hs(l,i),f&2048&&Tu(i.alternate,i);break;default:hs(l,i)}n=n.sibling}}var xs=8192;function bl(e,n,l){if(e.subtreeFlags&xs)for(e=e.child;e!==null;)xh(e,n,l),e=e.sibling}function xh(e,n,l){switch(e.tag){case 26:bl(e,n,l),e.flags&xs&&e.memoizedState!==null&&a0(l,Qn,e.memoizedState,e.memoizedProps);break;case 5:bl(e,n,l);break;case 3:case 4:var i=Qn;Qn=ao(e.stateNode.containerInfo),bl(e,n,l),Qn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=xs,xs=16777216,bl(e,n,l),xs=i):bl(e,n,l));break;default:bl(e,n,l)}}function gh(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 gs(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];Xt=i,yh(i,e)}gh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)vh(e),e=e.sibling}function vh(e){switch(e.tag){case 0:case 11:case 15:gs(e),e.flags&2048&&Yr(9,e,e.return);break;case 3:gs(e);break;case 12:gs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Gi(e)):gs(e);break;default:gs(e)}}function Gi(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];Xt=i,yh(i,e)}gh(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Yr(8,n,n.return),Gi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Gi(n));break;default:Gi(n)}e=e.sibling}}function yh(e,n){for(;Xt!==null;){var l=Xt;switch(l.tag){case 0:case 11:case 15:Yr(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:es(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,Xt=i;else e:for(l=e;Xt!==null;){i=Xt;var f=i.sibling,g=i.return;if(ch(i),i===l){Xt=null;break e}if(f!==null){f.return=g,Xt=f;break e}Xt=g}}}var y1={getCacheForType:function(e){var n=en(Bt),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return en(Bt).controller.signal}},b1=typeof WeakMap=="function"?WeakMap:Map,nt=0,xt=null,We=null,Ke=0,at=0,En=null,Kr=!1,jl=!1,Ru=!1,Mr=0,Mt=0,Xr=0,Oa=0,Au=0,Nn=0,Sl=0,vs=null,vn=null,Mu=!1,Wi=0,bh=0,qi=1/0,Yi=null,Qr=null,Ft=0,Zr=null,kl=null,Lr=0,Lu=0,zu=null,jh=null,ys=0,Du=null;function Tn(){return(nt&2)!==0&&Ke!==0?Ke&-Ke:A.T!==null?Hu():ct()}function Sh(){if(Nn===0)if((Ke&536870912)===0||Qe){var e=Rt;Rt<<=1,(Rt&3932160)===0&&(Rt=262144),Nn=e}else Nn=536870912;return e=wn.current,e!==null&&(e.flags|=32),Nn}function yn(e,n,l){(e===xt&&(at===2||at===9)||e.cancelPendingCommit!==null)&&(wl(e,0),Jr(e,Ke,Nn,!1)),jn(e,l),((nt&2)===0||e!==xt)&&(e===xt&&((nt&2)===0&&(Oa|=l),Mt===4&&Jr(e,Ke,Nn,!1)),ur(e))}function kh(e,n,l){if((nt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Zt(e,n),f=i?k1(e,n):Ou(e,n,!0),g=i;do{if(f===0){jl&&!i&&Jr(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!j1(l)){f=Ou(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)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=vs;var P=R.current.memoizedState.isDehydrated;if(P&&(wl(R,j).flags|=256),j=Ou(R,j,!1),j!==2){if(Ru&&!P){R.errorRecoveryDisabledLanes|=g,Oa|=g,f=4;break e}g=vn,vn=f,g!==null&&(vn===null?vn=g:vn.push.apply(vn,g))}f=j}if(g=!1,f!==2)continue}}if(f===1){wl(e,0),Jr(e,n,0,!0);break}e:{switch(i=e,g=f,g){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Jr(i,n,Nn,!Kr);break e;case 2:vn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Wi+300-Ye(),10<f)){if(Jr(i,n,Nn,!Kr),sn(i,0,!0)!==0)break e;Lr=n,i.timeoutHandle=ex(wh.bind(null,i,l,vn,Yi,Mu,n,Nn,Oa,Sl,Kr,g,"Throttled",-0,0),f);break e}wh(i,l,vn,Yi,Mu,n,Nn,Oa,Sl,Kr,g,null,-0,0)}}break}while(!0);ur(e)}function wh(e,n,l,i,f,g,j,R,P,Z,ie,de,J,ae){if(e.timeoutHandle=-1,de=n.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gr},xh(n,g,de);var we=(g&62914560)===g?Wi-Ye():(g&4194048)===g?bh-Ye():0;if(we=l0(de,we),we!==null){Lr=g,e.cancelPendingCommit=we(Lh.bind(null,e,n,g,l,i,f,j,R,P,ie,de,null,J,ae)),Jr(e,g,j,!Z);return}}Lh(e,n,g,l,i,f,j,R,P)}function j1(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],g=f.getSnapshot;f=f.value;try{if(!Sn(g(),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 Jr(e,n,l,i){n&=~Au,n&=~Oa,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var g=31-it(f),j=1<<g;i[g]=-1,f&=~j}l!==0&&lr(e,l,n)}function Ki(){return(nt&6)===0?(bs(0),!1):!0}function _u(){if(We!==null){if(at===0)var e=We.return;else e=We,jr=Na=null,Qc(e),ml=null,ns=0,e=We;for(;e!==null;)th(e.alternate,e),e=e.return;We=null}}function wl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,$1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Lr=0,_u(),xt=e,We=l=yr(e.current,null),Ke=n,at=0,En=null,Kr=!1,jl=Zt(e,n),Ru=!1,Sl=Nn=Au=Oa=Xr=Mt=0,vn=vs=null,Mu=!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-it(i),g=1<<f;n|=e[f],i&=~g}return Mr=n,xi(),l}function Ch(e,n){Pe=null,A.H=us,n===pl||n===wi?(n=$p(),at=3):n===Uc?(n=$p(),at=4):at=n===pu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,En=n,We===null&&(Mt=1,Ii(e,Un(n,e.current)))}function Eh(){var e=wn.current;return e===null?!0:(Ke&4194048)===Ke?Vn===null:(Ke&62914560)===Ke||(Ke&536870912)!==0?e===Vn:!1}function Nh(){var e=A.H;return A.H=us,e===null?us:e}function Th(){var e=A.A;return A.A=y1,e}function Xi(){Mt=4,Kr||(Ke&4194048)!==Ke&&wn.current!==null||(jl=!0),(Xr&134217727)===0&&(Oa&134217727)===0||xt===null||Jr(xt,Ke,Nn,!1)}function Ou(e,n,l){var i=nt;nt|=2;var f=Nh(),g=Th();(xt!==e||Ke!==n)&&(Yi=null,wl(e,n)),n=!1;var j=Mt;e:do try{if(at!==0&&We!==null){var R=We,P=En;switch(at){case 8:_u(),j=6;break e;case 3:case 2:case 9:case 6:wn.current===null&&(n=!0);var Z=at;if(at=0,En=null,Cl(e,R,P,Z),l&&jl){j=0;break e}break;default:Z=at,at=0,En=null,Cl(e,R,P,Z)}}S1(),j=Mt;break}catch(ie){Ch(e,ie)}while(!0);return n&&e.shellSuspendCounter++,jr=Na=null,nt=i,A.H=f,A.A=g,We===null&&(xt=null,Ke=0,xi()),j}function S1(){for(;We!==null;)Rh(We)}function k1(e,n){var l=nt;nt|=2;var i=Nh(),f=Th();xt!==e||Ke!==n?(Yi=null,qi=Ye()+500,wl(e,n)):jl=Zt(e,n);e:do try{if(at!==0&&We!==null){n=We;var g=En;t:switch(at){case 1:at=0,En=null,Cl(e,n,g,1);break;case 2:case 9:if(Up(g)){at=0,En=null,Ah(n);break}n=function(){at!==2&&at!==9||xt!==e||(at=7),ur(e)},g.then(n,n);break e;case 3:at=7;break e;case 4:at=5;break e;case 7:Up(g)?(at=0,En=null,Ah(n)):(at=0,En=null,Cl(e,n,g,7));break;case 5:var j=null;switch(We.tag){case 26:j=We.memoizedState;case 5:case 27:var R=We;if(j?hx(j):R.stateNode.complete){at=0,En=null;var P=R.sibling;if(P!==null)We=P;else{var Z=R.return;Z!==null?(We=Z,Qi(Z)):We=null}break t}}at=0,En=null,Cl(e,n,g,5);break;case 6:at=0,En=null,Cl(e,n,g,6);break;case 8:_u(),Mt=6;break e;default:throw Error(o(462))}}w1();break}catch(ie){Ch(e,ie)}while(!0);return jr=Na=null,A.H=i,A.A=f,nt=l,We!==null?0:(xt=null,Ke=0,xi(),Mt)}function w1(){for(;We!==null&&!Et();)Rh(We)}function Rh(e){var n=Jm(e.alternate,e,Mr);e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function Ah(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=qm(l,n,n.pendingProps,n.type,void 0,Ke);break;case 11:n=qm(l,n,n.pendingProps,n.type.render,n.ref,Ke);break;case 5:Qc(n);default:th(l,n),n=We=Tp(n,Mr),n=Jm(l,n,Mr)}e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function Cl(e,n,l,i){jr=Na=null,Qc(n),ml=null,ns=0;var f=n.return;try{if(f1(e,f,n,l,Ke)){Mt=1,Ii(e,Un(l,e.current)),We=null;return}}catch(g){if(f!==null)throw We=f,g;Mt=1,Ii(e,Un(l,e.current)),We=null;return}n.flags&32768?(Qe||i===1?e=!0:jl||(Ke&536870912)!==0?e=!1:(Kr=e=!0,(i===2||i===9||i===3||i===6)&&(i=wn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Mh(n,e)):Qi(n)}function Qi(e){var n=e;do{if((n.flags&32768)!==0){Mh(n,Kr);return}e=n.return;var l=h1(n.alternate,n,Mr);if(l!==null){We=l;return}if(n=n.sibling,n!==null){We=n;return}We=n=e}while(n!==null);Mt===0&&(Mt=5)}function Mh(e,n){do{var l=x1(e.alternate,e);if(l!==null){l.flags&=32767,We=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){We=e;return}We=e=l}while(e!==null);Mt=6,We=null}function Lh(e,n,l,i,f,g,j,R,P){e.cancelPendingCommit=null;do Zi();while(Ft!==0);if((nt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(g=n.lanes|n.childLanes,g|=wc,ha(e,l,g,j,R,P),e===xt&&(We=xt=null,Ke=0),kl=n,Zr=e,Lr=l,Lu=g,zu=f,jh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,T1(ht,function(){return Bh(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=A.T,A.T=null,f=B.p,B.p=2,j=nt,nt|=4;try{g1(e,n,l)}finally{nt=j,B.p=f,A.T=i}}Ft=1,zh(),Dh(),_h()}}function zh(){if(Ft===1){Ft=0;var e=Zr,n=kl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var i=B.p;B.p=2;var f=nt;nt|=4;try{ph(n,e);var g=Yu,j=yp(e.containerInfo),R=g.focusedElem,P=g.selectionRange;if(j!==R&&R&&R.ownerDocument&&vp(R.ownerDocument.documentElement,R)){if(P!==null&&yc(R)){var Z=P.start,ie=P.end;if(ie===void 0&&(ie=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(ie,R.value.length);else{var de=R.ownerDocument||document,J=de&&de.defaultView||window;if(J.getSelection){var ae=J.getSelection(),we=R.textContent.length,Le=Math.min(P.start,we),pt=P.end===void 0?Le:Math.min(P.end,we);!ae.extend&&Le>pt&&(j=pt,pt=Le,Le=j);var K=gp(R,Le),G=gp(R,pt);if(K&&G&&(ae.rangeCount!==1||ae.anchorNode!==K.node||ae.anchorOffset!==K.offset||ae.focusNode!==G.node||ae.focusOffset!==G.offset)){var Q=de.createRange();Q.setStart(K.node,K.offset),ae.removeAllRanges(),Le>pt?(ae.addRange(Q),ae.extend(G.node,G.offset)):(Q.setEnd(G.node,G.offset),ae.addRange(Q))}}}}for(de=[],ae=R;ae=ae.parentNode;)ae.nodeType===1&&de.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<de.length;R++){var ue=de[R];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}uo=!!qu,Yu=qu=null}finally{nt=f,B.p=i,A.T=l}}e.current=n,Ft=2}}function Dh(){if(Ft===2){Ft=0;var e=Zr,n=kl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=A.T,A.T=null;var i=B.p;B.p=2;var f=nt;nt|=4;try{oh(e,n.alternate,n)}finally{nt=f,B.p=i,A.T=l}}Ft=3}}function _h(){if(Ft===4||Ft===3){Ft=0,Yt();var e=Zr,n=kl,l=Lr,i=jh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ft=5:(Ft=0,kl=Zr=null,Oh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Qr=null),Br(l),n=n.stateNode,Pt&&typeof Pt.onCommitFiberRoot=="function")try{Pt.onCommitFiberRoot(_n,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=A.T,f=B.p,B.p=2,A.T=null;try{for(var g=e.onRecoverableError,j=0;j<i.length;j++){var R=i[j];g(R.value,{componentStack:R.stack})}}finally{A.T=n,B.p=f}}(Lr&3)!==0&&Zi(),ur(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Du?ys++:(ys=0,Du=e):ys=0,bs(0)}}function Oh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,es(n)))}function Zi(){return zh(),Dh(),_h(),Bh()}function Bh(){if(Ft!==5)return!1;var e=Zr,n=Lu;Lu=0;var l=Br(Lr),i=A.T,f=B.p;try{B.p=32>l?32:l,A.T=null,l=zu,zu=null;var g=Zr,j=Lr;if(Ft=0,kl=Zr=null,Lr=0,(nt&6)!==0)throw Error(o(331));var R=nt;if(nt|=4,vh(g.current),hh(g,g.current,j,l),nt=R,bs(0,!1),Pt&&typeof Pt.onPostCommitFiberRoot=="function")try{Pt.onPostCommitFiberRoot(_n,g)}catch{}return!0}finally{B.p=f,A.T=i,Oh(e,n)}}function Ih(e,n,l){n=Un(l,n),n=fu(e.stateNode,n,2),e=Gr(e,n,2),e!==null&&(jn(e,2),ur(e))}function lt(e,n,l){if(e.tag===3)Ih(e,e,l);else for(;n!==null;){if(n.tag===3){Ih(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Qr===null||!Qr.has(i))){e=Un(l,e),l=Um(2),i=Gr(n,l,2),i!==null&&(Hm(l,i,n,e),jn(i,2),ur(i));break}}n=n.return}}function Bu(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new b1;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)||(Ru=!0,f.add(l),e=C1.bind(null,e,n,l),n.then(e,e))}function C1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,xt===e&&(Ke&l)===l&&(Mt===4||Mt===3&&(Ke&62914560)===Ke&&300>Ye()-Wi?(nt&2)===0&&wl(e,0):Au|=l,Sl===Ke&&(Sl=0)),ur(e)}function Uh(e,n){n===0&&(n=Ce()),e=wa(e,n),e!==null&&(jn(e,n),ur(e))}function E1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Uh(e,l)}function N1(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),Uh(e,l)}function T1(e,n){return Lt(e,n)}var Ji=null,El=null,Iu=!1,eo=!1,Uu=!1,ea=0;function ur(e){e!==El&&e.next===null&&(El===null?Ji=El=e:El=El.next=e),eo=!0,Iu||(Iu=!0,A1())}function bs(e,n){if(!Uu&&eo){Uu=!0;do for(var l=!1,i=Ji;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var g=0;else{var j=i.suspendedLanes,R=i.pingedLanes;g=(1<<31-it(42|e)+1)-1,g&=f&~(j&~R),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Vh(i,g))}else g=Ke,g=sn(i,i===xt?g:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(g&3)===0||Zt(i,g)||(l=!0,Vh(i,g));i=i.next}while(l);Uu=!1}}function R1(){Hh()}function Hh(){eo=Iu=!1;var e=0;ea!==0&&H1()&&(e=ea);for(var n=Ye(),l=null,i=Ji;i!==null;){var f=i.next,g=$h(i,n);g===0?(i.next=null,l===null?Ji=f:l.next=f,f===null&&(El=l)):(l=i,(e!==0||(g&3)!==0)&&(eo=!0)),i=f}Ft!==0&&Ft!==5||bs(e),ea!==0&&(ea=0)}function $h(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var j=31-it(g),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&i)!==0)&&(f[j]=fe(R,n)):P<=n&&(e.expiredLanes|=R),g&=~R}if(n=xt,l=Ke,l=sn(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(at===2||at===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&st(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Zt(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&st(i),Br(l)){case 2:case 8:l=ye;break;case 32:l=ht;break;case 268435456:l=Ot;break;default:l=ht}return i=Ph.bind(null,e),l=Lt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&st(i),e.callbackPriority=2,e.callbackNode=null,2}function Ph(e,n){if(Ft!==0&&Ft!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Zi()&&e.callbackNode!==l)return null;var i=Ke;return i=sn(e,e===xt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(kh(e,i,n),$h(e,Ye()),e.callbackNode!=null&&e.callbackNode===l?Ph.bind(null,e):null)}function Vh(e,n){if(Zi())return null;kh(e,n,!0)}function A1(){P1(function(){(nt&6)!==0?Lt(bn,R1):Hh()})}function Hu(){if(ea===0){var e=dl;e===0&&(e=pn,pn<<=1,(pn&261888)===0&&(pn=256)),ea=e}return ea}function Fh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:oi(""+e)}function Gh(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 M1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var g=Fh((f[ut]||null).action),j=i.submitter;j&&(n=(n=j[ut]||null)?Fh(n.formAction):j.getAttribute("formAction"),n!==null&&(g=n,j=null));var R=new fi("action","action",null,i,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(ea!==0){var P=j?Gh(f,j):new FormData(f);su(l,{pending:!0,data:P,method:f.method,action:g},null,P)}}else typeof g=="function"&&(R.preventDefault(),P=j?Gh(f,j):new FormData(f),su(l,{pending:!0,data:P,method:f.method,action:g},g,P))},currentTarget:f}]})}}for(var $u=0;$u<kc.length;$u++){var Pu=kc[$u],L1=Pu.toLowerCase(),z1=Pu[0].toUpperCase()+Pu.slice(1);Xn(L1,"on"+z1)}Xn(Sp,"onAnimationEnd"),Xn(kp,"onAnimationIteration"),Xn(wp,"onAnimationStart"),Xn("dblclick","onDoubleClick"),Xn("focusin","onFocus"),Xn("focusout","onBlur"),Xn(Kb,"onTransitionRun"),Xn(Xb,"onTransitionStart"),Xn(Qb,"onTransitionCancel"),Xn(Cp,"onTransitionEnd"),Qa("onMouseEnter",["mouseout","mouseover"]),Qa("onMouseLeave",["mouseout","mouseover"]),Qa("onPointerEnter",["pointerout","pointerover"]),Qa("onPointerLeave",["pointerout","pointerover"]),ba("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ba("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ba("onBeforeInput",["compositionend","keypress","textInput","paste"]),ba("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ba("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var js="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(" "),D1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(js));function Wh(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 g=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!==g&&f.isPropagationStopped())break e;g=R,f.currentTarget=Z;try{g(f)}catch(ie){hi(ie)}f.currentTarget=null,g=P}else for(j=0;j<i.length;j++){if(R=i[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==g&&f.isPropagationStopped())break e;g=R,f.currentTarget=Z;try{g(f)}catch(ie){hi(ie)}f.currentTarget=null,g=P}}}}function qe(e,n){var l=n[sr];l===void 0&&(l=n[sr]=new Set);var i=e+"__bubble";l.has(i)||(qh(n,e,2,!1),l.add(i))}function Vu(e,n,l){var i=0;n&&(i|=4),qh(l,e,i,n)}var to="_reactListening"+Math.random().toString(36).slice(2);function Fu(e){if(!e[to]){e[to]=!0,Hf.forEach(function(l){l!=="selectionchange"&&(D1.has(l)||Vu(l,!1,e),Vu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[to]||(n[to]=!0,Vu("selectionchange",!1,n))}}function qh(e,n,l,i){switch(Sx(n)){case 2:var f=o0;break;case 8:f=c0;break;default:f=ld}l=f.bind(null,n,l,e),f=void 0,!uc||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 Gu(e,n,l,i,f){var g=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=Ya(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=g=j;continue e}R=R.parentNode}}i=i.return}Zf(function(){var Z=g,ie=oc(l),de=[];e:{var J=Ep.get(e);if(J!==void 0){var ae=fi,we=e;switch(e){case"keypress":if(ui(l)===0)break e;case"keydown":case"keyup":ae=Nb;break;case"focusin":we="focus",ae=mc;break;case"focusout":we="blur",ae=mc;break;case"beforeblur":case"afterblur":ae=mc;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=tp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=hb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=Ab;break;case Sp:case kp:case wp:ae=vb;break;case Cp:ae=Lb;break;case"scroll":case"scrollend":ae=pb;break;case"wheel":ae=Db;break;case"copy":case"cut":case"paste":ae=bb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=rp;break;case"toggle":case"beforetoggle":ae=Ob}var Le=(n&4)!==0,pt=!Le&&(e==="scroll"||e==="scrollend"),K=Le?J!==null?J+"Capture":null:J;Le=[];for(var G=Z,Q;G!==null;){var ue=G;if(Q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||Q===null||K===null||(ue=Vl(G,K),ue!=null&&Le.push(Ss(G,ue,Q))),pt)break;G=G.return}0<Le.length&&(J=new ae(J,we,null,l,ie),de.push({event:J,listeners:Le}))}}if((n&7)===0){e:{if(J=e==="mouseover"||e==="pointerover",ae=e==="mouseout"||e==="pointerout",J&&l!==ic&&(we=l.relatedTarget||l.fromElement)&&(Ya(we)||we[ya]))break e;if((ae||J)&&(J=ie.window===ie?ie:(J=ie.ownerDocument)?J.defaultView||J.parentWindow:window,ae?(we=l.relatedTarget||l.toElement,ae=Z,we=we?Ya(we):null,we!==null&&(pt=u(we),Le=we.tag,we!==pt||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(ae=null,we=Z),ae!==we)){if(Le=tp,ue="onMouseLeave",K="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Le=rp,ue="onPointerLeave",K="onPointerEnter",G="pointer"),pt=ae==null?J:Pl(ae),Q=we==null?J:Pl(we),J=new Le(ue,G+"leave",ae,l,ie),J.target=pt,J.relatedTarget=Q,ue=null,Ya(ie)===Z&&(Le=new Le(K,G+"enter",we,l,ie),Le.target=Q,Le.relatedTarget=pt,ue=Le),pt=ue,ae&&we)t:{for(Le=_1,K=ae,G=we,Q=0,ue=K;ue;ue=Le(ue))Q++;ue=0;for(var Me=G;Me;Me=Le(Me))ue++;for(;0<Q-ue;)K=Le(K),Q--;for(;0<ue-Q;)G=Le(G),ue--;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&&Yh(de,J,ae,Le,!1),we!==null&&pt!==null&&Yh(de,pt,we,Le,!0)}}e:{if(J=Z?Pl(Z):window,ae=J.nodeName&&J.nodeName.toLowerCase(),ae==="select"||ae==="input"&&J.type==="file")var Je=dp;else if(cp(J))if(fp)Je=Wb;else{Je=Fb;var Ee=Vb}else ae=J.nodeName,!ae||ae.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?Z&&sc(Z.elementType)&&(Je=dp):Je=Gb;if(Je&&(Je=Je(e,Z))){up(de,Je,l,ie);break e}Ee&&Ee(e,J,Z),e==="focusout"&&Z&&J.type==="number"&&Z.memoizedProps.value!=null&&lc(J,"number",J.value)}switch(Ee=Z?Pl(Z):window,e){case"focusin":(cp(Ee)||Ee.contentEditable==="true")&&(rl=Ee,bc=Z,Ql=null);break;case"focusout":Ql=bc=rl=null;break;case"mousedown":jc=!0;break;case"contextmenu":case"mouseup":case"dragend":jc=!1,bp(de,l,ie);break;case"selectionchange":if(Yb)break;case"keydown":case"keyup":bp(de,l,ie)}var Ve;if(xc)e:{switch(e){case"compositionstart":var Xe="onCompositionStart";break e;case"compositionend":Xe="onCompositionEnd";break e;case"compositionupdate":Xe="onCompositionUpdate";break e}Xe=void 0}else nl?ip(e,l)&&(Xe="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Xe="onCompositionStart");Xe&&(ap&&l.locale!=="ko"&&(nl||Xe!=="onCompositionStart"?Xe==="onCompositionEnd"&&nl&&(Ve=Jf()):(Ir=ie,dc="value"in Ir?Ir.value:Ir.textContent,nl=!0)),Ee=no(Z,Xe),0<Ee.length&&(Xe=new np(Xe,e,null,l,ie),de.push({event:Xe,listeners:Ee}),Ve?Xe.data=Ve:(Ve=op(l),Ve!==null&&(Xe.data=Ve)))),(Ve=Ib?Ub(e,l):Hb(e,l))&&(Xe=no(Z,"onBeforeInput"),0<Xe.length&&(Ee=new np("onBeforeInput","beforeinput",null,l,ie),de.push({event:Ee,listeners:Xe}),Ee.data=Ve)),M1(de,e,Z,l,ie)}Wh(de,n)})}function Ss(e,n,l){return{instance:e,listener:n,currentTarget:l}}function no(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Vl(e,l),f!=null&&i.unshift(Ss(e,f,g)),f=Vl(e,n),f!=null&&i.push(Ss(e,f,g))),e.tag===3)return i;e=e.return}return[]}function _1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yh(e,n,l,i,f){for(var g=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=Vl(l,g),Z!=null&&j.unshift(Ss(l,Z,P))):f||(Z=Vl(l,g),Z!=null&&j.push(Ss(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var O1=/\r\n?/g,B1=/\u0000|\uFFFD/g;function Kh(e){return(typeof e=="string"?e:""+e).replace(O1,`
|
|
50
|
-
`).replace(B1,"")}function Xh(e,n){return n=Kh(n),Kh(e)===n}function ft(e,n,l,i,f,g){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Ja(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Ja(e,""+i);break;case"className":si(e,"class",i);break;case"tabIndex":si(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":si(e,l,i);break;case"style":Xf(e,i,g);break;case"data":if(n!=="object"){si(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=oi(""+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 g=="function"&&(l==="formAction"?(n!=="input"&&ft(e,n,"name",f.name,f,null),ft(e,n,"formEncType",f.formEncType,f,null),ft(e,n,"formMethod",f.formMethod,f,null),ft(e,n,"formTarget",f.formTarget,f,null)):(ft(e,n,"encType",f.encType,f,null),ft(e,n,"method",f.method,f,null),ft(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=gr);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("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=oi(""+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":qe("beforetoggle",e),qe("toggle",e),li(e,"popover",i);break;case"xlinkActuate":xr(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":xr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":xr(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":xr(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":xr(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":xr(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":xr(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":xr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":xr(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":li(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=db.get(l)||l,li(e,l,i))}}function Wu(e,n,l,i,f,g){switch(l){case"style":Xf(e,i,g);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"?Ja(e,i):(typeof i=="number"||typeof i=="bigint")&&Ja(e,""+i);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"onClick":i!=null&&(e.onclick=gr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!$f.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),g=e[ut]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof i=="function")){typeof g!="function"&&g!==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,""):li(e,l,i)}}}function nn(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":qe("error",e),qe("load",e);var i=!1,f=!1,g;for(g in l)if(l.hasOwnProperty(g)){var j=l[g];if(j!=null)switch(g){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ft(e,n,g,j,l,null)}}f&&ft(e,n,"srcSet",l.srcSet,l,null),i&&ft(e,n,"src",l.src,l,null);return;case"input":qe("invalid",e);var R=g=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var ie=l[i];if(ie!=null)switch(i){case"name":f=ie;break;case"type":j=ie;break;case"checked":P=ie;break;case"defaultChecked":Z=ie;break;case"value":g=ie;break;case"defaultValue":R=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(o(137,n));break;default:ft(e,n,i,ie,l,null)}}Wf(e,g,R,P,Z,j,f,!1);return;case"select":qe("invalid",e),i=j=g=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":g=R;break;case"defaultValue":j=R;break;case"multiple":i=R;default:ft(e,n,f,R,l,null)}n=g,l=j,e.multiple=!!i,n!=null?Za(e,!!i,n,!1):l!=null&&Za(e,!!i,l,!0);return;case"textarea":qe("invalid",e),g=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":g=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:ft(e,n,j,R,l,null)}Yf(e,i,f,g);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:ft(e,n,P,i,l,null)}return;case"dialog":qe("beforetoggle",e),qe("toggle",e),qe("cancel",e),qe("close",e);break;case"iframe":case"object":qe("load",e);break;case"video":case"audio":for(i=0;i<js.length;i++)qe(js[i],e);break;case"image":qe("error",e),qe("load",e);break;case"details":qe("toggle",e);break;case"embed":case"source":case"link":qe("error",e),qe("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:ft(e,n,Z,i,l,null)}return;default:if(sc(n)){for(ie in l)l.hasOwnProperty(ie)&&(i=l[ie],i!==void 0&&Wu(e,n,ie,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&ft(e,n,R,i,l,null))}function I1(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,g=null,j=null,R=null,P=null,Z=null,ie=null;for(ae in l){var de=l[ae];if(l.hasOwnProperty(ae)&&de!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":P=de;default:i.hasOwnProperty(ae)||ft(e,n,ae,null,i,de)}}for(var J in i){var ae=i[J];if(de=l[J],i.hasOwnProperty(J)&&(ae!=null||de!=null))switch(J){case"type":g=ae;break;case"name":f=ae;break;case"checked":Z=ae;break;case"defaultChecked":ie=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!==de&&ft(e,n,J,ae,i,de)}}ac(e,j,R,P,Z,ie,g,f);return;case"select":ae=j=R=J=null;for(g in l)if(P=l[g],l.hasOwnProperty(g)&&P!=null)switch(g){case"value":break;case"multiple":ae=P;default:i.hasOwnProperty(g)||ft(e,n,g,null,i,P)}for(f in i)if(g=i[f],P=l[f],i.hasOwnProperty(f)&&(g!=null||P!=null))switch(f){case"value":J=g;break;case"defaultValue":R=g;break;case"multiple":j=g;default:g!==P&&ft(e,n,f,g,i,P)}n=R,l=j,i=ae,J!=null?Za(e,!!l,J,!1):!!i!=!!l&&(n!=null?Za(e,!!l,n,!0):Za(e,!!l,l?[]:"",!1));return;case"textarea":ae=J=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:ft(e,n,R,null,i,f)}for(j in i)if(f=i[j],g=l[j],i.hasOwnProperty(j)&&(f!=null||g!=null))switch(j){case"value":J=f;break;case"defaultValue":ae=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==g&&ft(e,n,j,f,i,g)}qf(e,J,ae);return;case"option":for(var we in l)if(J=l[we],l.hasOwnProperty(we)&&J!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:ft(e,n,we,null,i,J)}for(P in i)if(J=i[P],ae=l[P],i.hasOwnProperty(P)&&J!==ae&&(J!=null||ae!=null))switch(P){case"selected":e.selected=J&&typeof J!="function"&&typeof J!="symbol";break;default:ft(e,n,P,J,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)J=l[Le],l.hasOwnProperty(Le)&&J!=null&&!i.hasOwnProperty(Le)&&ft(e,n,Le,null,i,J);for(Z in i)if(J=i[Z],ae=l[Z],i.hasOwnProperty(Z)&&J!==ae&&(J!=null||ae!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(o(137,n));break;default:ft(e,n,Z,J,i,ae)}return;default:if(sc(n)){for(var pt in l)J=l[pt],l.hasOwnProperty(pt)&&J!==void 0&&!i.hasOwnProperty(pt)&&Wu(e,n,pt,void 0,i,J);for(ie in i)J=i[ie],ae=l[ie],!i.hasOwnProperty(ie)||J===ae||J===void 0&&ae===void 0||Wu(e,n,ie,J,i,ae);return}}for(var K in l)J=l[K],l.hasOwnProperty(K)&&J!=null&&!i.hasOwnProperty(K)&&ft(e,n,K,null,i,J);for(de in i)J=i[de],ae=l[de],!i.hasOwnProperty(de)||J===ae||J==null&&ae==null||ft(e,n,de,J,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 U1(){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],g=f.transferSize,j=f.initiatorType,R=f.duration;if(g&&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 ie=P.transferSize,de=P.initiatorType;ie&&Qh(de)&&(P=P.responseEnd,j+=ie*(P<R?1:(R-Z)/(P-Z)))}if(--i,n+=8*(g+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 qu=null,Yu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Zh(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 Jh(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 Ku(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 Xu=null;function H1(){var e=window.event;return e&&e.type==="popstate"?e===Xu?!1:(Xu=e,!0):(Xu=null,!1)}var ex=typeof setTimeout=="function"?setTimeout:void 0,$1=typeof clearTimeout=="function"?clearTimeout:void 0,tx=typeof Promise=="function"?Promise:void 0,P1=typeof queueMicrotask=="function"?queueMicrotask:typeof tx<"u"?function(e){return tx.resolve(null).then(e).catch(V1)}:ex;function V1(e){setTimeout(function(){throw e})}function ta(e){return e==="head"}function nx(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),Al(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")ks(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,ks(l);for(var g=l.firstChild;g;){var j=g.nextSibling,R=g.nodeName;g[$l]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=j}}else l==="body"&&ks(e.ownerDocument.body);l=f}while(l);Al(n)}function rx(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 Qu(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":Qu(l),nc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function F1(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[$l])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==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(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Fn(e.nextSibling),e===null)break}return null}function G1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Fn(e.nextSibling),e===null))return null;return e}function ax(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Fn(e.nextSibling),e===null))return null;return e}function Zu(e){return e.data==="$?"||e.data==="$~"}function Ju(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function W1(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 Fn(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 ed=null;function lx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Fn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function sx(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 ix(e,n,l){switch(n=ro(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 ks(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);nc(e)}var Gn=new Map,ox=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var zr=B.d;B.d={f:q1,r:Y1,D:K1,C:X1,L:Q1,m:Z1,X:e0,S:J1,M:t0};function q1(){var e=zr.f(),n=Ki();return e||n}function Y1(e){var n=Ka(e);n!==null&&n.tag===5&&n.type==="form"?Cm(n):zr.r(e)}var Nl=typeof document>"u"?null:document;function cx(e,n,l){var i=Nl;if(i&&typeof n=="string"&&n){var f=Bn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),ox.has(f)||(ox.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),nn(n,"link",e),Kt(n),i.head.appendChild(n)))}}function K1(e){zr.D(e),cx("dns-prefetch",e,null)}function X1(e,n){zr.C(e,n),cx("preconnect",e,n)}function Q1(e,n,l){zr.L(e,n,l);var i=Nl;if(i&&e&&n){var f='link[rel="preload"][as="'+Bn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+Bn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+Bn(l.imageSizes)+'"]')):f+='[href="'+Bn(e)+'"]';var g=f;switch(n){case"style":g=Tl(e);break;case"script":g=Rl(e)}Gn.has(g)||(e=y({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Gn.set(g,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(ws(g))||n==="script"&&i.querySelector(Cs(g))||(n=i.createElement("link"),nn(n,"link",e),Kt(n),i.head.appendChild(n)))}}function Z1(e,n){zr.m(e,n);var l=Nl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+Bn(i)+'"][href="'+Bn(e)+'"]',g=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Rl(e)}if(!Gn.has(g)&&(e=y({rel:"modulepreload",href:e},n),Gn.set(g,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Cs(g)))return}i=l.createElement("link"),nn(i,"link",e),Kt(i),l.head.appendChild(i)}}}function J1(e,n,l){zr.S(e,n,l);var i=Nl;if(i&&e){var f=Xa(i).hoistableStyles,g=Tl(e);n=n||"default";var j=f.get(g);if(!j){var R={loading:0,preload:null};if(j=i.querySelector(ws(g)))R.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Gn.get(g))&&td(e,l);var P=j=i.createElement("link");Kt(P),nn(P,"link",e),P._p=new Promise(function(Z,ie){P.onload=Z,P.onerror=ie}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,lo(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(g,j)}}}function e0(e,n){zr.X(e,n);var l=Nl;if(l&&e){var i=Xa(l).hoistableScripts,f=Rl(e),g=i.get(f);g||(g=l.querySelector(Cs(f)),g||(e=y({src:e,async:!0},n),(n=Gn.get(f))&&nd(e,n),g=l.createElement("script"),Kt(g),nn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},i.set(f,g))}}function t0(e,n){zr.M(e,n);var l=Nl;if(l&&e){var i=Xa(l).hoistableScripts,f=Rl(e),g=i.get(f);g||(g=l.querySelector(Cs(f)),g||(e=y({src:e,async:!0,type:"module"},n),(n=Gn.get(f))&&nd(e,n),g=l.createElement("script"),Kt(g),nn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},i.set(f,g))}}function ux(e,n,l,i){var f=(f=le.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=Tl(l.href),l=Xa(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=Tl(l.href);var g=Xa(f).hoistableStyles,j=g.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,j),(g=f.querySelector(ws(e)))&&!g._p&&(j.instance=g,j.state.loading=5),Gn.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},Gn.set(e,l),g||n0(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=Rl(l),l=Xa(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 Tl(e){return'href="'+Bn(e)+'"'}function ws(e){return'link[rel="stylesheet"]['+e+"]"}function dx(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function n0(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}),nn(n,"link",l),Kt(n),e.head.appendChild(n))}function Rl(e){return'[src="'+Bn(e)+'"]'}function Cs(e){return"script[async]"+e}function fx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+Bn(l.href)+'"]');if(i)return n.instance=i,Kt(i),i;var f=y({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Kt(i),nn(i,"style",f),lo(i,l.precedence,e),n.instance=i;case"stylesheet":f=Tl(l.href);var g=e.querySelector(ws(f));if(g)return n.state.loading|=4,n.instance=g,Kt(g),g;i=dx(l),(f=Gn.get(f))&&td(i,f),g=(e.ownerDocument||e).createElement("link"),Kt(g);var j=g;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),nn(g,"link",i),n.state.loading|=4,lo(g,l.precedence,e),n.instance=g;case"script":return g=Rl(l.src),(f=e.querySelector(Cs(g)))?(n.instance=f,Kt(f),f):(i=l,(f=Gn.get(g))&&(i=y({},l),nd(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Kt(f),nn(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,lo(i,l.precedence,e));return n.instance}function lo(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,g=f,j=0;j<i.length;j++){var R=i[j];if(R.dataset.precedence===n)g=R;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function td(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function nd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var so=null;function px(e,n,l){if(so===null){var i=new Map,f=so=new Map;f.set(l,i)}else f=so,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 g=l[f];if(!(g[$l]||g[Vt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var j=g.getAttribute(n)||"";j=e+j;var R=i.get(j);R?R.push(g):i.set(j,[g])}}return i}function mx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function r0(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 hx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function a0(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=Tl(i.href),g=n.querySelector(ws(f));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=io.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Kt(g);return}g=n.ownerDocument||n,i=dx(i),(f=Gn.get(f))&&td(i,f),g=g.createElement("link"),Kt(g);var j=g;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),nn(g,"link",i),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=io.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var rd=0;function l0(e,n){return e.stylesheets&&e.count===0&&co(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&co(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&rd===0&&(rd=62500*U1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&co(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>rd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function io(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)co(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var oo=null;function co(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oo=new Map,n.forEach(s0,e),oo=null,io.call(e))}function s0(e,n){if(!(n.state.loading&4)){var l=oo.get(e);if(l)var i=l.get(null);else{l=new Map,oo.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var j=f[g];(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"),g=l.get(j)||i,g===i&&l.set(null,f),l.set(j,f),this.count++,i=io.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Es={$$typeof:L,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function i0(e,n,l,i,f,g,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=ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ze(0),this.hiddenUpdates=ze(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function xx(e,n,l,i,f,g,j,R,P,Z,ie,de){return e=new i0(e,n,l,j,P,Z,ie,de,R),n=1,g===!0&&(n|=24),g=kn(3,null,null,n),e.current=g,g.stateNode=e,n=Oc(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:i,isDehydrated:l,cache:n},Hc(g),e}function gx(e){return e?(e=sl,e):sl}function vx(e,n,l,i,f,g){f=gx(f),i.context===null?i.context=f:i.pendingContext=f,i=Fr(n),i.payload={element:l},g=g===void 0?null:g,g!==null&&(i.callback=g),l=Gr(e,i,n),l!==null&&(yn(l,e,n),as(l,e,n))}function yx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function ad(e,n){yx(e,n),(e=e.alternate)&&yx(e,n)}function bx(e){if(e.tag===13||e.tag===31){var n=wa(e,67108864);n!==null&&yn(n,e,67108864),ad(e,67108864)}}function jx(e){if(e.tag===13||e.tag===31){var n=Tn();n=qa(n);var l=wa(e,n);l!==null&&yn(l,e,n),ad(e,n)}}var uo=!0;function o0(e,n,l,i){var f=A.T;A.T=null;var g=B.p;try{B.p=2,ld(e,n,l,i)}finally{B.p=g,A.T=f}}function c0(e,n,l,i){var f=A.T;A.T=null;var g=B.p;try{B.p=8,ld(e,n,l,i)}finally{B.p=g,A.T=f}}function ld(e,n,l,i){if(uo){var f=sd(i);if(f===null)Gu(e,n,i,fo,l),kx(e,i);else if(d0(f,e,n,l,i))i.stopPropagation();else if(kx(e,i),n&4&&-1<u0.indexOf(e)){for(;f!==null;){var g=Ka(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var j=ot(g.pendingLanes);if(j!==0){var R=g;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-it(j);R.entanglements[1]|=P,j&=~P}ur(g),(nt&6)===0&&(qi=Ye()+500,bs(0))}}break;case 31:case 13:R=wa(g,2),R!==null&&yn(R,g,2),Ki(),ad(g,2)}if(g=sd(i),g===null&&Gu(e,n,i,fo,l),g===f)break;f=g}f!==null&&i.stopPropagation()}else Gu(e,n,i,null,l)}}function sd(e){return e=oc(e),id(e)}var fo=null;function id(e){if(fo=null,e=Ya(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 fo=e,null}function Sx(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(vt()){case bn:return 2;case ye:return 8;case ht:case zt:return 32;case Ot:return 268435456;default:return 32}default:return 32}}var od=!1,na=null,ra=null,aa=null,Ns=new Map,Ts=new Map,la=[],u0="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 kx(e,n){switch(e){case"focusin":case"focusout":na=null;break;case"dragenter":case"dragleave":ra=null;break;case"mouseover":case"mouseout":aa=null;break;case"pointerover":case"pointerout":Ns.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ts.delete(n.pointerId)}}function Rs(e,n,l,i,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Ka(n),n!==null&&bx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function d0(e,n,l,i,f){switch(n){case"focusin":return na=Rs(na,e,n,l,i,f),!0;case"dragenter":return ra=Rs(ra,e,n,l,i,f),!0;case"mouseover":return aa=Rs(aa,e,n,l,i,f),!0;case"pointerover":var g=f.pointerId;return Ns.set(g,Rs(Ns.get(g)||null,e,n,l,i,f)),!0;case"gotpointercapture":return g=f.pointerId,Ts.set(g,Rs(Ts.get(g)||null,e,n,l,i,f)),!0}return!1}function wx(e){var n=Ya(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,va(e.priority,function(){jx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,va(e.priority,function(){jx(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 po(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=sd(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);ic=i,l.target.dispatchEvent(i),ic=null}else return n=Ka(l),n!==null&&bx(n),e.blockedOn=l,!1;n.shift()}return!0}function Cx(e,n,l){po(e)&&l.delete(n)}function f0(){od=!1,na!==null&&po(na)&&(na=null),ra!==null&&po(ra)&&(ra=null),aa!==null&&po(aa)&&(aa=null),Ns.forEach(Cx),Ts.forEach(Cx)}function mo(e,n){e.blockedOn===n&&(e.blockedOn=null,od||(od=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,f0)))}var ho=null;function Ex(e){ho!==e&&(ho=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ho===e&&(ho=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(id(i||l)===null)continue;break}var g=Ka(l);g!==null&&(e.splice(n,3),n-=3,su(g,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function Al(e){function n(P){return mo(P,e)}na!==null&&mo(na,e),ra!==null&&mo(ra,e),aa!==null&&mo(aa,e),Ns.forEach(n),Ts.forEach(n);for(var l=0;l<la.length;l++){var i=la[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<la.length&&(l=la[0],l.blockedOn===null);)wx(l),l.blockedOn===null&&la.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],g=l[i+1],j=f[ut]||null;if(typeof g=="function")j||Ex(l);else if(j){var R=null;if(g&&g.hasAttribute("formAction")){if(f=g,j=g[ut]||null)R=j.formAction;else if(id(f)!==null)continue}else R=j.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),Ex(l)}}}function Nx(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.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 g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.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 cd(e){this._internalRoot=e}xo.prototype.render=cd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Tn();vx(l,i,e,n,null,null)},xo.prototype.unmount=cd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;vx(e.current,2,null,e,null,null),Ki(),n[ya]=null}};function xo(e){this._internalRoot=e}xo.prototype.unstable_scheduleHydration=function(e){if(e){var n=ct();e={blockedOn:null,target:e,priority:n};for(var l=0;l<la.length&&n!==0&&n<la[l].priority;l++);la.splice(l,0,e),l===0&&wx(e)}};var Tx=a.version;if(Tx!=="19.2.4")throw Error(o(527,Tx,"19.2.4"));B.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?v(e):null,e=e===null?null:e.stateNode,e};var p0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var go=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!go.isDisabled&&go.supportsFiber)try{_n=go.inject(p0),Pt=go}catch{}}return Ms.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=_m,g=Om,j=Bm;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&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=xx(e,1,!1,null,null,l,i,null,f,g,j,Nx),e[ya]=n.current,Fu(e),new cd(n)},Ms.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",g=_m,j=Om,R=Bm,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=xx(e,1,!0,n,l??null,i,f,P,g,j,R,Nx),n.context=gx(null),l=n.current,i=Tn(),i=qa(i),f=Fr(i),f.callback=null,Gr(l,f,i),l=i,n.current.lanes=l,jn(n,l),ur(n),e[ya]=n.current,Fu(e),new xo(n)},Ms.version="19.2.4",Ms}var Ix;function S0(){if(Ix)return fd.exports;Ix=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(a){console.error(a)}}return t(),fd.exports=j0(),fd.exports}var k0=S0();/**
|
|
51
|
-
* react-router v7.13.1
|
|
52
|
-
*
|
|
53
|
-
* Copyright (c) Remix Software Inc.
|
|
54
|
-
*
|
|
55
|
-
* This source code is licensed under the MIT license found in the
|
|
56
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
57
|
-
*
|
|
58
|
-
* @license MIT
|
|
59
|
-
*/var Ux="popstate";function Hx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function w0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:x=""}=Bl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),Xd("",{pathname:d,search:h,hash:x},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 x=c.location.href,m=x.indexOf("#");h=m===-1?x:x.slice(0,m)}return h+"#"+(typeof u=="string"?u:Vs(u))}function o(c,u){er(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return E0(a,s,o,t)}function qt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function er(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function C0(){return Math.random().toString(36).substring(2,10)}function $x(t,a){return{usr:t.state,key:t.key,idx:a,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Xd(t,a,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Bl(a):a,state:s,key:a&&a.key||o||C0(),unstable_mask:c}}function Vs({pathname:t="/",search:a="",hash:s=""}){return a&&a!=="?"&&(t+=a.charAt(0)==="?"?a:"?"+a),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function Bl(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(a.search=t.substring(o),t=t.substring(0,o)),t&&(a.pathname=t)}return a}function E0(t,a,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",x=null,m=v();m==null&&(m=0,d.replaceState({...d.state,idx:m},""));function v(){return(d.state||{idx:null}).idx}function y(){h="POP";let w=v(),T=w==null?null:w-m;m=w,x&&x({action:h,location:k.location,delta:T})}function b(w,T){h="PUSH";let N=Hx(w)?w:Xd(k.location,w,T);s&&s(N,w),m=v()+1;let L=$x(N,m),_=k.createHref(N.unstable_mask||N);try{d.pushState(L,"",_)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(_)}u&&x&&x({action:h,location:k.location,delta:1})}function S(w,T){h="REPLACE";let N=Hx(w)?w:Xd(k.location,w,T);s&&s(N,w),m=v();let L=$x(N,m),_=k.createHref(N.unstable_mask||N);d.replaceState(L,"",_),u&&x&&x({action:h,location:k.location,delta:0})}function C(w){return N0(w)}let k={get action(){return h},get location(){return t(c,d)},listen(w){if(x)throw new Error("A history only accepts one active listener");return c.addEventListener(Ux,y),x=w,()=>{c.removeEventListener(Ux,y),x=null}},createHref(w){return a(c,w)},createURL:C,encodeLocation(w){let T=C(w);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:b,replace:S,go(w){return d.go(w)}};return k}function N0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),qt(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Vs(t);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function hv(t,a,s="/"){return T0(t,a,s,!1)}function T0(t,a,s,o){let c=typeof a=="string"?Bl(a):a,u=_r(c.pathname||"/",s);if(u==null)return null;let d=xv(t);R0(d);let h=null;for(let x=0;h==null&&x<d.length;++x){let m=H0(u);h=I0(d[x],m,o)}return h}function xv(t,a=[],s=[],o="",c=!1){let u=(d,h,x=c,m)=>{let v={relativePath:m===void 0?d.path||"":m,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&x)return;qt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let y=pr([o,v.relativePath]),b=s.concat(v);d.children&&d.children.length>0&&(qt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),xv(d.children,a,b,y,x)),!(d.path==null&&!d.index)&&a.push({path:y,score:O0(y,d.index),routesMeta:b})};return t.forEach((d,h)=>{var x;if(d.path===""||!((x=d.path)!=null&&x.includes("?")))u(d,h);else for(let m of gv(d.path))u(d,h,!0,m)}),a}function gv(t){let a=t.split("/");if(a.length===0)return[];let[s,...o]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=gv(o.join("/")),h=[];return h.push(...d.map(x=>x===""?u:[u,x].join("/"))),c&&h.push(...d),h.map(x=>t.startsWith("/")&&x===""?"/":x)}function R0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:B0(a.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var A0=/^:[\w-]+$/,M0=3,L0=2,z0=1,D0=10,_0=-2,Px=t=>t==="*";function O0(t,a){let s=t.split("/"),o=s.length;return s.some(Px)&&(o+=_0),a&&(o+=L0),s.filter(c=>!Px(c)).reduce((c,u)=>c+(A0.test(u)?M0:u===""?z0:D0),o)}function B0(t,a){return t.length===a.length&&t.slice(0,-1).every((o,c)=>o===a[c])?t[t.length-1]-a[a.length-1]:0}function I0(t,a,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let x=o[h],m=h===o.length-1,v=u==="/"?a:a.slice(u.length)||"/",y=Oo({path:x.relativePath,caseSensitive:x.caseSensitive,end:m},v),b=x.route;if(!y&&m&&s&&!o[o.length-1].route.index&&(y=Oo({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!y)return null;Object.assign(c,y.params),d.push({params:c,pathname:pr([u,y.pathname]),pathnameBase:F0(pr([u,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(u=pr([u,y.pathnameBase]))}return d}function Oo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=U0(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((m,{paramName:v,isOptional:y},b)=>{if(v==="*"){let C=h[b]||"";d=u.slice(0,u.length-C.length).replace(/(.)\/+$/,"$1")}const S=h[b];return y&&!S?m[v]=void 0:m[v]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:d,pattern:t}}function U0(t,a=!1,s=!0){er(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,x,m,v)=>{if(o.push({paramName:h,isOptional:x!=null}),x){let y=v.charAt(m+d.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),o]}function H0(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return er(!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 (${a}).`),t}}function _r(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var $0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function P0(t,a="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?Bl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Vx(s.substring(1),"/"):u=Vx(s,a)):u=a,{pathname:u,search:G0(o),hash:W0(c)}}function Vx(t,a){let s=a.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function xd(t,a,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` 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 V0(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function vv(t){let a=V0(t);return a.map((s,o)=>o===a.length-1?s.pathname:s.pathnameBase)}function gf(t,a,s,o=!1){let c;typeof t=="string"?c=Bl(t):(c={...t},qt(!c.pathname||!c.pathname.includes("?"),xd("?","pathname","search",c)),qt(!c.pathname||!c.pathname.includes("#"),xd("#","pathname","hash",c)),qt(!c.search||!c.search.includes("#"),xd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let y=a.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),y-=1;c.pathname=b.join("/")}h=y>=0?a[y]:"/"}let x=P0(c,h),m=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&s.endsWith("/");return!x.pathname.endsWith("/")&&(m||v)&&(x.pathname+="/"),x}var pr=t=>t.join("/").replace(/\/\/+/g,"/"),F0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),G0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,W0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,q0=class{constructor(t,a,s,o=!1){this.status=t,this.statusText=a||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function Y0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function K0(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var yv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function bv(t,a){let s=t;if(typeof s!="string"||!$0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(yv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=_r(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{er(!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 jv=["POST","PUT","PATCH","DELETE"];new Set(jv);var X0=["GET",...jv];new Set(X0);var Il=p.createContext(null);Il.displayName="DataRouter";var Po=p.createContext(null);Po.displayName="DataRouterState";var Q0=p.createContext(!1),Sv=p.createContext({isTransitioning:!1});Sv.displayName="ViewTransition";var Z0=p.createContext(new Map);Z0.displayName="Fetchers";var J0=p.createContext(null);J0.displayName="Await";var Kn=p.createContext(null);Kn.displayName="Navigation";var Vo=p.createContext(null);Vo.displayName="Location";var Or=p.createContext({outlet:null,matches:[],isDataRoute:!1});Or.displayName="Route";var vf=p.createContext(null);vf.displayName="RouteError";var kv="REACT_ROUTER_ERROR",ej="REDIRECT",tj="ROUTE_ERROR_RESPONSE";function nj(t){if(t.startsWith(`${kv}:${ej}:{`))try{let a=JSON.parse(t.slice(28));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.location=="string"&&typeof a.reloadDocument=="boolean"&&typeof a.replace=="boolean")return a}catch{}}function rj(t){if(t.startsWith(`${kv}:${tj}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new q0(a.status,a.statusText,a.data)}catch{}}function aj(t,{relative:a}={}){qt(Qs(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=p.useContext(Kn),{hash:c,pathname:u,search:d}=Zs(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:pr([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Qs(){return p.useContext(Vo)!=null}function da(){return qt(Qs(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Vo).location}var wv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Cv(t){p.useContext(Kn).static||p.useLayoutEffect(t)}function lj(){let{isDataRoute:t}=p.useContext(Or);return t?vj():sj()}function sj(){qt(Qs(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Il),{basename:a,navigator:s}=p.useContext(Kn),{matches:o}=p.useContext(Or),{pathname:c}=da(),u=JSON.stringify(vv(o)),d=p.useRef(!1);return Cv(()=>{d.current=!0}),p.useCallback((x,m={})=>{if(er(d.current,wv),!d.current)return;if(typeof x=="number"){s.go(x);return}let v=gf(x,JSON.parse(u),c,m.relative==="path");t==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:pr([a,v.pathname])),(m.replace?s.replace:s.push)(v,m.state,m)},[a,s,u,c,t])}p.createContext(null);function Zs(t,{relative:a}={}){let{matches:s}=p.useContext(Or),{pathname:o}=da(),c=JSON.stringify(vv(s));return p.useMemo(()=>gf(t,JSON.parse(c),o,a==="path"),[t,c,o,a])}function ij(t,a,s){qt(Qs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=p.useContext(Kn),{matches:c}=p.useContext(Or),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",x=u?u.pathnameBase:"/",m=u&&u.route;{let w=m&&m.path||"";Nv(h,!m||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${w}">) 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
|
-
|
|
61
|
-
Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let v=da(),y;y=v;let b=y.pathname||"/",S=b;if(x!=="/"){let w=x.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(w.length).join("/")}let C=hv(t,{pathname:S});return er(m||C!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),er(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.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.`),fj(C&&C.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:pr([x,o.encodeLocation?o.encodeLocation(w.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?x:pr([x,o.encodeLocation?o.encodeLocation(w.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,s)}function oj(){let t=gj(),a=Y0(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"}},a),s?p.createElement("pre",{style:c},s):null,d)}var cj=p.createElement(oj,null),Ev=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,a){return a.location!==t.location||a.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:a.error,location:a.location,revalidation:t.revalidation||a.revalidation}}componentDidCatch(t,a){this.props.onError?this.props.onError(t,a):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=rj(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(Or.Provider,{value:this.props.routeContext},p.createElement(vf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(uj,{error:t},a):a}};Ev.contextType=Q0;var gd=new WeakMap;function uj({children:t,error:a}){let{basename:s}=p.useContext(Kn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let o=nj(a.digest);if(o){let c=gd.get(a);if(c)throw c;let u=bv(o.location,s);if(yv&&!gd.get(a))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 gd.set(a,d),d}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function dj({routeContext:t,match:a,children:s}){let o=p.useContext(Il);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(Or.Provider,{value:t},s)}function fj(t,a=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(a.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 v=c.findIndex(y=>y.route.id&&(u==null?void 0:u[y.route.id])!==void 0);qt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let v=0;v<c.length;v++){let y=c[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(h=v),y.route.id){let{loaderData:b,errors:S}=o,C=y.route.loader&&!b.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||C){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let x=s==null?void 0:s.onError,m=o&&x?(v,y)=>{var b,S;x(v,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:K0(o.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let S,C=!1,k=null,w=null;o&&(S=u&&y.route.id?u[y.route.id]:void 0,k=y.route.errorElement||cj,d&&(h<0&&b===0?(Nv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,w=null):h===b&&(C=!0,w=y.route.hydrateFallbackElement||null)));let T=a.concat(c.slice(0,b+1)),N=()=>{let L;return S?L=k:C?L=w:y.route.Component?L=p.createElement(y.route.Component,null):y.route.element?L=y.route.element:L=v,p.createElement(dj,{match:y,routeContext:{outlet:v,matches:T,isDataRoute:o!=null},children:L})};return o&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?p.createElement(Ev,{location:o.location,revalidation:o.revalidation,component:k,error:S,children:N(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:m}):N()},null)}function yf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pj(t){let a=p.useContext(Il);return qt(a,yf(t)),a}function mj(t){let a=p.useContext(Po);return qt(a,yf(t)),a}function hj(t){let a=p.useContext(Or);return qt(a,yf(t)),a}function bf(t){let a=hj(t),s=a.matches[a.matches.length-1];return qt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function xj(){return bf("useRouteId")}function gj(){var o;let t=p.useContext(vf),a=mj("useRouteError"),s=bf("useRouteError");return t!==void 0?t:(o=a.errors)==null?void 0:o[s]}function vj(){let{router:t}=pj("useNavigate"),a=bf("useNavigate"),s=p.useRef(!1);return Cv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{er(s.current,wv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var Fx={};function Nv(t,a,s){!a&&!Fx[t]&&(Fx[t]=!0,er(!1,s))}p.memo(yj);function yj({routes:t,future:a,state:s,isStatic:o,onError:c}){return ij(t,void 0,{state:s,isStatic:o,onError:c})}function bj({basename:t="/",children:a=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){qt(!Qs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),x=p.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=Bl(s));let{pathname:m="/",search:v="",hash:y="",state:b=null,key:S="default",unstable_mask:C}=s,k=p.useMemo(()=>{let w=_r(m,h);return w==null?null:{location:{pathname:w,search:v,hash:y,state:b,key:S,unstable_mask:C},navigationType:o}},[h,m,v,y,b,S,o,C]);return er(k!=null,`<Router basename="${h}"> is not able to match the URL "${m}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),k==null?null:p.createElement(Kn.Provider,{value:x},p.createElement(Vo.Provider,{children:a,value:k}))}var Ro="get",Ao="application/x-www-form-urlencoded";function Fo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function jj(t){return Fo(t)&&t.tagName.toLowerCase()==="button"}function Sj(t){return Fo(t)&&t.tagName.toLowerCase()==="form"}function kj(t){return Fo(t)&&t.tagName.toLowerCase()==="input"}function wj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Cj(t,a){return t.button===0&&(!a||a==="_self")&&!wj(t)}var vo=null;function Ej(){if(vo===null)try{new FormData(document.createElement("form"),0),vo=!1}catch{vo=!0}return vo}var Nj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function vd(t){return t!=null&&!Nj.has(t)?(er(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ao}"`),null):t}function Tj(t,a){let s,o,c,u,d;if(Sj(t)){let h=t.getAttribute("action");o=h?_r(h,a):null,s=t.getAttribute("method")||Ro,c=vd(t.getAttribute("enctype"))||Ao,u=new FormData(t)}else if(jj(t)||kj(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 x=t.getAttribute("formaction")||h.getAttribute("action");if(o=x?_r(x,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Ro,c=vd(t.getAttribute("formenctype"))||vd(h.getAttribute("enctype"))||Ao,u=new FormData(h,t),!Ej()){let{name:m,type:v,value:y}=t;if(v==="image"){let b=m?`${m}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else m&&u.append(m,y)}}else{if(Fo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Ro,o=null,c=Ao,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 jf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Rj(t,a,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}`:a&&_r(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function Aj(t,a){if(t.id in a)return a[t.id];try{let s=await import(t.module);return a[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 Mj(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 Lj(t,a,s){let o=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await Aj(u,s);return d.links?d.links():[]}return[]}));return Oj(o.flat(1).filter(Mj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Gx(t,a,s,o,c,u){let d=(x,m)=>s[m]?x.route.id!==s[m].route.id:!0,h=(x,m)=>{var v;return s[m].pathname!==x.pathname||((v=s[m].route.path)==null?void 0:v.endsWith("*"))&&s[m].params["*"]!==x.params["*"]};return u==="assets"?a.filter((x,m)=>d(x,m)||h(x,m)):u==="data"?a.filter((x,m)=>{var y;let v=o.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(d(x,m)||h(x,m))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((y=s[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function zj(t,a,{includeHydrateFallback:s}={}){return Dj(t.map(o=>{let c=a.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 Dj(t){return[...new Set(t)]}function _j(t){let a={},s=Object.keys(t).sort();for(let o of s)a[o]=t[o];return a}function Oj(t,a){let s=new Set;return new Set(a),t.reduce((o,c)=>{let u=JSON.stringify(_j(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function Tv(){let t=p.useContext(Il);return jf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Bj(){let t=p.useContext(Po);return jf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Sf=p.createContext(void 0);Sf.displayName="FrameworkContext";function Rv(){let t=p.useContext(Sf);return jf(t,"You must render this element inside a <HydratedRouter> element"),t}function Ij(t,a){let s=p.useContext(Sf),[o,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:x,onMouseEnter:m,onMouseLeave:v,onTouchStart:y}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let k=T=>{T.forEach(N=>{d(N.isIntersecting)})},w=new IntersectionObserver(k,{threshold:.5});return b.current&&w.observe(b.current),()=>{w.disconnect()}}},[t]),p.useEffect(()=>{if(o){let k=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(k)}}},[o]);let S=()=>{c(!0)},C=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Ls(h,S),onBlur:Ls(x,C),onMouseEnter:Ls(m,S),onMouseLeave:Ls(v,C),onTouchStart:Ls(y,S)}]:[!1,b,{}]}function Ls(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function Uj({page:t,...a}){let{router:s}=Tv(),o=p.useMemo(()=>hv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?p.createElement($j,{page:t,matches:o,...a}):null}function Hj(t){let{manifest:a,routeModules:s}=Rv(),[o,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return Lj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),o}function $j({page:t,matches:a,...s}){let o=da(),{future:c,manifest:u,routeModules:d}=Rv(),{basename:h}=Tv(),{loaderData:x,matches:m}=Bj(),v=p.useMemo(()=>Gx(t,a,m,u,o,"data"),[t,a,m,u,o]),y=p.useMemo(()=>Gx(t,a,m,u,o,"assets"),[t,a,m,u,o]),b=p.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let k=new Set,w=!1;if(a.forEach(N=>{var _;let L=u.routes[N.route.id];!L||!L.hasLoader||(!v.some(D=>D.route.id===N.route.id)&&N.route.id in x&&((_=d[N.route.id])!=null&&_.shouldRevalidate)||L.hasClientLoader?w=!0:k.add(N.route.id))}),k.size===0)return[];let T=Rj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return w&&k.size>0&&T.searchParams.set("_routes",a.filter(N=>k.has(N.route.id)).map(N=>N.route.id).join(",")),[T.pathname+T.search]},[h,c.unstable_trailingSlashAwareDataRequests,x,o,u,v,a,t,d]),S=p.useMemo(()=>zj(y,u),[y,u]),C=Hj(y);return p.createElement(p.Fragment,null,b.map(k=>p.createElement("link",{key:k,rel:"prefetch",as:"fetch",href:k,...s})),S.map(k=>p.createElement("link",{key:k,rel:"modulepreload",href:k,...s})),C.map(({key:k,link:w})=>p.createElement("link",{key:k,nonce:s.nonce,...w,crossOrigin:w.crossOrigin??s.crossOrigin})))}function Pj(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var Vj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Vj&&(window.__reactRouterVersion="7.13.1")}catch{}function Fj({basename:t,children:a,unstable_useTransitions:s,window:o}){let c=p.useRef();c.current==null&&(c.current=w0({window:o,v5Compat:!0}));let u=c.current,[d,h]=p.useState({action:u.action,location:u.location}),x=p.useCallback(m=>{s===!1?h(m):p.startTransition(()=>h(m))},[s]);return p.useLayoutEffect(()=>u.listen(x),[u,x]),p.createElement(bj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Av=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Mv=p.forwardRef(function({onClick:a,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:x,target:m,to:v,preventScrollReset:y,viewTransition:b,unstable_defaultShouldRevalidate:S,...C},k){let{basename:w,navigator:T,unstable_useTransitions:N}=p.useContext(Kn),L=typeof v=="string"&&Av.test(v),_=bv(v,w);v=_.to;let D=aj(v,{relative:c}),F=da(),E=null;if(h){let I=gf(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);w!=="/"&&(I.pathname=I.pathname==="/"?w:pr([w,I.pathname])),E=T.createHref(I)}let[O,M,U]=Ij(o,C),$=Yj(v,{replace:d,unstable_mask:h,state:x,target:m,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:N});function Y(I){a&&a(I),I.defaultPrevented||$(I)}let X=!(_.isExternal||u),ee=p.createElement("a",{...C,...U,href:(X?E:void 0)||_.absoluteURL||D,onClick:X?Y:a,ref:Pj(k,M),target:m,"data-discover":!L&&s==="render"?"true":void 0});return O&&!L?p.createElement(p.Fragment,null,ee,p.createElement(Uj,{page:D})):ee});Mv.displayName="Link";var Gj=p.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:x,...m},v){let y=Zs(d,{relative:m.relative}),b=da(),S=p.useContext(Po),{navigator:C,basename:k}=p.useContext(Kn),w=S!=null&&Jj(y)&&h===!0,T=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,N=b.pathname,L=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(N=N.toLowerCase(),L=L?L.toLowerCase():null,T=T.toLowerCase()),L&&k&&(L=_r(L,k)||L);const _=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let D=N===T||!c&&N.startsWith(T)&&N.charAt(_)==="/",F=L!=null&&(L===T||!c&&L.startsWith(T)&&L.charAt(T.length)==="/"),E={isActive:D,isPending:F,isTransitioning:w},O=D?a:void 0,M;typeof o=="function"?M=o(E):M=[o,D?"active":null,F?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(E):u;return p.createElement(Mv,{...m,"aria-current":O,className:M,ref:v,style:U,to:d,viewTransition:h},typeof x=="function"?x(E):x)});Gj.displayName="NavLink";var Wj=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:o,replace:c,state:u,method:d=Ro,action:h,onSubmit:x,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...S},C)=>{let{unstable_useTransitions:k}=p.useContext(Kn),w=Qj(),T=Zj(h,{relative:m}),N=d.toLowerCase()==="get"?"get":"post",L=typeof h=="string"&&Av.test(h),_=D=>{if(x&&x(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,E=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>w(F||D.currentTarget,{fetcherKey:a,method:E,navigate:s,replace:c,state:u,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});k&&s!==!1?p.startTransition(()=>O()):O()};return p.createElement("form",{ref:C,method:N,action:T,onSubmit:o?x:_,...S,"data-discover":!L&&t==="render"?"true":void 0})});Wj.displayName="Form";function qj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Lv(t){let a=p.useContext(Il);return qt(a,qj(t)),a}function Yj(t,{target:a,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x,unstable_useTransitions:m}={}){let v=lj(),y=da(),b=Zs(t,{relative:d});return p.useCallback(S=>{if(Cj(S,a)){S.preventDefault();let C=s!==void 0?s:Vs(y)===Vs(b),k=()=>v(t,{replace:C,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x});m?p.startTransition(()=>k()):k()}},[y,v,b,s,o,c,a,t,u,d,h,x,m])}var Kj=0,Xj=()=>`__${String(++Kj)}__`;function Qj(){let{router:t}=Lv("useSubmit"),{basename:a}=p.useContext(Kn),s=xj(),o=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:x,encType:m,formData:v,body:y}=Tj(u,a);if(d.navigate===!1){let b=d.fetcherKey||Xj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||m,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||m,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,a,s])}function Zj(t,{relative:a}={}){let{basename:s}=p.useContext(Kn),o=p.useContext(Or);qt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Zs(t||".",{relative:a})},d=da();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),x=h.getAll("index");if(x.some(v=>v==="")){h.delete("index"),x.filter(y=>y).forEach(y=>h.append("index",y));let v=h.toString();u.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:pr([s,u.pathname])),Vs(u)}function Jj(t,{relative:a}={}){let s=p.useContext(Sv);qt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Lv("useViewTransitionState"),c=Zs(t,{relative:a});if(!s.isTransitioning)return!1;let u=_r(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=_r(s.nextLocation.pathname,o)||s.nextLocation.pathname;return Oo(c.pathname,d)!=null||Oo(c.pathname,u)!=null}var Go=mv();const eS=pv(Go),tS="modulepreload",nS=function(t){return"/"+t},Wx={},Va=function(a,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),x=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(m=>{if(m=nS(m),m in Wx)return;Wx[m]=!0;const v=m.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":tS,v||(b.as="script"),b.crossOrigin="",b.href=m,x&&b.setAttribute("nonce",x),document.head.appendChild(b),v)return new Promise((S,C)=>{b.addEventListener("load",S),b.addEventListener("error",()=>C(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 a().catch(u)})},rS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function yd(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!rS.test(a)||a==="0.0.0"?null:a}function zv(t){const a=yd(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=yd(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const o=yd(t.pluginVersion);return o?{version:o,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const qx={own:"authoring-project",installed:"available-project",global:"available-personal"},Qd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function aS(t){if(typeof t=="string"){if(Qd.has(t))return t;if(Object.prototype.hasOwnProperty.call(qx,t))return qx[t]}return"authoring-project"}function lS(t){return t.startsWith("available-")?"available":"authoring"}function sS(t){const a=t.indexOf("-");return t.slice(a+1)}const Wn="";class Us extends Error{constructor(a,s){super(a),this.name="ApiError",this.status=s}}async function Ie(t,a){const s=await fetch(`${Wn}${t}`,a);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()}async function Yx(t,a){const s=await fetch(t,a);return s.status>=502&&s.status<=504?(await new Promise(o=>setTimeout(o,250)),fetch(t,a)):s}function Qt(t){return typeof t=="string"&&t.length>0?t:null}function iS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function bd(t){if(!Array.isArray(t))return null;const a=t.filter(s=>typeof s=="string"&&s.length>0);return a.length>0?a:null}function oS(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let o;a.scope==="own"||a.scope==="installed"||a.scope==="global"?o=a.scope:o=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=o==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&Qd.has(a.scopeV2)?a.scopeV2:aS(a.scope),d=lS(u),h=sS(u),x=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let m;a.shadowedBy===null?m=null:typeof a.shadowedBy=="string"&&Qd.has(a.shadowedBy)?m=a.shadowedBy:m=void 0;const v={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:Qt(a.symlinkTarget),installMethod:c,sourcePath:Qt(a.sourcePath),scopeV2:u,group:d,source:h,pluginName:Qt(a.pluginName),pluginNamespace:Qt(a.pluginNamespace),pluginMarketplace:Qt(a.pluginMarketplace),pluginManifestPath:Qt(a.pluginManifestPath),pluginVersion:Qt(a.pluginVersion),precedenceRank:x,shadowedBy:m,description:Qt(a.description),version:Qt(a.version),category:Qt(a.category),author:Qt(a.author),license:Qt(a.license),homepage:Qt(a.homepage),repoUrl:Qt(a.repoUrl),skillPath:Qt(a.skillPath),tags:bd(a.tags),deps:bd(a.deps),mcpDeps:bd(a.mcpDeps),entryPoint:Qt(a.entryPoint),lastModified:Qt(a.lastModified),sizeBytes:iS(a.sizeBytes),sourceAgent:Qt(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const b=a.provenance;(b.promotedFrom==="installed"||b.promotedFrom==="global")&&typeof b.sourcePath=="string"&&typeof b.promotedAt=="number"?v.provenance={promotedFrom:b.promotedFrom,sourcePath:b.sourcePath,promotedAt:b.promotedAt,sourceSkillVersion:typeof b.sourceSkillVersion=="string"?b.sourceSkillVersion:void 0}:v.provenance=null}else a.provenance===null&&(v.provenance=null);typeof a.updateAvailable=="boolean"&&(v.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(v.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(v.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(v.pinnedVersion=a.pinnedVersion);const y=zv({frontmatterVersion:v.version??null,registryCurrentVersion:v.currentVersion??null,pluginVersion:v.pluginVersion??null});return v.resolvedVersion=y.version,v.versionSource=y.versionSource,v}const Se={getConfig(){return Ie("/api/config")},setConfig(t,a){return Ie("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},async getSkills(t){const a=new URLSearchParams;t!=null&&t.scope&&a.set("scope",t.scope),t!=null&&t.agent&&a.set("agent",t.agent);const s=a.toString(),o=await Ie(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(oS):[]},getAgents(){return Ie("/api/agents")},getSkillDetail(t,a){return Ie(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Ie(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Ie(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Ie(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Ie(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Ie(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Wn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,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 Ie(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Ie(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,o){return Ie(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,a,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return Ie(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Ie(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Ie(`/api/skills/${t}/${a}`,{method:"DELETE"})},improveSkill(t,a,s){return Ie(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Ie(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Ie(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Ie(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Ie(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Ie("/api/project-layout")},createSkill(t){return Ie("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Ie("/api/studio/detect-engines")},saveDraft(t){return Ie("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Ie("/api/skill-creator-status")},generateSkill(t){return Ie("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Ie(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Ie(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,o){return Ie(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,a){return Ie(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Ie(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const o=`${Wn}/api/skills/${t}/${a}/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,a){return Ie(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,o){return Ie(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,a){return Ie(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Ie(`/api/credentials/${t}/${a}/params?${o}`)},searchModels(){return Ie("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Ie(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Ie(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,o){return Ie(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const a=`${Wn}/api/skills/batch-update`,s=new EventSource(a);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,a){const s=`${Wn}/api/skills/${t}/${a}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,a,s){let o,c;if(s&&typeof s.aborted=="boolean")o=s;else if(s&&typeof s=="object"){const v=s;o=v.signal,c=v.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Wn}/api/skills/${t}/${a}/update${u}`,h=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:o});let x,m="";if(h.body){const v=h.body.getReader(),y=new TextDecoder;let b=!1,S="";for(;!b;){const k=await v.read();if(b=k.done,k.value){const w=y.decode(k.value,{stream:!b});S+=w,m.length<200&&(m+=w)}}const C=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(C)try{x=JSON.parse(C[1]).version}catch{}m=m.slice(0,200)}else{const v=await h.text();m=v.slice(0,200);const y=v.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{x=JSON.parse(y[1]).version}catch{}}return{ok:h.ok,status:h.status,body:m,version:x}},async rescanSkill(t,a){const s=`${t}/${a}`,o=await fetch(`${Wn}/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(`${Wn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const a=[...t].sort(),s=await Yx(`${Wn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const o=await s.json().catch(()=>null);return Array.isArray(o)?o:o&&typeof o=="object"&&Array.isArray(o.results)?o.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"?c.installed:void 0,latest:typeof c.latest=="string"?c.latest:void 0,name:typeof c.name=="string"?c.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const a=await Yx(`${Wn}/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(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.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,a,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return jd(`/api/skills/${t}/${a}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,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 jd(`/api/skills/${t}/${a}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,a,s){return jd(`/api/skills/${t}/${a}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const a=new URLSearchParams;(t==null?void 0:t.before)!=null&&a.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&a.set("limit",String(t.limit));const s=a.toString();return Ie(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Ie(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Wn}/api/studio/ops/stream`)},gitRemote(){return Ie("/api/git/remote")},gitDiff(){return Ie("/api/git/diff",{method:"POST"})},gitStatus(){return Ie("/api/git/status")},gitCommitMessage(t){return Ie("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return Ie("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function jd(t,a,s){const o=await fetch(`${Wn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let v=`HTTP ${o.status}`,y;try{const S=await o.json();S.error&&(v=S.error),typeof S.code=="string"&&(y=S.code)}catch{}const b=new Us(v,o.status);throw y&&(b.code=y),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",x=null,m=null;for(;;){const{done:v,value:y}=await c.read();if(v)break;d+=u.decode(y,{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 C={};try{C=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const k={type:h,...C};a==null||a(k),k.type==="done"&&(x=k),k.type==="error"&&(m=k)}h=""}}if(m){const v=new Us(m.message,500);throw v.code=m.code,v}if(!x)throw new Us("Transfer stream ended without 'done' event",500);return x}function cS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,o=t.match(s),c=a.match(s);if(!o||!c)return!1;const[,u,d,h]=o.map(Number),[,x,m,v]=c.map(Number);return u!==x?u>x:d!==m?d>m:h>=v}function uS(t,a){if(!a.length)return t;const s=new Map,o=new Map;for(const c of a){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=u.updateAvailable&&!cS(c.version,u.latest),h={...c,updateAvailable:d,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(h.trackedForUpdates=u.trackedForUpdates);const x=zv({frontmatterVersion:h.version??null,registryCurrentVersion:h.currentVersion??null,pluginVersion:h.pluginVersion??null});return h.resolvedVersion=x.version,h.versionSource=x.versionSource,h})}const Mo=new Map,Ua=new Map,Bs=new Map;function An(t){Mo.delete(t),Ua.delete(t);const a=Bs.get(t);if(a)for(const s of a)s()}function Js(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=p.useState(0),[d,h]=p.useState(void 0),[x,m]=p.useState(0),v=p.useRef(!0),y=p.useRef(t);y.current=t;const b=()=>{h(void 0),An(t),m(k=>k+1)};p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),p.useEffect(()=>{if(!c)return;const k=()=>{v.current&&m(w=>w+1)};return Bs.has(t)||Bs.set(t,new Set),Bs.get(t).add(k),()=>{var w;(w=Bs.get(t))==null||w.delete(k)}},[t,c]),p.useEffect(()=>{if(!c)return;const k=Mo.get(t);if(!(!k||Date.now()-k.fetchedAt>o))return;if(Ua.has(t)){const L=Ua.get(t),_=()=>{v.current&&y.current===t&&u(D=>D+1)};L.subscribers.push(_);return}const T={promise:Promise.resolve(),subscribers:[]},N=a().then(L=>{Mo.set(t,{data:L,fetchedAt:Date.now()}),Ua.delete(t),v.current&&y.current===t&&(h(void 0),u(_=>_+1));for(const _ of T.subscribers)_()},L=>{Ua.delete(t);const _=L instanceof Error?L:new Error(String(L));v.current&&y.current===t&&(h(_),u(D=>D+1));for(const D of T.subscribers)D()});T.promise=N,Ua.set(t,T)},[t,a,o,c,x]);const S=Mo.get(t),C=c&&!S&&!d&&Ua.has(t);return{data:S==null?void 0:S.data,loading:C,error:d,revalidate:b}}function dS(t){const[a,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]),a}const fS=500,Zd="vskill.updates.seenLastId";function pS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Zd)}catch{return null}}function Sd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Zd):window.localStorage.setItem(Zd,t)}catch{}}function mS(){let t=new Map;const a=new Set,s=new Set,o=[];let c=pS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>fS){const x=o.shift();x&&s.delete(x)}c=h,Sd(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.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,Sd(null)},mergeBulk(h){if(h.length!==0){for(const x of h)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,Sd(null),u()}}}const Ba=mS(),hS=3e5,xS=500,gS=15e3,vS=6e4,yS=6e4,bS="/api/v1/skills/stream";function Kx(t){const a=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;a.set(o,s)}return a}function Xx(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function jS(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function SS(t){const a=(t==null?void 0:t.intervalMs)??hS,s=(t==null?void 0:t.debounceMs)??xS,o=(t==null?void 0:t.timeoutMs)??gS,c=(t==null?void 0:t.staleAfterMs)??vS,u=(t==null?void 0:t.disconnectFallbackMs)??yS,d=(t==null?void 0:t.streamUrlBase)??bS,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=p.useMemo(()=>{const z=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return z.length===0?"":[...z].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,v]=p.useState([]),[y,b]=p.useState(()=>new Map),[S,C]=p.useState(0),[k,w]=p.useState(!1),[T,N]=p.useState(null),[L,_]=p.useState(null),D=p.useRef(null),F=p.useRef(null),E=p.useRef(null),O=p.useRef(null),M=p.useRef(!0),[U,$]=p.useState(()=>h?"connecting":"fallback"),Y=p.useRef(U);Y.current=U;const X=p.useSyncExternalStore(z=>Ba.subscribe(z),()=>Ba.getSnapshot(),()=>Ba.getSnapshot()),ee=X.size,I=p.useCallback(async()=>{w(!0);const z=new AbortController,W=setTimeout(()=>z.abort(),o);try{const te=await Promise.race([Se.getSkillUpdates(),new Promise((q,oe)=>{z.signal.addEventListener("abort",()=>{oe(new Error("TIMEOUT"))})})]);if(te==="TIMEOUT")throw new Error("TIMEOUT");if(!M.current)return;v(te),b(Kx(te)),C(Xx(te)),F.current=Date.now(),N(F.current),_(null)}catch(te){if(!M.current)return;_(te instanceof Error?te:new Error(String(te)))}finally{clearTimeout(W),M.current&&w(!1)}},[o]),A=p.useCallback(()=>{if(D.current)return D.current;const z=I().finally(()=>{D.current=null});return D.current=z,z},[I]),B=p.useCallback(()=>{E.current==null&&(E.current=setInterval(()=>{A()},a))},[a,A]),V=p.useCallback(()=>{E.current!=null&&(clearInterval(E.current),E.current=null)},[]);p.useEffect(()=>{M.current=!0,(F.current==null||Date.now()-F.current>c)&&A(),(typeof document>"u"||document.visibilityState!=="hidden")&&B();const te=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){V();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&A(),B()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",te),()=>{M.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",te),O.current&&clearTimeout(O.current),V()}},[]);const H=p.useCallback(async z=>{if(z.length!==0)try{const W=await Se.checkSkillUpdates(z);if(!M.current||W.length===0)return;const te=Date.now(),q=W.filter(le=>le.skillId&&le.eventId&&le.version).map(le=>({skillId:le.skillId,version:le.version,eventId:le.eventId,publishedAt:le.publishedAt,diffSummary:le.diffSummary,receivedAt:te}));q.length>0&&Ba.mergeBulk(q);const oe=W.filter(le=>typeof le.trackedForUpdates=="boolean"||typeof le.updateAvailable=="boolean").map(le=>({name:le.name??le.skillId,installed:le.installed??"",latest:le.latest??null,updateAvailable:le.updateAvailable??!1,trackedForUpdates:typeof le.trackedForUpdates=="boolean"?le.trackedForUpdates:void 0}));oe.length>0&&v(le=>{const ve=new Map;for(const Re of le)ve.set(Re.name.split("/").pop()||Re.name,Re);let ce=0;for(const Re of oe){const Ae=Re.name.split("/").pop()||Re.name,se=ve.get(Ae);if(se){const he={...se};se.trackedForUpdates===void 0&&Re.trackedForUpdates!==void 0&&(he.trackedForUpdates=Re.trackedForUpdates),ve.set(Ae,he)}else ve.set(Ae,{name:Re.name,installed:Re.installed??"",latest:Re.latest??null,updateAvailable:Re.updateAvailable??!1,trackedForUpdates:Re.trackedForUpdates}),ce+=1}if(ce===0&&ve.size===le.length)return le;const be=[...ve.values()];return b(Kx(be)),C(Xx(be)),be})}catch{}},[]);p.useEffect(()=>{const z=h||x;if(!z){$("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){$("fallback");return}$("connecting");const W=z.split(","),te=`${d}?skills=${encodeURIComponent(z)}`;let q=null,oe=null,le=null;const ve=()=>{oe==null&&(oe=setTimeout(()=>{oe=null,M.current&&Y.current!=="connected"&&$("fallback")},u))},ce=()=>{oe!=null&&(clearTimeout(oe),oe=null)};ve();const be=1e3,Re=()=>{M.current&&le==null&&(le=setTimeout(()=>{if(le=null,!!M.current&&!(q&&q.readyState!==EventSource.CLOSED)){if(q)try{q.close()}catch{}he()}},be))},Ae=pe=>{if(!M.current)return;let xe;try{xe=JSON.parse(pe.data)}catch{return}if(!jS(xe)||Ba.ingest(xe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Ue=`${xe.skillId} updated to ${xe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Ue,severity:"info",skillId:xe.skillId,version:xe.version,eventId:xe.eventId}}))}},se=()=>{M.current&&(Ba.clearSeen(),H(W))},he=()=>{M.current&&(q=new EventSource(te),q.onopen=()=>{M.current&&(ce(),$("connected"))},q.onerror=()=>{M.current&&(ve(),q&&q.readyState===EventSource.CLOSED&&Re())},q.onmessage=Ae,q.addEventListener("gone",se))};return he(),()=>{if(ce(),le!=null&&(clearTimeout(le),le=null),q){try{q.removeEventListener("gone",se)}catch{}try{q.close()}catch{}}}},[h,x,d,u,H]),p.useEffect(()=>{if(!x)return;const z=x.split(",");H(z)},[x,H]);const re=p.useCallback(z=>{Ba.dismiss(z)},[]);return{updates:m,updatesMap:y,updateCount:S,isRefreshing:k,lastFetchAt:T,error:L,refresh:A,updatesById:X,pushUpdateCount:ee,status:U,dismiss:re}}function kS(t){const a=[];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),a.push(u)}return a}const wS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function CS(t,a){switch(a.type){case"SELECT_SKILL":return{...t,selectedSkill:a.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:a.mode,selectedSkill:a.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:a.query};case"SET_SKILLS":return{...t,skills:a.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:a.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:a.loading};case"SET_MOBILE":return{...t,isMobile:a.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:a.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:a.skill,revealSkillId:`${a.skill.plugin}/${a.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Dv=p.createContext(null),_v=Dv;function nr(){const t=p.useContext(_v);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function ES({children:t}){const[a,s]=p.useReducer(CS,wS),o=dS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=p.useState(()=>{try{const H=window.localStorage.getItem("vskill.studio.prefs");if(!H)return null;const re=JSON.parse(H);return typeof re.activeAgent=="string"?re.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function H(re){if(!(re instanceof CustomEvent))return;const z=re.detail;z!=null&&z.agentId&&(u(z.agentId),h(!0))}return window.addEventListener("studio:agent-changed",H),()=>window.removeEventListener("studio:agent-changed",H)},[]),p.useEffect(()=>{if(d)return;let H=!1;return Se.getAgents().then(re=>{if(H)return;const z=(re==null?void 0:re.suggested)??"claude-code";u(W=>W??z),h(!0)}).catch(()=>{H||(u(re=>re??"claude-code"),h(!0))}),()=>{H=!0}},[d]);const x=p.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const H={agent:c};Se.getSkills(H).then(re=>{s({type:"SET_SKILLS",skills:re});const W=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(W){const[,te,q]=W,oe=re.find(le=>le.plugin===te&&le.skill===q);oe&&s({type:"SELECT_SKILL",skill:{plugin:te,skill:q,origin:oe.origin}})}}).catch(re=>s({type:"SET_SKILLS_ERROR",error:re.message}))},[c,d]);p.useEffect(()=>{x()},[x]);const m=p.useCallback(H=>{s({type:"SELECT_SKILL",skill:H}),window.location.hash=`/skills/${H.plugin}/${H.skill}`},[]),v=p.useRef(a.skills);p.useEffect(()=>{v.current=a.skills},[a.skills]);const y=p.useCallback((H,re)=>{const z=v.current,W=H?z.find(oe=>oe.plugin===H&&oe.skill===re):z.find(oe=>oe.skill===re&&oe.source!=="plugin");if(!H&&!W){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${re}" not yet in state — skipping reveal`);return}const te=(W==null?void 0:W.plugin)??H,q=(W==null?void 0:W.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:te,skill:re,origin:q}}),window.location.hash=`/skills/${te}/${re}`},[]),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)},[]),C=p.useCallback(H=>{s({type:"SET_MODE",mode:H})},[]),k=p.useCallback(H=>{s({type:"SET_SEARCH",query:H})},[]),w=p.useCallback(H=>{s({type:"SET_MOBILE_VIEW",view:H})},[]),T=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),N=p.useRef(new Map),L=p.useRef(""),_=p.useRef(!1),[D,F]=p.useState(""),E=p.useMemo(()=>a.skills.map(H=>`${H.plugin}/${H.skill}`),[a.skills]),O=p.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),M=SS({skillIds:O,trackingSkillIds:E}),U=p.useRef("");p.useEffect(()=>{const H=a.skills.filter(q=>q.origin==="installed");if(H.length===0){F(""),U.current="";return}const re=new Map;for(const q of M.updates)re.set(q.name.split("/").pop()||q.name,q);const z=H.map(q=>{const oe=re.get(q.skill),le=q.currentVersion??(oe==null?void 0:oe.installed)??q.version??q.pluginVersion??"1.0.0";return{plugin:q.plugin,skill:q.skill,name:(oe==null?void 0:oe.name)??q.skill,currentVersion:le}}),W=z.map(q=>`${q.plugin}/${q.skill}@${q.currentVersion}#${q.name}`).sort().join("|");if(W===U.current)return;U.current=W;let te=!1;return Se.resolveInstalledSkillIds(z).then(q=>{if(te)return;const ve=[...kS(q).flatMap(ce=>[ce.uuid,ce.slug].filter(Boolean))].sort().join(",");ve!==L.current&&(L.current=ve,N.current=new Map(q.map(ce=>[`${ce.plugin}/${ce.skill}`,{uuid:ce.uuid,slug:ce.slug}])),F(ve))}).catch(q=>{if(te||(U.current=""),!_.current){_.current=!0;const oe=q instanceof Error?q.message:String(q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",oe)}}),()=>{te=!0}},[a.skills,M.updates]);const $=p.useMemo(()=>{const H=a.skills.map(re=>{if(!re.updateAvailable&&re.latestVersion===void 0&&re.trackedForUpdates===void 0)return re;const z={...re};return delete z.updateAvailable,delete z.currentVersion,delete z.latestVersion,delete z.trackedForUpdates,z});return uS(H,M.updates)},[a.skills,M.updates]),Y=p.useMemo(()=>{const H={source:0,installed:0};for(const re of $)re.updateAvailable&&(H[re.origin]+=1);return H},[$]),X=p.useMemo(()=>({...a,skills:$}),[a,$]),ee=M.updateCount,I=M.refresh,A=M.isRefreshing,B=p.useCallback((H,re)=>{I(),x(),An(`versions/${H}/${re}`),M.dismiss(`${H}/${re}`)},[I,x,M]),V=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:C,setSearch:k,setMobileView:w,refreshSkills:x,updateCount:ee,dismissUpdateNotification:T,updates:M.updates,outdatedByOrigin:Y,isRefreshingUpdates:A,refreshUpdates:I,revealSkill:y,clearReveal:b,updatesById:M.updatesById,pushUpdateCount:M.pushUpdateCount,updateStreamStatus:M.status,dismissPushUpdate:M.dismiss,activeAgent:c,onSkillUpdated:B}),[X,m,S,C,k,w,x,ee,T,M.updates,Y,A,I,y,b,M.updatesById,M.pushUpdateCount,M.status,M.dismiss,c,B]);return r.jsx(_v.Provider,{value:V,children:t})}const NS={config:null,loading:!0};function TS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Ov=p.createContext(null);function Fa(){const t=p.useContext(Ov);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function RS({children:t}){const[a,s]=p.useReducer(TS,NS),o=p.useCallback(()=>{Se.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{o()},[o]);const c=p.useCallback(async(d,h)=>{const x=await Se.setConfig(d,h);return s({type:"SET_CONFIG",config:x}),x},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:o}),[a,c,o]);return r.jsx(Ov.Provider,{value:u,children:t})}function AS({topRail:t,sidebar:a,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:x=!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)"},v={display:"grid",gridTemplateColumns:x?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:m,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:v,children:[!x&&r.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:a}),!x&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),r.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 Qx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],MS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},LS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},zS={"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"},DS={"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 _S(t,a){var h,x;const s=MS[t.id]??null,o=LS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=o?!!((x=a==null?void 0:a.binaries)!=null&&x[o]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:DS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:OS(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:zS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function OS(t,a){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]??a}function BS(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Qx){const c=a.get(o);c&&s.push(c)}for(const o of t)Qx.includes(o.id)||s.push(o);return s}function IS(t){const[a,s]=p.useState(null),[o,c]=p.useState("loading"),[u,d]=p.useState(null),[h,x]=p.useState(null),m=p.useRef(null),v=p.useRef(0),y=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{y.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 N=await fetch("/api/config");if(!N.ok)throw new Error(`/api/config returned ${N.status}`);const L=await N.json(),_=BS((L.providers||[]).map(D=>_S(D,L.detection)));s({agents:_,activeAgent:L.provider??null,activeModel:L.model??null}),c("ready"),d(null)}catch(N){c("error"),d(N.message)}},[]);p.useEffect(()=>{S()},[S]);const C=p.useCallback(async()=>{var L;const N=Date.now();if(!(N-v.current<5*6e4))try{const _=await fetch("/api/openrouter/models");if(!_.ok){_.status!==400&&x(`OpenRouter catalog fetch failed (${_.status})`);return}const D=await _.json();v.current=N,x(null),s(O=>{if(!O)return O;const M=O.agents.map(U=>{if(U.id!=="openrouter")return U;const $=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:$,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:M}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((L=y.current)==null||L.call(y,"openrouter",F*1e3))}catch(_){x(`OpenRouter catalog unreachable: ${_.message}`)}},[]),k=p.useCallback(N=>{m.current=N,N==="openrouter"&&C()},[C]),w=p.useCallback(()=>{v.current=0,S()},[S]),T=p.useCallback(async(N,L)=>{var F,E;let _;try{_=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:N,model:L})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${N}: ${O.message}`);return}if(_.ok){s(O=>O&&{...O,activeAgent:N,activeModel:L});return}let D=`Failed to set ${N} (${_.status})`;try{const O=await _.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(E=b.current)==null||E.call(b,D)},[]);return{status:o,catalog:a,error:u,openRouterError:h,focusAgent:k,refresh:w,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:T}}function kd({variant:t,label:a,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 r.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":a,...c?{title:c}:{},children:a})}function Jd({unlocked:t=!1,size:a=10}){return t?r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const US={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,a)=>`${t} of ${a}`},HS={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"},$S={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"},PS={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"},VS={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"},FS={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"},GS={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."},WS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},qS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},YS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},KS={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"},XS={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)."}},QS={subscriptionBilling:"· subscription",free:"· free"},ZS={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`},JS={providersLabel:"Providers",providerSummary:(t,a)=>`${t}/${a} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},e2={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}`},t2={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.`},n2={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"},r2={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."},a2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},l2={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:US,shell:HS,detail:$S,actions:PS,palette:VS,shortcuts:FS,toasts:GS,connection:WS,forms:qS,errors:YS,picker:KS,providers:XS,models:QS,settings:ZS,statusBar:JS,scopePicker:e2,scopeSection:t2,claudeCodeLabel:n2,setupDrawer:r2,setupProviders:l2,scopeLabels:a2},s2=new Set(["claude-cli","claude-code"]);function Zx(t){return s2.has(t)}const Jx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function i2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>Jx.has(x.id)),h=t.filter(x=>!Jx.has(x.id));return r.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(x=>r.jsx(eg,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:o,onSelect:c,onOpenSettings:u},x.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(x=>r.jsx(eg,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:o,onSelect:c,onOpenSettings:u},x.id))]})}function eg({agent:t,isActive:a,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},x={"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=Zx(t.id),v={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:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(v.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"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:v,children:[t.wrapperFolder&&r.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&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Zx(t.id)&&r.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})]}),r.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?r.jsx(Jd,{unlocked:!0,size:10}):r.jsx(Jd,{size:10})}),a&&r.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"&&r.jsx(kd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(kd,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(kd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function o2(t,a,s,o){const d=t>=80,h=p.useRef(null),[x,m]=p.useState(0),v=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),C=Math.ceil(s/a)+8,k=Math.min(t,S+C);return{visibleStart:S,visibleEnd:k}},[d,x,a,s,t,4]);return{visibleStart:y,visibleEnd:b,totalHeight:t*a,offsetTop:y*a,virtualised:d,containerProps:{onScroll:v,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Bv=44,c2=352,u2=60,tg=480;function d2(t){var u,d;const a=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 a?`${a} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} 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 a?`${a} ctx · ${c}`:c}function f2(t,a){if(!a)return t;const s=a.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 p2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>x(u),u2);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 r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:tg,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),r.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 v=p.useMemo(()=>f2(t.models,h),[t.models,h]),y=o2(v.length,Bv,c2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:tg,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.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"}})}),v.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),r.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})]}):v.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):r.jsx("div",{...y.containerProps,children:r.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:y.virtualised?`translateY(${y.offsetTop}px)`:void 0},children:v.slice(y.visibleStart,y.visibleEnd).map((b,S)=>{const C=y.visibleStart+S;return r.jsx(h2,{model:b,isActive:b.id===a,isFocused:s===C,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function m2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function h2({model:t,isActive:a,isFocused:s,onSelect:o,resolvedModel:c}){const u=d2(t),d=m2(t.id,c,t.resolvedId),h=d!==null,x=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",m=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Bv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,borderLeft:m,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.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&&r.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 ng={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function x2(){const[t,a]=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 v=await m.json();a({...ng,...v}),u(null)}catch(m){u(m.message),a(ng)}finally{o(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,v)=>{const y=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:v})});if(!y.ok){const S=await y.json().catch(()=>({error:y.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${y.status}`)}const b=await y.json();return await d(),b},[d]),x=p.useCallback(async m=>{const v=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!v.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${v.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:x,refresh:d}}function g2({onMigrated:t,fetchImpl:a}){const[s,o]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const v=await c("/api/settings/migration-status");if(!v.ok){o({kind:"hidden"});return}const y=await v.json();y.pending&&(((m=y.darwinKeys)==null?void 0:m.length)??0)>0?o({kind:"visible",darwinKeys:y.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 v=await m.json().catch(()=>({migrated:[]}));t==null||t(v.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 r.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:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:wd,children:"Retry"})]});const x=s.kind==="working";return r.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:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.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."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:x,"data-testid":"migration-migrate",style:{...wd,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...wd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const wd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},v2=[{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 y2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Iv({open:t,onClose:a,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=x2(),x=p.useRef(null),m=p.useRef(null),[v,y]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const C=await fetch("/api/settings/storage-path");if(!C.ok)throw new Error(`GET /api/settings/storage-path returned ${C.status}`);const k=await C.json();S||y(k.path??null)}catch{S||y(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,C=setTimeout(()=>{var T;const k=s?`input[data-provider="${s}"]`:"input[data-provider]",w=(T=x.current)==null?void 0:T.querySelector(k);w==null||w.focus()},0);return()=>{var k;clearTimeout(C),(k=S==null?void 0:S.focus)==null||k.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=C=>{if(C.key==="Escape"){C.preventDefault(),a();return}if(C.key==="Tab"&&x.current){const k=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(k.length===0)return;const w=k[0],T=k[k.length-1];C.shiftKey&&document.activeElement===w?(C.preventDefault(),T.focus()):!C.shiftKey&&document.activeElement===T&&(C.preventDefault(),w.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,C;if(v)try{await((C=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:C.call(S,v)),o==null||o(ne.settings.pathCopied)}catch{}},[o,v]);return t?r.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&&a()},children:r.jsxs("div",{ref:x,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:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),r.jsx(g2,{onMigrated:()=>{h()}}),r.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}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),v2.map(S=>r.jsx(b2,{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 C=>{const k=await u(S.id,C);return o==null||o(ne.settings.keySaved(S.name)),k},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?m:void 0},S.id))]}),r.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:[r.jsx("span",{style:{flex:1},children:v?ne.settings.storagePath(v):ne.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Ha,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,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 b2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:x}){const[m,v]=p.useState(""),[y,b]=p.useState(!1),[S,C]=p.useState(!1),[k,w]=p.useState(!1),[T,N]=p.useState(null),L=m.trim(),_=L.length===0,D=L.length>0&&!L.startsWith(o),F=p.useCallback(async()=>{if(_)return;C(!0);const M=L;v("");try{const U=await d(M);U.warning?N(U.warning):N(null)}finally{C(!1)}},[_,d,L]),E=p.useCallback(async()=>{var M;try{if(!((M=navigator.clipboard)!=null&&M.readText))return;const U=await navigator.clipboard.readText();v(U)}catch{}},[]),O=p.useCallback(async()=>{w(!1),await h()},[h]);return r.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:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:x,type:y?"text":"password",value:m,onChange:M=>{v(M.target.value),N(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"}}),r.jsx("button",{type:"button",onClick:()=>b(!y),style:Ha,children:y?ne.settings.hide:ne.settings.show}),r.jsx("button",{type:"button",onClick:E,style:Ha,children:ne.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:rg,children:ne.settings.prefixWarn(a)}),T&&r.jsx("div",{role:"status",style:rg,children:T}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:F,disabled:_||S,"data-testid":`save-${t}`,style:{...Ha,background:_?"var(--surface-2)":"var(--accent, var(--color-accent))",color:_?"var(--text-muted)":"white",cursor:_?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Ha,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>w(!1),style:Ha,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>w(!0),"data-testid":`remove-${t}`,style:{...Ha,color:"var(--text-muted)"},children:ne.settings.remove})}),r.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(y2(u.updatedAt)):ne.settings.noKey})]})]})}const Ha={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},rg={fontSize:11,color:"var(--warning, var(--text-muted))"};function j2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function S2({onToast:t}){const{status:a,catalog:s,focusAgent:o,setActive:c}=IS({onStaleCatalog:(U,$)=>{const Y=Math.round($/6e4);t==null||t(`Using cached ${U} catalog (${Y} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,v]=p.useState(),[y,b]=p.useState(null),[S,C]=p.useState("agents"),[k,w]=p.useState(0),T=p.useRef(null);p.useRef(null),p.useEffect(()=>{var U;s&&!y&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,y]);const N=(s==null?void 0:s.agents)??[],L=p.useMemo(()=>N.find(U=>U.id===y)??N[0],[N,y]);p.useEffect(()=>{w(0)},[y]);const _=p.useCallback(()=>{var U;d(!0),C("agents"),b((s==null?void 0:s.activeAgent)??((U=N[0])==null?void 0:U.id)??null),w(0)},[s,N]),D=p.useCallback(()=>{var U;d(!1),(U=T.current)==null||U.focus()},[]);p.useEffect(()=>{const U=$=>{var X;if(!($.metaKey||$.ctrlKey)||$.key.toLowerCase()!=="k")return;const Y=(X=document.activeElement)==null?void 0:X.tagName;Y==="INPUT"||Y==="TEXTAREA"||($.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),p.useEffect(()=>{if(!u)return;const U=Y=>{if(Y.key==="Escape"){Y.preventDefault(),D();return}if(Y.key==="ArrowDown"){Y.preventDefault(),$(1);return}if(Y.key==="ArrowUp"){Y.preventDefault(),$(-1);return}if(Y.key==="ArrowRight"&&S==="agents"){Y.preventDefault(),C("models"),w(X=>{const ee=((L==null?void 0:L.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,ee)))});return}if(Y.key==="ArrowLeft"&&S==="models"){Y.preventDefault(),C("agents");return}if(Y.key==="Enter"){if(Y.preventDefault(),S==="agents"&&L)C("models"),w(0);else if(S==="models"&&L){const X=Math.max(0,Math.min(L.models.length-1,k)),ee=L.models[X];ee&&(c(L.id,ee.id),D())}return}};function $(Y){if(S==="agents"){const X=N.findIndex(I=>I.id===y),ee=N[Math.max(0,Math.min(N.length-1,X+Y))];ee&&(b(ee.id),o(ee.id));return}if(S==="models"&&L){const X=L.models.length;if(X===0)return;w(ee=>{const I=ee+Y;return Math.max(0,Math.min(X-1,I))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,N,y,L,k,D,o,c]);const F=p.useCallback(U=>{v(U==="anthropic"||U==="openrouter"?U:void 0),x(!0),d(!1)},[]),E=N.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=E==null?void 0:E.models.find(U=>U.id===(s==null?void 0:s.activeModel)),M=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const U=(E==null?void 0:E.displayName)??"Agent",$=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${$}`},[a,s,E,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:T,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():_(),"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:[r.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}}),r.jsx("span",{children:M})]}),u&&typeof document<"u"&&Go.createPortal(r.jsxs(k2,{reducedMotion:j2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(i2,{agents:N,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),C("models")},onOpenSettings:F}),L&&r.jsx(p2,{agent:L,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?k:-1,onSelect:U=>{c(L.id,U),D()},onOpenSettings:F})]}),r.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:[r.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}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),r.jsx(Iv,{open:h,onClose:()=>x(!1),initialProvider:m,onToast:t})]})}function k2({children:t,reducedMotion:a,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]),r.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:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
63
|
-
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
64
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
65
|
-
}`})]})}function ag(){typeof window>"u"||(window.location.hash="#/")}function w2({onHome:t}){const[a,s]=p.useState(!1),[o,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),ag(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),ag(),t==null||t())};return r.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:a?"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:[r.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:r.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:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const lg=p.memo(function({message:a,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return r.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:a})});function C2({toast:t,onDismiss:a}){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 r.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:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(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}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function E2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:o}){return r.jsxs(r.Fragment,{children:[r.jsx(lg,{politeness:"polite",message:s}),r.jsx(lg,{politeness:"assertive",message:o}),t.length>0&&r.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=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(C2,{toast:c,onDismiss:a})},c.id))})]})}const Uv=p.createContext(null);function Wo(){const t=p.useContext(Uv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function N2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[o,c]=p.useState([]),[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(new Map),v=p.useCallback(w=>{const T=m.current.get(w);T&&(clearTimeout(T),m.current.delete(w)),c(N=>N.filter(L=>L.id!==w))},[]),y=p.useCallback((w,T)=>{if(T<=0)return;const N=setTimeout(()=>{v(w)},T);m.current.set(w,N)},[v]),b=p.useCallback(w=>{const T=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,N={id:T,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(L=>[...L,N]),N.severity==="error"?x(N.message):d(N.message),y(T,N.durationMs),T},[s,y]),S=p.useCallback(()=>{for(const w of m.current.values())clearTimeout(w);m.current.clear(),c([])},[]);p.useEffect(()=>{function w(T){T.key==="Escape"&&c(N=>{if(N.length===0)return N;const L=N.slice(0,a),_=L[L.length-1],D=m.current.get(_.id);return D&&(clearTimeout(D),m.current.delete(_.id)),N.filter(F=>F.id!==_.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]),p.useEffect(()=>()=>{for(const w of m.current.values())clearTimeout(w);m.current.clear()},[]);const C=o.slice(0,a),k=p.useMemo(()=>({toast:b,dismiss:v,clear:S}),[b,v,S]);return r.jsxs(Uv.Provider,{value:k,children:[t,r.jsx(E2,{toasts:C,onDismiss:v,liveMessage:u,liveAssertiveMessage:h})]})}const T2="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",R2=p.lazy(()=>Va(()=>import("./UpdateDropdown-Borwxx95.js"),__vite__mapDeps([0,1])));function A2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,revealSkill:u,skills:d,updatesById:h,activeAgent:x}=nr(),{toast:m}=Wo(),v=p.useMemo(()=>{if(!h||h.size===0)return;const N=new Map;for(const[L,_]of h)_.diffSummary&&N.set(L,_.diffSummary);return N.size>0?N:void 0},[h]),[y,b]=p.useState(!1),S=p.useRef(null),C=p.useCallback(()=>b(!1),[]),k=t>0?"var(--text-primary)":"var(--text-secondary)",w=t>9?"9+":String(t),T=t===0?"No updates available":`${t} updates available, open summary`;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:S,type:"button","data-testid":"update-bell","aria-label":T,"aria-haspopup":"dialog","aria-expanded":y,onClick:()=>b(N=>!N),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:k,cursor:"pointer"},children:[r.jsx("img",{src:T2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&r.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:w})]}),y&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(R2,{updates:a,isRefreshing:s,diffSummariesById:v,onRefresh:()=>o(),onSelectSkill:N=>{const L=N.localSkill??N.name.split("/").pop()??"",_=N.localPlugin??"";if(u)u(_,L);else{const F=N.name.split("/"),E=F.length>=2?F[F.length-2]:F[0];c({plugin:E,skill:L,origin:"installed"})}if(!(d??[]).some(F=>F.skill===L&&(_===""||F.plugin===_))){const F=N.installLocations??[];if(F.length>0){const E=x?F.filter(M=>M.agent===x):[],O=x?F.filter(M=>M.agent!==x):F;if(E.length>0&&O.length>0){const M=O.length>=2?`Also installed under ${O.length} other locations.`:`Also installed under ${O[0].agentLabel}.`;m({severity:"info",message:M})}else{const M=F[0].agentLabel;m({severity:"info",message:`Skill installed under ${M} — switch to ${M} to view details.`})}}}C()},onViewAll:()=>{window.location.hash="#/updates",C()},onClose:C,anchorRef:S})})]})}function sg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function M2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(w2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.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})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(ig,{segment:"origin",onClick:()=>sg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:h}),r.jsx(og,{}),r.jsx(ig,{segment:"plugin",onClick:()=>sg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(og,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[d,u&&r.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:[r.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:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(S2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(A2,{})}),r.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:r.jsx("span",{children:"⌘K"})})]})]})}function ig({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,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 og(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const qo="vskill-theme";function Hv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function L2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function z2(t){try{const a=t.getItem(qo);return Hv(a)}catch{return"auto"}}function D2(t,a){try{t.setItem(qo,a)}catch{}}function _2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function O2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const $v=p.createContext(null);function B2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,x]=p.useState(()=>c?z2(c):"auto"),[m,v]=p.useState(()=>O2(u)),y=p.useMemo(()=>L2(h,m),[h,m]);p.useEffect(()=>{d&&_2(d,h,y)},[d,h,y]),p.useEffect(()=>{if(!u)return;const C=u("(prefers-color-scheme: dark)"),k=T=>v(T.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",k),()=>C.removeEventListener("change",k);const w=C;return w.addListener(k),()=>w.removeListener(k)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const C=k=>{k.key===qo&&x(Hv(k.newValue))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),p.useEffect(()=>{if(!u||!d)return;let C;try{C=u("(prefers-contrast: more)")}catch{return}const k=N=>{N?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};k(C.matches);const w=N=>k(N.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",w),()=>C.removeEventListener("change",w);const T=C;return T.addListener(w),()=>T.removeListener(w)},[u,d]);const b=p.useCallback(C=>{x(C),c&&D2(c,C)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:y,setTheme:b}),[h,y,b]);return r.jsx($v.Provider,{value:S,children:o})}function Pv(){const t=p.useContext($v);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const cg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function I2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of cg){const c=a.get(o);c&&s.push(c)}for(const o of t)cg.includes(o.id)||s.push(o);return s}function U2(t){const[a,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]),a}function H2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=I2(t),c=U2(640),[u,d]=p.useState(!1),h=p.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=o.filter(m=>m.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(x,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(x,o.length)}),u&&r.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=>r.jsx(ug,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(x=>r.jsx(ug,{p:x,onClick:h,compact:!0},x.id))})}function ug({p:t,onClick:a,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 r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(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:[r.jsx(Jd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function $2(){try{return typeof localStorage>"u"?null:localStorage.getItem(qo)}catch{return null}}function P2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:x,setTheme:m}=Pv(),y=$2()==="auto",b=V2(h,x,y),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.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:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(dg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(F2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(dg,{}),r.jsx(H2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.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:[r.jsx(G2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function V2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function F2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function dg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function G2({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.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"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ef=new Set;function Vv(){for(const t of ef)t()}const W2=5,q2=1e3,Y2=6e4;function K2(){const[t,a]=p.useState(void 0),[s,o]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),x=p.useRef(null),m=p.useRef(!0),v=p.useRef(0),[y,b]=p.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},C=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),k=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;C();const T=new AbortController;h.current=T;try{const N=await fetch("/api/plugins",{signal:T.signal});if(!m.current)return;const L=await N.json();if(!m.current)return;d.current=0,a(L.plugins??[]),u(!1),o(!1),x.current=setTimeout(()=>{m.current&&b(_=>_+1)},Y2)}catch(N){if(!m.current||N instanceof DOMException&&N.name==="AbortError")return;if(d.current+=1,u(!1),d.current>W2){o(!0);return}const L=q2*Math.pow(2,d.current-1);x.current=setTimeout(()=>{m.current&&b(_=>_+1)},L)}},[C]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),C()}),[C]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),k())},[y,k]),p.useEffect(()=>{const T=()=>{document.visibilityState==="hidden"?(S(),C()):(d.current=0,o(!1),b(N=>N+1))};return document.addEventListener("visibilitychange",T),()=>{document.removeEventListener("visibilitychange",T)}},[C]);const w=p.useCallback(()=>{d.current=0,o(!1),S(),v.current+=1,b(T=>T+1)},[]);return p.useEffect(()=>(ef.add(w),()=>{ef.delete(w)}),[w]),{plugins:t,paused:s,loading:c,retry:w}}const Yo=0,fa=1,Ul=2,Fv=4;function fg(t){return()=>t}function X2(t){t()}function Gv(t,a){return s=>t(a(s))}function pg(t,a){return()=>t(a)}function Q2(t,a){return s=>t(a,s)}function kf(t){return t!==void 0}function Z2(...t){return()=>{t.map(X2)}}function Hl(){}function Ko(t,a){return a(t),t}function J2(t,a){return a(t)}function St(...t){return t}function rt(t,a){return t(fa,a)}function Fe(t,a){t(Yo,a)}function wf(t){t(Ul)}function Ct(t){return t(Fv)}function Te(t,a){return rt(t,Q2(a,Yo))}function Jn(t,a){const s=t(fa,o=>{s(),a(o)});return s}function mg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Wv(t,a){return t===a}function jt(t=Wv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function Oe(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Gv(a,t)}function dr(t){return a=>()=>{a(t)}}function me(t,...a){const s=ek(...a);return((o,c)=>{switch(o){case Ul:wf(t);return;case fa:return rt(t,s(c))}})}function fr(t,a){return s=>o=>{s(a=t(a,o))}}function Pa(t){return a=>s=>{t>0?t--:a(s)}}function Dr(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Ge(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,x=>{const m=s;s|=h,a[d]=x,m!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function ek(...t){return a=>t.reduceRight(J2,a)}function tk(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case fa:return u?s===u?void 0:(o(),s=u,a=rt(t,u),a):(o(),Hl);case Ul:o(),s=null;return}}}function ge(t){let a=t;const s=Ze();return((o,c)=>{switch(o){case Yo:a=c;break;case fa:{c(a);break}case Fv:return a}return s(o,c)})}function ln(t,a){return Ko(ge(a),s=>Te(t,s))}function Ze(){const t=[];return((a,s)=>{switch(a){case Yo:t.slice().forEach(o=>{o(s)});return;case Ul:t.splice(0,t.length);return;case fa:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Mn(t){return Ko(Ze(),a=>Te(t,a))}function tt(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:nk(),singleton:s}}const nk=()=>Symbol();function rk(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(x=>s(x)));return d&&a.set(u,h),h};return s(t)}function $t(...t){const a=Ze(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,x=>{s[d]=x,o|=h,o===c&&Fe(a,s)})}),function(u,d){switch(u){case Ul:{wf(a);return}case fa:return o===c&&d(s),rt(a,d)}}}function _e(t,a=Wv){return me(t,jt(a))}function tf(...t){return function(a,s){switch(a){case Ul:return;case fa:return Z2(...t.map(o=>rt(o,s)))}}}const Wt={DEBUG:0,INFO:1,WARN:2,ERROR:3},ak={[Wt.DEBUG]:"debug",[Wt.ERROR]:"error",[Wt.INFO]:"log",[Wt.WARN]:"warn"},lk=()=>typeof globalThis>"u"?window:globalThis,pa=tt(()=>{const t=ge(Wt.ERROR);return{log:ge((a,s,o=Wt.INFO)=>{const c=lk().VIRTUOSO_LOG_LEVEL??Ct(t);o>=c&&console[ak[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ga(t,a,s){return Cf(t,a,s).callbackRef}function Cf(t,a,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function sk(t,a,s,o,c,u,d,h,x){const m=Ne.useCallback(v=>{const y=ik(v.children,a,h?"offsetWidth":"offsetHeight",c);let b=v.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let C;S&&(C=b.ownerDocument.defaultView);const k=d?h?d.scrollLeft:d.scrollTop:S?h?C.scrollX||C.document.documentElement.scrollLeft:C.scrollY||C.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,w=d?h?d.scrollWidth:d.scrollHeight:S?h?C.document.documentElement.scrollWidth:C.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,T=d?h?d.offsetWidth:d.offsetHeight:S?h?C.innerWidth:C.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:w,scrollTop:Math.max(k,0),viewportHeight:T}),u==null||u(h?hg("column-gap",getComputedStyle(v).columnGap,c):hg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,o,h]);return Cf(m,s,x)}function ik(t,a,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 x=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),v=a(h,s);if(v===0&&o("Zero-sized element, this should not happen",{child:h},Wt.ERROR),v===m)continue;const y=u[u.length-1];u.length===0||y.size!==v||y.endIndex!==x-1?u.push({endIndex:x,size:v,startIndex:x}):u[u.length-1].endIndex++}return u}function hg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Wt.WARN),a==="normal"?0:parseInt(a??"0",10)}function qv(t,a,s){const o=Ne.useRef(null),c=Ne.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const m=x.getBoundingClientRect(),v=m.width;let y,b;if(a){const S=a.getBoundingClientRect(),C=m.top-S.top;b=S.height-Math.max(0,C),y=C+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),y=m.top+S.scrollY}o.current={listHeight:m.height,offsetTop:y,visibleHeight:b,visibleWidth:v},t(o.current)},[t,a]),{callbackRef:u,ref:d}=Cf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const v=new ResizeObserver(()=>{requestAnimationFrame(h)});return v.observe(a),()=>{a.removeEventListener("scroll",h),v.unobserve(a)}}const x=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",h),x==null||x.addEventListener("resize",h),()=>{x==null||x.removeEventListener("scroll",h),x==null||x.removeEventListener("resize",h)}},[h,a,d]),u}const fn=tt(()=>{const t=Ze(),a=Ze(),s=ge(0),o=Ze(),c=ge(0),u=Ze(),d=Ze(),h=ge(0),x=ge(0),m=ge(0),v=ge(0),y=Ze(),b=Ze(),S=ge(!1),C=ge(!1),k=ge(!1);return Te(me(t,ke(({scrollTop:w})=>w)),a),Te(me(t,ke(({scrollHeight:w})=>w)),d),Te(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:x,footerHeight:v,headerHeight:h,horizontalDirection:C,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:y,scrollTop:a,skipAnimationFrameInResizeObserver:k,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Fs={lvl:0};function Yv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:x}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=x}return u.push({end:1/0,start:o,value:c}),u}function mt(t){return t===Fs}function Gs(t,a){if(!mt(t))return a===t.k?t.v:a<t.k?Gs(t.l,a):Gs(t.r,a)}function tr(t,a,s="k"){if(mt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=tr(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return tr(t.l,a,s)}function Rn(t,a,s){return mt(t)?Qv(a,s,1):a===t.k?Gt(t,{k:a,v:s}):a<t.k?xg(Gt(t,{l:Rn(t.l,a,s)})):xg(Gt(t,{r:Rn(t.r,a,s)}))}function zl(){return Fs}function Dl(t,a,s){if(mt(t))return[];const o=tr(t,a)[0];return ok(rf(t,o,s))}function nf(t,a){if(mt(t))return Fs;const{k:s,l:o,r:c}=t;if(a===s){if(mt(o))return c;if(mt(c))return o;const[u,d]=Xv(o);return Lo(Gt(t,{k:u,l:Kv(o),v:d}))}return a<s?Lo(Gt(t,{l:nf(o,a)})):Lo(Gt(t,{r:nf(c,a)}))}function $a(t){return mt(t)?[]:[...$a(t.l),{k:t.k,v:t.v},...$a(t.r)]}function rf(t,a,s){if(mt(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(rf(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(rf(u,a,s))),h}function Lo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(Cd(a))return Zv(Gt(t,{lvl:s-1}));if(!mt(a)&&!mt(a.r))return Gt(a.r,{l:Gt(a,{r:a.r.l}),lvl:s,r:Gt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Cd(t))return af(Gt(t,{lvl:s-1}));if(!mt(o)&&!mt(o.l)){const c=o.l,u=Cd(c)?o.lvl-1:o.lvl;return Gt(c,{l:Gt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:af(Gt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Gt(t,a){return Qv(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function Kv(t){return mt(t.r)?t.l:Lo(Gt(t,{r:Kv(t.r)}))}function Cd(t){return mt(t)||t.lvl>t.r.lvl}function Xv(t){return mt(t.r)?[t.k,t.v]:Xv(t.r)}function Qv(t,a,s,o=Fs,c=Fs){return{k:t,l:o,lvl:s,r:c,v:a}}function xg(t){return af(Zv(t))}function Zv(t){const{l:a}=t;return!mt(a)&&a.lvl===t.lvl?Gt(a,{r:Gt(t,{l:a.r})}):t}function af(t){const{lvl:a,r:s}=t;return!mt(s)&&!mt(s.r)&&s.lvl===a&&s.r.lvl===a?Gt(s,{l:Gt(t,{r:s.l}),lvl:a+1}):t}function ok(t){return Yv(t,({k:a,v:s})=>({index:a,value:s}))}function Jv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Ws(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Ef=tt(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function ey(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);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 ${a}`)}function ck(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ua(t,a){return Math.round(t.getBoundingClientRect()[a])}function Xo(t){return!mt(t.groupOffsetTree)}function Nf({index:t},a){return a===t?0:a<t?-1:1}function uk(){return{groupIndices:[],groupOffsetTree:zl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:zl()}}function dk(t,a){let s=mt(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),mt(t)){t=Rn(t,0,u);continue}const h=Dl(t,d-1,c+1);if(h.some(vk(o)))continue;let x=!1,m=!1;for(const{end:v,start:y,value:b}of h)x?(c>=y||u===b)&&(t=nf(t,y)):(m=b!==u,x=!0),v>c&&c>=y&&b!==u&&(t=Rn(t,c+1,b));m&&(t=Rn(t,d,u))}return[t,s]}function fk(t){return typeof t.groupIndex<"u"}function pk({offset:t},a){return a===t?0:a<t?-1:1}function qs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=ey(a,t,Nf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function ty(t,a){if(!Xo(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function ny(t,a,s){if(fk(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=ty(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function mk(t,a,s,o=0){return o>0&&(a=Math.max(a,ey(t,o,Nf).offset)),Yv(ck(t,a,s,pk),gk)}function hk(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Wt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&mt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((C,k)=>Rn(Rn(C,k,b),k+1,S),d)}else[d,h]=dk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:m,lastSize:v,offsetTree:y}=lf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>Rn(b,S,qs(S,y,c)),zl()),lastIndex:x,lastOffset:m,lastSize:v,offsetTree:y,sizeTree:d}}function xk(t){return $a(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function gg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function lf(t,a,s,o){let c=t,u=0,d=0,h=0,x=0;if(a!==0){x=Bo(c,a-1,Nf),h=c[x].offset;const m=tr(s,a-1);u=m[0],d=m[1],c.length&&c[x].size===tr(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:m,value:v}of Dl(s,a,1/0)){const y=m-u,b=y*d+h+y*o;c.push({index:m,offset:b,size:v}),u=m,h=b,d=v}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function gk(t){return{index:t.index,value:t}}function vk(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const yk={offsetHeight:"height",offsetWidth:"width"},mr=tt(([{log:t},{recalcInProgress:a}])=>{const s=Ze(),o=Ze(),c=ln(o,0),u=Ze(),d=Ze(),h=ge(0),x=ge([]),m=ge(void 0),v=ge(void 0),y=ge(void 0),b=ge(void 0),S=ge((E,O)=>ua(E,yk[O])),C=ge(void 0),k=ge(0),w=uk(),T=ln(me(s,Ge(x,t,k),fr(hk,w),jt()),w),N=ln(me(x,jt(),fr((E,O)=>({current:O,prev:E.current}),{current:[],prev:[]}),ke(({prev:E})=>E)),[]);Te(me(x,Oe(E=>E.length>0),Ge(T,k),ke(([E,O,M])=>{const U=E.reduce(($,Y,X)=>Rn($,Y,qs(Y,O.offsetTree,M)||X),zl());return{...O,groupIndices:E,groupOffsetTree:U}})),T),Te(me(o,Ge(T),Oe(([E,{lastIndex:O}])=>E<O),ke(([E,{lastIndex:O,lastSize:M}])=>[{endIndex:O,size:M,startIndex:E}])),s),Te(m,v);const L=ln(me(m,ke(E=>E===void 0)),!0);Te(me(v,Oe(E=>E!==void 0&&mt(Ct(T).sizeTree)),ke(E=>{const O=Ct(y),M=Ct(x).length>0;return O!==void 0&&O!==0?M?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:E,startIndex:1}]:[]:[{endIndex:0,size:E,startIndex:0}]})),s),Te(me(b,Oe(E=>E!==void 0&&E.length>0&&mt(Ct(T).sizeTree)),ke(E=>{const O=[];let M=E[0],U=0;for(let $=1;$<E.length;$++){const Y=E[$];Y!==M&&(O.push({endIndex:$-1,size:M,startIndex:U}),M=Y,U=$)}return O.push({endIndex:E.length-1,size:M,startIndex:U}),O})),s),Te(me(x,Ge(y,v),Oe(([,E,O])=>E!==void 0&&O!==void 0),ke(([E,O,M])=>{const U=[];for(let $=0;$<E.length;$++){const Y=E[$],X=E[$+1];U.push({startIndex:Y,endIndex:Y,size:O}),X!==void 0&&U.push({startIndex:Y+1,endIndex:X-1,size:M})}return U})),s);const _=Mn(me(s,Ge(T),fr(({sizes:E},[O,M])=>({changed:M!==E,sizes:M}),{changed:!1,sizes:w}),ke(E=>E.changed)));rt(me(h,fr((E,O)=>({diff:E.prev-O,prev:O}),{diff:0,prev:0}),ke(E=>E.diff)),E=>{const{groupIndices:O}=Ct(T);if(E>0)Fe(a,!0),Fe(u,E+gg(E,O));else if(E<0){const M=Ct(N);M.length>0&&(E-=gg(-E,M)),Fe(d,E)}}),rt(me(h,Ge(t)),([E,O])=>{E<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},Wt.ERROR)});const D=Mn(u);Te(me(u,Ge(T),ke(([E,O])=>{const M=O.groupIndices.length>0,U=[],$=O.lastSize;if(M){const Y=Gs(O.sizeTree,0);let X=0,ee=0;for(;X<E;){const A=O.groupIndices[ee],B=O.groupIndices.length===ee+1?1/0:O.groupIndices[ee+1]-A-1;U.push({endIndex:A,size:Y,startIndex:A}),U.push({endIndex:A+1+B-1,size:$,startIndex:A+1}),ee++,X+=B+1}const I=$a(O.sizeTree);return X!==E&&I.shift(),I.reduce((A,{k:B,v:V})=>{let H=A.ranges;return A.prevSize!==0&&(H=[...A.ranges,{endIndex:B+E-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:B+E,prevSize:V,ranges:H}},{prevIndex:E,prevSize:0,ranges:U}).ranges}return $a(O.sizeTree).reduce((Y,{k:X,v:ee})=>({prevIndex:X+E,prevSize:ee,ranges:[...Y.ranges,{endIndex:X+E-1,size:Y.prevSize,startIndex:Y.prevIndex}]}),{prevIndex:0,prevSize:$,ranges:[]}).ranges})),s);const F=Mn(me(d,Ge(T,k),ke(([E,{offsetTree:O},M])=>{const U=-E;return qs(U,O,M)})));return Te(me(d,Ge(T,k),ke(([E,O,M])=>{if(O.groupIndices.length>0){if(mt(O.sizeTree))return O;let $=zl();const Y=Ct(N);let X=0,ee=0,I=0;for(;X<-E;){I=Y[ee];const A=Y[ee+1]-I-1;ee++,X+=A+1}if($=$a(O.sizeTree).reduce((A,{k:B,v:V})=>Rn(A,Math.max(0,B+E),V),$),X!==-E){const A=Gs(O.sizeTree,I);$=Rn($,0,A);const B=tr(O.sizeTree,-E+1)[1];$=Rn($,1,B)}return{...O,sizeTree:$,...lf(O.offsetTree,0,$,M)}}const U=$a(O.sizeTree).reduce(($,{k:Y,v:X})=>Rn($,Math.max(0,Y+E),X),zl());return{...O,sizeTree:U,...lf(O.offsetTree,0,U,M)}})),T),{beforeUnshiftWith:D,data:C,defaultItemSize:v,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:y,gap:k,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:_,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:T,statefulTotalCount:c,totalCount:o,trackItemSizes:L,unshiftWith:u}},St(pa,Ef),{singleton:!0});function bk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const ry=tt(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Ze(),d=Ze(),h=Mn(me(u,ke(bk)));return Te(me(h,ke(x=>x.totalCount)),s),Te(me(h,ke(x=>x.groupIndices)),t),Te(me($t(c,a,o),Oe(([x,m])=>Xo(m)),ke(([x,m,v])=>tr(m.groupOffsetTree,Math.max(x-v,0),"v")[0]),jt(),ke(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},St(mr,fn)),ma=tt(([{log:t}])=>{const a=ge(!1),s=Mn(me(a,Oe(o=>o),jt()));return rt(a,o=>{o&&Ct(t)("props updated",{},Wt.DEBUG)}),{didMount:s,propsReady:a}},St(pa),{singleton:!0}),jk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ay(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!jk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ei=tt(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:x,scrollTo:m,smoothScrollTargetReached:v,viewportHeight:y},{log:b}])=>{const S=Ze(),C=Ze(),k=ge(0);let w=null,T=null,N=null;function L(){w!==null&&(w(),w=null),N!==null&&(N(),N=null),T&&(clearTimeout(T),T=null),Fe(x,!1)}return Te(me(S,Ge(s,y,o,k,h,d,b),Ge(t,u,c),ke(([[_,D,F,E,O,M,U,$],Y,X,ee])=>{const I=ay(_),{align:A,behavior:B,offset:V}=I,H=E-1,re=ny(I,D,H);let z=qs(re,D.offsetTree,Y)+M;A==="end"?(z+=X+tr(D.sizeTree,re)[1]-F+ee,re===H&&(z+=U)):A==="center"?z+=(X+tr(D.sizeTree,re)[1]-F+ee)/2:z-=O,V!==void 0&&V!==0&&(z+=V);const W=te=>{L(),te?($("retrying to scroll to",{location:_},Wt.DEBUG),Fe(S,_)):(Fe(C,!0),$("list did not change, scroll successful",{},Wt.DEBUG))};if(L(),B==="smooth"){let te=!1;N=rt(a,q=>{te=te||q}),w=Jn(v,()=>{W(te)})}else w=Jn(me(a,Sk(150)),W);return T=setTimeout(()=>{L()},1200),Fe(x,!0),$("scrolling from index to",{behavior:B,index:re,top:z},Wt.DEBUG),{behavior:B,top:z}})),m),{scrollTargetReached:C,scrollToIndex:S,topListHeight:k}},St(mr,fn,pa),{singleton:!0});function Sk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function Tf(t,a){t===0?a():requestAnimationFrame(()=>{Tf(t-1,a)})}function Rf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ti=tt(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),x=ge(0),m=ge(!0);return Te(me(d,Ge(x),Oe(([v,y])=>y!==0),dr(!1)),h),Te(me(d,Ge(x),Oe(([v,y])=>y!==0),dr(!1)),m),rt(me($t(a,d),Ge(h,s,t,m),Oe(([[,v],y,{sizeTree:b},S,C])=>v&&(!mt(b)||kf(S))&&!y&&!C),Ge(x)),([,v])=>{Jn(c,()=>{Fe(m,!0)}),Tf(4,()=>{Jn(o,()=>{Fe(h,!0)}),Fe(u,v)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:x,scrolledToInitialItem:h}},St(mr,fn,ei,ma),{singleton:!0});function ly(t,a){return Math.abs(t-a)<1.01}const Ys="up",Hs="down",kk="none",wk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ck=0,ni=tt(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),x=Ze(),m=Ze(),v=ge(4),y=ge(Ck),b=ln(me(tf(me(_e(c),Pa(1),dr(!0)),me(_e(c),Pa(1),dr(!1),mg(100))),jt()),!1),S=ln(me(tf(me(s,dr(!0)),me(s,dr(!1),mg(200))),jt()),!1);Te(me($t(_e(c),_e(y)),ke(([N,L])=>N<=L),jt()),h),Te(me(h,Dr(50)),m);const C=Mn(me($t(o,_e(u),_e(a),_e(t),_e(v)),fr((N,[{scrollHeight:L,scrollTop:_},D,F,E,O])=>{const M=_+D-L>-O,U={scrollHeight:L,scrollTop:_,viewportHeight:D};if(M){let Y,X;return _>N.state.scrollTop?(Y="SCROLLED_DOWN",X=N.state.scrollTop-_):(Y="SIZE_DECREASED",X=N.state.scrollTop-_||N.scrollTopDelta),{atBottom:!0,atBottomBecause:Y,scrollTopDelta:X,state:U}}let $;return U.scrollHeight>N.state.scrollHeight?$="SIZE_INCREASED":D<N.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":_<N.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:U}},wk),jt((N,L)=>N!==void 0&&N.atBottom===L.atBottom))),k=ln(me(o,fr((N,{scrollHeight:L,scrollTop:_,viewportHeight:D})=>{if(!ly(N.scrollHeight,L)){const F=L-(_+D)<1;return N.scrollTop!==_&&F?{changed:!0,jump:N.scrollTop-_,scrollHeight:L,scrollTop:_}:{changed:!0,jump:0,scrollHeight:L,scrollTop:_}}return{changed:!1,jump:0,scrollHeight:L,scrollTop:_}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Oe(N=>N.changed),ke(N=>N.jump)),0);Te(me(C,ke(N=>N.atBottom)),d),Te(me(d,Dr(50)),x);const w=ge(Hs);Te(me(o,ke(({scrollTop:N})=>N),jt(),fr((N,L)=>Ct(S)?{direction:N.direction,prevScrollTop:L}:{direction:L<N.prevScrollTop?Ys:Hs,prevScrollTop:L},{direction:Hs,prevScrollTop:0}),ke(N=>N.direction)),w),Te(me(o,Dr(50),dr(kk)),w);const T=ge(0);return Te(me(b,Oe(N=>!N),dr(0)),T),Te(me(c,Dr(100),Ge(b),Oe(([N,L])=>L),fr(([N,L],[_])=>[L,_],[0,0]),ke(([N,L])=>L-N)),T),{atBottomState:C,atBottomStateChange:x,atBottomThreshold:v,atTopStateChange:m,atTopThreshold:y,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:k,scrollDirection:w,scrollVelocity:T}},St(fn)),Ks="top",Xs="bottom",vg="none";function yg(t,a,s){return typeof t=="number"?s===Ys&&a===Ks||s===Hs&&a===Xs?t:0:s===Ys?a===Ks?t.main:t.reverse:a===Xs?t.main:t.reverse}function bg(t,a){return typeof t=="number"?t:t[a]??0}const Af=tt(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Ze(),d=ge(0),h=ge(0),x=ge(0),m=ln(me($t(_e(o),_e(c),_e(s),_e(u,Ws),_e(x),_e(d),_e(a),_e(t),_e(h)),ke(([v,y,b,[S,C],k,w,T,N,L])=>{const _=v-N,D=w+T,F=Math.max(b-_,0);let E=vg;const O=bg(L,Ks),M=bg(L,Xs);return S-=N,S+=b+T,C+=b+T,C-=N,S>v+D-O&&(E=Ys),C<v-F+y+M&&(E=Hs),E!==vg?[Math.max(_-b-yg(k,Ks,E)-O,0),_-F-T+y+yg(k,Xs,E)+M]:null}),Oe(v=>v!==null),jt(Ws)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:x,topListHeight:d,visibleRange:m}},St(fn),{singleton:!0});function Ek(t,a,s){if(Xo(a)){const o=ty(t,a);return[{index:tr(a.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 Ed={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function zo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:x}=c;let m=0,v=0;if(t.length>0){m=t[0].offset;const k=t[t.length-1];v=k.offset+k.size}const y=s-d,b=h+y*x+(y-1)*o,S=m,C=b-v;return{bottom:v,firstItemIndex:u,items:jg(t,c,u),offsetBottom:C,offsetTop:m,top:S,topItems:jg(a,c,u),topListHeight:a.reduce((k,w)=>w.size+k,0),totalCount:s}}function sy(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const v of s.groupIndices){if(v-d>=t)break;d++}const h=t+d,x=Rf(a,h),m=Array.from({length:h}).map((v,y)=>({data:u[y+x],index:y+x,offset:0,size:0}));return zo(m,[],h,c,s,o)}function jg(t,a,s){if(t.length===0)return[];if(!Xo(a))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=Dl(a.groupOffsetTree,o,c);let h,x=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),x=a.groupIndices.indexOf(h.start));let v;m.index===h.start?v={index:x,type:"group"}:v={groupIndex:x,index:m.index-(x+1)+s},u.push({...v,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function Sg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Wa=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:x},{initialTopMostItemIndex:m,scrolledToInitialItem:v},{topListHeight:y},b,{didMount:S},{recalcInProgress:C}])=>{const k=ge([]),w=ge(0),T=Ze(),N=ge(0);Te(u.topItemsIndexes,k);const L=ln(me($t(S,C,_e(x,Ws),_e(c),_e(o),_e(m),v,_e(k),_e(a),_e(s),_e(N),t),Oe(([E,O,,M,,,,,,,,U])=>{const $=U!==void 0&&U.length!==M;return E&&!O&&!$}),ke(([,,[E,O],M,U,$,Y,X,ee,I,A,B])=>{var be,Re;const V=U,{offsetTree:H,sizeTree:re}=V,z=Ct(w);if(M===0)return{...Ed,totalCount:M};if(E===0&&O===0)return z===0?{...Ed,totalCount:M}:sy(z,$,U,ee,I,B||[]);if(mt(re))return z>0?null:zo(Ek(Rf($,M),V,B),[],M,I,V,ee);const W=[];if(X.length>0){const Ae=X[0],se=X[X.length-1];let he=0;for(const pe of Dl(re,Ae,se)){const xe=pe.value,je=Math.max(pe.start,Ae),Be=Math.min(pe.end,se);for(let Ue=je;Ue<=Be;Ue++)W.push({data:B==null?void 0:B[Ue],index:Ue,offset:he,size:xe}),he+=xe}}if(!Y)return zo([],W,M,I,V,ee);const te=X.length>0?X[X.length-1]+1:0,q=mk(H,E,O,te);if(q.length===0)return null;const oe=M-1,le=Ko([],Ae=>{for(const se of q){const he=se.value;let pe=he.offset,xe=se.start;const je=he.size;if(he.offset<E){xe+=Math.floor((E-he.offset+I)/(je+I));const Ue=xe-se.start;pe+=Ue*je+Ue*I}xe<te&&(pe+=(te-xe)*je,xe=te);const Be=Math.min(se.end,oe);for(let Ue=xe;Ue<=Be&&!(pe>=O);Ue++)Ae.push({data:B==null?void 0:B[Ue],index:Ue,offset:pe,size:je}),pe+=je+I}}),ve=Sg(A,Ks),ce=Sg(A,Xs);if(le.length>0&&(ve>0||ce>0)){const Ae=le[0],se=le[le.length-1];if(ve>0&&Ae.index>te){const he=Math.min(ve,Ae.index-te),pe=[];let xe=Ae.offset;for(let je=Ae.index-1;je>=Ae.index-he;je--){const Be=((be=Dl(re,je,je)[0])==null?void 0:be.value)??Ae.size;xe-=Be+I,pe.unshift({data:B==null?void 0:B[je],index:je,offset:xe,size:Be})}le.unshift(...pe)}if(ce>0&&se.index<oe){const he=Math.min(ce,oe-se.index);let pe=se.offset+se.size+I;for(let xe=se.index+1;xe<=se.index+he;xe++){const je=((Re=Dl(re,xe,xe)[0])==null?void 0:Re.value)??se.size;le.push({data:B==null?void 0:B[xe],index:xe,offset:pe,size:je}),pe+=je+I}}}return zo(le,W,M,I,V,ee)}),Oe(E=>E!==null),jt()),Ed);Te(me(t,Oe(kf),ke(E=>E==null?void 0:E.length)),c),Te(me(L,ke(E=>E.topListHeight)),y),Te(y,h),Te(me(L,ke(E=>[E.top,E.bottom])),d),Te(me(L,ke(E=>E.items)),T);const _=Mn(me(L,Oe(({items:E})=>E.length>0),Ge(c,t),Oe(([{items:E},O])=>E[E.length-1].originalIndex===O-1),ke(([,E,O])=>[E-1,O]),jt(Ws),ke(([E])=>E))),D=Mn(me(L,Dr(200),Oe(({items:E,topItems:O})=>E.length>0&&E[0].originalIndex===O.length),ke(({items:E})=>E[0].index),jt())),F=Mn(me(L,Oe(({items:E})=>E.length>0),ke(({items:E})=>{let O=0,M=E.length-1;for(;E[O].type==="group"&&O<M;)O++;for(;E[M].type==="group"&&M>O;)M--;return{endIndex:E[M].index,startIndex:E[O].index}}),jt(Jv)));return{endReached:_,initialItemCount:w,itemsRendered:T,listState:L,minOverscanItemCount:N,rangeChanged:F,startReached:D,topItemsIndexes:k,...b}},St(mr,ry,Af,ti,ei,ni,ma,Ef),{singleton:!0}),iy=tt(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Ze(),d=ln(me($t(s,t,o,a,c),ke(([h,x,m,v,y])=>h+x+m+v+y.offsetBottom+y.bottom)),0);return Te(_e(d),u),{totalListHeight:d,totalListHeightChanged:u}},St(fn,Wa),{singleton:!0}),Nk=tt(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),o=ln(me($t(s,t,a),Oe(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Dr(0),jt()),0);return{alignToBottom:s,paddingTopAddition:o}},St(fn,iy),{singleton:!0}),oy=tt(()=>({context:ge(null)})),Tk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,cy=tt(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:x},{scrollToIndex:m}])=>{const v=Ze();return Te(me(v,Ge(a,x,s,u,c,o,h),Ge(t),ke(([[y,b,S,C,k,w,T,N],L])=>{const{calculateViewLocation:_=Tk,done:D,...F}=y,E=ny(y,b,C-1),O=qs(E,b.offsetTree,L)+k+w,M=O+tr(b.sizeTree,E)[1],U=N+w,$=N+S-T,Y=_({itemBottom:M,itemTop:O,locationParams:F,viewportBottom:$,viewportTop:U});return Y!==null?D&&Jn(me(d,Oe(X=>!X),Pa(Ct(d)?1:2)),D):D==null||D(),Y}),Oe(y=>y!==null)),m),{scrollIntoView:v}},St(mr,fn,ei,Wa,pa),{singleton:!0});function kg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Rk=(t,a)=>typeof t=="function"?kg(t(a)):a&&kg(t),Ak=tt(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:x,propsReady:m},{log:v},{scrollingInProgress:y},{context:b},{scrollIntoView:S}])=>{const C=ge(!1),k=Ze();let w=null;function T(D){Fe(d,{align:"end",behavior:D,index:"LAST"})}rt(me($t(me(_e(a),Pa(1)),x),Ge(_e(C),u,h,y),ke(([[D,F],E,O,M,U])=>{let $=F&&M,Y="auto";return $&&(Y=Rk(E,O||U),$=$&&Y!==!1),{followOutputBehavior:Y,shouldFollow:$,totalCount:D}}),Oe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{w!==null&&(w(),w=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(v)("following output to ",{totalCount:F},Wt.DEBUG),T(D)}):w=Jn(t,()=>{Ct(v)("following output to ",{totalCount:F},Wt.DEBUG),T(D),w=null})});function N(D){const F=Jn(c,E=>{D&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(Ct(v)("scrolling to bottom due to increased size",{},Wt.DEBUG),T("auto"))});setTimeout(F,100)}rt(me($t(_e(C),a,m),Oe(([D,,F])=>D!==!1&&F),fr(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),Oe(({refreshed:D})=>D),Ge(C,a)),([,D])=>{Ct(h)&&N(D!==!1)}),rt(k,()=>{N(Ct(C)!==!1)}),rt($t(_e(C),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&T("auto")});const L=ge(null),_=Ze();return Te(tf(me(_e(o),ke(D=>(D==null?void 0:D.length)??0)),me(_e(a))),_),rt(me($t(me(_,Pa(1)),x),Ge(_e(L),h,y,b),ke(([[D,F],E,O,M,U])=>F&&O&&(E==null?void 0:E({context:U,totalCount:D,scrollingInProgress:M}))),Oe(D=>!!D),Dr(0)),D=>{w!==null&&(w(),w=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(v)("scrolling into view",{}),Fe(S,D)}):w=Jn(t,()=>{Ct(v)("scrolling into view",{}),Fe(S,D),w=null})}),{autoscrollToBottom:k,followOutput:C,scrollIntoViewOnChange:L}},St(mr,ni,ei,ti,ma,pa,fn,oy,cy)),Mk=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(me(h,Ge(u),Oe(([,x])=>x!==0),Ge(c,o,a,s,t),ke(([[,x],m,v,y,b,S=[]])=>sy(x,m,v,y,b,S))),d),{}),St(mr,ti,Wa,ma),{singleton:!0}),Lk=tt(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ge(0);return rt(me(t,Ge(o),Oe(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Jn(me(s,Pa(1),Oe(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:o}},St(ma,fn,Wa),{singleton:!0}),uy=tt(([{scrollVelocity:t}])=>{const a=ge(!1),s=Ze(),o=ge(!1);return Te(me(t,Ge(o,a,s),Oe(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:x,exit:m}=u;if(d){if(m(c,h))return!1}else if(x(c,h))return!0;return d}),jt()),a),rt(me($t(a,t,s),Ge(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},St(ni),{singleton:!0}),Mf=tt(([{scrollContainerState:t,scrollTo:a}])=>{const s=Ze(),o=Ze(),c=Ze(),u=ge(!1),d=ge(void 0);return Te(me($t(s,o),ke(([{scrollTop:h,viewportHeight:x},{offsetTop:m,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,h-m),viewportHeight:x}))),t),Te(me(a,Ge(o),ke(([h,{offsetTop:x}])=>({...h,top:h.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},St(fn)),zk=tt(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:x}])=>{const m=Ze(),v=ge(void 0),y=ge(null),b=ge(null);return Te(h,y),Te(x,b),rt(me(m,Ge(a,o,d,y,b,s)),([S,C,k,w,T,N,L])=>{const _=xk(C.sizeTree);w&&T!==null&&N!==null&&(k=T.scrollTop-N.offsetTop),k-=L,S({ranges:_,scrollTop:k})}),Te(me(v,Oe(kf),ke(Dk)),c),Te(me(u,Ge(v),Oe(([,S])=>S!==void 0),jt(),ke(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:v}},St(mr,fn,ti,ma,Mf));function Dk(t){return{align:"start",index:0,offset:t.scrollTop}}const _k=tt(([{topItemsIndexes:t}])=>{const a=ge(0);return Te(me(a,Oe(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},St(Wa));function dy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const Ok=dy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Bk=tt(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:x},{beforeUnshiftWith:m,gap:v,shiftWithOffset:y,sizes:b},{log:S},{recalcInProgress:C}])=>{const k=Mn(me(x,Ge(d),fr(([,T,N,L],[{bottom:_,items:D,offsetBottom:F,totalCount:E},O])=>{const M=_+F;let U=0;return N===E&&T.length>0&&D.length>0&&(D[0].originalIndex===0&&T[0].originalIndex===0||(U=M-L,U!==0&&(U+=O))),[U,D,E,M]},[0,[],0,0]),Oe(([T])=>T!==0),Ge(o,h,s,c,S,C),Oe(([,T,N,L,,,_])=>!_&&!L&&T!==0&&N===Ys),ke(([[T],,,,,N])=>(N("Upward scrolling compensation",{amount:T},Wt.DEBUG),T))));function w(T){T>0?(Fe(a,{behavior:"auto",top:-T}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-T}))}return rt(me(k,Ge(t,u)),([T,N,L])=>{L&&Ok()?Fe(t,N-T):w(-T)}),rt(me($t(ln(u,!1),t,C),Oe(([T,N,L])=>!T&&!L&&N!==0),ke(([T,N])=>N),Dr(1)),w),Te(me(y,ke(T=>({top:-T}))),a),rt(me(m,Ge(b,v),ke(([T,{groupIndices:N,lastSize:L,sizeTree:_},D])=>{function F($){return $*(L+D)}if(N.length===0)return F(T);let E=0;const O=Gs(_,0);let M=0,U=0;for(;M<T;){M++,E+=O;let $=N.length===U+1?1/0:N[U+1]-N[U]-1;M+$>T&&(E-=O,$=T-M+1),M+=$,E+=F($),U++}return E})),T=>{Fe(t,T),requestAnimationFrame(()=>{Fe(a,{top:T}),requestAnimationFrame(()=>{Fe(t,0),Fe(C,!1)})})}),{deviation:t}},St(fn,ni,Wa,mr,pa,Ef)),Ik=tt(([t,a,s,o,c,u,d,h,x,m,v])=>({...t,...a,...s,...o,...c,...u,...d,...h,...x,...m,...v}),St(Af,Mk,ma,uy,iy,Lk,Nk,Mf,cy,pa,oy)),fy=tt(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:x,sizeRanges:m,sizes:v,statefulTotalCount:y,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:C,initialTopMostItemIndex:k,scrolledToInitialItem:w},T,N,L,_,{scrollToIndex:D},F,{topItemCount:E},{groupCounts:O},M])=>{const{listState:U,minOverscanItemCount:$,topItemsIndexes:Y,rangeChanged:X,...ee}=_;return Te(X,M.scrollSeekRangeChanged),Te(me(M.windowViewportRect,ke(I=>I.visibleHeight)),T.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:C,initialTopMostItemIndex:k,scrolledToInitialItem:w,sizeRanges:m,topItemCount:E,topItemsIndexes:Y,totalCount:b,...L,groupIndices:d,itemSize:x,listState:U,minOverscanItemCount:$,scrollToIndex:D,statefulTotalCount:y,trackItemSizes:S,rangeChanged:X,...ee,...M,...T,sizes:v,...N}},St(mr,ti,fn,zk,Ak,Wa,ei,Bk,_k,ry,Ik));function Uk(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function py(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Ne.createContext({});function x(w,T){w.propsReady!==void 0&&Fe(w.propsReady,!1);for(const N of o){const L=w[a.required[N]];Fe(L,T[N])}for(const N of c)if(N in T){const L=w[a.optional[N]];Fe(L,T[N])}w.propsReady!==void 0&&Fe(w.propsReady,!0)}function m(w){return u.reduce((T,N)=>(T[N]=L=>{const _=w[a.methods[N]];Fe(_,L)},T),{})}function v(w){return d.reduce((T,N)=>(T[N]=tk(w[a.events[N]]),T),{})}const y=Ne.forwardRef(function(w,T){const{children:N,...L}=w,[_]=Ne.useState(()=>Ko(rk(t),E=>{x(E,L)})),[D]=Ne.useState(pg(v,_));yo(()=>{for(const E of d)E in L&&rt(D[E],L[E]);return()=>{Object.values(D).map(wf)}},[L,D,_]),yo(()=>{x(_,L)}),Ne.useImperativeHandle(T,fg(m(_)));const F=s;return r.jsx(h.Provider,{value:_,children:s!==void 0?r.jsx(F,{...Uk([...o,...c,...d],L),children:N}):N})}),b=w=>{const T=Ne.useContext(h);return Ne.useCallback(N=>{Fe(T[w],N)},[T,w])},S=w=>{const T=Ne.useContext(h)[w],N=Ne.useCallback(L=>rt(T,L),[T]);return Ne.useSyncExternalStore(N,()=>Ct(T),()=>Ct(T))},C=w=>{const T=Ne.useContext(h)[w],[N,L]=Ne.useState(pg(Ct,T));return yo(()=>rt(T,_=>{_!==N&&L(fg(_))}),[T,N]),N},k=parseInt(Ne.version)>=18?S:C;return{Component:y,useEmitter:(w,T)=>{const N=Ne.useContext(h)[w];yo(()=>rt(N,T),[T,N])},useEmitterValue:k,usePublisher:b}}const my=Ne.createContext(void 0),hy=Ne.createContext(void 0),Nd="-webkit-sticky",wg="sticky",Lf=dy(()=>{if(typeof document>"u")return wg;const t=document.createElement("div");return t.style.position=Nd,t.style.position===Nd?Nd:wg}),xy=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Td(t){return"self"in t}function Hk(t){return"body"in t}function gy(t,a,s,o=Hl,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),x=Ne.useRef(null),m=Ne.useCallback(b=>{let S,C,k;const w=b.target;if(Hk(w)||Td(w)){const N=Td(w)?w:w.defaultView;k=u===!0?N.scrollX:N.scrollY,S=u===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,C=u===!0?N.innerWidth:N.innerHeight}else k=u===!0?w.scrollLeft:w.scrollTop,S=u===!0?w.scrollWidth:w.scrollHeight,C=u===!0?w.offsetWidth:w.offsetHeight;const T=()=>{t({scrollHeight:S,scrollTop:Math.max(k,0),viewportHeight:C})};b.suppressFlushSync===!0?T():eS.flushSync(T),h.current!==null&&(k===h.current||k<=0||k===S-C)&&(h.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,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 v(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const C=b.behavior==="smooth";let k,w,T;Td(S)?(w=Math.max(ua(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),k=u===!0?S.innerWidth:S.innerHeight,T=u===!0?window.scrollX:window.scrollY):(w=S[u===!0?"scrollWidth":"scrollHeight"],k=ua(S,u===!0?"width":"height"),T=S[u===!0?"scrollLeft":"scrollTop"]);const N=w-k;if(b.top=Math.ceil(Math.max(Math.min(N,b.top),0)),ly(k,w)||b.top===T){t({scrollHeight:w,scrollTop:T,viewportHeight:k}),C&&a(!0);return}C?(h.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function y(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:y,scrollerRef:d,scrollToCallback:v}}function zf(t){return t}const $k=tt(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),o=ge(zf),c=ge("div"),u=ge(Hl),d=(h,x=null)=>ln(me(s,ke(m=>m[h]),jt()),x);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,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")}}),Pk=tt(([t,a])=>({...t,...a}),St(fy,$k)),Vk=({height:t})=>r.jsx("div",{style:{height:t}}),Fk={overflowAnchor:"none",position:Lf(),zIndex:1},vy={overflowAnchor:"none"},Gk={...vy,display:"inline-block",height:"100%"},Cg=Ne.memo(function({showTopList:t=!1}){const a=$e("listState"),s=qn("sizeRanges"),o=$e("useWindowScroll"),c=$e("customScrollParent"),u=qn("windowScrollContainerState"),d=qn("scrollContainerState"),h=c||o?u:d,x=$e("itemContent"),m=$e("context"),v=$e("groupContent"),y=$e("trackItemSizes"),b=$e("itemSize"),S=$e("log"),C=qn("gap"),k=$e("horizontalDirection"),{callbackRef:w}=sk(s,b,y,t?Hl:h,S,C,c,k,$e("skipAnimationFrameInResizeObserver")),[T,N]=Ne.useState(0);Df("deviation",ee=>{T!==ee&&N(ee)});const L=$e("EmptyPlaceholder"),_=$e("ScrollSeekPlaceholder")??Vk,D=$e("ListComponent"),F=$e("ItemComponent"),E=$e("GroupComponent"),O=$e("computeItemKey"),M=$e("isSeeking"),U=$e("groupIndices").length>0,$=$e("alignToBottom"),Y=$e("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...k?{display:"inline-block",height:"100%",marginLeft:T!==0?T:$?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:T!==0?T:$?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...Y?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&L!==null&&L!==void 0?r.jsx(L,{...an(L,m)}):r.jsx(D,{...an(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:X,children:(t?a.topItems:a.items).map(ee=>{const I=ee.originalIndex,A=O(I+a.firstItemIndex,ee.data,m);return M?p.createElement(_,{...an(_,m),height:ee.size,index:ee.index,key:A,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?p.createElement(E,{...an(E,m),"data-index":I,"data-item-index":ee.index,"data-known-size":ee.size,key:A,style:Fk},v(ee.index,m)):p.createElement(F,{...an(F,m),...Kk(F,ee.data),"data-index":I,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:A,style:k?Gk:vy},U?x(ee.index,ee.groupIndex,ee.data,m):x(ee.index,ee.data,m))})})}),Wk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},qk={outline:"none",overflowX:"auto",position:"relative"},Qo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Yk={position:Lf(),top:0,width:"100%",zIndex:1};function an(t,a){if(typeof t!="string")return{context:a}}function Kk(t,a){return{item:typeof t=="string"?void 0:a}}const Xk=Ne.memo(function(){const t=$e("HeaderComponent"),a=qn("headerHeight"),s=$e("HeaderFooterTag"),o=Ga(Ne.useMemo(()=>u=>{a(ua(u,"height"))},[a]),!0,$e("skipAnimationFrameInResizeObserver")),c=$e("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...an(t,c)})}):null}),Qk=Ne.memo(function(){const t=$e("FooterComponent"),a=qn("footerHeight"),s=$e("HeaderFooterTag"),o=Ga(Ne.useMemo(()=>u=>{a(ua(u,"height"))},[a]),!0,$e("skipAnimationFrameInResizeObserver")),c=$e("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...an(t,c)})}):null});function yy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),v=a("scrollerRef"),y=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:C}=gy(h,m,x,v,void 0,y);return t("scrollTo",C),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...y?qk:Wk,...c},tabIndex:0,...d,...an(x,u),children:o})})}function by({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),v=a("totalListHeight"),y=a("deviation"),b=a("customScrollParent"),S=Ne.useRef(null),C=a("scrollerRef"),{scrollByCallback:k,scrollerRef:w,scrollToCallback:T}=gy(h,m,x,C,b);return xy(()=>{var N;return w.current=b||((N=S.current)==null?void 0:N.ownerDocument.defaultView),()=>{w.current=null}},[w,b]),t("windowScrollTo",T),t("scrollBy",k),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...an(x,u),children:o})})}const Zk=({children:t})=>{const a=Ne.useContext(my),s=qn("viewportHeight"),o=qn("fixedItemHeight"),c=$e("alignToBottom"),u=$e("horizontalDirection"),d=Ne.useMemo(()=>Gv(s,x=>ua(x,u?"width":"height")),[s,u]),h=Ga(d,!0,$e("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Qo(c),children:t})},Jk=({children:t})=>{const a=Ne.useContext(my),s=qn("windowViewportRect"),o=qn("fixedItemHeight"),c=$e("customScrollParent"),u=qv(s,c,$e("skipAnimationFrameInResizeObserver")),d=$e("alignToBottom");return Ne.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Qo(d),children:t})},ew=({children:t})=>{const a=$e("TopItemListComponent")??"div",s=$e("headerHeight"),o={...Yk,marginTop:`${s}px`},c=$e("context");return r.jsx(a,{style:o,...an(a,c),children:t})},tw=Ne.memo(function(t){const a=$e("useWindowScroll"),s=$e("topItemsIndexes").length>0,o=$e("customScrollParent"),c=$e("context");return r.jsxs(o||a?aw:rw,{...t,context:c,children:[s&&r.jsx(ew,{children:r.jsx(Cg,{showTopList:!0})}),r.jsxs(o||a?Jk:Zk,{children:[r.jsx(Xk,{}),r.jsx(Cg,{}),r.jsx(Qk,{})]})]})}),{Component:nw,useEmitter:Df,useEmitterValue:$e,usePublisher:qn}=py(Pk,{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"}},tw),rw=yy({useEmitter:Df,useEmitterValue:$e,usePublisher:qn}),aw=by({useEmitter:Df,useEmitterValue:$e,usePublisher:qn}),lw=nw,sw=tt(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),o=ge(null),c=ge(null),u=ge({}),d=ge(zf),h=ge(Hl),x=(m,v=null)=>ln(me(u,ke(y=>y[m]),jt()),v);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});St(fy,sw);Lf();const Eg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},iw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ng,floor:Io,max:$s,min:Rd,round:Tg}=Math;function Rg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function ow(t){return{...iw,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function cw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const uw=tt(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:x,scrollTop:m,smoothScrollTargetReached:v,viewportHeight:y},b,S,{didMount:C,propsReady:k},{customScrollParent:w,useWindowScroll:T,windowScrollContainerState:N,windowScrollTo:L,windowViewportRect:_},D])=>{const F=ge(0),E=ge(0),O=ge(Eg),M=ge({height:0,width:0}),U=ge({height:0,width:0}),$=Ze(),Y=Ze(),X=ge(0),ee=ge(null),I=ge({column:0,row:0}),A=Ze(),B=Ze(),V=ge(!1),H=ge(0),re=ge(!0),z=ge(!1),W=ge(!1);rt(me(C,Ge(H),Oe(([ce,be])=>be!==0)),()=>{Fe(re,!1)}),rt(me($t(C,re,U,M,H,z),Oe(([ce,be,Re,Ae,,se])=>ce&&!be&&Re.height!==0&&Ae.height!==0&&!se)),([,,,,ce])=>{Fe(z,!0),Tf(1,()=>{Fe($,ce)}),Jn(me(m),()=>{Fe(a,[0,0]),Fe(re,!0)})}),Te(me(B,Oe(ce=>ce!=null&&ce.scrollTop>0),dr(0)),E),rt(me(C,Ge(B),Oe(([,ce])=>ce!=null)),([,ce])=>{ce&&(Fe(M,ce.viewport),Fe(U,ce.item),Fe(I,ce.gap),ce.scrollTop>0&&(Fe(V,!0),Jn(me(m,Pa(1)),be=>{Fe(V,!1)}),Fe(x,{top:ce.scrollTop})))}),Te(me(M,ke(({height:ce})=>ce)),y),Te(me($t(_e(M,bo),_e(U,bo),_e(I,(ce,be)=>ce!==void 0&&ce.column===be.column&&ce.row===be.row),_e(m)),ke(([ce,be,Re,Ae])=>({gap:Re,item:be,scrollTop:Ae,viewport:ce}))),A),Te(me($t(_e(F),o,_e(I,cw),_e(U,bo),_e(M,bo),_e(ee),_e(E),_e(V),_e(re),_e(H)),Oe(([,,,,,,,ce])=>!ce),ke(([ce,[be,Re],Ae,se,he,pe,xe,,je,Be])=>{const{column:Ue,row:gt}=Ae,{height:Lt,width:st}=se,{width:Et}=he;if(xe===0&&(ce===0||Et===0))return Eg;if(st===0){const Dn=Rf(Be,ce),Nt=Dn+Math.max(xe-1,0);return ow(Rg(Dn,Nt,pe))}const Yt=jy(Et,st,Ue);let Ye,vt;je?be===0&&Re===0&&xe>0?(Ye=0,vt=xe-1):(Ye=Yt*Io((be+gt)/(Lt+gt)),vt=Yt*Ng((Re+gt)/(Lt+gt))-1,vt=Rd(ce-1,$s(vt,Yt-1)),Ye=Rd(vt,$s(0,Ye))):(Ye=0,vt=-1);const bn=Rg(Ye,vt,pe),{bottom:ye,top:ht}=Ag(he,Ae,se,bn),zt=Ng(ce/Yt),Ot=zt*Lt+(zt-1)*gt-ye;return{bottom:ye,itemHeight:Lt,items:bn,itemWidth:st,offsetBottom:Ot,offsetTop:ht,top:ht}})),O),Te(me(ee,Oe(ce=>ce!==null),ke(ce=>ce.length)),F),Te(me($t(M,U,O,I),Oe(([ce,be,{items:Re}])=>Re.length>0&&be.height!==0&&ce.height!==0),ke(([ce,be,{items:Re},Ae])=>{const{bottom:se,top:he}=Ag(ce,Ae,be,Re);return[he,se]}),jt(Ws)),a);const te=ge(!1);Te(me(m,Ge(te),ke(([ce,be])=>be||ce!==0)),te);const q=Mn(me($t(O,F),Oe(([{items:ce}])=>ce.length>0),Ge(te),Oe(([[ce,be],Re])=>{const Ae=ce.items[ce.items.length-1].index===be-1;return(Re||ce.bottom>0&&ce.itemHeight>0&&ce.offsetBottom===0&&ce.items.length===be)&&Ae}),ke(([[,ce]])=>ce-1),jt())),oe=Mn(me(_e(O),Oe(({items:ce})=>ce.length>0&&ce[0].index===0),dr(0),jt())),le=Mn(me(_e(O),Ge(V),Oe(([{items:ce},be])=>ce.length>0&&!be),ke(([{items:ce}])=>({endIndex:ce[ce.length-1].index,startIndex:ce[0].index})),jt(Jv),Dr(0)));Te(le,S.scrollSeekRangeChanged),Te(me($,Ge(M,U,F,I),ke(([ce,be,Re,Ae,se])=>{const he=ay(ce),{align:pe,behavior:xe,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=Ae-1),Be=$s(0,Be,Rd(Ae-1,Be));let Ue=sf(be,se,Re,Be);return pe==="end"?Ue=Tg(Ue-be.height+Re.height):pe==="center"&&(Ue=Tg(Ue-be.height/2+Re.height/2)),je!==void 0&&je!==0&&(Ue+=je),{behavior:xe,top:Ue}})),x);const ve=ln(me(O,ke(ce=>ce.offsetBottom+ce.bottom)),0);return Te(me(_,ke(ce=>({height:ce.visibleHeight,width:ce.visibleWidth}))),M),{customScrollParent:w,data:ee,deviation:X,footerHeight:c,gap:I,headerHeight:u,increaseViewportBy:t,initialItemCount:E,itemDimensions:U,overscan:s,restoreStateFrom:B,scrollBy:d,scrollContainerState:h,scrollHeight:Y,scrollTo:x,scrollToIndex:$,scrollTop:m,smoothScrollTargetReached:v,totalCount:F,useWindowScroll:T,viewportDimensions:M,windowScrollContainerState:N,windowScrollTo:L,windowViewportRect:_,...S,gridState:O,horizontalDirection:W,initialTopMostItemIndex:H,totalListHeight:ve,...b,endReached:q,propsReady:k,rangeChanged:le,startReached:oe,stateChanged:A,stateRestoreInProgress:V,...D}},St(Af,fn,ni,uy,ma,Mf,pa));function jy(t,a,s){return $s(1,Io((t+s)/(Io(a)+s)))}function Ag(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=sf(t,a,s,o[0].index);return{bottom:sf(t,a,s,o[o.length-1].index)+c,top:u}}function sf(t,a,s,o){const c=jy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+$s(0,u-1)*a.row;return d>0?d+a.row:d}const dw=tt(()=>{const t=ge(y=>`Item ${y}`),a=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(zf),d=ge("div"),h=ge(Hl),x=(y,b=null)=>ln(me(a,ke(S=>S[y]),jt()),b),m=ge(!1),v=ge(!1);return Te(_e(v),m),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:m,reportReadyState:v,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),fw=tt(([t,a])=>({...t,...a}),St(uw,dw)),pw=Ne.memo(function(){const t=wt("gridState"),a=wt("listClassName"),s=wt("itemClassName"),o=wt("itemContent"),c=wt("computeItemKey"),u=wt("isSeeking"),d=Yn("scrollHeight"),h=wt("ItemComponent"),x=wt("ListComponent"),m=wt("ScrollSeekPlaceholder"),v=wt("context"),y=Yn("itemDimensions"),b=Yn("gap"),S=wt("log"),C=wt("stateRestoreInProgress"),k=Yn("reportReadyState"),w=Ga(Ne.useMemo(()=>T=>{const N=T.parentElement.parentElement.scrollHeight;d(N);const L=T.firstChild;if(L!==null){const{height:_,width:D}=L.getBoundingClientRect();y({height:_,width:D})}b({column:Mg("column-gap",getComputedStyle(T).columnGap,S),row:Mg("row-gap",getComputedStyle(T).rowGap,S)})},[d,y,b,S]),!0,!1);return xy(()=>{t.itemHeight>0&&t.itemWidth>0&&k(!0)},[t]),C?null:r.jsx(x,{className:a,ref:w,...an(x,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(T=>{const N=c(T.index,T.data,v);return u?r.jsx(m,{...an(m,v),height:t.itemHeight,index:T.index,width:t.itemWidth},N):p.createElement(h,{...an(h,v),className:s,"data-index":T.index,key:N},o(T.index,T.data,v))})})}),mw=Ne.memo(function(){const t=wt("HeaderComponent"),a=Yn("headerHeight"),s=wt("headerFooterTag"),o=Ga(Ne.useMemo(()=>u=>{a(ua(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...an(t,c)})}):null}),hw=Ne.memo(function(){const t=wt("FooterComponent"),a=Yn("footerHeight"),s=wt("headerFooterTag"),o=Ga(Ne.useMemo(()=>u=>{a(ua(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...an(t,c)})}):null}),xw=({children:t})=>{const a=Ne.useContext(hy),s=Yn("itemDimensions"),o=Yn("viewportDimensions"),c=Ga(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Qo(!1),children:t})},gw=({children:t})=>{const a=Ne.useContext(hy),s=Yn("windowViewportRect"),o=Yn("itemDimensions"),c=wt("customScrollParent"),u=qv(s,c,!1);return Ne.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Qo(!1),children:t})},vw=Ne.memo(function({...t}){const a=wt("useWindowScroll"),s=wt("customScrollParent"),o=s||a?bw:yw,c=s||a?gw:xw,u=wt("context");return r.jsx(o,{...t,...an(o,u),children:r.jsxs(c,{children:[r.jsx(mw,{}),r.jsx(pw,{}),r.jsx(hw,{})]})})}),{useEmitter:Sy,useEmitterValue:wt,usePublisher:Yn}=py(fw,{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"}},vw),yw=yy({useEmitter:Sy,useEmitterValue:wt,usePublisher:Yn}),bw=by({useEmitter:Sy,useEmitterValue:wt,usePublisher:Yn});function Mg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Wt.WARN),a==="normal"?0:parseInt(a??"0",10)}const jw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},ky={source:"Own",installed:"Installed"};function Sw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function kw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Lg({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=jw[t],[d,h]=p.useState(()=>Sw(u)),x=p.useCallback(()=>{h(b=>{const S=!b;return kw(u,S),S})},[u]),m=ky[t],v=`sidebar-section-${t}-header`,y=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:v,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":y,onClick:x,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:[r.jsx(Cw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(ww,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function ww({origin:t,updateCount:a}){const[s,o]=p.useState(!1),c=ky[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.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:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Cw({collapsed:t}){return r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function _f(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Ew({value:t,onChange:a,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 x(m){var b;if(m.key!=="/")return;const v=m.target;if(!v)return;const y=v.tagName;y==="INPUT"||y==="TEXTAREA"||v.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.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:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.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:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.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&&r.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}),r.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 Nw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.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:r.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:[r.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"}),r.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 Tw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.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:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Rw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Dv)}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 r.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 a?null:r.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 Aw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ri(t){const{version:a,showPrefix:s=!0,size:o="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",h=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!h.startsWith("v")?`v${h}`:h,m=o==="sm"?10:12,v=o==="sm"?1:2,y=o==="sm"?5:8,b=c!==void 0&&c!=="frontmatter",S=Aw(c,h,u),C=t.title??S,k={display:"inline-flex",alignItems:"center",padding:`${v}px ${y}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:m,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(k.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":h,"data-version-source":c,title:C,style:k,children:x})}function Mw({skill:t,isSelected:a,onSelect:s,onContextMenu:o,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?d=>{d.preventDefault(),o(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"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:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"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:[r.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:u,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"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ri,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Nw,{target:t.symlinkTarget??null}),r.jsx(Tw,{skill:t}),r.jsx(Rw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=p.memo(Mw);function Lw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((h,x)=>h.skill.localeCompare(x.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.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}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:d.map(h=>{const x=!!s&&s.plugin===h.plugin&&s.skill===h.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:h,isSelected:x,onSelect:()=>o(h),onContextMenu:c,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})},`${h.plugin}/${h.skill}`)})})]})}function zw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function zg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,m]=p.useState(()=>zw(o,s)),v=d?!1:x,y=p.useCallback(()=>{m(C=>{const k=!C;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(k))}catch{}return k})},[o]),b=v?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,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:[r.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}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.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&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!v&&r.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(C=>r.jsx("div",{"data-vskill-plugin-skill":C.pluginNamespace??C.skill,children:c(C)},`${C.pluginNamespace??C.skill}`))})]})}function of({open:t,title:a,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const x=p.useRef(null),m=p.useRef(null),v=p.useRef(null);if(p.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var C;(C=m.current)==null||C.focus()}),()=>{var C,k;(k=(C=v.current)==null?void 0:C.focus)==null||k.call(C),v.current=null}},[t]),p.useEffect(()=>{if(!t)return;function C(k){if(k.key==="Escape"){k.preventDefault(),h();return}if(k.key==="Tab"&&x.current){const w=x.current.querySelectorAll("button:not([disabled])");if(w.length===0)return;const T=w[0],N=w[w.length-1];k.shiftKey&&document.activeElement===T?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),T.focus())}}return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[t,h]),!t)return null;const y="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 r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:C=>{C.target===C.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":y,"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:[r.jsx("h2",{id:y,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.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}),r.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 Dw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Ad(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function _w({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=p.useState(!1),[u,d]=p.useState(null),[h,x]=p.useState(null),[m,v]=p.useState(!1),y=p.useRef(null);p.useEffect(()=>{if(!o)return;function C(k){y.current&&!y.current.contains(k.target)&&c(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o]);async function b(C){d(C),x(null);try{const k=await fetch(`/api/plugins/${encodeURIComponent(t)}/${C}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),w=await k.json().catch(()=>({}));if(!k.ok||!w.ok){const T=w.error??`${C} failed (${k.status})`;x(T),C==="uninstall"&&Ad(`Failed to uninstall ${t}: ${T}`,"error");return}if(C==="uninstall"){const T=w.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Ad(T,"success")}An("skills"),Vv(),s==null||s(),c(!1)}catch(k){const w=k instanceof Error?k.message:String(k);x(w),C==="uninstall"&&Ad(`Failed to uninstall ${t}: ${w}`,"error")}finally{d(null)}}function S(){v(!0)}return r.jsxs("div",{ref:y,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:C=>{C.stopPropagation(),c(k=>!k)},"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:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-tertiary)",C.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.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:[a?r.jsx(Md,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Md,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Md,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.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})]}),r.jsx(of,{open:m,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{v(!1),c(!1)},onConfirm:()=>{v(!1),b("uninstall")}})]})}function Md({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Dg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=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",v={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,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"},y=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[m&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:y}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.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:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(Ow,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,children:b})}function Ow({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??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 Bw(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function Iw(t){const a=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(a.length>1){for(const h of a.slice(0,-1)){const x=h.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?o=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.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 Uw(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function Hw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function cf(t,a={}){const{enabled:s=!0,target:o}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(Iw),p.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(x){const m=x,v=Uw(m.target);for(const y of c.current){if(!Hw(m,y))continue;const b=y.meta||y.ctrl||y.alt;if(!(v&&!y.allowInInputs&&!b)){y.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const $w=200;function Pw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Vw(t,a){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(x=>_f(x,a)),d={};for(const x of u){const m=x.pluginName??x.plugin;(d[m]||(d[m]=[])).push(x)}const h=Object.entries(d).sort((x,m)=>x[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 Fw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Pw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var v;const h=d.filter(y=>_f(y,a)),x={};for(const y of h)(x[v=y.plugin]||(x[v]=[])).push(y);const m=Object.entries(x).sort((y,b)=>y[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(o),global:u(c)}}function Gw(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var m;const d=u.filter(v=>_f(v,a)),h={};for(const v of d)(h[m=v.plugin]||(h[m]=[])).push(v);const x=Object.entries(h).sort((v,y)=>v[0].localeCompare(y[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(o)}}function Ww({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:x,outdatedByScope:m,topSlot:v,revealSkillId:y,onRevealComplete:b,dirtySkillIds:S}){const C=!!x||t.some(q=>q.scope!==void 0&&q.scope!==null),k=x??"claude-cli",[w,T]=p.useState(""),N=p.useDeferredValue(w),L=p.useMemo(()=>Fw(t,N),[t,N]),_=p.useMemo(()=>Vw(t,N),[t,N]),D=k==="claude-code",{plugins:F}=K2(),E=D?{plugins:F??[]}:void 0,O=p.useMemo(()=>{const q=new Map;for(const oe of(E==null?void 0:E.plugins)??[]){const le=q.get(oe.name);q.set(oe.name,!!le||!!oe.enabled)}return q},[E==null?void 0:E.plugins]),[M,U]=p.useState(()=>uf(`vskill-sidebar-${k}-group-available-collapsed`)),[$,Y]=p.useState(()=>uf(`vskill-sidebar-${k}-group-authoring-collapsed`)),X=p.useCallback(q=>{U(q);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(q))}catch{}},[k]),ee=p.useCallback(q=>{Y(q);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(q))}catch{}},[k]),{own:I,installed:A}=p.useMemo(()=>Gw(t,N),[t,N]),V=L.own.filtered+L.installed.filtered+L.global.filtered>=$w,H=p.useMemo(()=>{const q=oe=>{const le=[];for(const[,ve]of oe){const ce=[...ve].sort((be,Re)=>be.skill.localeCompare(Re.skill));le.push(...ce)}return le};return C?[...q(L.own.byPlugin),...q(L.installed.byPlugin),...q(L.global.byPlugin)]:[...q(I.byPlugin),...q(A.byPlugin)]},[C,L.own.byPlugin,L.installed.byPlugin,L.global.byPlugin,I.byPlugin,A.byPlugin]),re=p.useMemo(()=>a?H.findIndex(q=>q.plugin===a.plugin&&q.skill===a.skill):-1,[H,a]),z=p.useCallback(q=>{if(H.length===0)return;const oe=re<0?q>0?0:H.length-1:Math.min(Math.max(re+q,0),H.length-1);s(H[oe])},[H,re,s]),W=p.useMemo(()=>{if(!y)return null;const[q,oe]=y.split("/");if(!q||!oe)return null;const le=t.find(be=>be.plugin===q&&be.skill===oe);if(!le)return{plugin:q,skill:oe,bucket:null,pluginName:null};const ve=le.source==="plugin"?"plugin":"project",ce=ve==="plugin"?le.pluginName??q:null;return{plugin:q,skill:oe,bucket:ve,pluginName:ce}},[y,t]),te=p.useRef(null);return p.useEffect(()=>{if(!y){te.current=null;return}if(te.current===y)return;const q=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),oe=document.querySelector(`[data-skill-id="${q}"]`);oe&&(te.current=y,oe.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),cf([{key:"j",handler:()=>z(1)},{key:"k",handler:()=>z(-1)},{key:"Enter",handler:()=>{re>=0&&s(H[re])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,r.jsx(Ew,{value:w,onChange:T}),o&&r.jsx(Qw,{}),!o&&c&&r.jsx(Zw,{error:c,onRetry:u}),!o&&!c&&C&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Dg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:M,onToggle:X,count:_.availableProject.total+_.availablePersonal.total+_.availablePlugin.total}),!M&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:_.availableProject.total,filteredCount:w?_.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),children:_.availableProject.filtered===0?r.jsx(Og,{queryActive:!!w,agentId:k}):r.jsx(Ds,{items:_.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:V,dirtySkillIds:S})}),r.jsx(zs,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:_.availablePersonal.total,filteredCount:w?_.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:_.availablePersonal.filtered===0?r.jsx(Yw,{queryActive:!!w,agentId:k}):r.jsx(Ds,{items:_.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:V,dirtySkillIds:S})}),D&&r.jsxs(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:_.availablePlugin.total,filteredCount:w?_.availablePlugin.filtered:null,children:[r.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:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),_.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):_.availablePlugin.byPlugin.map(([q,oe])=>r.jsx(zg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-available-${q}-collapsed`,headerActionSlot:D?r.jsx(_w,{pluginName:q,enabled:O.get(q)??!0}):void 0,renderSkill:le=>r.jsx(Uo,{skill:le,isSelected:(a==null?void 0:a.plugin)===le.plugin&&(a==null?void 0:a.skill)===le.skill,onSelect:()=>s(le),onContextMenu:d,dirty:S==null?void 0:S.has(`${le.plugin}/${le.skill}`)})},`available-${q}`))]})]}),r.jsx(Xw,{}),r.jsx(Dg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:W?!1:$,onToggle:ee,count:_.authoringProject.total+_.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.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:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.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"}}))}}}),(!$||W)&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:_.authoringProject.total,filteredCount:w?_.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(W==null?void 0:W.bucket)==="project",children:_.authoringProject.filtered===0?r.jsx(_g,{queryActive:!!w}):r.jsx(Ds,{items:_.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:V,dirtySkillIds:S})}),D&&r.jsx(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:_.authoringPlugin.total,filteredCount:w?_.authoringPlugin.filtered:null,forceOpen:(W==null?void 0:W.bucket)==="plugin",children:_.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):_.authoringPlugin.byPlugin.map(([q,oe])=>r.jsx(zg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-authoring-${q}-collapsed`,forceOpen:(W==null?void 0:W.bucket)==="plugin"&&W.pluginName===q,renderSkill:le=>r.jsx(Uo,{skill:le,isSelected:(a==null?void 0:a.plugin)===le.plugin&&(a==null?void 0:a.skill)===le.skill,onSelect:()=>s(le),onContextMenu:d,dirty:S==null?void 0:S.has(`${le.plugin}/${le.skill}`)})},`authoring-${q}`))})]})]}),!o&&!c&&!C&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Lg,{origin:"source",count:I.total,filteredCount:w?I.filtered:null,updateCount:h==null?void 0:h.source,children:I.filtered===0?r.jsx(_g,{queryActive:!!w}):r.jsx(Ds,{items:I.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:V,dirtySkillIds:S})}),r.jsx(Kw,{}),r.jsx(Lg,{origin:"installed",count:A.total,filteredCount:w?A.filtered:null,updateCount:h==null?void 0:h.installed,children:A.filtered===0?r.jsx(Og,{queryActive:!!w}):r.jsx(Ds,{items:A.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:V,dirtySkillIds:S})})]})]})}function uf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function zs({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,x]=p.useState(()=>uf(a)),m=d?!1:h,v=p.useCallback(()=>{x(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),y=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:v,"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:[r.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?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",y,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!m&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function qw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ds({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c,dirtySkillIds:u}){if(c){const d=qw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(lw,{overscan:4,totalCount:d.length,itemContent:h=>{const x=d[h];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const m=x.skill,v=!!a&&a.plugin===m.plugin&&a.skill===m.skill;return r.jsx(Uo,{skill:m,isSelected:v,onSelect:()=>s(m),onContextMenu:o,dirty:u==null?void 0:u.has(`${m.plugin}/${m.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,h])=>r.jsx(Lw,{plugin:d,skills:h,selectedKey:a,onSelect:s,onContextMenu:o,dirtySkillIds:u},d))})}function _g({queryActive:t}){return t?r.jsx(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Of,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Og({queryActive:t,agentId:a}){return t?r.jsx(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Of,{children:"vskill install <skill>"})," to add one."]})})}function Yw({queryActive:t,agentId:a}){return t?r.jsx(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Of,{children:"vskill install --global <skill>"})," to add one."]})})}function _l({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function Of({children:t}){return r.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 Kw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Xw(){return r.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 Qw(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(Bw,{},t))})}function Zw({error:t,onRetry:a}){return r.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:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:Jw(t)}),r.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})]}),a&&r.jsx("button",{type:"button",onClick:a,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 Jw(t){const a=t.split(`
|
|
66
|
-
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const wy=240,Cy=480,Ey="vskill-sidebar-width",Ps=320;function Bf(t){return Number.isFinite(t)?Math.round(Math.max(wy,Math.min(Cy,t))):Ps}function eC(){try{const t=localStorage.getItem(Ey);if(!t)return Ps;const a=Number(t);return Number.isFinite(a)?Bf(a):Ps}catch{return Ps}}function tC(t){try{localStorage.setItem(Ey,String(Bf(t)))}catch{}}function nC({initialWidth:t,onChange:a}){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,x=Bf(s.current.startWidth+h);o.current=x,a(x)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,tC(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)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":wy,"aria-valuemax":Cy,"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"}})}const rC=/^[ MADRCU?!]{1,2} +/;function aC(t){return t.replace(rC,"")}function lC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function sC(t,a,s){const o=new Set;if(a.length===0||t.length===0)return o;const c=a.map(u=>aC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const h=lC(s,d);if(h===null)continue;const x=`${u.plugin}/${u.skill}`;if(h===""){c.length>0&&o.add(x);continue}const m=h+"/";for(const v of c)if(v===h||v.startsWith(m)){o.add(x);break}}return o}const iC=5e3;function oC(t,a,s=iC){const[o,c]=p.useState([]),u=p.useRef(t);return u.current=t,p.useEffect(()=>{if(!a){c([]);return}let d=!1,h=null;const x=async()=>{try{const v=await Se.gitStatus();d||c(v.paths??[])}catch{d||c([])}d||(h=setTimeout(x,s))};x();const m=()=>{x()};return typeof window<"u"&&window.addEventListener("studio:content-saved",m),()=>{d=!0,h&&clearTimeout(h),typeof window<"u"&&window.removeEventListener("studio:content-saved",m)}},[a,s]),a?sC(u.current,o,a):new Set}function cC({connected:t,hint:a,onRetry:s}){return t?null:r.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:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.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 Ny(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;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 Ty(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);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 Ld(){const[t,a]=p.useState([]),[s,o]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),x=p.useRef(null),m=p.useCallback(async(y,b)=>{a([]),o(!0),u(!1),h(null);const S=new AbortController;x.current=S;try{const C=Ty(b),k=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:C,signal:S.signal});if(!k.ok||!k.body){let _=`HTTP ${k.status}`,D;try{D=await k.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Ny(k.status,D),new Error(_)}const w=k.body.getReader(),T=new TextDecoder;let N="",L="";for(;;){const{done:_,value:D}=await w.read();if(_)break;N+=T.decode(D,{stream:!0});const F=N.split(`
|
|
67
|
-
`);N=F.pop()||"";for(const E of F)if(E.startsWith("event: "))L=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),M={event:L,data:O};L==="done"?(u(!0),a(U=>[...U,M])):a(U=>[...U,M])}catch{}L=""}}}catch(C){C.name!=="AbortError"&&h(C.message)}finally{o(!1),x.current=null}},[]),v=p.useCallback(()=>{var y;(y=x.current)==null||y.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:v}}function uC(t){const a=p.useRef(t);a.current=t;const[s,o]=p.useState(new Set),c=p.useRef(new Map),u=p.useCallback(async(m,v,y)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),o(C=>{const k=new Set(C);return k.add(m),k});try{const C=Ty(y),k=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:C,signal:b.signal});if(!k.ok||!k.body){let _=`HTTP ${k.status}`,D;try{D=await k.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Ny(k.status,D),new Error(_)}const w=k.body.getReader(),T=new TextDecoder;let N="",L="";for(;;){const{done:_,value:D}=await w.read();if(_)break;N+=T.decode(D,{stream:!0});const F=N.split(`
|
|
68
|
-
`);N=F.pop()||"";for(const E of F)if(E.startsWith("event: "))L=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),M={event:L,data:O};a.current.onEvent(m,M)}catch{}L=""}}a.current.onDone(m)}catch(C){C.name!=="AbortError"&&a.current.onError(m,C.message)}finally{o(C=>{const k=new Set(C);return k.delete(m),k}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var v;(v=c.current.get(m))==null||v.abort()},[]),h=p.useCallback(()=>{for(const m of c.current.values())m.abort()},[]),x=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:x}}const dC={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 fC(t,a){var s,o;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.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=a.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.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 a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.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(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.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,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.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:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:a.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,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.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:a.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function pC(t){if(t==="unit"||t==="integration")return t}function mC(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.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)}a.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 Ry=p.createContext(null);function zn(){const t=p.useContext(Ry);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function hC({plugin:t,skill:a,origin:s,children:o}){const c=s==="installed",[u,d]=p.useReducer(fC,{...dC,plugin:t,skill:a}),h=p.useRef(new Set),x=p.useRef(new Set),m=p.useRef(new Map),v=p.useCallback((se,he)=>{let pe=m.current.get(se);pe||(pe={assertions:[]},m.current.set(se,pe)),mC(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:se,result:{...pe,assertions:[...pe.assertions]}})},[]),y=p.useCallback(se=>{if(x.current.has(se))return;x.current.add(se);const he=m.current.get(se)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:se,result:{...he,assertions:[...he.assertions]}}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&Se.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((se,he)=>{x.current.has(se)||(x.current.add(se),d({type:"CASE_RUN_ERROR",caseId:se,error:he}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&Se.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:C,stopAll:k}=uC({onEvent:v,onDone:y,onError:b});p.useEffect(()=>()=>{k()},[k]);const w=p.useCallback(async()=>{try{const se=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!se.ok){if(se.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await se.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let se=!1;async function he(){try{const[pe,xe,je]=await Promise.allSettled([Se.getSkillDetail(t,a),Se.getEvals(t,a),Se.getLatestBenchmark(t,a)]);if(se)return;let Be=null,Ue=null;if(xe.status==="fulfilled")Be=xe.value;else{const gt=xe.reason;Ue=(gt==null?void 0:gt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Ue,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){se||d({type:"SET_ERROR",error:pe.message})}}return he(),w(),()=>{se=!0}},[t,a,w]);const T=p.useCallback(async()=>{if(!c)try{await Se.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(se){d({type:"SET_ERROR",error:se.message})}},[c,t,a,u.skillContent]),N=p.useCallback(async se=>{if(!c)try{const he=await Se.saveEvals(t,a,se);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),L=p.useCallback((se,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(se);if((pe==null?void 0:pe.status)!=="running")if(m.current.delete(se),x.current.delete(se),d({type:"CASE_RUN_START",caseId:se,mode:he}),he==="comparison"){const xe=`/api/skills/${t}/${a}/compare`;S(se,xe,{eval_ids:[se]})}else{const xe=`/api/skills/${t}/${a}/benchmark/case/${se}`;S(se,xe,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),_=p.useCallback((se="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),x.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:se}),h.current=new Set(pe);for(const je of pe)if(se==="comparison")S(je,`/api/skills/${t}/${a}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${je}`;S(je,Be,se==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=p.useCallback(se=>{C(se),d({type:"CASE_RUN_CANCEL",caseId:se}),h.current.delete(se),x.current.add(se)},[C]),F=p.useCallback(()=>{k(),d({type:"CANCEL_ALL"}),h.current.clear()},[k]),E=p.useCallback(async(se,he)=>{d({type:"OPEN_IMPROVE",evalId:se})},[]),O=p.useCallback(async(se,he)=>{try{await Se.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),L(se,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,L]),M=Ld(),U=p.useRef(null),$=p.useRef(0);p.useEffect(()=>{const se=M.events;for(let he=$.current;he<se.length;he++){const pe=se[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,Ue=xe.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Ue})}if(pe.event==="error"){const je=xe;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}$.current=se.length},[M.events]),p.useEffect(()=>{M.error&&d({type:"AI_EDIT_ERROR",message:M.error})},[M.error]),p.useEffect(()=>()=>{M.stop()},[M.stop]);const Y=p.useCallback(async(se,he,pe)=>{c||($.current=0,d({type:"AI_EDIT_LOADING"}),U.current=M.stop,M.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:se,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,M]),X=p.useCallback(()=>{M.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[M]),ee=p.useCallback(async()=>{const se=u.aiEditResult;if(se!=null&&se.improved)try{if(await Se.applyImprovement(t,a,se.improved),d({type:"SET_CONTENT",content:se.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Va(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),xe=u.evals??{skill_name:a,evals:[]},je=pe(xe,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Se.saveEvals(t,a,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,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),I=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),A=p.useCallback(se=>{d({type:"TOGGLE_EVAL_CHANGE",index:se})},[]),B=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),V=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),H=p.useCallback(async()=>{const se=u.aiEditEvalsRetry;if(se)try{const he=await Se.saveEvals(t,a,se);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,a,u.aiEditEvalsRetry]),re=p.useCallback(async()=>{try{const se=await Se.getSkillDetail(t,a);d({type:"SET_CONTENT",content:se.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:z}=Fa(),W=Ld(),te=p.useRef(0);p.useEffect(()=>{const se=W.events;for(let he=te.current;he<se.length;he++){const pe=se[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;Se.saveEvals(t,a,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})}te.current=se.length},[W.events,t,a]),p.useEffect(()=>{W.error&&d({type:"SET_ERROR",error:W.error})},[W.error]),p.useEffect(()=>()=>{W.stop()},[W.stop]);const q=p.useCallback(async se=>{if(c)return;te.current=0,d({type:"GENERATE_EVALS_START"});const he={};z!=null&&z.provider&&(he.provider=z.provider),z!=null&&z.model&&(he.model=z.model);const pe=pC(se==null?void 0:se.testType);pe&&(he.testType=pe),W.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,W,z]),oe=Ld(),le=p.useRef(0);p.useEffect(()=>()=>{oe.stop()},[oe.stop]),p.useEffect(()=>{const se=oe.events;for(let he=le.current;he<se.length;he++){const pe=se[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"){ve.current&&(clearTimeout(ve.current),ve.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:(z==null?void 0:z.model)||"unknown",provider:(z==null?void 0:z.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??[]]})}}}le.current=se.length},[oe.events,z,u.activationHistory]),p.useEffect(()=>{oe.error&&(ve.current&&(clearTimeout(ve.current),ve.current=null),d({type:"ACTIVATION_ERROR",error:oe.error}))},[oe.error]);const ve=p.useRef(null),ce=p.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),oe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[oe]),be=p.useCallback(se=>{const pe=se.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"});le.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:se});const xe={prompts:pe};z!=null&&z.provider&&(xe.provider=z.provider),z!=null&&z.model&&(xe.model=z.model),oe.start(`/api/skills/${t}/${a}/activation-test`,xe),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{oe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ve.current=null},12e4)},[t,a,oe,z]),Re=p.useCallback(async(se=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:se};z!=null&&z.provider&&(he.provider=z.provider),z!=null&&z.model&&(he.model=z.model);const pe=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let st=`HTTP ${pe.status}`;try{const Et=await pe.json();Et.error&&(st=Et.error)}catch{}throw new Error(st)}const xe=pe.body.getReader(),je=new TextDecoder;let Be="",Ue="",gt=[];for(;;){const{done:st,value:Et}=await xe.read();if(st)break;Be+=je.decode(Et,{stream:!0});const Yt=Be.split(`
|
|
70
|
-
`);Be=Yt.pop()||"";for(const Ye of Yt)if(Ye.startsWith("event: "))Ue=Ye.slice(7).trim();else if(Ye.startsWith("data: ")){try{const vt=JSON.parse(Ye.slice(6));if(Ue==="done"){if(vt.error)throw new Error(vt.error);gt=vt.prompts||[]}if(Ue==="error")throw new Error(vt.message||vt.description||"Generation failed")}catch(vt){if(!(vt instanceof SyntaxError))throw vt}Ue=""}}const Lt=gt.map(st=>`${st.expected==="should_activate"?"+":"!"}${st.prompt}`).join(`
|
|
71
|
-
`);d({type:"SET_ACTIVATION_PROMPTS",prompts:Lt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,a,z]),Ae=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:T,saveEvals:N,runCase:L,runAll:_,cancelCase:D,cancelAll:F,improveForCase:E,applyImproveAndRerun:O,refreshSkillContent:re,generateEvals:q,runActivationTest:be,cancelActivation:ce,generateActivationPrompts:Re,fetchActivationHistory:w,submitAiEdit:Y,cancelAiEdit:X,applyAiEdit:ee,discardAiEdit:I,toggleEvalChange:A,selectAllEvalChanges:B,deselectAllEvalChanges:V,retryEvalsSave:H}),[u,c,T,N,L,_,D,F,E,O,re,q,be,ce,Re,w,Y,X,ee,I,A,B,V,H]);return r.jsx(Ry.Provider,{value:Ae,children:o})}function xC(t){if(!t)return[];const a=t.split(`
|
|
72
|
-
`),s=[];for(const o of a)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 If({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[x,m]=p.useState(u),[v,y]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),C=p.useMemo(()=>xC(t),[t]),k=p.useMemo(()=>{const D=C.filter(E=>E.type==="add").length,F=C.filter(E=>E.type==="remove").length;return{added:D,removed:F}},[C]),w=p.useMemo(()=>{let D=0,F=0;return C.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}))},[C]),T=p.useMemo(()=>{const D=[],F=[];for(const E of w)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}},[w]),N=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||C.length===0)return r.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&r.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":"",_=r.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[a," → ",s]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",k.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",k.removed]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>y(v==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:v==="unified"?"Side-by-side":"Unified"}),u&&r.jsx("button",{onClick:()=>m(!x),className:"btn btn-ghost text-[11px]",children:x?"Expand":"Collapse"})]})]}),o&&r.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}),!x&&(v==="unified"?r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:w.map((D,F)=>r.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[r.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??""}),r.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??""}),r.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"?"-":" "}),r.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))})})}):r.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:[r.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>N("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:T.left.map((D,F)=>r.jsxs("tr",{style:{background:D.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[r.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??""}),r.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))})})}),r.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>N("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:T.right.map((D,F)=>r.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[r.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??""}),r.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"?r.jsx("div",{className:L,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:_})}):_}const zd="https://verified-skill.com/submit",gC=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function vC(t){if(!t)return zd;const a=t.trim();return!a||!gC.test(a)?zd:`${zd}?repo=${encodeURIComponent(a)}`}const yC={sm:{icon:12,fontSize:"0.625rem",gap:"0.25rem",px:"0.375rem",py:"0.125rem",height:"18px",radius:"3px"},md:{icon:14,fontSize:"0.6875rem",gap:"0.3rem",px:"0.5rem",py:"0.15rem",height:"22px",radius:"4px"},lg:{icon:16,fontSize:"0.75rem",gap:"0.375rem",px:"0.625rem",py:"0.2rem",height:"26px",radius:"4px"}};function bC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 1L3 4.5V9.5C3 13.64 5.99 17.52 10 18.5C14.01 17.52 17 13.64 17 9.5V4.5L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),r.jsx("path",{d:"M7.5 10.5L9.5 12.5L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function jC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 1L11.9 4.1L15.5 3.5L14.2 7L17 9.5L14.2 12L15.5 15.5L11.9 14.9L10 18L8.1 14.9L4.5 15.5L5.8 12L3 9.5L5.8 7L4.5 3.5L8.1 4.1L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.1",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 6.5L10.9 8.6L13.1 8.8L11.4 10.3L11.9 12.5L10 11.3L8.1 12.5L8.6 10.3L6.9 8.8L9.1 8.6L10 6.5Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.4",strokeLinejoin:"round"})]})}const Bg={VERIFIED:{color:"var(--tier-verified)",bg:"var(--tier-verified-bg)",border:"var(--tier-verified-border)"},CERTIFIED:{color:"var(--tier-certified)",bg:"var(--tier-certified-bg)",border:"var(--tier-certified-border)"},TAINTED:{color:"var(--tier-tainted)",bg:"var(--tier-tainted-bg)",border:"var(--tier-tainted-border)"}},SC={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function Ay(t){return SC[t]??t}function kC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 2L1.5 17.5H18.5L10 2Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 8V12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"10",cy:"14.5",r:"1",fill:"currentColor"})]})}function wC({tier:t,size:a}){return t==="TAINTED"?r.jsx(kC,{size:a}):t==="CERTIFIED"?r.jsx(jC,{size:a}):r.jsx(bC,{size:a})}function gR({tier:t,size:a="md",isTainted:s}){const o=yC[a],c=s?"TAINTED":t,u=Bg[c]??Bg.VERIFIED;return r.jsxs("span",{"data-testid":"tier-badge","data-tier":c,style:{display:"inline-flex",alignItems:"center",gap:o.gap,padding:`${o.py} ${o.px}`,height:o.height,borderRadius:o.radius,fontFamily:"var(--font-geist-mono)",fontSize:o.fontSize,fontWeight:600,letterSpacing:"0.03em",whiteSpace:"nowrap",color:u.color,backgroundColor:u.bg,border:`1px solid ${u.border}`,lineHeight:1},children:[r.jsx(wC,{tier:c,size:o.icon}),Ay(c)]})}const Ig={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 CC(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function EC(){const{state:t}=zn(),{plugin:a,skill:s}=t,o=nr(),{onSkillUpdated:c,updateCount:u}=o,d=p.useMemo(()=>o.state.skills.find(A=>A.plugin===a&&A.skill===s)??null,[o.state.skills,a,s]),h=`versions/${a}/${s}`,x=p.useCallback(()=>Se.getSkillVersions(a,s),[a,s]),{data:m,loading:v}=Js(h,x),[y,b]=p.useState(null),[S,C]=p.useState(null),[k,w]=p.useState(null),[T,N]=p.useState(!1),[L,_]=p.useState("idle"),[D,F]=p.useState(null),E=p.useRef(null),O=p.useRef(null),M=p.useMemo(()=>(m==null?void 0:m.find(A=>A.isInstalled))??null,[m]),U=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),$=M&&U&&M.version!==U.version,Y=p.useCallback(A=>{y?!S&&A!==y?C(A):(b(A),C(null),w(null)):(b(A),w(null))},[y,S]),X=p.useCallback(async(A,B)=>{N(!0);try{const V=await Se.getVersionDiff(a,s,A,B);w(V)}catch{w(null)}finally{N(!1)}},[a,s]);p.useEffect(()=>{if(y&&S){const A=m||[],B=A.findIndex(z=>z.version===y),V=A.findIndex(z=>z.version===S),[H,re]=B>V?[y,S]:[S,y];X(H,re)}},[y,S,m,X]);const ee=p.useCallback(()=>{!M||!U||(b(M.version),C(U.version))},[M,U]),I=p.useCallback(async()=>{_("updating"),F(null);const A=new AbortController;E.current=A;try{const B=await Se.postSkillUpdate(a,s,A.signal);if(B.ok)_("done"),c(a,s);else{const V=`Update failed (HTTP ${B.status}): ${B.body||"no response body"}`;_("error"),F(V)}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const V=B instanceof Error?B.message:"Network error";_("error"),F(V)}finally{E.current===A&&(E.current=null)}},[a,s,c]);if(p.useEffect(()=>()=>{var A;(A=E.current)==null||A.abort(),E.current=null},[]),v)return r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!m||m.length===0){if((d==null?void 0:d.origin)==="source"){const B=vC((d==null?void 0:d.homepage)??null);return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),r.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."}),r.jsx("a",{href:B,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return d!=null&&d.version?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsxs("div",{"data-testid":"version-row-local",className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg",style:{background:"transparent",border:"1px solid transparent"},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:d.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"LOCAL"}),r.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"})]})}),r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Local-only — this skill is not registered on verified-skill.com, so no upstream history is available."})]})]})]}):r.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:r.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return r.jsxs("div",{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"flex items-center gap-2",children:[$&&r.jsx("button",{onClick:ee,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),$&&L!=="done"&&(L==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),r.jsx("button",{onClick:I,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:I,disabled:L!=="idle",className:"btn btn-primary text-[11px]",children:L==="idle"?`Update to ${U==null?void 0:U.version}`:L==="updating"?"Starting update...":L==="scanning"?"Scanning...":"Installing..."})),u>1&&r.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,")"]})]})]}),y&&!S&&r.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 ",y]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsx("div",{className:"space-y-1",children:m.map(A=>{const B=Ig[A.certTier]||Ig.COMMUNITY,V=A.version===y||A.version===S,H=A.isInstalled;return r.jsxs("button",{onClick:()=>Y(A.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:V?"var(--accent-muted)":"transparent",border:V?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:re=>{V||(re.currentTarget.style.background="var(--surface-1)")},onMouseLeave:re=>{V||(re.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:H?10:8,height:H?10:8,background:H?"var(--accent)":"var(--surface-3)",border:H?"2px solid var(--accent)":"2px solid var(--border-default)"}}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:A.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:B.bg,color:B.text},children:Ay(A.certTier)}),H&&r.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"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(A.createdAt).toLocaleDateString()})]}),A.diffSummary&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:CC(A.diffSummary,80)})]},A.version)})}),r.jsx("div",{ref:O,style:{height:1}})]}),T&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),k&&!T&&r.jsx("div",{className:"mt-4",children:r.jsx(If,{contentDiff:k.contentDiff,fromLabel:k.from,toLabel:k.to,diffSummary:k.diffSummary,renderContext:"inline",onRetry:()=>y&&S&&X(k.from,k.to)})})]})}function NC(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],o=a[2].trim(),c={},u=s.split(`
|
|
73
|
-
`);let d="",h=!1;for(const x of u){const m=x.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(m&&d&&h){const b=m[1],S=m[2].trim();let C=c[d];if((typeof C!="object"||Array.isArray(C))&&(C={},c[d]=C),!S)C[b]=[];else{const k=S.match(/^\[(.+)\]$/);k?C[b]=k[1].split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean):C[b]=S.replace(/^["']|["']$/g,"")}continue}const v=x.match(/^\s+-\s+(.+)$/);if(v&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(v[1].trim().replace(/^["']|["']$/g,"")):c[d]=[v[1].trim().replace(/^["']|["']$/g,"")];continue}const y=x.match(/^([\w-]+):\s*(.*)$/);if(y){d=y[1];const b=y[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Zo(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=TC(a);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,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`}}function TC(t){const a=t.split(`
|
|
74
|
-
`),s=[];let o=0;for(;o<a.length;)if(a[o].trim().startsWith("|")&&o+1<a.length&&a[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[o+1])){const c=Ug(a[o]);o+=2;const u=[];for(;o<a.length&&a[o].trim().startsWith("|");)u.push(Ug(a[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 x='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';x+="<thead><tr>";for(const m of c)x+=`<th ${d}>${m}</th>`;x+="</tr></thead><tbody>";for(const m of u){x+="<tr>";for(const v of m)x+=`<td ${h}>${v}</td>`;x+="</tr>"}x+="</tbody></table>",s.push(x)}else s.push(a[o]),o++;return s.join(`
|
|
75
|
-
`)}function Ug(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function Jo(t,a){const s=t.split(`
|
|
76
|
-
`),o=a.split(`
|
|
77
|
-
`);if(s.length>1e3||o.length>1e3)return[...s.map(v=>({type:"unchanged",content:v}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let v=1;v<=c;v++)for(let y=1;y<=u;y++)s[v-1]===o[y-1]?d[v][y]=d[v-1][y-1]+1:d[v][y]=Math.max(d[v-1][y],d[v][y-1]);const h=[];let x=c,m=u;for(;x>0||m>0;)x>0&&m>0&&s[x-1]===o[m-1]?(h.push({type:"unchanged",content:s[x-1]}),x--,m--):m>0&&(x===0||d[x][m-1]>=d[x-1][m])?(h.push({type:"added",content:o[m-1]}),m--):(h.push({type:"removed",content:s[x-1]}),x--);return h.reverse()}function RC(t,a){if(a&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return r.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 r.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ai({entries:t,isRunning:a}){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&&!a?null:r.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.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:[r.jsxs("span",{className:"flex items-center gap-2",children:[a&&r.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),r.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:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&r.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&&a,x=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return r.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[RC(u.phase,h),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:x}),r.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&r.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const Hg={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 ec({error:t,onRetry:a,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(x=>x==null||x<=1?(u.current&&clearInterval(u.current),0):x-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=Hg[t.category]||Hg.unknown,h=o!=null&&o>0;return r.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:[r.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{style:{fontSize:14},children:d.icon}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&r.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-3.5 pb-3",children:[r.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(a||o!=null)&&r.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&r.jsx("button",{onClick:a,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function AC({plugin:t,skill:a,skillContent:s,onApplied:o}){const[c,u]=p.useState("closed"),{config:d}=Fa(),[h,x]=p.useState("claude-cli"),[m,v]=p.useState("opus"),[y,b]=p.useState([]),[S,C]=p.useState(""),[k,w]=p.useState(""),[T,N]=p.useState(null),[L,_]=p.useState(null),[D,F]=p.useState([]),[E,O]=p.useState(!1),M=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(B=>B.id==="claude-cli"&&B.available)&&(x("claude-cli"),v("opus"))},[d]),p.useEffect(()=>()=>{var A;(A=M.current)==null||A.abort()},[]);function U(){return d==null?void 0:d.providers.find(A=>A.id===h&&A.available)}const $=p.useCallback(()=>{var A;(A=M.current)==null||A.abort(),u("open")},[]);async function Y(){u("loading"),N(null),_(null),F([]);const A=new AbortController;M.current=A;try{const B=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(a)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:m}),signal:A.signal});if(!B.ok||!B.body){let W=`HTTP ${B.status}`;try{const te=await B.json();te.error&&(W=te.error)}catch{}throw new Error(W)}const V=B.body.getReader(),H=new TextDecoder;let re="",z="";for(;;){const{done:W,value:te}=await V.read();if(W)break;re+=H.decode(te,{stream:!0});const q=re.split(`
|
|
78
|
-
`);re=q.pop()||"";for(const oe of q)if(oe.startsWith("event: "))z=oe.slice(7).trim();else if(oe.startsWith("data: ")){try{const le=JSON.parse(oe.slice(6));z==="progress"?F(ve=>[...ve,{phase:le.phase,message:le.message,timestamp:Date.now()}]):z==="done"||z==="complete"?(C(le.improved),w(le.reasoning||""),b(Jo(le.original||s,le.improved)),u("diff_shown")):z==="error"&&(N(le.message||le.description||"Unknown error"),le.category&&_(le),u("open"))}catch{}z=""}}}catch(B){B.name!=="AbortError"&&(N(B.message),u("open"))}finally{M.current=null}}async function X(){O(!0);try{await Se.applyImprovement(t,a,S),o(S),u("closed")}catch(A){N(A.message)}finally{O(!1)}}function ee(){u("closed"),b([]),C(""),w(""),N(null)}if(c==="closed")return r.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const I=U();return r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.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:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),r.jsx("button",{onClick:ee,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:A=>{A.currentTarget.style.background="var(--surface-3)"},onMouseLeave:A=>{A.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:A=>{x(A.target.value);const B=d==null?void 0:d.providers.find(V=>V.id===A.target.value);B!=null&&B.models[0]&&v(B.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(A=>A.available).map(A=>r.jsx("option",{value:A.id,children:A.label},A.id))})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:m,onChange:A=>v(A.target.value),disabled:c==="loading",children:I==null?void 0:I.models.map(A=>r.jsx("option",{value:A.id,children:A.label},A.id))})]}),c==="loading"?r.jsx("button",{onClick:$,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:Y,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(ai,{entries:D,isRunning:!0})})]}),T&&r.jsx("div",{className:"mb-4",children:L?r.jsx(ec,{error:L,onRetry:Y,onDismiss:()=>{N(null),_(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:T})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[k&&r.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:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),k]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:y.map((A,B)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:A.type==="added"?"rgba(34,197,94,0.1)":A.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:A.type==="added"?"var(--green)":A.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:A.type==="added"?"3px solid var(--green)":A.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:A.type==="added"?"+":A.type==="removed"?"-":" "}),A.content]},B))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:E,className:"btn btn-primary",children:E?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),r.jsx("button",{onClick:ee,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const $g={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"}},MC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function LC({change:t,index:a,selected:s,onToggle:o,originalEval:c}){var y;const[u,d]=p.useState(!1),h=$g[t.action]??$g.add,x=MC[t.action]??"var(--border-subtle)",m=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((y=t.eval)==null?void 0:y.name)??"Unnamed",v=p.useCallback(()=>o(a),[o,a]);return r.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${x}`,opacity:s?1:.5},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:v,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),r.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),r.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:m}),r.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),r.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:r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&r.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&r.jsx(zC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(DC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(_C,{evalCase:c})]})]})}function zC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(df,{label:"Prompt",value:t.prompt}),r.jsx(df,{label:"Expected",value:t.expected_output}),r.jsxs("div",{children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((a=t.assertions)==null?void 0:a.length)??0,")"]}),r.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>r.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function DC({original:t,proposed:a}){const s=[];t.name!==a.name&&s.push({label:"Name",old:t.name,new:a.name}),t.prompt!==a.prompt&&s.push({label:"Prompt",old:t.prompt,new:a.prompt}),t.expected_output!==a.expected_output&&s.push({label:"Expected",old:t.expected_output,new:a.expected_output});const o=t.assertions??[],c=a.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)),x=o.filter(m=>!d.has(m.text));return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(m=>r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:m.label}),r.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[r.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",ff(m.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",ff(m.new,120)]})]})]},m.label)),(h.length>0||x.length>0)&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),r.jsxs("div",{className:"mt-1 space-y-0.5",children:[x.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",m.text]},m.id)),h.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",m.text]},m.id))]})]}),s.length===0&&h.length===0&&x.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function _C({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(df,{label:"Prompt",value:t.prompt}),r.jsxs("div",{children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((a=t.assertions)==null?void 0:a.length)??0,")"]}),r.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>r.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function df({label:t,value:a}){return r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),r.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:ff(a,300)})]})}function ff(t,a){return t.length>a?t.slice(0,a)+"...":t}const Pg={remove:0,modify:1,add:2};function OC({changes:t,selections:a,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((x,m)=>({change:x,originalIndex:m}));d.sort((x,m)=>(Pg[x.change.action]??2)-(Pg[m.change.action]??2));const h=Array.from(a.values()).filter(Boolean).length;return r.jsxs("div",{className:"mt-3 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:x=>{x.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:"Select All"}),r.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:x=>{x.currentTarget.style.background="var(--surface-3)"},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:x,originalIndex:m})=>r.jsx(LC,{change:x,index:m,selected:a.get(m)??!1,onToggle:o,originalEval:x.evalId!=null?s.find(v=>v.id===x.evalId):void 0},m))})]})}function BC(){var A;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:x,retryEvalsSave:m}=zn(),{aiEditLoading:v,aiEditResult:y,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:C,aiEditEvalChanges:k,aiEditEvalSelections:w,aiEditEvalsRetry:T}=t,[N,L]=p.useState(""),{config:_}=Fa(),[D,F]=p.useState("claude-cli"),[E,O]=p.useState("opus"),M=p.useRef(null);p.useEffect(()=>{var B;(B=M.current)==null||B.focus()},[]),p.useEffect(()=>{if(!_)return;_.providers.find(V=>V.id==="claude-cli"&&V.available)&&(F("claude-cli"),O("opus"))},[_]);const U=_==null?void 0:_.providers.find(B=>B.id===D&&B.available),$=p.useCallback(()=>{const B=N.trim();!B||v||s(B,D,E)},[N,v,s,D,E]),Y=p.useCallback(B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),$()),B.key==="Escape"&&(B.preventDefault(),v?u():c())},[$,v,u,c]),X=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),ee=y?Jo(t.skillContent,y.improved):[],I=((A=t.evals)==null?void 0:A.evals)??[];return r.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),r.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:B=>{B.currentTarget.style.background="var(--surface-3)"},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-4 py-3",children:[!y&&r.jsxs(r.Fragment,{children:[r.jsx("textarea",{ref:M,value:N,onChange:B=>L(B.target.value),onKeyDown:Y,placeholder:"e.g., Add an error handling section...",disabled:v,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}}),r.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:D,onChange:B=>{F(B.target.value);const V=_==null?void 0:_.providers.find(H=>H.id===B.target.value);V!=null&&V.models[0]&&O(V.models[0].id)},disabled:v,style:{width:"100%"},children:_==null?void 0:_.providers.filter(B=>B.available).map(B=>r.jsx("option",{value:B.id,children:B.label},B.id))})]}),r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:E,onChange:B=>O(B.target.value),disabled:v,style:{width:"100%"},children:U==null?void 0:U.models.map(B=>r.jsx("option",{value:B.id,children:B.label},B.id))})]}),r.jsx("div",{className:"flex-1"}),v?r.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):r.jsx("button",{onClick:$,disabled:!N.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),v&&C.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(ai,{entries:C,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(ec,{error:S,onRetry:X,onDismiss:c}):r.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),y&&r.jsxs("div",{className:"animate-fade-in",children:[y.reasoning&&r.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:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),y.reasoning]}),r.jsx("div",{className:"mb-1",children:r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:ee.map((B,V)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:B.type==="added"?"rgba(34,197,94,0.1)":B.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:B.type==="added"?"var(--green)":B.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:B.type==="added"?"3px solid var(--green)":B.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:B.type==="added"?"+":B.type==="removed"?"-":" "}),B.content]},V))}),r.jsx(OC,{changes:k,selections:w,currentEvals:I,onToggle:d,onSelectAll:h,onDeselectAll:x}),T&&r.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:[r.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),r.jsx("button",{onClick:m,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),r.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function IC(t,a){const[s,o]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[x,m]=p.useState(!1),[v,y]=p.useState(null),b=p.useCallback(async()=>{try{const k=await Se.getSkillFiles(t,a);o(k.files)}catch{o([])}},[t,a]);p.useEffect(()=>{u("SKILL.md"),h(null),y(null),b()},[t,a,b]);const S=p.useCallback(async k=>{if(u(k),k==="SKILL.md"){h(null),y(null);return}m(!0),y(null);try{const w=await Se.getSkillFile(t,a,k);h(w)}catch(w){y(`Unable to open file: ${w.message}`),h(null)}finally{m(!1)}},[t,a]),C=p.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:x,error:v,selectFile:S,refresh:C,isSkillMd:c==="SKILL.md"}}function UC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function HC(t){const a=[],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&&a.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 a}function My({expanded:t}){return r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Ly(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.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 $C(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function PC(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"23 4 23 10 17 10"}),r.jsx("polyline",{points:"1 20 1 14 7 14"}),r.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 zy({node:t,depth:a,activeFile:s,onSelect:o}){const[c,u]=p.useState(!0),d=t.path===s;return t.type==="dir"?r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*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:[r.jsx(My,{expanded:c}),r.jsx(Ly,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(zy,{node:h,depth:a+1,activeFile:s,onSelect:o},h.path))]}):r.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*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:[r.jsx("span",{style:{width:10}}),r.jsx($C,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:UC(t.size)})]})}function VC({files:t,activeFile:a,onSelect:s,onRefresh:o}){const[c,u]=p.useState(!1),d=p.useMemo(()=>HC(t),[t]);return r.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[r.jsx(My,{expanded:c}),r.jsx(Ly,{}),r.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r.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:r.jsx(PC,{})})]}),c&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>r.jsx(zy,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function jo(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 GC(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Vg({content:t}){return r.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 Fg({content:t,fileType:a}){if(a==="json"){const s=FC(t);return r.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 a==="md"?r.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:Zo(t)}}):r.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 Gg(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").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,"&").replace(/</g,"<").replace(/>/g,">")}}function WC({file:t,loading:a,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[x,m]=p.useState(o),[v,y]=p.useState(!1),[b,S]=p.useState(""),[C,k]=p.useState(!1),[w,T]=p.useState(null),N=o!==x?o:x;p.useEffect(()=>{h==null||h(v)},[v,h]);const L=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),y(!0))},[t]),_=p.useCallback(()=>{y(!1)},[]),D=p.useCallback(async()=>{if(!(!c||!u||!t)){k(!0);try{await Se.saveSkillFile(c,u,t.path,b),T("Saved"),y(!1),d==null||d(),setTimeout(()=>T(null),2e3)}catch(O){T(`Save failed: ${O.message}`),setTimeout(()=>T(null),3e3)}finally{k(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!v)return;const O=M=>{(M.ctrlKey||M.metaKey)&&M.key==="s"&&(M.preventDefault(),D())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[v,D]),a)return r.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return r.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:r.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),r.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return r.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",jo(t.size),") — cannot be displayed"]});const F=t.content??"",E=GC(t.path);return r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&r.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 ",jo(512*1024)," — ",jo(t.size)," total"]}),r.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(O=>r.jsx("button",{onClick:()=>m(O),style:{padding:"2px 8px",fontSize:11,background:N===O?"var(--accent-muted)":"none",color:N===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[jo(t.size),c&&u&&!t.binary&&!v&&r.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"}),v&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:D,disabled:C,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:C?.6:1},children:C?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),w&&r.jsx("div",{style:{padding:"4px 12px",background:w.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:w.startsWith("Save failed")?"var(--red)":"var(--green)"},children:w}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:v?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[r.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}}),r.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:[r.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),r.jsx("button",{onClick:D,disabled:C,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:C?.6:1},children:C?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):N==="split"&&E!=="other"?r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:r.jsx(Vg,{content:F})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:E==="json"?r.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:Gg(F)}}):r.jsx(Fg,{content:F,fileType:E})})]}):N==="preview"&&E!=="other"?E==="json"?r.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:Gg(F)}}):r.jsx(Fg,{content:F,fileType:E}):r.jsx(Vg,{content:F})})]})}const qC=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,YC=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function KC(t){const a=t.trim();if(!a)throw new Error("normalizeRemoteUrl: empty input");let s=a.match(qC);if(s)return`https://github.com/${s[1]}/${s[2]}`;if(s=a.match(YC),s)return`https://github.com/${s[1]}/${s[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${t}`)}function Dy(t){const a=KC(t);return`https://verified-skill.com/submit?repo=${encodeURIComponent(a)}`}function Wg(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function XC({remoteUrl:t,fileCount:a,provider:s,model:o,onClose:c}){const[u,d]=p.useState(""),[h,x]=p.useState(!1),[m,v]=p.useState(!1),[y,b]=p.useState(null),S=p.useCallback(async()=>{x(!0),b(null);try{const w=await Se.gitCommitMessage({provider:s,model:o});d(w.message)}catch(w){const T=w instanceof Error?w.message:String(w);b(T)}finally{x(!1)}},[s,o]);p.useEffect(()=>{S()},[]);const C=p.useCallback(async()=>{const w=u.trim();if(!(!w||m)){v(!0);try{const T=await Se.gitPublish({commitMessage:w}),N=T.remoteUrl??t,L=Dy(N);window.open(L,"_blank","noopener,noreferrer");const _=(T.commitSha??"").slice(0,7),D=T.branch??"";Wg(`Opening verified-skill.com — ${_} on ${D}`,"info"),c()}catch(T){const N=T instanceof Error?T.message:String(T),L=N.length>200?N.slice(0,200)+"…":N;Wg(`Publish failed: ${L}`,"error")}finally{v(!1)}}},[u,m,t,c]),k=u.trim().length>0&&!m&&!h;return r.jsxs("div",{role:"dialog","aria-label":"Publish",style:{position:"fixed",right:16,bottom:16,width:420,maxWidth:"calc(100vw - 32px)",background:"var(--bg-elevated, #1a1a1a)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:14,boxShadow:"0 8px 32px rgba(0,0,0,0.4)",zIndex:1e3,fontSize:12,color:"var(--text-primary)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[r.jsx("strong",{style:{fontSize:13},children:"Publish"}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[a," file",a===1?"":"s"," changed"]})]}),r.jsx("label",{htmlFor:"commit-message",style:{display:"block",marginBottom:4,color:"var(--text-secondary)"},children:"Commit message"}),r.jsx("textarea",{id:"commit-message",value:u,onChange:w=>d(w.target.value),rows:5,disabled:h,placeholder:h?"Generating with AI…":"Enter a commit message",style:{width:"100%",background:"var(--bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"6px 8px",fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-primary)",resize:"vertical"}}),y&&r.jsxs("div",{style:{color:"var(--error, #f87171)",marginTop:6,fontSize:11},children:["AI generation failed: ",y]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:10},children:[r.jsx("button",{type:"button","aria-label":"Regenerate",onClick:S,disabled:h||m,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:h?"Generating…":"Regenerate"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("button",{type:"button","aria-label":"Cancel",onClick:c,disabled:m,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:"Cancel"}),r.jsx("button",{type:"button","aria-label":"Commit & Push",onClick:C,disabled:!k,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:m?"Publishing…":"Commit & Push"})]})]})]})}function qg(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function QC({remoteUrl:t,provider:a,model:s}){const[o,c]=p.useState(!1),[u,d]=p.useState(!1),[h,x]=p.useState(0),m=p.useCallback(async()=>{if(!(o||u)){c(!0);try{let y=!1,b=0;try{const N=await Se.gitDiff();y=!!N.hasChanges,b=N.fileCount??0}catch{}if(y){x(b),d(!0);return}const S=await Se.gitPublish(),C=S.remoteUrl??t,k=Dy(C);window.open(k,"_blank","noopener,noreferrer");const w=(S.commitSha??"").slice(0,7),T=S.branch??"";qg(`Opening verified-skill.com — ${w} on ${T}`,"info")}catch(y){const b=y instanceof Error?y.message:String(y),S=b.length>200?b.slice(0,200)+"…":b;qg(`Publish failed: ${S}`,"error")}finally{c(!1)}}},[o,u,t]),v=p.useCallback(()=>d(!1),[]);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Publish",onClick:m,disabled:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},title:"Push committed changes and open verified-skill.com to submit",children:o?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Publishing…"]}):"Publish"}),u&&r.jsx(XC,{remoteUrl:t,fileCount:h,provider:a,model:s,onClose:v})]})}const ZC={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function JC(){const[t,a]=p.useState(ZC);return p.useEffect(()=>{let s=!1;return Se.gitRemote().then(o=>{s||a({hasRemote:!!o.hasRemote,remoteUrl:o.remoteUrl??null,branch:o.branch??null,loading:!1,error:null})}).catch(o=>{s||a({hasRemote:!1,remoteUrl:null,branch:null,loading:!1,error:o instanceof Error?o:new Error(String(o))})}),()=>{s=!0}},[]),t}function eE({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function tE({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),r.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function nE({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function rE({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}function Dd({size:t=15}){return r.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function aE(){const{state:t,dispatch:a,saveContent:s,isReadOnly:o}=zn(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:x,aiEditOpen:m}=t,[v,y]=p.useState("split"),[b,S]=p.useState(!1),C=p.useRef(null),[k,w]=p.useState(!1),[T,N]=p.useState(""),[L,_]=p.useState(!1),[D,F]=p.useState(null),[E,O]=p.useState([]),[M,U]=p.useState([]),[$,Y]=p.useState(null),X=p.useRef(null),{config:ee}=Fa(),I=JC(),{files:A,activeFile:B,secondaryContent:V,loading:H,error:re,selectFile:z,refresh:W,isSkillMd:te}=IC(c??"",u??""),[q,oe]=p.useState(!1),le=p.useCallback(ye=>{q&&!window.confirm("You have unsaved changes. Discard?")||z(ye)},[q,z]);p.useEffect(()=>()=>{var ye;(ye=X.current)==null||ye.abort()},[]);const{metadata:ve,body:ce}=NC(d),be=ve["allowed-tools"],Re=Array.isArray(be)?be:typeof be=="string"?[be]:[],Ae=ve.name,se=ve.description,he=ve.metadata,pe=typeof he=="object"&&!Array.isArray(he)?he:null,xe=ve.version||(pe==null?void 0:pe.version),je=ve.tags||(pe==null?void 0:pe.tags),Be=Array.isArray(je)?je:typeof je=="string"?je.split(",").map(ye=>ye.trim()).filter(Boolean):[],Ue=new Set(["name","description","metadata","allowed-tools","version","tags"]),gt=Object.entries(ve).filter(([ye])=>!Ue.has(ye)),Lt=p.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),st=p.useCallback(ye=>{(ye.ctrlKey||ye.metaKey)&&ye.key==="s"&&(ye.preventDefault(),ye.stopPropagation(),h&&Lt()),(ye.ctrlKey||ye.metaKey)&&ye.key==="k"&&(ye.preventDefault(),ye.stopPropagation(),a({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,Lt,m,a]),Et=p.useCallback(async()=>{var ht,zt;if(!T.trim())return;(ht=X.current)==null||ht.abort();const ye=new AbortController;X.current=ye,_(!0),Y(null),U([]),F(null),O([]);try{const Ot=(ee==null?void 0:ee.provider)||"claude-cli",Dn=(ee==null?void 0:ee.model)||"sonnet",Nt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:T,provider:Ot,model:Dn}),signal:ye.signal});if(!Nt.ok||!Nt.body){let rr=`HTTP ${Nt.status}`;try{const ar=await Nt.json();ar.error&&(rr=ar.error)}catch{}throw new Error(rr)}const _n=Nt.body.getReader(),Pt=new TextDecoder;let Tt="",it="";for(;;){const{done:rr,value:ar}=await _n.read();if(rr)break;Tt+=Pt.decode(ar,{stream:!0});const hr=Tt.split(`
|
|
79
|
-
`);Tt=hr.pop()||"";for(const pn of hr)if(pn.startsWith("event: "))it=pn.slice(7).trim();else if(pn.startsWith("data: ")){try{const Rt=JSON.parse(pn.slice(6));if(it==="progress")U(De=>[...De,{phase:Rt.phase,message:Rt.message,timestamp:Date.now()}]);else if(it==="done"||it==="complete"){const De=["---"];Rt.name&&De.push(`name: ${Rt.name}`),Rt.description&&De.push(`description: "${Rt.description.replace(/"/g,'\\"')}"`),Rt.model&&De.push(`model: ${Rt.model}`),(zt=Rt.allowedTools)!=null&&zt.trim()&&De.push(`allowed-tools: ${Rt.allowedTools.trim()}`),De.push("---","",Rt.body||"");const ot=De.join(`
|
|
80
|
-
`);F(ot),O(Jo(d,ot)),_(!1)}else it==="error"&&(Y(Rt.message||Rt.description||"Generation failed"),_(!1))}catch{}it=""}}}catch(Ot){Ot.name!=="AbortError"&&Y(Ot.message)}finally{_(!1),X.current=null}},[T,ee,d]),Yt=p.useCallback(()=>{D&&a({type:"SET_CONTENT",content:D}),w(!1),F(null),O([]),N(""),U([])},[D,a]),Ye=p.useCallback(()=>{w(!1),F(null),O([]),N(""),U([]),Y(null)},[]),vt=p.useCallback(()=>{var ye;k?((ye=X.current)==null||ye.abort(),Ye()):(m&&a({type:"CLOSE_AI_EDIT"}),w(!0))},[k,m,a,Ye]),bn=[{mode:"raw",icon:r.jsx(eE,{}),label:"Editor"},{mode:"split",icon:r.jsx(tE,{}),label:"Split"},{mode:"preview",icon:r.jsx(nE,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:st,tabIndex:-1,children:[r.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:[r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:bn.map(({mode:ye,icon:ht,label:zt})=>r.jsxs("button",{onClick:()=>y(ye),title:zt,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:v===ye?"var(--surface-4)":"transparent",color:v===ye?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:v===ye?600:400,border:"none",cursor:"pointer"},children:[ht,r.jsx("span",{style:{letterSpacing:"0.01em"},children:zt})]},ye))}),te?o?r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{m?a({type:"CLOSE_AI_EDIT"}):(k&&Ye(),a({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:[r.jsx(rE,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:vt,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:k?600:400,border:"none",cursor:"pointer",color:k?"var(--purple)":"var(--text-tertiary)",background:k?"var(--purple-muted)":"transparent"},children:[r.jsx(Dd,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&r.jsx("button",{onClick:()=>a({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),r.jsx("button",{onClick:Lt,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"}),I.hasRemote&&I.remoteUrl&&r.jsx(QC,{remoteUrl:I.remoteUrl,provider:ee==null?void 0:ee.provider,model:ee==null?void 0:ee.model})]}):null]}),c&&u&&r.jsx(VC,{files:A,activeFile:B,onSelect:le,onRefresh:W}),!te&&r.jsx(WC,{file:V,loading:H,error:re,viewMode:v,plugin:c??void 0,skill:u??void 0,onSaved:()=>{z(B),W()},onDirtyChange:oe}),te&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:v==="raw"||v==="preview"?"1fr":"1fr 1fr"},children:[v!=="preview"&&r.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:v==="split"?"1px solid var(--border-subtle)":"none"},children:r.jsx("textarea",{ref:C,value:d,onChange:ye=>{o||a({type:"SET_CONTENT",content:ye.target.value})},onKeyDown:st,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}})}),v!=="raw"&&r.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:r.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Ae||xe||se)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Ae&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Ae}),xe&&r.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",xe]})]}),se&&r.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:se})]}),Be.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:Be.map(ye=>r.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:ye},ye))}),Re.length>0&&r.jsx("div",{style:{marginBottom:16},children:r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),Re.map(ye=>r.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:ye},ye))]})}),gt.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:gt.map(([ye,ht],zt)=>{const Ot=Array.isArray(ht)?ht.join(", "):typeof ht=="object"?Object.entries(ht).map(([Dn,Nt])=>`${Dn}: ${Array.isArray(Nt)?Nt.join(", "):Nt}`).join(" | "):ht;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:zt>0?"1px solid var(--border-subtle)":"none"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:ye}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Ot})]},ye)})}),(Ae||se||Be.length>0||Re.length>0||gt.length>0)&&ce&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ce&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Zo(ce)}})]})})]}),te&&m&&r.jsx(BC,{}),te&&k&&r.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:r.jsxs("div",{className:"px-4 py-3",children:[!D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Dd,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),r.jsx("div",{className:"flex gap-2 mb-2",children:r.jsx("textarea",{value:T,onChange:ye=>N(ye.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:ye=>{ye.key==="Enter"&&(ye.ctrlKey||ye.metaKey)&&T.trim()&&!L&&(ye.preventDefault(),Et())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[L?r.jsx("button",{onClick:()=>{var ye;(ye=X.current)==null||ye.abort(),_(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:Et,disabled:!T.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Ye,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),L&&M.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(ai,{entries:M,isRunning:!0})}),$&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[$,r.jsx("button",{onClick:Et,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Dd,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:E.map((ye,ht)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:ye.type==="added"?"var(--green-muted)":ye.type==="removed"?"var(--red-muted)":"transparent",color:ye.type==="added"?"var(--green)":ye.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:ye.type==="added"?"3px solid var(--green)":ye.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:ye.type==="added"?"+":ye.type==="removed"?"-":" "}),ye.content]},ht))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:Yt,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:Ye,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),te&&x!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(AC,{plugin:c,skill:u,skillContent:d,onApplied:ye=>{a({type:"SET_CONTENT",content:ye}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Ml(t){return t.testType==="integration"?"integration":"unit"}function Ol(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function _y(t){const a=new Date(t);return a.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function Oy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const lE=new Set(["benchmark","comparison","baseline"]);function Yg(t,a,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(a-o*2),x=o+(s-o*2)-c*(s-o*2);return`${h},${x}`})}function By({entries:t}){const a=t.filter(y=>lE.has(y.type)).slice().reverse(),s=a.map((y,b,S)=>({rate:y.pass_rate,idx:b,total:S.length})).filter((y,b)=>{const S=a[b].type;return S==="benchmark"||S==="comparison"}),o=a.flatMap((y,b)=>y.type==="baseline"?[{rate:y.pass_rate,idx:b,total:a.length}]:y.type==="comparison"&&y.baselinePassRate!=null?[{rate:y.baselinePassRate,idx:b,total:a.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Yg(s,c,u,d):[],x=o.length>=2?Yg(o,c,u,d):[],m=h[h.length-1],v=x[x.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[x.length>0&&r.jsx("polyline",{points:x.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&r.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),v&&r.jsx("circle",{cx:parseFloat(v.split(",")[0]),cy:parseFloat(v.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),m&&r.jsx("circle",{cx:parseFloat(m.split(",")[0]),cy:parseFloat(m.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Iy(t,a,s){const o=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const m=c.length>0?` Met criteria: ${c.map(v=>v.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(y=>y.criterion).join(", ")}.`:"",v=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return v.length===0&&v.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:v}}if(t==="INEFFECTIVE"){if(o<.2){const v=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.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:v}}const m=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.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(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`),...u.map(v=>`Improve "${v.criterion}" (score: ${v.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(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.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(", ")}.`:"",x=d.length>0?` Needs improvement: ${d.map(m=>m.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${x}`}}const Uy={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function sE(t){return Object.hasOwn(Uy,t)}function iE(t){return sE(t)?Uy[t]:t}function oE(){const{state:t}=zn(),{plugin:a,skill:s}=t,[o,c]=p.useState([]),[u,d]=p.useState([]),[h,x]=p.useState(!0),[m,v]=p.useState(null),[y,b]=p.useState(new Set),[S,C]=p.useState({}),[k,w]=p.useState(null),[T,N]=p.useState(""),[L,_]=p.useState(!1),[D,F]=p.useState(""),[E,O]=p.useState(""),M=p.useCallback(async()=>{x(!0),v(null);try{const[I,A]=await Promise.all([Se.getCredentials(a,s),Se.getParams(a,s)]);c(I.credentials),d(A.params)}catch(I){v(I instanceof Error?I.message:"Failed to load parameters"),c([]),d([])}finally{x(!1)}},[a,s]);p.useEffect(()=>{M()},[M]);const U=p.useCallback(async(I,A)=>{_(!0),v(null);try{await Se.setCredential(a,s,I,A),w(null),N(""),await M()}catch(B){v(B instanceof Error?B.message:`Failed to save ${I}`)}finally{_(!1)}},[a,s,M]),$=p.useCallback(async()=>{const I=D.trim().toUpperCase(),A=E.trim();if(!(!I||!A)){_(!0),v(null);try{await Se.setCredential(a,s,I,A),F(""),O(""),await M()}catch(B){v(B instanceof Error?B.message:`Failed to add ${I}`)}finally{_(!1)}}},[a,s,D,E,M]),Y=p.useCallback(async I=>{if(y.has(I)){b(A=>{const B=new Set(A);return B.delete(I),B}),C(A=>{const B={...A};return delete B[I],B});return}try{const B=(await Se.getParamsRevealed(a,s,I)).params.find(V=>V.name===I);B!=null&&B.value&&(C(V=>({...V,[I]:B.value})),b(V=>new Set(V).add(I)))}catch{}},[a,s,y]),X=new Set(o.map(I=>I.name)),ee=[...o.map(I=>{const A=u.find(B=>B.name===I.name);return{name:I.name,status:I.status,maskedValue:(A==null?void 0:A.maskedValue)??""}}),...u.filter(I=>!X.has(I.name)).map(I=>({name:I.name,status:I.status,maskedValue:I.maskedValue}))];return r.jsxs("div",{className:"py-2 px-3",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),m&&r.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&&ee.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&ee.length===0&&!m&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),ee.map(I=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:I.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:I.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:I.status==="ready"?"var(--green)":"var(--red)"},children:I.status}),(I.maskedValue||I.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[y.has(I.name)?S[I.name]??I.maskedValue:I.maskedValue||"***",r.jsx("button",{onClick:()=>Y(I.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${y.has(I.name)?"Hide":"Reveal"} value for ${I.name}`,children:y.has(I.name)?"hide":"show"})]}),k===I.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:T,onChange:A=>N(A.target.value),onKeyDown:A=>{A.key==="Enter"&&T.trim()&&U(I.name,T)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${I.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>U(I.name,T),disabled:L||!T.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{w(null),N("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{w(I.name),N("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},I.name)),r.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:D,onChange:I=>F(I.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:E,onChange:I=>O(I.target.value),onKeyDown:I=>{I.key==="Enter"&&D.trim()&&E.trim()&&$()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:$,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"})]})]})]})}const _s="This is an installed copy (read-only). Open the source skill to edit.";function cE(t,a,s){const[o,c]=p.useState(null),[u,d]=p.useState(!1),h=p.useRef("");p.useEffect(()=>{const m=`${t}/${a}/${s}`;h.current!==m&&(h.current=m,d(!0),Se.getCaseHistory(t,a,s).then(v=>c(v)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const x=p.useCallback(()=>{d(!0),h.current="",Se.getCaseHistory(t,a,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:o,loading:u,refetch:x}}function uE(t,a,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(x=>x.assertions.find(m=>m.id===t)).filter(Boolean);if(u.length>=2){const m=u.filter(v=>v.pass).length/u.length;m>=.3&&m<=.7&&(o.flaky=!0)}const d=s.find(x=>x.type==="benchmark"),h=s.find(x=>x.type==="baseline");if(d&&h){const x=d.assertions.find(v=>v.id===t),m=h.assertions.find(v=>v.id===t);x!=null&&x.pass&&(m!=null&&m.pass)&&(o.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const m=s[0].assertions.find(v=>v.id===t);m!=null&&m.pass&&(o.regression=!0)}return o}function dE(){var V;const{state:t,dispatch:a,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:x}=zn(),{evals:m,evalsError:v,selectedCaseId:y,inlineResults:b,caseRunStates:S,generateEvalsLoading:C,generateEvalsProgress:k,generateEvalsError:w}=t,T=p.useMemo(()=>{for(const H of S.values())if(H.status==="running"||H.status==="queued")return!0;return!1},[S]),[N,L]=p.useState(!1),[_,D]=p.useState("all"),F={skill_name:t.skill,evals:[]},E=m??F,O=E.evals,M=p.useMemo(()=>_==="all"?O:O.filter(H=>Ml(H)===_),[_,O]),U=M.find(H=>H.id===y)??null;p.useEffect(()=>{y!==null&&!M.find(H=>H.id===y)&&a({type:"SELECT_CASE",caseId:M.length>0?M[0].id:null})},[M,y,a]);const[$,Y]=p.useState([]),X=p.useMemo(()=>O.some(H=>Ml(H)==="integration"),[O]);p.useEffect(()=>{X&&Se.getCredentials(t.plugin,t.skill).then(H=>Y(H.credentials)).catch(()=>Y([]))},[t.plugin,t.skill,X]);const ee=p.useMemo(()=>new Set($.filter(H=>H.status==="missing").map(H=>H.name)),[$]),[I,A]=p.useState(!1),B=p.useCallback(H=>{A(!1),h(H?{testType:H}:void 0)},[h]);return!m||O.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:v?"var(--red-muted)":"var(--accent-muted)"},children:v?r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9 11l3 3L22 4"}),r.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),r.jsx("div",{className:"text-center",children:v?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),r.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:v}),r.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"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>L(!0),disabled:x,title:x?_s:void 0,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{className:"flex",children:[r.jsx("button",{onClick:()=>B("unit"),disabled:C||x,title:x?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:C?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),r.jsx("button",{onClick:()=>A(!I),disabled:C||x,title:x?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),I&&r.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:r.jsx("button",{onClick:()=>B("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:H=>{H.currentTarget.style.background="var(--surface-2)"},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),C&&k.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ai,{entries:k,isRunning:!0})}),w&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ec,{error:w,onRetry:()=>B()})}),N&&r.jsx(Kg,{evals:E,onSave:H=>{s(H),L(!1)},onCancel:()=>L(!1)})]}):r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[r.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.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:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",M.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:T?r.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"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>c("benchmark"),disabled:M.length===0||x,title:x?_s:void 0,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),r.jsx("button",{onClick:()=>c("comparison"),disabled:M.length===0||x,title:x?_s:void 0,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),r.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(H=>r.jsx("button",{onClick:()=>D(H),style:{padding:"2px 8px",fontSize:10,fontWeight:_===H?600:400,background:_===H?"var(--accent-muted)":"transparent",color:_===H?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:H==="all"?`All (${O.length})`:H==="unit"?`Unit (${O.filter(re=>Ml(re)==="unit").length})`:`Integration (${O.filter(re=>Ml(re)==="integration").length})`},H))}),r.jsxs("div",{className:"py-1",children:[M.length===0&&O.length>0&&r.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",_==="all"?"":_+" ","tests yet"]}),M.map(H=>{var te;const re=b.get(H.id),z=y===H.id,W=Ml(H);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:H.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:z?"var(--accent-muted)":"transparent",borderLeft:z?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:q=>{z||(q.currentTarget.style.background="var(--surface-2)")},onMouseLeave:q=>{z||(q.currentTarget.style.background="transparent")},children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:z?"var(--text-primary)":"var(--text-secondary)"},children:["#",H.id," ",H.name,r.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:W==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:W==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:W==="unit"?"U":"I"}),W==="integration"&&((te=H.requiredCredentials)==null?void 0:te.some(q=>ee.has(q)))&&r.jsx("span",{title:"Configure credentials to run",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),r.jsx(Hy,{result:re})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[H.assertions.length," assertion",H.assertions.length!==1?"s":"",(re==null?void 0:re.passRate)!=null&&r.jsx(mE,{passRate:re.passRate})]})]},H.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!x&&r.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:H=>{H.currentTarget.style.borderColor="var(--accent)",H.currentTarget.style.color="var(--accent)"},onMouseLeave:H=>{H.currentTarget.style.borderColor="var(--border-default)",H.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(oE,{})})]}),r.jsx("div",{className:"overflow-auto",children:U?r.jsx(fE,{evalCase:U,result:b.get(U.id),evals:m,caseStatus:((V=S.get(U.id))==null?void 0:V.status)??"idle",onSaveEvals:s,onRun:H=>o(H,"benchmark"),onCompare:H=>o(H,"comparison"),onCancel:H=>u(H),onImprove:H=>a({type:"OPEN_IMPROVE",evalId:H})}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),N&&r.jsx(Kg,{evals:E,onSave:H=>{s(H),L(!1)},onCancel:()=>L(!1)})]})}function fE({evalCase:t,result:a,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:x}){const{state:m,isReadOnly:v}=zn(),{plugin:y,skill:b}=m,{entries:S,loading:C}=cE(y,b,t.id),[k,w]=p.useState(!1),[T,N]=p.useState(t.prompt),[L,_]=p.useState(!1),[D,F]=p.useState(t.expected_output);p.useState(()=>{N(t.prompt),F(t.expected_output)});const E=p.useCallback(H=>{c({...s,evals:s.evals.map(re=>re.id===H.id?H:re)})},[s,c]),O=p.useCallback(()=>{E({...t,prompt:T}),w(!1)},[t,T,E]),M=p.useCallback(()=>{E({...t,expected_output:D}),_(!1)},[t,D,E]),U=p.useCallback(()=>{E({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,E]),$=p.useCallback((H,re)=>{E({...t,assertions:t.assertions.map(z=>z.id===H?{...z,text:re}:z)})},[t,E]),Y=p.useCallback(H=>{E({...t,assertions:t.assertions.filter(re=>re.id!==H)})},[t,E]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(H=>H.id!==t.id)})},[s,t.id,c]),ee=a&&a.assertions.length>0&&a.assertions.every(H=>H.pass),I=a&&a.assertions.some(H=>!H.pass),A=Ml(t),B=t.requiredCredentials??[],V=A==="integration"&&B.length>0;return r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[r.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[r.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]}),v?r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:A==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:A==="unit"?"var(--accent)":"var(--orange)"},children:A==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((A==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:re,requirements:z,cleanup:W,...te}=t;E({...te,testType:"unit"})}else E({...t,testType:"integration"})},title:`Click to switch to ${A==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:A==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:A==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:A==="unit"?"Unit":"Integration"}),r.jsx(Hy,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?r.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:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>u(t.id),disabled:v,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),r.jsx("button",{onClick:()=>d(t.id),disabled:v,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),I&&!v&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:()=>x(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!v&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.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"})]})})]})]}),v&&A==="integration"&&r.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:[r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),ee&&r.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:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),V&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:B.map(H=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:H},H))})]}),!v&&A==="integration"&&r.jsx(gE,{evalCase:t,onUpdate:E}),r.jsx(So,{title:"Prompt",children:k?r.jsxs("div",{children:[r.jsx("textarea",{value:T,onChange:H=>N(H.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{N(t.prompt),w(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.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:v?"default":"pointer"},onClick:()=>{v||w(!0)},onMouseEnter:H=>{v||(H.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:H=>{H.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:v?"No prompt":"Click to edit prompt..."})})}),r.jsx(So,{title:"Expected Output",children:L?r.jsxs("div",{children:[r.jsx("textarea",{value:D,onChange:H=>F(H.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:M,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{F(t.expected_output),_(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.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:v?"default":"pointer"},onClick:()=>{v||_(!0)},onMouseEnter:H=>{v||(H.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:H=>{H.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:v?"No expected output":"Click to edit expected output..."})})}),r.jsx(So,{title:`Assertions (${t.assertions.length})`,action:v?void 0:r.jsx("button",{onClick:U,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?r.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):r.jsx("div",{className:"space-y-2",children:t.assertions.map(H=>{const re=a==null?void 0:a.assertions.find(W=>W.assertion_id===H.id),z=uE(H.id,re,S);return r.jsx(pE,{assertion:H,result:re,badges:z,isReadOnly:v,onUpdate:W=>$(H.id,W),onDelete:()=>Y(H.id)},H.id)})})}),(a==null?void 0:a.output)&&r.jsx(hE,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const H=Iy("INEFFECTIVE",a.passRate);return H.recommendations&&H.recommendations.length>0?r.jsx(So,{title:"Recommendations",children:r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),r.jsx("ul",{className:"space-y-1.5 ml-1",children:H.recommendations.map((re,z)=>r.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),re]},z))})]})}):null})(),r.jsx(xE,{evalId:t.id,sharedEntries:S,sharedLoading:C})]},t.id)}function pE({assertion:t,result:a,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[x,m]=p.useState(t.text),[v,y]=p.useState(!1),b=()=>{c(x),h(!1)};return r.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:r.jsxs("div",{className:"flex items-start gap-2",children:[a?r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):r.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)&&r.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:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&r.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)&&r.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?r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:x,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}),r.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(m(t.text),h(!0))},children:t.text}),(a==null?void 0:a.reasoning)&&r.jsx("button",{onClick:()=>y(!v),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:v?"Hide reasoning":"Show reasoning"}),v&&(a==null?void 0:a.reasoning)&&r.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:a.reasoning})]}),!o&&r.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:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function So({title:t,action:a,children:s}){return r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a]}),s]})}function Hy({result:t}){const[a,s]=p.useState(!1);if(!t||t.status==null)return r.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=Iy(o?"PASS":"FAIL",c);return r.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":a?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,a&&r.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 mE({passRate:t}){const a=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:r.jsx("div",{className:"h-full rounded-full",style:{width:`${a}%`,background:a>=80?"var(--green)":a>=50?"var(--yellow)":"var(--red)"}})})})}function hE({output:t,durationMs:a,tokens:s}){const[o,c]=p.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.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:[r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",a!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",(a/1e3).toFixed(1),"s)"]}),s!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&r.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 _d(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Od({entry:t}){return r.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:_y(t.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),r.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}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ol(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),r.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&&r.jsx("span",{children:Oy(t.durationMs)}),t.tokens!=null&&r.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const a=t.pass_rate-t.baselinePassRate,s=a>.001?"skill":a<-.001?"baseline":"tie",o=a>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:a>=0?"var(--green)":"var(--red)"},children:[o,(a*100).toFixed(1),"%"]}),r.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),r.jsx("div",{className:"space-y-0.5",children:t.assertions.map(a=>r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a.text})]},a.id))})]})}function xE({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:o,dispatch:c}=zn(),{plugin:u,skill:d}=o,[h,x]=p.useState(!0),m=a??null,v=s??!1,y=p.useCallback(()=>{x(k=>!k)},[]),b=m?m.slice(0,10):[],S=b.some(k=>{const w=_d(k.type);return w==="left"||w==="full"}),C=b.some(k=>{const w=_d(k.type);return w==="right"||w==="full"});return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:y,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:[r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",m&&m.length>0&&r.jsxs("span",{style:{fontWeight:400},children:["(",m.length," run",m.length!==1?"s":"",")"]})]}),h&&r.jsx("div",{className:"animate-fade-in",children:v?r.jsxs("div",{className:"flex items-center gap-2 py-3",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!m||m.length===0?r.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):r.jsxs("div",{children:[b.length>=2&&r.jsx("div",{className:"mb-2",children:r.jsx(By,{entries:b})}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!C&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((k,w)=>{const T=_d(k.type);return T==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(Od,{entry:k})},w):T==="left"?r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(Od,{entry:k})}),r.jsx("div",{style:{gridColumn:"2"}})]},w):r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(Od,{entry:k})})]},w)})]}),r.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:k=>{k.currentTarget.style.textDecoration="underline"},onMouseLeave:k=>{k.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function Kg({evals:t,onSave:a,onCancel:s}){const[o,c]=p.useState(""),[u,d]=p.useState(""),[h,x]=p.useState(""),[m,v]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[y,b]=p.useState("unit"),[S,C]=p.useState(""),[k,w]=p.useState([]),[T,N]=p.useState(""),[L,_]=p.useState(""),D=Math.max(0,...t.evals.map(M=>M.id))+1,F=M=>{b(M),M==="unit"&&(w([]),C(""),N(""),_(""))},E=()=>{const M=S.trim().toUpperCase();M&&!k.includes(M)&&w([...k,M]),C("")},O=()=>{if(!o.trim()||!u.trim())return;const M={id:D,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter(U=>U.text.trim()),...y==="integration"?{testType:"integration",...k.length>0?{requiredCredentials:k}:{},...T||L?{requirements:{...T?{platform:T}:{},...L?{chromeProfile:L}:{}}}:{}}:{}};a({...t,evals:[...t.evals,M]})};return r.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:r.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:[r.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),r.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(M=>r.jsx("button",{onClick:()=>F(M),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:y===M?M==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:y===M?M==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:M},M))})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),r.jsx("input",{value:o,onChange:M=>c(M.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),r.jsx("textarea",{value:u,onChange:M=>d(M.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),r.jsx("textarea",{value:h,onChange:M=>x(M.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),m.map((M,U)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:M.text,onChange:$=>v(m.map((Y,X)=>X===U?{...Y,text:$.target.value}:Y)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&r.jsx("button",{onClick:()=>v(m.filter(($,Y)=>Y!==U)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},M.id)),r.jsx("button",{onClick:()=>v([...m,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),y==="integration"&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:k.map(M=>r.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:[M,r.jsx("button",{onClick:()=>w(k.filter(U=>U!==M)),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},M))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:M=>C(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),E())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:E,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:T,onChange:M=>N(M.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:L,onChange:M=>_(M.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function gE({evalCase:t,onUpdate:a}){var d,h;const[s,o]=p.useState(""),c=()=>{const x=s.trim().toUpperCase();x&&!(t.requiredCredentials??[]).includes(x)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],x]}),o("")},u=x=>{const m=(t.requiredCredentials??[]).filter(v=>v!==x);a({...t,requiredCredentials:m.length>0?m:void 0})};return r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(x=>r.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:[x,r.jsx("button",{onClick:()=>u(x),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},x))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:x=>o(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),r.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:x=>a({...t,requirements:{...t.requirements,platform:x.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:x=>a({...t,requirements:{...t.requirements,chromeProfile:x.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Ln(t,a){return a==="free"?"Free":a==="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 $y(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function vE(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function yE(t,a){let s="";if(a){const c=new Date(a);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 bE(t,a,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)*a);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 Xg(t,a){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(a)}}function jE(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function SE(t,a){const s=t+a,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const kE={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function wE(t,a){if(!t)return null;const s=kE[t];if(s==null||s===0)return null;const o=s*a*.5,c=s*a*2;return`${Ln(o)}–${Ln(c)}`}function CE(){const{state:t,runCase:a,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=zn(),{evals:d,caseRunStates:h,bulkRunActive:x,latestBenchmark:m,inlineResults:v}=t,{config:y}=Fa(),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]),C=b.filter(E=>{const O=h.get(E.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,k=b.filter(E=>{const O=h.get(E.id);return O&&(O.status==="running"||O.status==="queued")}).length,w=p.useRef(null),[T,N]=p.useState(0);p.useEffect(()=>{if(S&&!w.current&&(w.current=Date.now()),!S){w.current=null,N(0);return}const E=setInterval(()=>{w.current&&N(Math.round((Date.now()-w.current)/1e3))},1e3);return()=>clearInterval(E)},[S]);const L=b.reduce((E,O)=>E+O.assertions.length,0),_=b.length+L,D=p.useMemo(()=>SE(b.length,L),[b.length,L]),F=p.useMemo(()=>wE((y==null?void 0:y.provider)??null,_),[y==null?void 0:y.provider,_]);return r.jsxs("div",{className:"p-5",children:[u&&r.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:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),r.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[k," running"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),r.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"}),r.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"}),r.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&&r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("span",{children:["Est. duration: ",D]}),F&&r.jsxs("span",{children:["Est. cost: ",F]}),!F&&(y==null?void 0:y.provider)&&(y.provider==="claude-cli"||y.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!F&&(y==null?void 0:y.provider)&&(y.provider==="ollama"||y.provider==="lm-studio"||y.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",C,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(C/b.length*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${C/b.length*100}%`,background:"var(--accent)"}})}),r.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",T>=60?`${Math.floor(T/60)}m ${T%60}s`:`${T}s`]}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:b.map(E=>{const O=v.get(E.id),M=h.get(E.id),U=(M==null?void 0:M.status)??"idle",$=m==null?void 0:m.cases.find(Y=>Y.eval_id===E.id);return r.jsx(NE,{name:E.name,evalId:E.id,result:O,caseCost:$==null?void 0:$.cost,caseBillingMode:$==null?void 0:$.billingMode,caseInputTokens:$==null?void 0:$.inputTokens,caseOutputTokens:$==null?void 0:$.outputTokens,caseStatus:U,runMode:(M==null?void 0:M.mode)??null,comparisonDetail:$==null?void 0:$.comparisonDetail,isReadOnly:u,onRun:Y=>a(Y,"benchmark"),onBaseline:Y=>a(Y,"baseline"),onCompare:Y=>a(Y,"comparison"),onCancel:Y=>o(Y)},E.id)})}),!S&&m&&m.cases.length>0&&r.jsxs("div",{className:"mt-5",children:[r.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:vE(m.type)}),r.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&&r.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: ${$y(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${Ln(m.totalCost)}`]}),m.overall_pass_rate>=.9999&&!m.comparison&&r.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&&r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const E=yE(m.model,m.timestamp);return E?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:E}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Qg,{label:"Skill",value:m.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(Qg,{label:"Baseline",value:m.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),r.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&&` | ${iE(m.verdict)}`]}),(()=>{const E=m.cases.reduce((M,U)=>M+U.assertions.length,0),O=bE(m.comparison.delta,E,m.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const EE={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 NE({name:t,evalId:a,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:x,comparisonDetail:m,isReadOnly:v,onRun:y,onBaseline:b,onCompare:S,onCancel:C}){const[k,w]=p.useState(!1),T=h==="running"||h==="queued",N=h==="complete"||h==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:T?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:T?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&r.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&r.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),r.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",a," ",t]}),x&&(T||N)&&(()=>{const L=EE[x];return L?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:L.bg,color:L.color,padding:"1px 6px"},children:L.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[T?r.jsx("button",{onClick:()=>C(a),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>S(a),disabled:v,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>y(a),disabled:v,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),r.jsx("button",{onClick:()=>b(a),disabled:v,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&r.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&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:$y(u,d)}),o!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Ln(o,c)}),h==="cancelled"&&r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"space-y-1",children:s.assertions.map(L=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:L.pass?"var(--green)":"var(--red)"},children:L.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:L.text})]},L.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>w(!k),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:k?"Hide output":"Show output"}),k&&s.output&&r.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&&r.jsx("div",{className:"px-4 pb-3",children:r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const L=Xg(m.skillContentScore,m.baselineContentScore),_=Xg(m.skillStructureScore,m.baselineStructureScore),D=jE(m.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",L.skill,"% / Baseline ",L.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",_.skill,"% / Baseline ",_.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsx("span",{style:{color:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&r.jsx(TE,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Bd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function TE({errorMessage:t,classifiedError:a}){const[s,o]=p.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?Bd[a.category]??Bd.unknown:Bd.unknown;return r.jsx("div",{className:"px-4 pb-3",children:r.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsx("span",{style:{fontSize:12},children:d}),r.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),r.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&&r.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&r.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 Qg({label:t,value:a,color:s}){return r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(a*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${a*100}%`,background:s}})})]})}const Zg={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 RE(){const{state:t,dispatch:a,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=zn(),{plugin:u,skill:d,activationPrompts:h,activationResults:x,activationSummary:m,activationRunning:v,activationError:y,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:C,generatingPromptsError:k,activationHistory:w}=t,{state:T}=nr(),N=T.skills.find(V=>V.plugin===u&&V.skill===d),L=(N==null?void 0:N.resolvedVersion)??(N==null?void 0:N.version)??null,[_,D]=p.useState(h),[F,E]=p.useState(null),[O,M]=p.useState(!1);p.useEffect(()=>{h&&h!==_&&D(h)},[h]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:_})},[_,a]),p.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(V=>V.json()).then(V=>E(V.rawContent||V.description||null)).catch(()=>E(null))},[u,d]);function U(){s(_)}function $(){c(8)}const Y=_.trim().split(`
|
|
81
|
-
`).filter(Boolean).length,X=x.filter(V=>V.classification==="TP"||V.classification==="TN"),ee=x.filter(V=>V.classification==="FP"||V.classification==="FN"),I=(F==null?void 0:F.replace(/^---[\s\S]*?---\s*/,"").trim())??null,A=_.trim().length>0,B=I?Zo(I):"";return r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),r.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."})]}),r.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[r.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),r.jsx("div",{className:"flex gap-1.5",children:r.jsx("button",{onClick:$,disabled:C||!I||v,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:C?"var(--surface-3)":"var(--surface-2)",color:I?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:I?void 0:"No skill description available",onMouseEnter:V=>{I&&!C&&(V.currentTarget.style.background="var(--surface-3)")},onMouseLeave:V=>{C||(V.currentTarget.style.background="var(--surface-2)")},children:C?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.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"})}),A?"Regenerate":"Generate"," Test Prompts"]})})})]}),!I&&!v&&r.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."}),k&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:k}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:_,onChange:V=>D(V.target.value),placeholder:`How do I write a unit test?
|
|
82
|
-
What edge cases should I test?
|
|
83
|
-
+Deploy this to production
|
|
84
|
-
!What's the weather like today?
|
|
85
|
-
!Write me a poem about flowers`}),r.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:"One prompt per line"}),r.jsx(ko,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),r.jsx(ko,{}),r.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[Y," prompt",Y!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:U,disabled:v||!_.trim(),className:"btn btn-primary",children:v?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("circle",{cx:"12",cy:"12",r:"6"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),v&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${x.length} / ${Y} prompts tested`,b&&r.jsx(zE,{startedAt:b})]})]})]})]}),r.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[r.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:I?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:B}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),y&&r.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:y}),v&&x.length===0&&r.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[r.jsx("div",{className:"spinner-lg mx-auto mb-4"}),r.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),x.length>0&&r.jsxs("div",{className:"space-y-5",children:[ee.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),r.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",ee.length,")"]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:ee.map((V,H)=>r.jsx(Jg,{result:V},`incorrect-${H}`))})]}),X.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("polyline",{points:"16 10 11 15 8 12"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",X.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((V,H)=>r.jsx(Jg,{result:V},`correct-${H}`))})]})]}),m&&r.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[r.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&&r.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"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(Id,{label:"Precision",value:m.precision,description:"Of all activations, how many were correct?",detail:`${m.tp} true / ${m.tp+m.fp} total activations`}),r.jsx(Id,{label:"Recall",value:m.recall,description:"Of expected activations, how many fired?",detail:`${m.tp} activated / ${m.tp+m.fn} expected`}),r.jsx(Id,{label:"Reliability",value:m.reliability,description:"Overall correct classification rate",detail:`${m.tp+m.tn} correct / ${m.total} total`})]}),r.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[r.jsx(wo,{label:"True Positive",abbr:"TP",count:m.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(wo,{label:"False Positive",abbr:"FP",count:m.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(wo,{label:"False Negative",abbr:"FN",count:m.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(wo,{label:"True Negative",abbr:"TN",count:m.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),r.jsx(AE,{history:w,expanded:O,onToggle:()=>M(!O),skillVersion:L})]})}function AE({history:t,expanded:a,onToggle:s,skillVersion:o}){return t===null?null:r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:a?"1px solid var(--border-subtle)":"none"},onClick:s,children:[r.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&r.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),r.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:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&r.jsx("div",{className:"px-4 py-3",children:t.length===0?r.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):r.jsx("div",{className:"space-y-2",children:t.map(c=>r.jsx(ME,{run:c,skillVersion:o},c.id))})})]})}function ME({run:t,skillVersion:a}){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 r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:LE(t.timestamp)}),r.jsx(ri,{version:a??null,size:"sm","data-testid":"activation-row-version"}),r.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),r.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),r.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 LE(t){const a=Date.now(),s=new Date(t).getTime(),o=Math.floor((a-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 ko(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Jg({result:t}){const a=Zg[t.classification]||Zg.FN,s=t.classification==="TP"||t.classification==="TN";return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:a.bg,border:"1px solid transparent"},children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${a.text} 20%, transparent)`},children:s?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),r.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[r.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:a.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),r.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&r.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Id({label:t,value:a,description:s,detail:o}){const c=Math.round(a*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),r.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),r.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),r.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function wo({abbr:t,count:a,bg:s,color:o,description:c}){return r.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[r.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function zE({startedAt:t}){const[a,s]=p.useState(0);return p.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}const Ud={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},ev={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},pf=600,mf=180,un=40,Hd=pf-un*2,ia=mf-un*2,DE=[25,50,75,100];function tv(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function _E(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function OE({entries:t,onPointClick:a}){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,v)=>{const y=un+v/(u-1)*Hd,b=m.passRate*100,S=un+ia-b/100*ia;return{x:y,y:S,pct:b,entry:m}}),h=d.map(m=>`${m.x},${m.y}`).join(" "),x=Array.from(new Set(c.map(m=>m.type)));return r.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[r.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),r.jsx("div",{className:"flex items-center gap-5 mb-3",children:x.map(m=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Ud[m]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:ev[m]??m})]},m))}),r.jsxs("svg",{width:pf,height:mf,viewBox:`0 0 ${pf} ${mf}`,style:{display:"block",overflow:"visible"},children:[DE.map(m=>{const v=un+ia-m/100*ia;return r.jsxs("g",{children:[r.jsx("line",{x1:un,y1:v,x2:un+Hd,y2:v,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:un-8,y:v+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),r.jsx("line",{x1:un,y1:un+ia,x2:un+Hd,y2:un+ia,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:un-8,y:un+ia+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),r.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((m,v)=>r.jsx("circle",{cx:m.x,cy:m.y,r:5,fill:Ud[m.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:y=>{y.currentTarget.setAttribute("r","7"),o({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:y=>{y.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>a==null?void 0:a(m.entry)},v)),BE(u).map(m=>r.jsx("text",{x:d[m].x,y:un+ia+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:tv(c[m].timestamp)},m))]}),s&&r.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:[r.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:tv(s.entry.timestamp)}),r.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:Ud[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:ev[s.entry.type]??s.entry.type}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),r.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:_E(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function BE(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 a=Math.ceil(t/10),s=[0];for(let o=a;o<t-1;o+=a)s.push(o);return s.push(t-1),s}const Is=new Map;let dn=null,Do=null,Co=1e3,Ll=0;function Py(){if(dn)return;dn=new EventSource("/api/events");const t=a=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Is.get(a);if(c)for(const u of c)u(o)};dn.addEventListener("benchmark:complete",t("benchmark:complete")),dn.addEventListener("history:written",t("history:written")),dn.addEventListener("leaderboard:updated",t("leaderboard:updated")),dn.onerror=()=>{dn==null||dn.close(),dn=null,Ll>0&&(Do=setTimeout(()=>{Co=Math.min(Co*2,3e4),Py()},Co))},dn.onopen=()=>{Co=1e3}}function IE(){Do!=null&&(clearTimeout(Do),Do=null),dn==null||dn.close(),dn=null}function UE(t,a){return Is.has(t)||Is.set(t,new Set),Is.get(t).add(a),Ll++,Py(),()=>{var s;(s=Is.get(t))==null||s.delete(a),Ll--,Ll<=0&&(Ll=0,queueMicrotask(()=>{Ll<=0&&IE()}))}}function Ho(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>UE(t,c=>s.current(c)),[t])}function $o(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function HE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function $E({rate:t,label:a}){const s=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:a}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:$o(t)},children:[s,"%"]})]}),r.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:$o(t)}})})]})})}function PE({points:t}){if(t.length<2)return null;const a=200,s=48,o=4,c=t.length,u=t.map((x,m)=>{const v=o+m/(c-1)*(a-o*2),y=o+(s-o*2)-x.passRate*(s-o*2);return{x:v,y}}),d=`M ${u[0].x},${s-o} `+u.map(x=>`L ${x.x},${x.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((x,m)=>`${m===0?"M":"L"} ${x.x},${x.y}`).join(" ");return r.jsxs("svg",{width:a,height:s,style:{display:"block"},children:[r.jsx("path",{d,fill:"var(--accent-muted)"}),r.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function VE({plugin:t,skill:a}){const s=`stats/${t}/${a}`,o=p.useCallback(()=>Se.getStats(t,a),[t,a]),{data:c,loading:u}=Js(s,o),d=p.useCallback(()=>An(s),[s]);if(Ho("benchmark:complete",d),Ho("history:written",d),u)return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"skeleton h-24 rounded-xl"}),r.jsx("div",{className:"skeleton h-48 rounded-xl"}),r.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),r.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,x=c.trendPoints.length>0?c.trendPoints[0].passRate:0,m=h-x,v=c.assertionStats.slice(0,10);return r.jsxs("div",{className:"space-y-4 stagger-children",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:$o(h)},children:[Math.round(h*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:m>=0?"var(--green)":"var(--red)"},children:[m>=0?"+":"",Math.round(m*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Ln(c.totalCost)})]}),c.costPerRun!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Ln(c.costPerRun)})]})]}),c.trendPoints.length>=2&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),r.jsx(PE,{points:c.trendPoints})]}),c.modelStats.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),r.jsx("tbody",{children:c.modelStats.map(y=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:y.model}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.runs}),r.jsx("td",{style:{padding:"8px",textAlign:"center"},children:r.jsxs("span",{className:"font-semibold",style:{color:$o(y.avgPassRate)},children:[Math.round(y.avgPassRate*100),"%"]})}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:HE(y.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.avgCost!=null?Ln(y.avgCost):"N/A"})]},y.model))})]})]}),v.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),r.jsx("div",{className:"space-y-3",children:v.map(y=>r.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:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.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:["#",y.evalId]}),r.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:y.evalName}),r.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[y.totalRuns," runs"]})]}),r.jsx($E,{rate:y.passRate,label:y.text})]},`${y.evalId}:${y.id}`))})]})]})}function FE({plugin:t,skill:a}){const[s,o]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState({}),[x,m]=p.useState({});p.useEffect(()=>{Se.getEvals(t,a).then(o).catch(()=>o(null))},[t,a]);async function v(y){if(c===y){u(null);return}if(u(y),!d[y]){m(b=>({...b,[y]:!0}));try{const b=await Se.getCaseHistory(t,a,y);h(S=>({...S,[y]:b}))}catch{h(b=>({...b,[y]:[]}))}finally{m(b=>({...b,[y]:!1}))}}}return s?r.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(y=>{const b=d[y.id]||[],S=c===y.id,C=x[y.id],k=b.length>0?b[0].pass_rate:null;return r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>v(y.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:w=>{S||(w.currentTarget.style.background="var(--surface-2)")},onMouseLeave:w=>{S||(w.currentTarget.style.background="transparent")},children:[r.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:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),r.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:["#",y.id]}),r.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:y.name}),b.length>=2&&r.jsx(By,{entries:b}),k!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Ol(k)},children:[Math.round(k*100),"%"]}),b.length>0&&r.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:C?r.jsxs("div",{className:"p-4 flex items-center gap-2",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?r.jsx("div",{className:"p-4",children:r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):r.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((w,T)=>r.jsxs("div",{className:"p-4",style:{background:T===0?"var(--surface-2)":"transparent"},children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:_y(w.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:w.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:w.type==="benchmark"?"rgba(99,131,255,0.15)":w.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:w.type==="benchmark"?"#6383ff":w.type==="comparison"?"var(--purple)":"#fb923c"},children:w.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ol(w.pass_rate)},children:[Math.round(w.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[w.durationMs!=null&&r.jsx("span",{children:Oy(w.durationMs)}),w.tokens!=null&&r.jsxs("span",{children:[w.tokens>=1e3?`${(w.tokens/1e3).toFixed(1)}k`:w.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:w.assertions.map(N=>r.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[r.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:N.pass?"var(--green)":"var(--red)"},children:r.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:N.pass?r.jsx("polyline",{points:"20 6 9 17 4 12"}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:N.text}),N.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:N.reasoning})]})]},N.id))})]},T))})})]},y.id)})}):r.jsx("div",{className:"text-center py-12",children:r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function GE(){const{state:t,dispatch:a}=zn(),{plugin:s,skill:o}=t,{state:c}=nr(),u=c.skills.find(V=>V.plugin===s&&V.skill===o),d=(u==null?void 0:u.resolvedVersion)??(u==null?void 0:u.version)??null,[h,x]=p.useState("timeline"),[m,v]=p.useState(""),[y,b]=p.useState(""),[S,C]=p.useState(!1),[k,w]=p.useState([]),[T,N]=p.useState(null),[L,_]=p.useState(!1),[D,F]=p.useState(null),[E,O]=p.useState(!1),M=`history/${s}/${o}?model=${m}&type=${y}`,U=p.useCallback(()=>Se.getHistory(s,o,{model:m||void 0,type:y||void 0}),[s,o,m,y]),{data:$,loading:Y}=Js(M,U),X=$??[];p.useEffect(()=>{!$||$.length<2||Se.compareRuns(s,o,$[0].timestamp,$[1].timestamp).then(V=>{const H=V.regressions.filter(re=>re.change==="regression");a({type:"SET_REGRESSIONS",regressions:H})}).catch(()=>{})},[$,s,o,a]);const ee=p.useCallback(()=>An(M),[M]);Ho("history:written",ee);const I=p.useCallback(async V=>{if(S){w(H=>H.includes(V)?H.filter(re=>re!==V):H.length>=2?[H[1],V]:[...H,V]);return}O(!0);try{const H=await Se.getHistoryEntry(s,o,V);F(H)}catch{}finally{O(!1)}},[s,o,S]),A=p.useCallback(async()=>{if(k.length===2){_(!0);try{const V=await Se.compareRuns(s,o,k[0],k[1]);N(V)}catch{}finally{_(!1)}}},[s,o,k]),B=[...new Set(X.map(V=>V.model))];return Y?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"skeleton h-12 rounded-lg"}),r.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(V=>r.jsx("button",{onClick:()=>x(V),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===V?"var(--accent-muted)":"transparent",color:h===V?"var(--accent)":"var(--text-tertiary)"},children:V==="timeline"?"Timeline":V==="per-eval"?"Per Eval":"Statistics"},V))}),h==="timeline"&&r.jsxs("div",{children:[X.length>0&&r.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:r.jsx(OE,{entries:X,onPointClick:V=>I(V.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:m,onChange:V=>v(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),B.map(V=>r.jsx("option",{value:V,children:V},V))]}),r.jsxs("select",{value:y,onChange:V=>b(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Types"}),r.jsx("option",{value:"benchmark",children:"Benchmark"}),r.jsx("option",{value:"comparison",children:"Comparison"}),r.jsx("option",{value:"baseline",children:"Baseline"}),r.jsx("option",{value:"model-compare",children:"Model Compare"}),r.jsx("option",{value:"improve",children:"AI Improve"}),r.jsx("option",{value:"instruct",children:"AI Edit"}),r.jsx("option",{value:"ai-generate",children:"AI Generate"}),r.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>{C(!S),w([]),N(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&k.length===2&&r.jsx("button",{onClick:A,disabled:L,className:"btn btn-primary text-[12px]",children:L?"Comparing...":"Compare"})]}),r.jsx("div",{className:"space-y-2",children:X.length===0?r.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(V=>{const H=k.includes(V.timestamp);return r.jsx("button",{onClick:()=>I(V.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:H?"var(--accent-muted)":"var(--surface-1)",border:H?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:re=>{H||(re.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:re=>{H||(re.currentTarget.style.borderColor="var(--border-subtle)")},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:H?"var(--accent)":"var(--border-default)",background:H?"var(--accent)":"transparent"},children:H&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(V.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:V.type==="comparison"?"var(--purple-muted)":V.type==="baseline"?"var(--surface-3)":V.type==="model-compare"?"var(--accent-muted)":V.type==="improve"||V.type==="instruct"?"var(--purple-muted)":V.type==="ai-generate"?"var(--green-muted)":V.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:V.type==="comparison"?"var(--purple)":V.type==="baseline"?"var(--text-tertiary)":V.type==="model-compare"?"var(--accent)":V.type==="improve"||V.type==="instruct"?"var(--purple)":V.type==="ai-generate"?"var(--green)":V.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:V.type==="model-compare"?"model compare":V.type==="improve"?"ai improve":V.type==="instruct"?"ai edit":V.type==="ai-generate"?"ai generate":V.type==="eval-generate"?"eval generate":V.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ri,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:V.model}),V.totalCost!=null&&V.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Ln(V.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:V.passRate>=.8?"var(--green)":V.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(V.passRate*100),"%"]})]})]})},V.timestamp)})}),T&&r.jsx(WE,{result:T}),D&&!S&&r.jsx(qE,{run:D,onClose:()=>F(null)})]}),h==="per-eval"&&r.jsx(FE,{plugin:s,skill:o}),h==="statistics"&&r.jsx(VE,{plugin:s,skill:o})]})}function WE({result:t}){const a=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.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)&&r.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[r.jsxs("span",{children:["Run A cost: ",Ln(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Ln(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&r.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Ln(t.runB.totalCost-t.runA.totalCost)]})]}),a.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",a.length,")"]}),a.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),r.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:r.jsxs("table",{className:"w-full text-[12px]",children:[r.jsx("thead",{children:r.jsxs("tr",{style:{background:"var(--surface-2)"},children:[r.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),r.jsx("tbody",{children:t.caseDiffs.map(o=>r.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),r.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}),r.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 qE({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(YE,{run:t,onClose:a}):r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),r.jsx("button",{onClick:a,className:"btn btn-ghost text-[11px]",children:"Close"})]}),r.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: ${Ln(t.totalCost)}`]}),r.jsx("div",{className:"space-y-2",children:t.cases.map(s=>r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&r.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Ln(s.cost)}),r.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 YE({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?Jo(t.improve.original,t.improve.improved):[],[t.improve]),o=p.useMemo(()=>{const d=s.filter(x=>x.type==="added").length,h=s.filter(x=>x.type==="removed").length;return{added:d,removed:h}},[s]),c=p.useMemo(()=>{let d=0,h=0;return s.map(x=>x.type==="removed"?(d++,{...x,origNum:d,newNum:null}):x.type==="added"?(h++,{...x,origNum:null,newNum:h}):(d++,h++,{...x,origNum:d,newNum:h}))},[s]);return r.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),r.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),r.jsx("button",{onClick:a,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:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&r.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:[r.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:c.map((d,h)=>r.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[r.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??""}),r.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??""}),r.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"?"-":" "}),r.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 Vy({data:t}){if(t.length<2)return r.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const a=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=a.length,x=Math.min(...a),v=Math.max(...a)-x||1,y=a.map((C,k)=>{const w=c+k/(h-1)*u,T=c+d-(C-x)/v*d;return`${w.toFixed(1)},${T.toFixed(1)}`}),b=a[a.length-1],S=Ol(b);return r.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[r.jsx("polyline",{points:y.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[C,k]=y[y.length-1].split(",");return r.jsx("circle",{cx:C,cy:k,r:2.5,fill:S})})()]})}function KE(){return r.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:r.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 XE({pct:t}){const a=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 r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function QE({score:t,rating:a}){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[a]??s.minimal,c=t>=0?"+":"";return r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),r.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function ZE({warning:t}){return r.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:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function JE({active:t,onChange:a,hasBaseline:s}){return r.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[r.jsx("button",{onClick:()=>a("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"}),r.jsx("button",{onClick:()=>a("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 eN(t){var o,c,u;if(t.length===0)return[];const a=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const x=`${h.provider}/${h.model}`;a.has(x)||a.set(x,{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=a.get(x);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 a){const[x,...m]=d.split("/");s.push({rank:0,model:m.join("/"),provider:x,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 x=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-x}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Fy=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function tN({entries:t}){return r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(a=>r.jsx("th",{style:Fy(a==="#"?"center":"left"),children:a},a))})}),r.jsx("tbody",{children:t.map(a=>r.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:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:a.rank}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:a.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:a.provider}),a.isBest&&r.jsx(KE,{})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:a.passRate>=.7?"var(--green-muted)":a.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ol(a.passRate),fontSize:11,fontWeight:600},children:[Math.round(a.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.rubricScore!=null?a.rubricScore.toFixed(1):"--"}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.duration<1e3?`${Math.round(a.duration)}ms`:`${(a.duration/1e3).toFixed(1)}s`}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.cost!=null?`$${a.cost.toFixed(4)}`:"N/A"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(Vy,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function nN({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return a.length===0?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"text-center",children:r.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",r.jsx("code",{children:"--baseline"})," flag."]})})}):r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>r.jsx("th",{style:Fy(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,o)=>r.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:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ol(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?r.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"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?r.jsx(XE,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(Vy,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function rN(){const{state:t}=zn(),{plugin:a,skill:s}=t,[o,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>Se.getLeaderboard(a,s),[a,s]),{data:h,loading:x,error:m}=Js(u,d),v=(h==null?void 0:h.entries)??[],y=(m==null?void 0:m.message)??null;p.useEffect(()=>{c("rankings")},[a,s]);const b=p.useCallback(()=>An(u),[u]);Ho("leaderboard:updated",b);const S=p.useMemo(()=>eN(v),[v]),C=S.some(T=>T.hasBaseline),k=v[0],w=k==null?void 0:k.judgeBiasWarning;return x?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):y?r.jsx("div",{className:"flex items-center justify-center h-full px-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Failed to load leaderboard"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:y})]})}):S.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),r.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),r.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"'}),r.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",r.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),r.jsx(JE,{active:o,onChange:c,hasBaseline:C})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[v.length," sweep",v.length!==1?"s":""," · ",S.length," model",S.length!==1?"s":""]})]}),w&&r.jsx(ZE,{warning:w}),o==="rankings"?r.jsx(tN,{entries:S}):r.jsx(nN,{entries:S}),o==="amplification"&&(k==null?void 0:k.skillQualityScore)!=null&&(k==null?void 0:k.skillQualityRating)&&r.jsx(QE,{score:k.skillQualityScore,rating:k.skillQualityRating})]})}function aN({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState([]),[d,h]=p.useState(!0),[x,m]=p.useState(null);p.useEffect(()=>{Se.getDependencies(t,a).then(y=>{o(y.mcpDependencies),u(y.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,a]);async function v(y,b){try{await navigator.clipboard.writeText(b),m(y),setTimeout(()=>m(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?r.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"}):r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.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:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.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"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),r.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&r.jsxs("div",{className:"space-y-3 mb-4",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(y=>r.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:y.server}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:y.transport})]}),r.jsx("button",{onClick:()=>v(y.server,y.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:x===y.server?"var(--green)":"var(--accent)"},children:x===y.server?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.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"]})})]}),r.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:y.url}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.matchedTools.map(b=>r.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))})]},y.server))]}),c.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),r.jsx("div",{className:"space-y-1.5",children:c.map(y=>r.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:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.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"})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:y.name}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:y.source==="frontmatter"?"frontmatter":"referenced"})]},y.name))})]})]})]})}function nv({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[x,m]=p.useState(""),[v,y]=p.useState(!1),[b,S]=p.useState(null),[C,k]=p.useState(""),[w,T]=p.useState(""),[N,L]=p.useState(!1),[_,D]=p.useState(new Set),F=p.useCallback(async()=>{u(!0);try{const[U,$]=await Promise.all([Se.getCredentials(t,a).catch(()=>({credentials:[]})),Se.getParams(t,a).catch(()=>({params:[]}))]),Y=new Map($.params.map(I=>[I.name,I])),X=new Set,ee=[];for(const I of U.credentials){X.add(I.name);const A=Y.get(I.name);ee.push({name:I.name,status:I.status==="ready"||I.status==="resolved"?"ready":"missing",source:I.source,maskedValue:A==null?void 0:A.maskedValue})}for(const I of $.params)X.has(I.name)||ee.push({name:I.name,status:I.status,maskedValue:I.maskedValue});o(ee)}finally{u(!1)}},[t,a]);p.useEffect(()=>{F()},[F]);const E=p.useCallback(async U=>{if(_.has(U)){D($=>{const Y=new Set($);return Y.delete(U),Y}),o($=>$.map(Y=>Y.name===U?{...Y,revealedValue:void 0}:Y));return}try{const Y=(await Se.getParamsRevealed(t,a,U)).params.find(X=>X.name===U);Y&&(o(X=>X.map(ee=>ee.name===U?{...ee,revealedValue:Y.value}:ee)),D(X=>new Set(X).add(U)))}catch{}},[t,a,_]),O=async(U,$)=>{if(!(!U.trim()||!$.trim())){y(!0),S(null);try{await Se.setCredential(t,a,U,$),h(null),m(""),D(new Set),F()}catch(Y){S(Y.message)}finally{y(!1)}}},M=async()=>{if(!(!C.trim()||!w.trim())){y(!0),S(null);try{await Se.setCredential(t,a,C.trim().toUpperCase(),w),k(""),T(""),L(!1),F()}catch(U){S(U.message)}finally{y(!1)}}};return c?r.jsxs("div",{className:"mt-6",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):r.jsxs("div",{className:"mt-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("button",{onClick:()=>L(!N),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&r.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&&!N?r.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"}):r.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(U=>r.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:[r.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:U.name}),U.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:_.has(U.name)&&U.revealedValue!=null?U.revealedValue:U.maskedValue}),U.maskedValue&&r.jsx("button",{onClick:()=>E(U.name),className:"btn btn-ghost px-1",title:_.has(U.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:_.has(U.name)?r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.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"}),r.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"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),r.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&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:U.source}),d===U.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:x,onChange:$=>m($.target.value),onKeyDown:$=>{$.key==="Enter"&&O(U.name,x)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(U.name,x),disabled:v||!x.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:v?"...":"Save"}),r.jsx("button",{onClick:()=>{h(null),m("")},className:"btn btn-ghost text-[10px] px-1",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):r.jsx("button",{onClick:()=>{h(U.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},U.name))}),N&&r.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:C,onChange:U=>k(U.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:w,onChange:U=>T(U.target.value),onKeyDown:U=>{U.key==="Enter"&&M()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx("button",{onClick:()=>{L(!1),k(""),T("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:M,disabled:v||!C.trim()||!w.trim(),className:"btn btn-primary text-[10px]",children:v?"Saving...":"Save"})]})]})]})}function lN(){const{state:t}=zn(),{plugin:a,skill:s}=t,[o,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{Se.getDependencies(a,s).then(c).catch(()=>{}).finally(()=>d(!1))},[a,s]),u?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx(aN,{plugin:a,skill:s}),r.jsx(nv,{plugin:a,skill:s})]}):r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),r.jsx(nv,{plugin:a,skill:s})]})}function sN(t){const a={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(a.targetAgents=t.targetAgents),a}function iN(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function hf(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function oN(t,a,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){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 cN({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[o,c]=p.useState("ai"),[u,d]=p.useState(null),[h,x]=p.useState(!0),{config:m}=Fa(),[v,y]=p.useState(""),[b,S]=p.useState(s??3),[C,k]=p.useState(""),[w,T]=p.useState(""),[N,L]=p.useState(""),[_,D]=p.useState(""),[F,E]=p.useState(""),[O,M]=p.useState(""),[U,$]=p.useState("write"),[Y,X]=p.useState([]),[ee,I]=p.useState(!1),[A,B]=p.useState(null),[V,H]=p.useState(null),[re,z]=p.useState("vskill"),[W,te]=p.useState("1.0.0"),[q,oe]=p.useState(!0),le=p.useCallback(async()=>{try{const De=await Se.detectEngines();H(De),z(ot=>ot!=="vskill"?ot:De.vskillSkillBuilder?"vskill":De.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{H({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{le()},[le]);const[ve,ce]=p.useState(""),[be,Re]=p.useState(!1),[Ae,se]=p.useState(!1),[he,pe]=p.useState(null),[xe,je]=p.useState(null),[Be,Ue]=p.useState([]),gt=p.useRef(null),Lt=p.useRef(null),st=p.useRef(null),Et=p.useRef(null),Yt=p.useRef(null),[Ye,vt]=p.useState(!1),[bn,ye]=p.useState(!1),ht=p.useRef(v),zt=p.useRef(C),Ot=p.useRef(w);p.useEffect(()=>{ht.current=v},[v]),p.useEffect(()=>{zt.current=C},[C]),p.useEffect(()=>{Ot.current=w},[w]),p.useEffect(()=>{Se.getProjectLayout().then(De=>{if(d(De),s)return;S(De.suggestedLayout);const ot=De.detectedLayouts.find(sn=>sn.layout===De.suggestedLayout);ot!=null&&ot.existingPlugins.length&&k(ot.existingPlugins[0])}).catch(()=>{}).finally(()=>x(!1))},[s]),p.useEffect(()=>{var De;o==="ai"&&((De=gt.current)==null||De.focus())},[o]),p.useEffect(()=>()=>{var De;(De=Lt.current)==null||De.abort()},[]);const Dn=p.useMemo(()=>{var De;return u?((De=u.detectedLayouts.find(ot=>ot.layout===b))==null?void 0:De.existingPlugins)||[]:[]},[u,b]),Nt=C==="__new__"?w:C,_n=u?oN(u.root,b,Nt||"{plugin}",v||"{skill}"):"",Pt=p.useMemo(()=>u?u.detectedLayouts.filter(De=>De.layout!==4):[],[u]),Tt=p.useMemo(()=>{if(!u)return null;const De=u.detectedLayouts.find(Zt=>Zt.layout===2&&Zt.existingPlugins.length>0),ot=u.detectedLayouts.find(Zt=>Zt.layout===1&&Zt.existingPlugins.length>0),sn=De||ot;return sn?{layout:sn.layout,plugins:sn.existingPlugins}:null},[u]),it=p.useCallback(()=>{if(a)return a();if(!m)return{provider:"claude-cli",model:"sonnet"};const De=m.provider||"claude-cli",ot=m.model||"sonnet";return{provider:De,model:ot}},[m,a]),rr=p.useCallback(()=>{var De;(De=Lt.current)==null||De.abort(),Re(!1)},[]),ar=p.useCallback(()=>{pe(null),je(null)},[]),hr=p.useCallback(async()=>{var Zt,fe;if(pe(null),je(null),Ue([]),st.current=null,Et.current=null,!ve.trim()){pe("Describe what your skill should do");return}Re(!0);const De=new AbortController;Lt.current=De;const{provider:ot,model:sn}=it();try{const Ce=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(sN({prompt:ve.trim(),provider:ot,model:sn,targetAgents:Y})),signal:De.signal});if(!Ce.ok||!Ce.body){let xa=`HTTP ${Ce.status}`;try{const ga=await Ce.json();ga.error&&(xa=ga.error)}catch{}throw new Error(xa)}const ze=Ce.body.getReader(),jn=new TextDecoder;let ha="",lr="";for(;;){const{done:xa,value:ga}=await ze.read();if(xa)break;ha+=jn.decode(ga,{stream:!0});const qa=ha.split(`
|
|
86
|
-
`);ha=qa.pop()||"";for(const Br of qa)if(Br.startsWith("event: "))lr=Br.slice(7).trim();else if(Br.startsWith("data: ")){try{const ct=JSON.parse(Br.slice(6));if(lr==="progress")Ue(va=>[...va,{phase:ct.phase,message:ct.message,timestamp:Date.now()}]);else if(lr==="provenance")Et.current={resolvedModelId:typeof ct.resolvedModelId=="string"?ct.resolvedModelId:null,snapshotDate:typeof ct.snapshotDate=="string"?ct.snapshotDate:null};else if(lr==="done"||lr==="complete"){const va={prompt:ve.trim(),provider:it().provider,model:it().model,resolvedModelId:((Zt=Et.current)==null?void 0:Zt.resolvedModelId)??null,snapshotDate:((fe=Et.current)==null?void 0:fe.snapshotDate)??null,reasoning:ct.reasoning||""},on=iN({userName:ht.current,userPlugin:zt.current,userNewPlugin:Ot.current,aiName:ct.name,aiSuggestedPlugin:ct.suggestedPlugin&&ct.suggestedPlugin.plugin?{plugin:ct.suggestedPlugin.plugin,layout:ct.suggestedPlugin.layout}:null,forceLayout:s});if(on.applyName!==null&&y(on.applyName),L(ct.description),D(ct.model||""),E(ct.allowedTools||""),M(ct.body),se(!0),st.current=va,c("manual"),s===3)S(3),k(""),T("");else if(on.applySuggestedPlugin&&on.suggestedPluginValue){const ut=on.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(sr=>sr.existingPlugins))??[]).includes(ut.plugin))if(k(ut.plugin),ut.layout&&(ut.layout===1||ut.layout===2))S(ut.layout);else{const sr=u==null?void 0:u.detectedLayouts.find(tc=>tc.existingPlugins.includes(ut.plugin));sr&&(sr.layout===1||sr.layout===2)&&S(sr.layout)}else k("__new__"),T(ut.plugin)}else!on.applySuggestedPlugin&&zt.current.trim().length===0&&Ot.current.trim().length===0&&b===3&&Tt&&ye(!0);const Vt={name:ct.name,plugin:Nt||"",layout:b,description:ct.description,model:ct.model||void 0,allowedTools:ct.allowedTools||void 0,body:ct.body,aiMeta:va};Se.saveDraft(Vt).then(ut=>{vt(!0),ut!=null&&ut.dir&&(Yt.current=ut.dir)}).catch(()=>{})}else lr==="error"&&(pe(ct.message||ct.description||"Unknown error"),ct.category&&je(ct))}catch{}lr=""}}}catch(Ce){Ce.name!=="AbortError"&&pe(Ce.message)}finally{Re(!1),Lt.current=null}},[ve,it,b,Tt,Nt,u,Y,s]),pn=p.useCallback(async()=>{if(B(null),!v.trim()){B("Skill name is required");return}if(!N.trim()){B("Description is required");return}if(b!==3&&!Nt.trim()){B("Plugin name is required");return}if(!q){B("Version is not valid semver");return}I(!0);try{const De=await Se.createSkill({name:hf(v),plugin:Nt||"",layout:b,description:N,model:_||void 0,allowedTools:F||void 0,body:O,aiMeta:st.current||void 0,draftDir:Yt.current||void 0,version:W.trim()||void 0,engine:re});Yt.current=null,t(De.plugin,De.skill)}catch(De){B(De.message)}finally{I(!1)}},[v,N,b,Nt,_,F,O,W,q,re,t]),Rt=p.useCallback(()=>{Tt&&(S(Tt.layout),k(Tt.plugins[0]),ye(!1))},[Tt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Pt,availablePlugins:Dn,pathPreview:_n,plugin:C,setPlugin:k,newPlugin:w,setNewPlugin:T,effectivePlugin:Nt,name:v,setName:y,description:N,setDescription:L,model:_,setModel:D,allowedTools:F,setAllowedTools:E,body:O,setBody:M,bodyViewMode:U,setBodyViewMode:$,aiPrompt:ve,setAiPrompt:ce,generating:be,aiGenerated:Ae,aiError:he,aiClassifiedError:xe,aiProgress:Be,promptRef:gt,handleGenerate:hr,handleCancelGenerate:rr,clearAiError:ar,targetAgents:Y,setTargetAgents:X,draftSaved:Ye,showPluginRecommendation:bn,setShowPluginRecommendation:ye,pluginLayoutInfo:Tt,applyPluginRecommendation:Rt,creating:ee,error:A,handleCreate:pn,engineDetection:V,refreshEngineDetection:le,engine:re,setEngine:z,version:W,setVersion:te,versionValid:q,setVersionValid:oe,standaloneLocked:s===3}}function Gy(){return r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.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 uN(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Wy({node:t,depth:a=0}){var s;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${a*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?r.jsx(Gy,{}):r.jsx(uN,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>r.jsx(Wy,{node:o,depth:a+1},o.name))]})}function dN(t,a,s){const o=[];a&&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 fN({skillName:t,hasEvals:a,isDraft:s}){const o=dN(t,a,s);return r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsx(Gy,{})}),"Skill Structure"]}),r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:r.jsx(Wy,{node:o})})]})}const oa={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function $d({size:t=14,color:a="currentColor"}){return r.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.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 pN({onCreated:t,onCancel:a}){const s=cN({onCreated:t});return r.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),r.jsx("div",{className:"flex items-center justify-between mt-2",children:r.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.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:r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx($d,{size:12}),"AI-Assisted"]})}),r.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&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsx($d,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.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
|
-
|
|
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:{...oa,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),r.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&&r.jsx(ai,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(ec,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):r.jsxs("div",{children:[r.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}),r.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?r.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"}):r.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:[r.jsx($d,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,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&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.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"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>r.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&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.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:oa,children:[s.availablePlugins.map(o=>r.jsx("option",{value:o,children:o},o)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(hf(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:oa})]}),r.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&&r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.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"}),r.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:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(hf(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:oa})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.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:{...oa,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:oa,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.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:oa})]})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"}),r.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),r.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),r.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>r.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"?r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]}):r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),r.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
|
|
89
|
-
|
|
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:{...oa,minHeight:"150px"}}):s.body.trim()?r.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:Zo(s.body)}}):r.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:r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),r.jsx(fN,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&r.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}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.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"}),r.jsx("button",{onClick:a,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 mN(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.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:[r.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"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function _o({variant:t,message:a,onRetry:s}){const{setMode:o,setSearch:c}=nr(),[u,d]=p.useState(!1);return t==="no-selection"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(mN,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.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"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.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:r.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"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.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"]}),r.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:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.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:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.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"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.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 hN(t,a){const[s,o]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const xN={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 qy(){const[t,a]=p.useState([]),[s,o]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[x,m]=p.useState(!1),[v,y]=p.useState(new Set),[b,S]=p.useState(new Map),[C,k]=p.useState(null),[w,T]=p.useState(null),[N,L]=p.useState(!1),_=p.useCallback(async()=>{o(!0);try{const $=await Se.getSkillUpdates();a($.filter(Y=>Y.updateAvailable))}catch{a([])}finally{o(!1)}},[]);p.useEffect(()=>{_()},[_]);const D=p.useMemo(()=>t.filter($=>!$.pinned),[t]),F=p.useCallback($=>{u(Y=>{const X=new Set(Y);return X.has($)?X.delete($):X.add($),X})},[]),E=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map($=>$.name)))},[c,D]),O=p.useCallback(()=>{const $=[...c];if(!$.length)return;m(!0),h(new Map($.map(X=>[X,{skill:X,status:"pending"}])));const Y=Se.startBatchUpdate($);Y.addEventListener("progress",X=>{try{const ee=JSON.parse(X.data);h(I=>new Map(I).set(ee.skill,ee))}catch{}}),Y.addEventListener("done",X=>{Y.close(),m(!1);try{const ee=JSON.parse(X.data);k(`Updated ${ee.updated??0} skills, ${ee.failed??0} failed`),setTimeout(()=>k(null),5e3)}catch{}_()}),Y.addEventListener("error",()=>{Y.close(),m(!1),k("Batch update failed"),setTimeout(()=>k(null),5e3)})},[c,_]),M=p.useCallback(async $=>{const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ee=Y[Y.length-1];y(I=>new Set(I).add($.name)),S(I=>{const A=new Map(I);return A.delete($.name),A});try{const I=await Se.postSkillUpdate(X,ee);if(I.ok)_();else{const A=`Update failed (HTTP ${I.status}): ${I.body}`;S(B=>new Map(B).set($.name,A)),k(`Couldn't update ${ee} — HTTP ${I.status}`),setTimeout(()=>k(null),5e3)}}catch(I){const A=I instanceof Error?I.message:"Network error";S(B=>new Map(B).set($.name,A)),k(`Couldn't update ${ee} — ${A}`),setTimeout(()=>k(null),5e3)}finally{y(I=>{const A=new Set(I);return A.delete($.name),A})}},[_]),U=p.useCallback(async $=>{if(!$.latest)return;const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ee=Y[Y.length-1];L(!0);try{const I=await Se.getVersionDiff(X,ee,$.installed,$.latest);T({skill:$,diff:I})}catch{T(null)}finally{L(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.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:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:_,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[C&&r.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:C}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:_,className:"btn btn-ghost text-[12px]",disabled:x,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||x,className:"btn btn-primary text-[12px]",children:x?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.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:[r.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&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),r.jsx("div",{className:"space-y-2",children:t.map($=>{const Y=$.name.split("/").pop()||$.name,X=$.latest?hN($.installed,$.latest):"patch",ee=xN[X],I=!!$.pinned,A=v.has($.name),B=d.get($.name),V=c.has($.name);return r.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:I?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!I&&F($.name),disabled:I,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:I?"not-allowed":"pointer"},children:r.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",opacity:I?.4:1},children:V&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Y}),I&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:ee.bg,color:ee.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[$.installed," → ",$.latest||"?",I&&` (pinned at ${$.pinnedVersion||$.installed})`]})]}),B&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:B.status==="done"?"var(--green-muted)":B.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:B.status==="done"?"var(--green)":B.status==="error"?"var(--red)":"var(--yellow)"},children:[B.status,B.error&&`: ${B.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>U($),className:"btn btn-ghost text-[11px]",disabled:N,children:"View Changes"}),r.jsx("button",{onClick:()=>M($),disabled:I||A||x,title:I?"Pinned — unpin from CLI to update":"",className:`btn ${I?"btn-ghost":"btn-primary"} text-[11px]`,children:A?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(B==null?void 0:B.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},$.name)})}),w&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>T(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:$=>$.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>T(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(If,{contentDiff:w.diff.contentDiff,fromLabel:w.diff.from,toLabel:w.diff.to,diffSummary:w.diff.diffSummary,renderContext:"inline"})]})})]})}const gN=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:qy},Symbol.toStringTag,{value:"Module"}));function vN(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function yN(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function bN(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),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 Yy(t){const{author:a,repoUrl:s}=t,o=bN(s??null),c=a&&a.trim()!==""?a:o??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var x;try{await((x=navigator.clipboard)==null?void 0:x.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?r.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}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.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,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function jN(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function SN(t,a){const s=jN(t),o=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function rv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function Ky(t){const{repoUrl:a,skillPath:s,absolutePath:o}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?rv(s):o?rv(o):"source",x=p.useCallback(async()=>{var y;const v=o??s??"";if(v)try{await((y=navigator.clipboard)==null?void 0:y.writeText(v)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const v=SN(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:v,target:"_blank",rel:"noopener noreferrer",title:v,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:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return r.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 r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:x,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:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function av(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Xy(t){return t.skill?wN({skill:t.skill}):EN({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function kN(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),o=t.slice(t.length-(a-12-1));return`${s}…${o}`}function wN({skill:t}){const[a,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),av(ne.toasts.pathCopied,"info")}catch{av(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.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:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.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}),r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ri,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})})]}),r.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:[r.jsx(Yy,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(Ky,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(CN,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.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:kN(t.dir||"—")}),r.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:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function CN({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let o="";switch(a){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 r.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:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function EN({state:t,isReadOnly:a,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:x,regressions:m,iterationCount:v}=t,y=Array.from(x.values()).some(T=>T.status==="running"||T.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((T,N)=>T+N.assertions.length,0))??0,C=(u==null?void 0:u.evals.length)??0,k=vN(b),w=yN(b);return r.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:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),r.jsx(NN,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.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:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.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"}),y&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:y,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:y?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:y?.4:1,borderRadius:4},onMouseEnter:T=>{y||(T.currentTarget.style.color="var(--red)")},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(TN,{})}),m.length>0&&r.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.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"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),v>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",v]}),r.jsx("span",{className:"pill",style:{background:w,color:k},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[C," case",C!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function NN(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function TN(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.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"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function ca(t){const{title:a,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:x}=t,m=a??s??"",v=typeof x=="function",y=b=>{v&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x==null||x())};return r.jsxs("div",{className:v?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:v?"button":void 0,tabIndex:v?0:void 0,onClick:v?()=>x==null?void 0:x():void 0,onKeyDown:v?y: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:v?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?r.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,r.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?r.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?r.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?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.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 RN="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 AN(t){const{onNavigate:a}=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=>{a==null||a(d),o(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.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&&r.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:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:RN}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Pd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Pd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Pd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Pd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function MN(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const a=t/1024;if(a<1024)return a>=10?`${Math.round(a)} KB`:`${a.toFixed(1).replace(/\.0$/,"")} KB`;const s=a/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Os(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.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 x=Math.floor(h/12);return`${x} year${x===1?"":"s"} ago`}function LN(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function zN(t){const a=t.installMethod;if(!a)return null;const s=a==="authored"?"Authored":a==="copied"?"Copied":"Symlinked";return r.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 DN(t){var v,y;const{skill:a,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(_N(a.homepage)?a.homepage??null:null),x=((v=a.mcpDeps)==null?void 0:v.length)??0,m=((y=a.deps)==null?void 0:y.length)??0;return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[r.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:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.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:a.skill}),r.jsx(ri,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),zN(a)]}),r.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:[r.jsx(Yy,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(Ky,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Os(a.lastModified)]}):null]})]}),r.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:[r.jsx(ca,{title:"Benchmark",value:LN(a),subtitle:a.lastBenchmark?Os(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:r.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:r.jsx(AN,{onNavigate:s})})}),r.jsx(ca,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(ca,{title:"Activations",value:o,subtitle:c?`Last: ${Os(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(ca,{title:"Last run",value:Os(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(ca,{title:"MCP deps",value:x,subtitle:x>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ca,{title:"Skill deps",value:m,subtitle:m>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ca,{title:"Size",value:MN(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(ca,{title:"Last modified",value:Os(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function _N(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function ON({skill:t}){const{onSkillUpdated:a}=nr(),{toast:s}=Wo(),[o,c]=p.useState("idle"),[u,d]=p.useState(null),[h,x]=p.useState(!1),[m,v]=p.useState(null),[y,b]=p.useState(!1),S=p.useRef(null),C=p.useCallback(async()=>{if(!t||o==="updating")return;const N=new AbortController;S.current=N,c("updating"),d(null);try{const L=await Se.postSkillUpdate(t.plugin,t.skill,N.signal);if(L.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const _=`Update failed (HTTP ${L.status}): ${L.body}`;c("idle"),d(_),s({message:`Couldn't update ${t.skill} — HTTP ${L.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{C()}}})}}catch(L){if(L instanceof DOMException&&L.name==="AbortError")return;const _=L instanceof Error?L.message:"Network error";c("idle"),d(_),s({message:`Couldn't update ${t.skill} — ${_}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{C()}}})}finally{S.current===N&&(S.current=null)}},[t,o,a,s]);if(p.useEffect(()=>{if(!h||m!=null||!t||!t.latestVersion)return;let N=!1;return b(!0),Se.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(L=>{N||v(L)}).catch(()=>{N||v(null)}).finally(()=>{N||b(!1)}),()=>{N=!0}},[h,m,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 N;(N=S.current)==null||N.abort()},[]),!t||t.updateAvailable!==!0)return null;const k=t.latestVersion,w=o==="updating"?"Updating…":k?`Update to ${k}`:"Update",T=o==="updating";return r.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:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{C()},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:w}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>x(N=>!N),disabled:T||!k,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:h?"Hide changelog":"Preview changelog"})]}),o==="updating"&&r.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…"}),u&&o!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:u}),h&&k&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[y&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!y&&m&&r.jsx(If,{contentDiff:m.contentDiff,fromLabel:m.from,toLabel:m.to,diffSummary:m.diffSummary??void 0,renderContext:"inline"}),!y&&!m&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const BN=3e4;function IN({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=nr(),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[,m]=p.useState(0),v=p.useRef(null),y=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const k=setInterval(()=>m(w=>(w+1)%1e6),250);return()=>clearInterval(k)},[u]),p.useEffect(()=>{if(!u||!S)return;const k=y.current??0;S.receivedAt<k||(v.current&&(clearTimeout(v.current),v.current=null),d(!1),x(!1),y.current=null)},[u,S]),p.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]),s===!1||o)return null;const C=async()=>{if(!u){x(!1),d(!0),y.current=Date.now(),v.current=setTimeout(()=>{d(!1),x(!0),v.current=null,y.current=null},BN);try{await Se.rescanSkill(t,a)}catch{v.current&&(clearTimeout(v.current),v.current=null),d(!1),y.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:C,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&&r.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&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const Qy=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],UN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function HN(t){return typeof t=="string"&&Qy.includes(t)}function $N(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return HN(a)?a:"overview"}function Vd(){const{state:t,setMobileView:a}=nr();return t.isMobile?r.jsxs("button",{onClick:()=>a("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:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function PN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return VN(t);const{state:a,selectSkill:s,setMode:o,refreshSkills:c}=nr(),[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 r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Vd,{}),r.jsx(qy,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Vd,{}),r.jsx(pN,{onCreated:(m,v)=>{o("browse"),c(),s({plugin:m,skill:v,origin:"source"})},onCancel:()=>o("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(_o,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(_o,{variant:"no-skills"}):r.jsx(_o,{variant:"no-selection"});const h=a.selectedSkill,x=a.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Vd,{}),r.jsx(FN,{skillInfo:x,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function VN(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return WN();if(t.loadError)return qN(a,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Zy(a,s,t.onDetailTabChange,o)}function FN({skillInfo:t,allSkills:a,onSelectSkill:s}){const[o,c]=p.useState($N());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(),x=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",x)},[o]);const u=p.useMemo(()=>t?Zy(t,o,c,{}):r.jsx(_o,{variant:"no-selection"}),[t,o,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function GN(t,a){return r.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:Qy.map(s=>{const o=s===t;return r.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:()=>a==null?void 0:a(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:UN[s]},s)})})}function WN(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[r.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"}),r.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 qN(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Xy({skill:t}),r.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[r.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]}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:a})]})]})}function YN({active:t}){return t==="editor"?r.jsx(aE,{}):t==="tests"?r.jsx(dE,{}):t==="run"?r.jsx(CE,{}):t==="activation"?r.jsx(RE,{}):t==="history"?r.jsx(GE,{}):t==="leaderboard"?r.jsx(rN,{}):t==="deps"?r.jsx(lN,{}):t==="versions"?r.jsx(EC,{}):null}function KN({active:t}){const{state:a,dispatch:s}=zn();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function Zy(t,a,s,o){const c=h=>{s==null||s(h)},u=r.jsx(DN,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?r.jsxs(hC,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(KN,{active:a}),r.jsx(YN,{active:a})]},`${t.plugin}/${t.skill}`):r.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 ",a," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:Xy({skill:t})}),r.jsx(ON,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."})]}),t.origin==="installed"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(IN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),GN(a,s),r.jsx("div",{role:"tabpanel",id:`detail-panel-${a}`,"aria-labelledby":`detail-tab-${a}`,"data-testid":`detail-panel-${a}`,style:{flex:1,minHeight:0,overflow:"auto"},children:a==="overview"?u:d})]})}function XN(){const{updateCount:t,state:a,dismissUpdateNotification:s}=nr(),o=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?r.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:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.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"}),r.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 QN=[{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 ZN({open:t,onClose:a,groups:s=QN,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,x;(x=(h=c.current)==null?void 0:h.focus)==null||x.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var x;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(x=u.current)==null||x.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.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&&a()},children:r.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:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,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=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.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 JN(t){const a=ne.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:a.update}),o.push({action:"uninstall",label:a.uninstall}),o.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),o}function eT({state:t,onClose:a,onAction:s,itemsOverride:o}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),x=p.useMemo(()=>t.skill?o??JN(t.skill):[],[t.skill,o]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const y=8,b=220,S=44+x.length*28;let C=t.x,k=t.y;return C+b+y>window.innerWidth&&(C=Math.max(y,t.x-b)),k+S+y>window.innerHeight&&(k=Math.max(y,t.y-S)),{left:C,top:k}},[t.x,t.y,x.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var y;(y=c.current)==null||y.focus()}),()=>{var y,b;(b=(y=u.current)==null?void 0:y.focus)==null||b.call(y),u.current=null}},[t.open]);const v=p.useCallback(()=>{if(!t.skill)return;const y=x[d];!y||y.disabled||(s(y.action,t.skill),a())},[x,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function y(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(C=>Math.min(C+1,Math.max(x.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(C=>Math.max(C-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),v();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",y,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",y,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,x.length,v]),!t.open||!t.skill?null:r.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:x.map((y,b)=>r.jsx("div",{role:"menuitem","aria-disabled":y.disabled||void 0,title:y.title||void 0,"data-action":y.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{y.disabled||(s(y.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:y.disabled?"default":"pointer",opacity:y.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:y.label},y.action))})}const lv=t=>`${t.plugin}/${t.skill}`;function tT(t){const a=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),x=p.useCallback(()=>h(C=>C+1),[]),m=p.useCallback(async C=>{var k,w;try{await Se.deleteSkill(C.skill.plugin,C.skill.skill),(k=c.current)==null||k.call(c,C.skill)}catch(T){(w=u.current)==null||w.call(u,C.skill,T)}finally{d.current.delete(lv(C.skill)),x()}},[x]),v=p.useCallback(C=>{const k=lv(C),w=d.current.get(k);w!=null&&w.timeoutId&&clearTimeout(w.timeoutId);const T={skill:C,timeoutId:null};T.timeoutId=setTimeout(()=>{T.timeoutId=null,m(T)},a),d.current.set(k,T),x()},[a,m,x]),y=p.useCallback(C=>{const k=d.current.get(C);k&&(k.timeoutId&&clearTimeout(k.timeoutId),d.current.delete(C),x())},[x]),b=p.useCallback(async()=>{const C=Array.from(d.current.values());for(const k of C)k.timeoutId&&(clearTimeout(k.timeoutId),k.timeoutId=null);await Promise.all(C.map(k=>m(k)))},[m]),S=p.useCallback(C=>d.current.has(C),[]);return p.useEffect(()=>{const C=()=>{b()};return window.addEventListener("beforeunload",C),()=>{window.removeEventListener("beforeunload",C)}},[b]),p.useEffect(()=>{const C=d.current;return()=>{for(const k of C.values())k.timeoutId&&clearTimeout(k.timeoutId);C.clear()}},[]),{enqueueDelete:v,cancelDelete:y,flushPending:b,isPending:S}}const nT={"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 rT(t){return t?nT[t]??null:null}function aT({open:t,providerKey:a,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=rT(a),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Go.createPortal(r.jsxs(r.Fragment,{children:[r.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"}}),r.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:[r.jsx(lT,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(sT,{content:c}):r.jsx(iT,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
92
|
-
from { transform: translateX(100%); }
|
|
93
|
-
to { transform: translateX(0); }
|
|
94
|
-
}
|
|
95
|
-
@keyframes vskillDrawerBackdropIn {
|
|
96
|
-
from { opacity: 0; }
|
|
97
|
-
to { opacity: 1; }
|
|
98
|
-
}`})]})]}),document.body)}function lT({title:t,onClose:a}){return r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function sT({content:t}){var a,s;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>r.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&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>r.jsx("li",{children:r.jsx(oT,{name:o})},o))})]}),t.keyUrl&&r.jsx(cT,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((o,c)=>r.jsx(Fd,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>r.jsx(Fd,{code:o},`start-${c}`)),t.pullExample&&r.jsx(Fd,{code:t.pullExample})]})]}),r.jsx("footer",{style:{marginTop:8},children:r.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 iT(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function oT({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return r.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:[r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),r.jsx("button",{type:"button",onClick:a,"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 Fd({code:t}){return r.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 cT({href:t,label:a,testId:s}){return r.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:[a," →"]})}function uT(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),c=p.useRef(null),u=p.useCallback((h,x)=>{var m;c.current=typeof document<"u"?document.activeElement:null,(m=x==null?void 0:x.beforeOpen)==null||m.call(x),o(h),a(!0)},[]),d=p.useCallback(()=>{a(!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 dT(t){const a=[],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));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,x)=>h+x.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function fT({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=p.useRef(null);p.useEffect(()=>{const v=y=>{y.key==="Escape"&&(y.preventDefault(),d())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[d]),p.useEffect(()=>{const v=b=>{h.current&&!h.current.contains(b.target)&&d()},y=setTimeout(()=>{document.addEventListener("mousedown",v)},0);return()=>{clearTimeout(y),document.removeEventListener("mousedown",v)}},[d]);const x=p.useMemo(()=>dT(t),[t]),m=t.find(v=>v.id===s)??t.find(v=>v.id===a)??t[0];return typeof document>"u"?null:Go.createPortal(r.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:[r.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[r.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:[x.detected.length===0&&x.notDetected.length===0&&r.jsx(sv,{}),x.detected.map(v=>v.kind==="aggregate"?r.jsx(mT,{row:v,onFocus:()=>{var y;return o(((y=v.consumers[0])==null?void 0:y.id)??a??"")}},v.key):r.jsx(pT,{agent:v.agent,focused:v.agent.id===s,active:v.agent.id===a,onClick:()=>o(v.agent.id)},v.key)),x.notDetected.length>0&&r.jsxs(r.Fragment,{children:[r.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}),x.notDetected.map(v=>r.jsx(hT,{agent:v.agent},v.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:m?r.jsx(xT,{agent:m,activeAgentId:a,onSwitch:()=>c(m.id)}):r.jsx(sv,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
|
|
99
|
-
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
100
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
101
|
-
}`})]}),document.body)}function pT({agent:t,focused:a,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.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:a?"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:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function mT({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,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:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.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)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function hT({agent:t}){const a=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 r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.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 xT({agent:t,activeAgentId:a,onSwitch:s}){const o=t.id===a,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":vT(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Gd,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Gd,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Gd,{label:ne.scopePicker.statsLastSync,value:t.lastSync?gT(t.lastSync):"—"})]}),r.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 Gd({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function sv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function gT(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))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 vT(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function yT(t){const a=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)a.set(o,s);return t.agents.map(s=>{const o=a.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 bT({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),x=p.useRef(null),m=p.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),v=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),y=p.useCallback(()=>{var S;u(!1),(S=x.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,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:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:v,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.displayName)??"Select agent"}),r.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,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(fT,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),y()},onClose:y})]})}const Jy="vskill-ccode-banner-dismissed",jT=new Set(["claude-cli","claude-code"]);function ST(){try{return sessionStorage.getItem(Jy)==="true"}catch{return!1}}function kT(){try{sessionStorage.setItem(Jy,"true")}catch{}}function wT({activeAgentId:t}){const[a,s]=p.useState(()=>ST()),o=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{kT(),s(!0)},[]);return!t||!jT.has(t)||a?null:r.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:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),r.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})]}),r.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 CT(){const[t,a]=p.useState(null),[s,o]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Se.getAgents();a(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 Eo="workspace",ET=["skills","agents"];async function NT(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function TT(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function RT(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function AT(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function Wd(){for(const t of ET)An(t)}function MT(){const{data:t,loading:a,error:s,revalidate:o}=Js(Eo,NT),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await TT(m),An(Eo),Wd()},[]),h=p.useCallback(async m=>{await RT(m),An(Eo),Wd()},[]),x=p.useCallback(async m=>{await AT(m),An(Eo),Wd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:x,revalidate:o}}function LT({workspace:t,onSwitch:a,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,v]=p.useState(""),[y,b]=p.useState(null),[S,C]=p.useState(null),[k,w]=p.useState(null),[T,N]=p.useState(!1),L=p.useRef(null),_=(t==null?void 0:t.projects)??[],D=_.find(M=>M.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function M(U){L.current&&!L.current.contains(U.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[u]);async function F(){b(null);const M=m.trim();if(!M){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!M.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(M)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:M}),v(""),x(!1)}catch(U){const $=U instanceof Error?U.message:String(U);/does not exist/i.test($)?b(`Path not found on disk: ${M}`):/Duplicate/i.test($)?b("That project is already registered."):b($)}}async function E(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const M=await window.showDirectoryPicker();v(M.name),x(!0)}catch{}else x(!0)}function O(M){if(M.length<=50)return M;const U=M.split("/");return U.length<=4?M:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return r.jsxs("div",{ref:L,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(M=>!M),"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:[r.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)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.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:[_.length===0&&r.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."}),_.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:_.map(M=>{const U=c?c(M.path):!1,$=M.id===(t==null?void 0:t.activeProjectId),Y=S===M.id;return r.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>C(M.id),onMouseLeave:()=>C(X=>X===M.id?null:X),onClick:()=>{if(!U){if($){d(!1);return}w(M)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:Y&&!U?"var(--surface-2, rgba(0,0,0,0.04))":$?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:M.colorDot,boxShadow:$?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:$?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.name}),$&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:M.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(M.path)}),U&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${M.name}`,onClick:X=>{X.stopPropagation(),o(M.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:Y?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:r.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:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},M.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.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:M=>{M.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="transparent"},children:[r.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:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:m,onChange:M=>v(M.target.value),onKeyDown:M=>{M.key==="Enter"&&F(),M.key==="Escape"&&(x(!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"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{x(!1),b(null),v("")},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"}),r.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"})]}),y&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:y})]})]})]}),k&&r.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:()=>w(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:M=>M.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:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",k.name]}),r.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:"}),r.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 "${k.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${k.path}" && npx vskill@latest studio`),N(!0),setTimeout(()=>N(!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:T?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>w(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 zT(t,a){const s=a.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 DT({open:t,projects:a,onSwitch:s,onClose:o}){const[c,u]=p.useState(""),[d,h]=p.useState(0),x=p.useMemo(()=>zT(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=x.length&&h(0)},[x.length,d]);const m=v=>{if(v.key==="Escape"){v.preventDefault(),o();return}if(v.key==="ArrowDown"){v.preventDefault(),h(y=>Math.min(y+1,Math.max(x.length-1,0)));return}if(v.key==="ArrowUp"){v.preventDefault(),h(y=>Math.max(y-1,0));return}if(v.key==="Enter"){v.preventDefault();const y=x[d];y&&(s(y.id),o())}};return t?r.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:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:v=>u(v.target.value),onKeyDown:m,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.map((v,y)=>r.jsxs("li",{role:"option","aria-selected":y===d,"data-highlighted":y===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",y===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(y),onClick:()=>{s(v.id),o()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:v.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:v.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:v.path})]})]},v.id))]})]})]}):null}const iv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function _T({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[x,m]=p.useState(s),[v,y]=p.useState(""),[b,S]=p.useState(""),[C,k]=p.useState(""),[w,T]=p.useState([]),[N,L]=p.useState(!1),[_,D]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),y(""),S(""),k(""),D(null))},[t,s]),p.useEffect(()=>{if(!t)return;let I=!0;return fetch("/api/authoring/plugins").then(A=>A.json()).then(A=>{I&&T(A.plugins??[])}).catch(()=>{}),()=>{I=!1}},[t]),p.useEffect(()=>{if(!t)return;function I(A){A.key==="Escape"&&(A.preventDefault(),a())}return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[t,a]),!t)return null;const F=w.length>0,E=o&&F,O=o,M=iv.test(v),U=x==="existing-plugin"?b.length>0:iv.test(b),$=!N&&M&&(x==="standalone"||U),Y=OT(c,x,b,v);async function X(){D(null),L(!0);try{const B=new URLSearchParams;B.set("mode",x),B.set("skillName",v),b&&B.set("pluginName",b);const V=await fetch(`/api/authoring/skill-exists?${B.toString()}`),H=await V.json();if(!V.ok){D(H.error??`Check failed: ${V.status}`);return}if(H.exists){D(`Skill '${v}' already exists${H.path?` at ${H.path}`:""}`);return}}catch(B){D(B instanceof Error?B.message:String(B));return}finally{L(!1)}const I=new URLSearchParams;I.set("mode",x),I.set("skillName",v),C.trim()&&I.set("description",C.trim()),b&&I.set("pluginName",b);const A=`#/create?${I.toString()}`;typeof window<"u"&&(window.location.hash=A),a()}async function ee(){D(null),L(!0);try{const I=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:v,description:C.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),A=await I.json();if(!I.ok||!A.ok){D(A.error??`Create failed: ${I.status}`);return}An("skills"),u==null||u({mode:x,skillName:v,pluginName:A.pluginName??null,skillMdPath:A.skillMdPath}),a()}catch(I){D(I instanceof Error?I.message:String(I))}finally{L(!1)}}return r.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:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.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:[r.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:[r.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"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(qd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>m("standalone")}),r.jsx(qd,{title:"Add to existing plugin",subtitle:E?`${w.length} plugin source${w.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:x==="existing-plugin",onClick:()=>E&&m("existing-plugin")}),r.jsx(qd,{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:x==="new-plugin",onClick:()=>O&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(No,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:I=>S(I.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:To(!b||U)})}),x==="existing-plugin"&&r.jsx(No,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:I=>S(I.target.value),style:{...To(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),w.map(I=>r.jsx("option",{value:I.name,children:I.name},I.path))]})}),r.jsx(No,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:v,onChange:I=>y(I.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:To(!v||M)})}),r.jsx(No,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:C,onChange:I=>k(I.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...To(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),Y&&r.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:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),Y.map((I,A)=>r.jsx("div",{children:I},A))]}),_&&r.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:_})]}),r.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:[r.jsx("button",{type:"button",onClick:a,style:Yd,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:ov,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:Yd,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!$,style:{...Yd,opacity:$?1:.5,cursor:$?"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"}),r.jsx("button",{type:"button",onClick:()=>void ee(),disabled:!$,style:{...ov,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:N?"Creating…":"Create empty scaffold"})]})]})]})]})}function qd({title:t,subtitle:a,description:s,icon:o,selected:c,disabled:u,onClick:d}){return r.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:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function No({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function To(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 ov={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"},Yd={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 OT(t,a,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function eb(t){return t.trim().toLowerCase()}function BT(t,a){const s=eb(a);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function IT(t,a){const s=eb(a);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function UT({open:t,onClose:a,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=p.useState(null),[h,x]=p.useState([]),[m,v]=p.useState(null),[y,b]=p.useState(null),[S,C]=p.useState(!1),[k,w]=p.useState(null),[T,N]=p.useState(""),[L,_]=p.useState("");p.useEffect(()=>{m?N(""):_("")},[m]);const D=p.useMemo(()=>BT(h,T),[h,T]),F=p.useMemo(()=>IT((y==null?void 0:y.plugins)??[],L),[y,L]);return p.useEffect(()=>{t&&(C(!0),w(null),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>{if(E.error)throw new Error(E.error);x(E.marketplaces??[])}).catch(E=>w(E instanceof Error?E.message:String(E))).finally(()=>C(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}C(!0),w(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(E=>E.json()).then(E=>{if(E.error)throw new Error(E.error);b(E)}).catch(E=>w(E instanceof Error?E.message:String(E))).finally(()=>C(!1))},[m]),p.useEffect(()=>{if(!t)return;function E(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.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:[r.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:[m&&r.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:m?(y==null?void 0:y.name)??m:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),k&&r.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:k}),!m&&!S&&h.length===0&&!k&&r.jsx(HT,{}),!m&&h.length>0&&r.jsx(cv,{value:T,onChange:N,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!m&&h.length>0&&D.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",T,"”."]}),!m&&D.map(E=>r.jsxs("button",{type:"button",onClick:()=>v(E.name),style:PT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:E.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.source})]},E.name)),m&&y&&r.jsxs(r.Fragment,{children:[y.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:y.description}),y.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),y.plugins.length>0&&r.jsx(cv,{value:L,onChange:_,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),y.plugins.length>0&&F.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",L,"”."]}),F.map(E=>{const O=c.has(E.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[E.name,E.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:E.version}),E.category&&r.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:E.category})]}),E.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:E.description})]}),O&&o?r.jsx("button",{type:"button",disabled:u===E.name,onClick:async()=>{d(E.name);try{await o(E.name)}finally{d(null)}},"aria-label":`Uninstall ${E.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===E.name?"wait":"pointer",opacity:u===E.name?.6:1,fontFamily:"inherit"},children:u===E.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(E.name,m),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"})]})},E.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx($T,{onAdded:()=>{An("marketplaces"),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>x(E.marketplaces??[]))}})})]})]}):null}function cv({value:t,onChange:a,placeholder:s,ariaLabel:o,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(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 HT(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function $T({onAdded:t}){const[a,s]=p.useState(""),[o,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const x=a.trim();if(x){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),v=await m.json().catch(()=>({}));if(!m.ok||!v.ok){d(v.error??`Add failed (${m.status})`);return}s(""),t()}catch(m){d(m instanceof Error?m.message:String(m))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:x=>s(x.target.value),onKeyDown:x=>{x.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"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!a.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||!a.trim()?"not-allowed":"pointer",opacity:o||!a.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&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const PT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Kd=12;function VT({job:t,onDone:a}){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 y=new AbortController;let b=[],S="running";return(async()=>{try{const C=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:y.signal});if(!C.ok||!C.body){u("failed"),a({ok:!1,code:C.status,lines:[`HTTP ${C.status}`]});return}const k=C.body.getReader(),w=new TextDecoder;let T="";for(;;){const{value:N,done:L}=await k.read();if(L)break;T+=w.decode(N,{stream:!0});const _=T.split(/\n\n/);T=_.pop()??"";for(const D of _){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(-Kd),o(b)):E.type==="stderr"&&E.line?(b=[...b,`⚠ ${E.line}`].slice(-Kd),o(b)):E.type==="done"?(S=E.ok?"ok":"failed",u(S),Vv(),An("skills"),a({ok:E.ok??!1,code:E.code??null,lines:b})):E.type==="error"&&E.error&&(b=[...b,`✘ ${E.error}`].slice(-Kd),o(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(C){if(C.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,C instanceof Error?C.message:String(C)]})}})(),()=>y.abort()},[t==null?void 0:t.ref]),!t)return null;const x=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",m=c==="ok"?"✔":c==="failed"?"✘":"…",v=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.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 ${x}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(y=>!y),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(FT,{}):m}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[v,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.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]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.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 r.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:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const GT=3e3,WT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function uv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function qT(){const{toast:t}=Wo(),a=p.useRef(new Map),s=p.useCallback(o=>{if(!uv(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<GT)return;a.current.set(o.provider,c);const d=WT[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||!uv(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 tb="vskill.studio.prefs";function nb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function rb(){const t=nb();if(!t)return{};try{const a=t.getItem(tb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function YT(t,a){const s=nb();if(s)try{const c={...rb(),[t]:a};s.setItem(tb,JSON.stringify(c))}catch{}}function KT(t,a){const o=rb()[t];return o===void 0?a:o}const dv={open:!1,x:0,y:0,skill:null};function XT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ia(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function QT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function ZT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ia(ne.toasts.permissionDenied,"error");return}Ia(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ia(ne.actions.editPlaceholder,"info");return;case"run-benchmark":Ia(ne.toasts.benchmarkQueued,"info");return;case"duplicate":Ia(ne.toasts.skillDuplicated,"info");return;case"update":Ia(ne.toasts.skillUpdated,"info");return;case"uninstall":Ia(ne.actions.editPlaceholder,"info");return;case"delete":QT(a);return;default:return}}function JT(t){return t.startsWith("#/create")}function eR(t){return t.startsWith("#/updates")}function ab(t){const[a,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)},[]),a}function tR(){return ab(JT)}function nR(){return ab(eR)}function rR(){var o,c;if(typeof navigator>"u")return"⌘⇧K";const t=((o=navigator.platform)==null?void 0:o.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function aR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function lR(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(rR())},[]);const s=aR();function o(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:o,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const sR=p.lazy(()=>Va(()=>import("./CommandPalette-DWl6kb7K.js"),__vite__mapDeps([2,1]))),iR=p.lazy(()=>Va(()=>import("./FindSkillsPalette-Br5cToMQ.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),oR=p.lazy(()=>Va(()=>import("./SkillDetailPanel-ZGSkm510.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),cR=p.lazy(()=>Va(()=>import("./CreateSkillPage-IndkXdwH.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),uR=p.lazy(()=>Va(()=>Promise.resolve().then(()=>gN),void 0).then(t=>({default:t.UpdatesPanel})));function dR(){return r.jsx(RS,{children:r.jsx(ES,{children:r.jsxs(N2,{children:[r.jsx(fR,{}),r.jsx(XN,{})]})})})}function fR(){var sn,Zt;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=nr(),{config:h}=Fa(),{mode:x,resolvedTheme:m,setTheme:v}=Pv(),{toast:y}=Wo(),[b,S]=p.useState(()=>eC()),[C]=p.useState(!0),[k,w]=p.useState(!1),[T,N]=p.useState(!1),[L,_]=p.useState(!1),[D,F]=p.useState("overview"),[E,O]=p.useState(dv),M=p.useCallback((fe,Ce)=>{O(XT(fe,Ce))},[]),U=CT(),[$,Y]=p.useState(()=>KT("activeAgent",null)),X=p.useCallback(fe=>{Y(fe),YT("activeAgent",fe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:fe}}))},[]);p.useEffect(()=>{var fe;!$&&((fe=U.response)!=null&&fe.suggested)&&X(U.response.suggested)},[$,(sn=U.response)==null?void 0:sn.suggested,X]);const ee=p.useMemo(()=>U.response?yT(U.response):[],[U.response]),{workspace:I,switchProject:A,addProject:B,removeProject:V,activeProject:H}=MT(),[re,z]=p.useState(!1),[W,te]=p.useState(!1),[q,oe]=p.useState("standalone"),le=p.useCallback((fe="standalone")=>{oe(fe),te(!0)},[]);p.useEffect(()=>{function fe(Ce){if(!(Ce instanceof CustomEvent))return;const ze=Ce.detail;le((ze==null?void 0:ze.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",fe),()=>window.removeEventListener("studio:request-create-skill",fe)},[le]);const[ve,ce]=p.useState(!1),[be,Re]=p.useState(null),[Ae,se]=p.useState(null);p.useEffect(()=>{function fe(){ce(!0)}return window.addEventListener("studio:open-marketplace",fe),()=>window.removeEventListener("studio:open-marketplace",fe)},[]);const he=p.useMemo(()=>{const fe=new Set;for(const Ce of t.skills)Ce.source==="plugin"&&Ce.pluginName&&fe.add(Ce.pluginName);return fe},[t.skills]);cf([{key:"p",meta:!0,handler:fe=>{var ze;const Ce=typeof document<"u"?document.activeElement:null;Ce&&Ce.tagName==="INPUT"||((ze=fe==null?void 0:fe.preventDefault)==null||ze.call(fe),z(jn=>!jn))}}],{enabled:!0});const pe=uT(),xe=pe.open;p.useEffect(()=>{function fe(Ce){if(!(Ce instanceof CustomEvent))return;const ze=Ce.detail;ze!=null&&ze.provider&&xe(ze.provider)}return window.addEventListener("studio:open-setup-drawer",fe),()=>window.removeEventListener("studio:open-setup-drawer",fe)},[xe]);const je=p.useCallback(()=>{O(dv)},[]);p.useEffect(()=>{function fe(Ce){if(!(Ce instanceof CustomEvent))return;const ze=Ce.detail;ze!=null&&ze.message&&y({message:ze.message,severity:ze.severity??"info"})}return window.addEventListener("studio:toast",fe),()=>window.removeEventListener("studio:toast",fe)},[y]),qT();const[Be,Ue]=p.useState(!1),[gt,Lt]=p.useState(void 0);p.useEffect(()=>{function fe(Ce){if(!(Ce instanceof CustomEvent))return;const ze=Ce.detail;Lt(ze==null?void 0:ze.provider),Ue(!0)}return window.addEventListener("studio:open-settings",fe),()=>window.removeEventListener("studio:open-settings",fe)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[st,Et]=p.useState(null),[Yt,Ye]=p.useState(()=>new Set),vt=p.useRef(!1),bn=p.useMemo(()=>Dw(),[]),ye=p.useCallback(fe=>`${fe.plugin}/${fe.skill}`,[]),ht=p.useCallback(fe=>{Ye(Ce=>{const ze=new Set(Ce);return ze.add(ye(fe)),ze})},[ye]),zt=p.useCallback(fe=>{Ye(Ce=>{const ze=new Set(Ce);return ze.delete(ye(fe)),ze})},[ye]),Ot=tT({delayMs:1e4,onCommit:fe=>{o(),zt(fe)},onFailure:(fe,Ce)=>{zt(fe),y({message:`Couldn't delete ${fe.skill}: ${Ce.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{ht(fe),Ot.enqueueDelete(fe)}}})}});p.useEffect(()=>{function fe(Ce){if(!(Ce instanceof CustomEvent))return;const ze=Ce.detail;ze!=null&&ze.skill&&Et(ze.skill)}return window.addEventListener("studio:request-delete",fe),()=>window.removeEventListener("studio:request-delete",fe)},[]);const Dn=p.useCallback(()=>{const fe=st;if(Et(null),!fe)return;const Ce={plugin:fe.plugin,skill:fe.skill};ht(Ce),Ot.enqueueDelete(Ce);const ze=vt.current?"":`Sent to your ${bn}. Open Trash to restore. `;vt.current=!0,y({message:`${ze}Deleted ${fe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ot.cancelDelete(ye(Ce)),zt(Ce)}}})},[st,ht,zt,Ot,y,bn,ye]),Nt=p.useCallback(()=>{Et(null)},[]),_n=p.useMemo(()=>t.skills.filter(fe=>!Yt.has(ye(fe))),[t.skills,Yt,ye]),Pt=oC(_n,(H==null?void 0:H.path)??null),Tt=p.useMemo(()=>t.selectedSkill?t.skills.find(fe=>fe.plugin===t.selectedSkill.plugin&&fe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),it=p.useCallback(fe=>{a({plugin:fe.plugin,skill:fe.skill,origin:fe.origin})},[a]),rr=p.useMemo(()=>{if(!t.selectedSkill)return"";const fe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${fe})`},[t.selectedSkill]),ar=p.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>v(x==="light"?"dark":x==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>_(fe=>!fe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>N(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[x,v,o]),[hr,pn]=p.useState(null);cf([{key:"cmd+k",handler:()=>w(fe=>!fe)},{key:"ctrl+k",handler:()=>w(fe=>!fe)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>N(fe=>!fe)},{key:"cmd+shift+d",handler:()=>v(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>v(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>_(fe=>!fe)},{key:"ctrl+b",handler:()=>_(fe=>!fe)},{key:"e",handler:()=>y({message:ne.actions.editPlaceholder,severity:"info"})}]);const Rt=tR(),ot=nR()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(uR,{})}):Rt?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(cR,{})}):r.jsx(PN,{selectedSkillInfo:Tt,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:it});return r.jsxs(r.Fragment,{children:[r.jsx(AS,{sidebarWidth:b,sidebarHidden:L||t.isMobile&&t.mobileView==="detail",banner:r.jsx(cC,{connected:C}),liveMessage:rr,topRail:r.jsx(M2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>w(!0),onHome:s,onRequestCreateSkill:()=>le("standalone"),projectPickerSlot:I&&I.projects.length>0?r.jsx(LT,{workspace:I,onSwitch:A,onAdd:B,onRemove:V}):void 0,findSkillsSlot:r.jsx(lR,{})}),sidebar:r.jsx(Ww,{skills:_n,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:it,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:M,outdatedByOrigin:c,activeAgentId:$,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:Pt,topSlot:U.status==="ready"&&ee.length>0?r.jsxs(r.Fragment,{children:[r.jsx(bT,{agents:ee,activeAgentId:$,onActiveAgentChange:X,onOpenSetup:fe=>pe.open(fe)}),r.jsx(wT,{activeAgentId:$})]}):null}),resizeHandle:r.jsx(nC,{initialWidth:b??Ps,onChange:S}),main:ot,statusBar:r.jsx(P2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Zt=h==null?void 0:h.providers)==null?void 0:Zt.map(fe=>{const Ce=fe.id;return{id:Ce,label:fe.label,available:fe.available,kind:Ce==="ollama"||Ce==="lm-studio"?"start-service":Ce==="anthropic"||Ce==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(ZN,{open:T,onClose:()=>N(!1)}),r.jsx(aT,{open:pe.isOpen,providerKey:pe.providerKey,onClose:pe.close}),r.jsx(eT,{state:E,onClose:je,onAction:(fe,Ce)=>ZT(fe,Ce)}),k&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(sR,{open:k,onClose:()=>w(!1),commands:ar})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(iR,{onSelect:fe=>{const Ce=fe.name.split("/");Ce.length===3&&pn({owner:Ce[0],repo:Ce[1],slug:Ce[2],displayName:fe.displayName??fe.name})}})}),hr&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(oR,{selectedSkill:hr,onClose:()=>pn(null)})}),r.jsx(DT,{open:re,projects:(I==null?void 0:I.projects)??[],onSwitch:fe=>{A(fe)},onClose:()=>z(!1)}),r.jsx(_T,{open:W,onClose:()=>te(!1),initialMode:q,isClaudeCode:$==="claude-code",projectRoot:(H==null?void 0:H.path)??(h==null?void 0:h.projectName)??"",onCreated:fe=>{o(),setTimeout(()=>{u(fe.pluginName??"",fe.skillName)},500)}}),r.jsx(UT,{open:ve,onClose:()=>ce(!1),installedNames:he,onInstall:(fe,Ce)=>{Re({plugin:fe,marketplace:Ce,ref:`${fe}@${Ce}`}),ce(!1)},onUninstall:async fe=>{if(await new Promise(ze=>{se({plugin:fe,resolve:ze})}))try{const ze=await fetch(`/api/plugins/${encodeURIComponent(fe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),jn=await ze.json().catch(()=>({}));if(!ze.ok||!jn.ok){y({message:jn.error??`Uninstall failed (${ze.status})`,severity:"error"});return}const ha=jn.fallback==="orphan-cache-removed"?`Removed orphaned ${fe}.`:`Uninstalled ${fe}.`;y({message:ha,severity:"success"}),o()}catch(ze){y({message:ze instanceof Error?ze.message:String(ze),severity:"error"})}}}),r.jsx(Iv,{open:Be,onClose:()=>Ue(!1),initialProvider:gt,onToast:fe=>y({message:fe,severity:"info"})}),r.jsx(VT,{job:be,onDone:fe=>{fe.ok&&(o(),setTimeout(()=>Re(null),3e3))}}),r.jsx(of,{open:st!==null,title:st?`Delete "${st.skill}"?`:"",body:`It will be sent to your ${bn}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Dn,onCancel:Nt}),r.jsx(of,{open:Ae!==null,title:Ae?`Uninstall ${Ae.plugin}?`:"",body:Ae?`This removes the ${Ae.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ae==null||Ae.resolve(!0),se(null)},onCancel:()=>{Ae==null||Ae.resolve(!1),se(null)}})]})}const fv="vskill.migrations.scope-rename.v1",pR={own:"authoring-project",installed:"available-project",global:"available-personal"},mR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function hR(t){if(t.getItem(fv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(mR);if(!c)continue;const[,u,d]=c,h=pR[d];if(!h)continue;const x=t.getItem(o);x!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:x})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(fv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.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{hR(window.localStorage)}catch{}k0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(Fj,{children:r.jsx(B2,{children:r.jsx(dR,{})})})}));export{ec as E,Mv as L,ai as P,Ne as R,fN as S,gR as T,Va as _,Fa as a,rb as b,cN as c,Zo as d,Wo as e,nr as f,KT as g,Se as h,Ay as i,r as j,p as r,ne as s,hf as t,lj as u,YT as w};
|