vskill 1.0.13 → 1.0.15
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 +63 -2
- package/agents.json +1 -1
- package/dist/bin.js +0 -0
- package/dist/clone/github-scaffold.d.ts +38 -0
- package/dist/clone/github-scaffold.js +108 -0
- package/dist/clone/github-scaffold.js.map +1 -0
- package/dist/clone/provenance-fork.d.ts +34 -0
- package/dist/clone/provenance-fork.js +97 -0
- package/dist/clone/provenance-fork.js.map +1 -0
- package/dist/clone/reference-scanner.d.ts +19 -0
- package/dist/clone/reference-scanner.js +144 -0
- package/dist/clone/reference-scanner.js.map +1 -0
- package/dist/clone/skill-locator.d.ts +26 -0
- package/dist/clone/skill-locator.js +248 -0
- package/dist/clone/skill-locator.js.map +1 -0
- package/dist/clone/target-router.d.ts +73 -0
- package/dist/clone/target-router.js +200 -0
- package/dist/clone/target-router.js.map +1 -0
- package/dist/clone/types.d.ts +82 -0
- package/dist/clone/types.js +11 -0
- package/dist/clone/types.js.map +1 -0
- package/dist/commands/add.js +96 -32
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/auth.d.ts +23 -0
- package/dist/commands/auth.js +273 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/check.d.ts +55 -0
- package/dist/commands/check.js +279 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/clone-prompts.d.ts +13 -0
- package/dist/commands/clone-prompts.js +67 -0
- package/dist/commands/clone-prompts.js.map +1 -0
- package/dist/commands/clone.d.ts +70 -0
- package/dist/commands/clone.js +649 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/eval/serve.js +8 -1
- package/dist/commands/eval/serve.js.map +1 -1
- package/dist/commands/keys.js +54 -2
- package/dist/commands/keys.js.map +1 -1
- package/dist/core/agent-prompts.d.ts +35 -0
- package/dist/core/agent-prompts.js +201 -0
- package/dist/core/agent-prompts.js.map +1 -0
- package/dist/core/skill-generator.d.ts +25 -3
- package/dist/core/skill-generator.js +131 -0
- package/dist/core/skill-generator.js.map +1 -1
- package/dist/eval/skill-scanner.d.ts +2 -12
- package/dist/eval/skill-scanner.js +27 -5
- package/dist/eval/skill-scanner.js.map +1 -1
- package/dist/eval-server/api-routes.d.ts +14 -0
- package/dist/eval-server/api-routes.js +376 -31
- package/dist/eval-server/api-routes.js.map +1 -1
- package/dist/eval-server/data-events.d.ts +1 -1
- package/dist/eval-server/data-events.js.map +1 -1
- package/dist/eval-server/install-engine-routes-helpers.d.ts +1 -3
- package/dist/eval-server/install-engine-routes-helpers.js +6 -14
- package/dist/eval-server/install-engine-routes-helpers.js.map +1 -1
- package/dist/eval-server/origin-resolver.d.ts +42 -0
- package/dist/eval-server/origin-resolver.js +168 -0
- package/dist/eval-server/origin-resolver.js.map +1 -0
- package/dist/eval-server/platform-proxy.d.ts +10 -0
- package/dist/eval-server/platform-proxy.js +58 -2
- package/dist/eval-server/platform-proxy.js.map +1 -1
- package/dist/eval-server/skill-create-routes.d.ts +8 -0
- package/dist/eval-server/skill-create-routes.js +96 -0
- package/dist/eval-server/skill-create-routes.js.map +1 -1
- package/dist/eval-server/skill-resolver.js +40 -0
- package/dist/eval-server/skill-resolver.js.map +1 -1
- package/dist/eval-server/utils/resolve-editor.d.ts +18 -0
- package/dist/eval-server/utils/resolve-editor.js +77 -0
- package/dist/eval-server/utils/resolve-editor.js.map +1 -0
- package/dist/eval-server/utils/scan-install-locations.d.ts +7 -0
- package/dist/eval-server/utils/scan-install-locations.js +20 -0
- package/dist/eval-server/utils/scan-install-locations.js.map +1 -1
- package/dist/eval-server/utils/which.d.ts +15 -0
- package/dist/eval-server/utils/which.js +76 -0
- package/dist/eval-server/utils/which.js.map +1 -0
- package/dist/eval-ui/assets/{CreateSkillPage-T0YWZWw-.js → CreateSkillPage-BmbvQEzE.js} +1 -1
- package/dist/eval-ui/assets/{FindSkillsPalette-KcFM32hZ.js → FindSkillsPalette-D0Zjhm31.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-EhBtr4Xx.js → SearchPaletteCore-EhcN1xEa.js} +1 -1
- package/dist/eval-ui/assets/SkillDetailPanel-B5J60ffv.js +1 -0
- package/dist/eval-ui/assets/{UpdateDropdown-pjFhHTi6.js → UpdateDropdown-Celf0_Cr.js} +1 -1
- package/dist/eval-ui/assets/index-BV7k6fdk.js +124 -0
- package/dist/eval-ui/assets/{index-BKAvJDDF.css → index-CKLqBL52.css} +1 -1
- package/dist/eval-ui/index.html +2 -2
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -1
- package/dist/installer/frontmatter.d.ts +26 -0
- package/dist/installer/frontmatter.js +90 -0
- package/dist/installer/frontmatter.js.map +1 -1
- package/dist/lib/github-fetch.d.ts +22 -0
- package/dist/lib/github-fetch.js +152 -0
- package/dist/lib/github-fetch.js.map +1 -0
- package/dist/lib/keychain.d.ts +41 -0
- package/dist/lib/keychain.js +232 -0
- package/dist/lib/keychain.js.map +1 -0
- package/dist/studio/types.d.ts +13 -0
- package/dist/utils/claude-plugin.d.ts +26 -0
- package/dist/utils/claude-plugin.js +60 -0
- package/dist/utils/claude-plugin.js.map +1 -1
- package/package.json +2 -1
- package/dist/eval-ui/assets/SkillDetailPanel-cyzLsLcK.js +0 -1
- package/dist/eval-ui/assets/index-C3S9iHnq.js +0 -122
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-Celf0_Cr.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-D0Zjhm31.js","assets/SkillDetailPanel-B5J60ffv.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-BmbvQEzE.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"]'))i(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"&&i(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 i(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function Av(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jd={exports:{}},Os={};/**
|
|
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 Ux;function V0(){if(Ux)return Os;Ux=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(i,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var f in c)f!=="key"&&(u[f]=c[f])}else u=c;return c=u.ref,{$$typeof:t,type:i,key:d,ref:c!==void 0?c:null,props:u}}return Os.Fragment=a,Os.jsx=s,Os.jsxs=s,Os}var Hx;function F0(){return Hx||(Hx=1,jd.exports=V0()),jd.exports}var r=F0(),Sd={exports:{}},Pe={};/**
|
|
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 Px;function W0(){if(Px)return Pe;Px=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function j(L){return L===null||typeof L!="object"?null:(L=b&&L[b]||L["@@iterator"],typeof L=="function"?L:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,w={};function N(L,I,K){this.props=L,this.context=I,this.refs=w,this.updater=K||k}N.prototype.isReactComponent={},N.prototype.setState=function(L,I){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,I,"setState")},N.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function T(){}T.prototype=N.prototype;function A(L,I,K){this.props=L,this.context=I,this.refs=w,this.updater=K||k}var B=A.prototype=new T;B.constructor=A,C(B,N.prototype),B.isPureReactComponent=!0;var M=Array.isArray;function P(){}var E={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function z(L,I,K){var Q=K.ref;return{$$typeof:t,type:L,key:I,ref:Q!==void 0?Q:null,props:K}}function _(L,I){return z(L.type,I,L.props)}function H(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function F(L){var I={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(K){return I[K]})}var q=/\/+/g;function ee(L,I){return typeof L=="object"&&L!==null&&L.key!=null?F(""+L.key):I.toString(36)}function U(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(P,P):(L.status="pending",L.then(function(I){L.status==="pending"&&(L.status="fulfilled",L.value=I)},function(I){L.status==="pending"&&(L.status="rejected",L.reason=I)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function D(L,I,K,Q,ue){var J=typeof L;(J==="undefined"||J==="boolean")&&(L=null);var ie=!1;if(L===null)ie=!0;else switch(J){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(L.$$typeof){case t:case a:ie=!0;break;case v:return ie=L._init,D(ie(L._payload),I,K,Q,ue)}}if(ie)return ue=ue(L),ie=Q===""?"."+ee(L,0):Q,M(ue)?(K="",ie!=null&&(K=ie.replace(q,"$&/")+"/"),D(ue,I,K,"",function(je){return je})):ue!=null&&(H(ue)&&(ue=_(ue,K+(ue.key==null||L&&L.key===ue.key?"":(""+ue.key).replace(q,"$&/")+"/")+ie)),I.push(ue)),1;ie=0;var Z=Q===""?".":Q+":";if(M(L))for(var me=0;me<L.length;me++)Q=L[me],J=Z+ee(Q,me),ie+=D(Q,I,K,J,ue);else if(me=j(L),typeof me=="function")for(L=me.call(L),me=0;!(Q=L.next()).done;)Q=Q.value,J=Z+ee(Q,me++),ie+=D(Q,I,K,J,ue);else if(J==="object"){if(typeof L.then=="function")return D(U(L),I,K,Q,ue);throw I=String(L),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.")}return ie}function $(L,I,K){if(L==null)return L;var Q=[],ue=0;return D(L,Q,"","",function(J){return I.call(K,J,ue++)}),Q}function W(L){if(L._status===-1){var I=L._result;I=I(),I.then(function(K){(L._status===0||L._status===-1)&&(L._status=1,L._result=K)},function(K){(L._status===0||L._status===-1)&&(L._status=2,L._result=K)}),L._status===-1&&(L._status=0,L._result=I)}if(L._status===1)return L._result.default;throw L._result}var Y=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var I=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(I))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},oe={map:$,forEach:function(L,I,K){$(L,function(){I.apply(this,arguments)},K)},count:function(L){var I=0;return $(L,function(){I++}),I},toArray:function(L){return $(L,function(I){return I})||[]},only:function(L){if(!H(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return Pe.Activity=y,Pe.Children=oe,Pe.Component=N,Pe.Fragment=s,Pe.Profiler=c,Pe.PureComponent=A,Pe.StrictMode=i,Pe.Suspense=h,Pe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,Pe.__COMPILER_RUNTIME={__proto__:null,c:function(L){return E.H.useMemoCache(L)}},Pe.cache=function(L){return function(){return L.apply(null,arguments)}},Pe.cacheSignal=function(){return null},Pe.cloneElement=function(L,I,K){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var Q=C({},L.props),ue=L.key;if(I!=null)for(J in I.key!==void 0&&(ue=""+I.key),I)!O.call(I,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&I.ref===void 0||(Q[J]=I[J]);var J=arguments.length-2;if(J===1)Q.children=K;else if(1<J){for(var ie=Array(J),Z=0;Z<J;Z++)ie[Z]=arguments[Z+2];Q.children=ie}return z(L.type,ue,Q)},Pe.createContext=function(L){return L={$$typeof:d,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:u,_context:L},L},Pe.createElement=function(L,I,K){var Q,ue={},J=null;if(I!=null)for(Q in I.key!==void 0&&(J=""+I.key),I)O.call(I,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(ue[Q]=I[Q]);var ie=arguments.length-2;if(ie===1)ue.children=K;else if(1<ie){for(var Z=Array(ie),me=0;me<ie;me++)Z[me]=arguments[me+2];ue.children=Z}if(L&&L.defaultProps)for(Q in ie=L.defaultProps,ie)ue[Q]===void 0&&(ue[Q]=ie[Q]);return z(L,J,ue)},Pe.createRef=function(){return{current:null}},Pe.forwardRef=function(L){return{$$typeof:f,render:L}},Pe.isValidElement=H,Pe.lazy=function(L){return{$$typeof:v,_payload:{_status:-1,_result:L},_init:W}},Pe.memo=function(L,I){return{$$typeof:x,type:L,compare:I===void 0?null:I}},Pe.startTransition=function(L){var I=E.T,K={};E.T=K;try{var Q=L(),ue=E.S;ue!==null&&ue(K,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(P,Y)}catch(J){Y(J)}finally{I!==null&&K.types!==null&&(I.types=K.types),E.T=I}},Pe.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},Pe.use=function(L){return E.H.use(L)},Pe.useActionState=function(L,I,K){return E.H.useActionState(L,I,K)},Pe.useCallback=function(L,I){return E.H.useCallback(L,I)},Pe.useContext=function(L){return E.H.useContext(L)},Pe.useDebugValue=function(){},Pe.useDeferredValue=function(L,I){return E.H.useDeferredValue(L,I)},Pe.useEffect=function(L,I){return E.H.useEffect(L,I)},Pe.useEffectEvent=function(L){return E.H.useEffectEvent(L)},Pe.useId=function(){return E.H.useId()},Pe.useImperativeHandle=function(L,I,K){return E.H.useImperativeHandle(L,I,K)},Pe.useInsertionEffect=function(L,I){return E.H.useInsertionEffect(L,I)},Pe.useLayoutEffect=function(L,I){return E.H.useLayoutEffect(L,I)},Pe.useMemo=function(L,I){return E.H.useMemo(L,I)},Pe.useOptimistic=function(L,I){return E.H.useOptimistic(L,I)},Pe.useReducer=function(L,I,K){return E.H.useReducer(L,I,K)},Pe.useRef=function(L){return E.H.useRef(L)},Pe.useState=function(L){return E.H.useState(L)},Pe.useSyncExternalStore=function(L,I,K){return E.H.useSyncExternalStore(L,I,K)},Pe.useTransition=function(){return E.H.useTransition()},Pe.version="19.2.4",Pe}var Vx;function Tf(){return Vx||(Vx=1,Sd.exports=W0()),Sd.exports}var m=Tf();const Ae=Av(m);var kd={exports:{}},Bs={},wd={exports:{}},Cd={};/**
|
|
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 Fx;function G0(){return Fx||(Fx=1,(function(t){function a(D,$){var W=D.length;D.push($);e:for(;0<W;){var Y=W-1>>>1,oe=D[Y];if(0<c(oe,$))D[Y]=$,D[W]=oe,W=Y;else break e}}function s(D){return D.length===0?null:D[0]}function i(D){if(D.length===0)return null;var $=D[0],W=D.pop();if(W!==$){D[0]=W;e:for(var Y=0,oe=D.length,L=oe>>>1;Y<L;){var I=2*(Y+1)-1,K=D[I],Q=I+1,ue=D[Q];if(0>c(K,W))Q<oe&&0>c(ue,K)?(D[Y]=ue,D[Q]=W,Y=Q):(D[Y]=K,D[I]=W,Y=I);else if(Q<oe&&0>c(ue,W))D[Y]=ue,D[Q]=W,Y=Q;else break e}}return $}function c(D,$){var W=D.sortIndex-$.sortIndex;return W!==0?W:D.id-$.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();t.unstable_now=function(){return d.now()-f}}var h=[],x=[],v=1,y=null,b=3,j=!1,k=!1,C=!1,w=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function B(D){for(var $=s(x);$!==null;){if($.callback===null)i(x);else if($.startTime<=D)i(x),$.sortIndex=$.expirationTime,a(h,$);else break;$=s(x)}}function M(D){if(C=!1,B(D),!k)if(s(h)!==null)k=!0,P||(P=!0,F());else{var $=s(x);$!==null&&U(M,$.startTime-D)}}var P=!1,E=-1,O=5,z=-1;function _(){return w?!0:!(t.unstable_now()-z<O)}function H(){if(w=!1,P){var D=t.unstable_now();z=D;var $=!0;try{e:{k=!1,C&&(C=!1,T(E),E=-1),j=!0;var W=b;try{t:{for(B(D),y=s(h);y!==null&&!(y.expirationTime>D&&_());){var Y=y.callback;if(typeof Y=="function"){y.callback=null,b=y.priorityLevel;var oe=Y(y.expirationTime<=D);if(D=t.unstable_now(),typeof oe=="function"){y.callback=oe,B(D),$=!0;break t}y===s(h)&&i(h),B(D)}else i(h);y=s(h)}if(y!==null)$=!0;else{var L=s(x);L!==null&&U(M,L.startTime-D),$=!1}}break e}finally{y=null,b=W,j=!1}$=void 0}}finally{$?F():P=!1}}}var F;if(typeof A=="function")F=function(){A(H)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,ee=q.port2;q.port1.onmessage=H,F=function(){ee.postMessage(null)}}else F=function(){N(H,0)};function U(D,$){E=N(function(){D(t.unstable_now())},$)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(D){D.callback=null},t.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<D?Math.floor(1e3/D):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(D){switch(b){case 1:case 2:case 3:var $=3;break;default:$=b}var W=b;b=$;try{return D()}finally{b=W}},t.unstable_requestPaint=function(){w=!0},t.unstable_runWithPriority=function(D,$){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var W=b;b=D;try{return $()}finally{b=W}},t.unstable_scheduleCallback=function(D,$,W){var Y=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?Y+W:Y):W=Y,D){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=W+oe,D={id:v++,callback:$,priorityLevel:D,startTime:W,expirationTime:oe,sortIndex:-1},W>Y?(D.sortIndex=W,a(x,D),s(h)===null&&D===s(x)&&(C?(T(E),E=-1):C=!0,U(M,W-Y))):(D.sortIndex=oe,a(h,D),k||j||(k=!0,P||(P=!0,F()))),D},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(D){var $=b;return function(){var W=b;b=$;try{return D.apply(this,arguments)}finally{b=W}}}})(Cd)),Cd}var Wx;function q0(){return Wx||(Wx=1,wd.exports=G0()),wd.exports}var Ed={exports:{}},dn={};/**
|
|
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 Gx;function Y0(){if(Gx)return dn;Gx=1;var t=Tf();function a(h){var x="https://react.dev/errors/"+h;if(1<arguments.length){x+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)x+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+h+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={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(h,x,v){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:y==null?null:""+y,children:h,containerInfo:x,implementation:v}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(h,x){if(h==="font")return"";if(typeof x=="string")return x==="use-credentials"?x:""}return dn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,dn.createPortal=function(h,x){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)throw Error(a(299));return u(h,x,null,v)},dn.flushSync=function(h){var x=d.T,v=i.p;try{if(d.T=null,i.p=2,h)return h()}finally{d.T=x,i.p=v,i.d.f()}},dn.preconnect=function(h,x){typeof h=="string"&&(x?(x=x.crossOrigin,x=typeof x=="string"?x==="use-credentials"?x:"":void 0):x=null,i.d.C(h,x))},dn.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},dn.preinit=function(h,x){if(typeof h=="string"&&x&&typeof x.as=="string"){var v=x.as,y=f(v,x.crossOrigin),b=typeof x.integrity=="string"?x.integrity:void 0,j=typeof x.fetchPriority=="string"?x.fetchPriority:void 0;v==="style"?i.d.S(h,typeof x.precedence=="string"?x.precedence:void 0,{crossOrigin:y,integrity:b,fetchPriority:j}):v==="script"&&i.d.X(h,{crossOrigin:y,integrity:b,fetchPriority:j,nonce:typeof x.nonce=="string"?x.nonce:void 0})}},dn.preinitModule=function(h,x){if(typeof h=="string")if(typeof x=="object"&&x!==null){if(x.as==null||x.as==="script"){var v=f(x.as,x.crossOrigin);i.d.M(h,{crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0})}}else x==null&&i.d.M(h)},dn.preload=function(h,x){if(typeof h=="string"&&typeof x=="object"&&x!==null&&typeof x.as=="string"){var v=x.as,y=f(v,x.crossOrigin);i.d.L(h,v,{crossOrigin:y,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0,type:typeof x.type=="string"?x.type:void 0,fetchPriority:typeof x.fetchPriority=="string"?x.fetchPriority:void 0,referrerPolicy:typeof x.referrerPolicy=="string"?x.referrerPolicy:void 0,imageSrcSet:typeof x.imageSrcSet=="string"?x.imageSrcSet:void 0,imageSizes:typeof x.imageSizes=="string"?x.imageSizes:void 0,media:typeof x.media=="string"?x.media:void 0})}},dn.preloadModule=function(h,x){if(typeof h=="string")if(x){var v=f(x.as,x.crossOrigin);i.d.m(h,{as:typeof x.as=="string"&&x.as!=="script"?x.as:void 0,crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0})}else i.d.m(h)},dn.requestFormReset=function(h){i.d.r(h)},dn.unstable_batchedUpdates=function(h,x){return h(x)},dn.useFormState=function(h,x,v){return d.H.useFormState(h,x,v)},dn.useFormStatus=function(){return d.H.useHostTransitionStatus()},dn.version="19.2.4",dn}var qx;function Lv(){if(qx)return Ed.exports;qx=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(),Ed.exports=Y0(),Ed.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 Yx;function K0(){if(Yx)return Bs;Yx=1;var t=q0(),a=Tf(),s=Lv();function i(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 f(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 h(e){if(u(e)!==e)throw Error(i(188))}function x(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(i(188));return n!==e?null:e}for(var l=e,o=n;;){var p=l.return;if(p===null)break;var g=p.alternate;if(g===null){if(o=p.return,o!==null){l=o;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===l)return h(p),e;if(g===o)return h(p),n;g=g.sibling}throw Error(i(188))}if(l.return!==o.return)l=p,o=g;else{for(var S=!1,R=p.child;R;){if(R===l){S=!0,l=p,o=g;break}if(R===o){S=!0,o=p,l=g;break}R=R.sibling}if(!S){for(R=g.child;R;){if(R===l){S=!0,l=g,o=p;break}if(R===o){S=!0,o=g,l=p;break}R=R.sibling}if(!S)throw Error(i(189))}}if(l.alternate!==o)throw Error(i(190))}if(l.tag!==3)throw Error(i(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"),j=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),_=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function F(e){return e===null||typeof e!="object"?null:(e=H&&e[H]||e["@@iterator"],typeof e=="function"?e:null)}var q=Symbol.for("react.client.reference");function ee(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case N:return"Profiler";case w:return"StrictMode";case M:return"Suspense";case P:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case A:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case 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 U=Array.isArray,D=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},Y=[],oe=-1;function L(e){return{current:e}}function I(e){0>oe||(e.current=Y[oe],Y[oe]=null,oe--)}function K(e,n){oe++,Y[oe]=e.current,e.current=n}var Q=L(null),ue=L(null),J=L(null),ie=L(null);function Z(e,n){switch(K(J,n),K(ue,e),K(Q,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?cx(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=cx(n),e=ux(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}I(Q),K(Q,e)}function me(){I(Q),I(ue),I(J)}function je(e){e.memoizedState!==null&&K(ie,e);var n=Q.current,l=ux(n,e.type);n!==l&&(K(ue,e),K(Q,l))}function Te(e){ue.current===e&&(I(Q),I(ue)),ie.current===e&&(I(ie),Ms._currentValue=W)}var Me,Fe;function Ue(e){if(Me===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);Me=n&&n[1]||"",Fe=-1<l.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+Me+e+Fe}var De=!1;function We(e,n){if(!e||De)return"";De=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(se){var le=se}Reflect.construct(e,[],pe)}else{try{pe.call()}catch(se){le=se}e.call(pe.prototype)}}else{try{throw Error()}catch(se){le=se}(pe=e())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(se){if(se&&le&&typeof se.stack=="string")return[se.stack,le.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=o.DetermineComponentFrameRoot(),S=g[0],R=g[1];if(S&&R){var V=S.split(`
|
|
45
|
+
`),ne=R.split(`
|
|
46
|
+
`);for(p=o=0;o<V.length&&!V[o].includes("DetermineComponentFrameRoot");)o++;for(;p<ne.length&&!ne[p].includes("DetermineComponentFrameRoot");)p++;if(o===V.length||p===ne.length)for(o=V.length-1,p=ne.length-1;1<=o&&0<=p&&V[o]!==ne[p];)p--;for(;1<=o&&0<=p;o--,p--)if(V[o]!==ne[p]){if(o!==1||p!==1)do if(o--,p--,0>p||V[o]!==ne[p]){var de=`
|
|
47
|
+
`+V[o].replace(" at new "," at ");return e.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",e.displayName)),de}while(1<=o&&0<=p);break}}}finally{De=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ue(l):""}function ft(e,n){switch(e.tag){case 26:case 27:case 5:return Ue(e.type);case 16:return Ue("Lazy");case 13:return e.child!==n&&n!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return We(e.type,!1);case 11:return We(e.type.render,!1);case 1:return We(e.type,!0);case 31:return Ue("Activity");default:return""}}function ce(e){try{var n="",l=null;do n+=ft(e,l),l=e,e=e.return;while(e);return n}catch(o){return`
|
|
48
|
+
Error generating stack: `+o.message+`
|
|
49
|
+
`+o.stack}}var ve=Object.prototype.hasOwnProperty,ye=t.unstable_scheduleCallback,be=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,qe=t.unstable_requestPaint,He=t.unstable_now,jt=t.unstable_getCurrentPriorityLevel,Ot=t.unstable_ImmediatePriority,St=t.unstable_UserBlockingPriority,Lt=t.unstable_NormalPriority,xe=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,Xe=t.log,kt=t.unstable_setDisableYieldValue,Bt=null,lt=null;function jn(e){if(typeof Xe=="function"&&kt(e),lt&&typeof lt.setStrictMode=="function")try{lt.setStrictMode(Bt,e)}catch{}}var Kt=Math.clz32?Math.clz32:ur,mn=Math.log,un=Math.LN2;function ur(e){return e>>>=0,e===0?32:31-(mn(e)/un|0)|0}var wt=256,Pn=262144,Sn=4194304;function Et(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 Be(e,n,l){var o=e.pendingLanes;if(o===0)return 0;var p=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var R=o&134217727;return R!==0?(o=R&~g,o!==0?p=Et(o):(S&=R,S!==0?p=Et(S):l||(l=R&~e,l!==0&&(p=Et(l))))):(R=o&~g,R!==0?p=Et(R):S!==0?p=Et(S):l||(l=o&~e,l!==0&&(p=Et(l)))),p===0?0:n!==0&&n!==p&&(n&g)===0&&(g=p&-p,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:p}function Je(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function An(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 kn(){var e=Sn;return Sn<<=1,(Sn&62914560)===0&&(Sn=4194304),e}function Vr(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function rn(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Xa(e,n,l,o,p,g){var S=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,V=e.expirationTimes,ne=e.hiddenUpdates;for(l=S&~l;0<l;){var de=31-Kt(l),pe=1<<de;R[de]=0,V[de]=-1;var le=ne[de];if(le!==null)for(ne[de]=null,de=0;de<le.length;de++){var se=le[de];se!==null&&(se.lane&=-536870913)}l&=~pe}o!==0&&re(e,o,0),g!==0&&p===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~n))}function re(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var o=31-Kt(n);e.entangledLanes|=n,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function Se(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var o=31-Kt(l),p=1<<o;p&n|e[o]&n&&(e[o]|=n),l&=~p}}function Ce(e,n){var l=n&-n;return l=(l&42)!==0?1:Xt(l),(l&(e.suspendedLanes|n))!==0?0:l}function Xt(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 Ct(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function hn(){var e=$.p;return e!==0?e:(e=window.event,e===void 0?32:zx(e.type))}function dr(e,n){var l=$.p;try{return $.p=e,n()}finally{$.p=l}}var et=Math.random().toString(36).slice(2),Mt="__reactFiber$"+et,Ut="__reactProps$"+et,Fr="__reactContainer$"+et,an="__reactEvents$"+et,Xf="__reactListeners$"+et,Wr="__reactHandles$"+et,pi="__reactResources$"+et,ql="__reactMarker$"+et;function pc(e){delete e[Mt],delete e[Ut],delete e[an],delete e[Xf],delete e[Wr]}function Qa(e){var n=e[Mt];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Fr]||l[Mt]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=gx(e);e!==null;){if(l=e[Mt])return l;e=gx(e)}return n}e=l,l=e.parentNode}return null}function Za(e){if(e=e[Mt]||e[Fr]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Yl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(i(33))}function Ja(e){var n=e[pi];return n||(n=e[pi]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function tn(e){e[ql]=!0}var Qf=new Set,Zf={};function wa(e,n){el(e,n),el(e+"Capture",n)}function el(e,n){for(Zf[e]=n,e=0;e<n.length;e++)Qf.add(n[e])}var Db=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]*$"),Jf={},ep={};function _b(e){return ve.call(ep,e)?!0:ve.call(Jf,e)?!1:Db.test(e)?ep[e]=!0:(Jf[e]=!0,!1)}function mi(e,n,l){if(_b(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function hi(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 Sr(e,n,l,o){if(o===null)e.removeAttribute(l);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+o)}}function Vn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tp(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ob(e,n,l){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var p=o.get,g=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return p.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function mc(e){if(!e._valueTracker){var n=tp(e)?"checked":"value";e._valueTracker=Ob(e,n,""+e[n])}}function np(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),o="";return e&&(o=tp(e)?e.checked?"true":"false":e.value),e=o,e!==l?(n.setValue(e),!0):!1}function xi(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 Bb=/[\n"\\]/g;function Fn(e){return e.replace(Bb,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function hc(e,n,l,o,p,g,S,R){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),n!=null?S==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Vn(n)):e.value!==""+Vn(n)&&(e.value=""+Vn(n)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),n!=null?xc(e,S,Vn(n)):l!=null?xc(e,S,Vn(l)):o!=null&&e.removeAttribute("value"),p==null&&g!=null&&(e.defaultChecked=!!g),p!=null&&(e.checked=p&&typeof p!="function"&&typeof p!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Vn(R):e.removeAttribute("name")}function rp(e,n,l,o,p,g,S,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)){mc(e);return}l=l!=null?""+Vn(l):"",n=n!=null?""+Vn(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}o=o??p,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=R?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),mc(e)}function xc(e,n,l){n==="number"&&xi(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function tl(e,n,l,o){if(e=e.options,n){n={};for(var p=0;p<l.length;p++)n["$"+l[p]]=!0;for(l=0;l<e.length;l++)p=n.hasOwnProperty("$"+e[l].value),e[l].selected!==p&&(e[l].selected=p),p&&o&&(e[l].defaultSelected=!0)}else{for(l=""+Vn(l),n=null,p=0;p<e.length;p++){if(e[p].value===l){e[p].selected=!0,o&&(e[p].defaultSelected=!0);return}n!==null||e[p].disabled||(n=e[p])}n!==null&&(n.selected=!0)}}function ap(e,n,l){if(n!=null&&(n=""+Vn(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Vn(l):""}function lp(e,n,l,o){if(n==null){if(o!=null){if(l!=null)throw Error(i(92));if(U(o)){if(1<o.length)throw Error(i(93));o=o[0]}l=o}l==null&&(l=""),n=l}l=Vn(n),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),mc(e)}function nl(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Ib=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 sp(e,n,l){var o=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?o?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":o?e.setProperty(n,l):typeof l!="number"||l===0||Ib.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function ip(e,n,l){if(n!=null&&typeof n!="object")throw Error(i(62));if(e=e.style,l!=null){for(var o in l)!l.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var p in n)o=n[p],n.hasOwnProperty(p)&&l[p]!==o&&sp(e,p,o)}else for(var g in n)n.hasOwnProperty(g)&&sp(e,g,n[g])}function gc(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 $b=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"]]),Ub=/^[\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 gi(e){return Ub.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function kr(){}var vc=null;function yc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rl=null,al=null;function op(e){var n=Za(e);if(n&&(e=n.stateNode)){var l=e[Ut]||null;e:switch(e=n.stateNode,n.type){case"input":if(hc(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="'+Fn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var o=l[n];if(o!==e&&o.form===e.form){var p=o[Ut]||null;if(!p)throw Error(i(90));hc(o,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(n=0;n<l.length;n++)o=l[n],o.form===e.form&&np(o)}break e;case"textarea":ap(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&tl(e,!!l.multiple,n,!1)}}}var bc=!1;function cp(e,n,l){if(bc)return e(n,l);bc=!0;try{var o=e(n);return o}finally{if(bc=!1,(rl!==null||al!==null)&&(ao(),rl&&(n=rl,e=al,al=rl=null,op(n),e)))for(n=0;n<e.length;n++)op(e[n])}}function Kl(e,n){var l=e.stateNode;if(l===null)return null;var o=l[Ut]||null;if(o===null)return null;l=o[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":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(i(231,n,typeof l));return l}var wr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jc=!1;if(wr)try{var Xl={};Object.defineProperty(Xl,"passive",{get:function(){jc=!0}}),window.addEventListener("test",Xl,Xl),window.removeEventListener("test",Xl,Xl)}catch{jc=!1}var Gr=null,Sc=null,vi=null;function up(){if(vi)return vi;var e,n=Sc,l=n.length,o,p="value"in Gr?Gr.value:Gr.textContent,g=p.length;for(e=0;e<l&&n[e]===p[e];e++);var S=l-e;for(o=1;o<=S&&n[l-o]===p[g-o];o++);return vi=p.slice(e,1<o?1-o:void 0)}function yi(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 bi(){return!0}function dp(){return!1}function wn(e){function n(l,o,p,g,S){this._reactName=l,this._targetInst=p,this.type=o,this.nativeEvent=g,this.target=S,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)?bi:dp,this.isPropagationStopped=dp,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=bi)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=bi)},persist:function(){},isPersistent:bi}),n}var Ca={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ji=wn(Ca),Ql=y({},Ca,{view:0,detail:0}),Hb=wn(Ql),kc,wc,Zl,Si=y({},Ql,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ec,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!==Zl&&(Zl&&e.type==="mousemove"?(kc=e.screenX-Zl.screenX,wc=e.screenY-Zl.screenY):wc=kc=0,Zl=e),kc)},movementY:function(e){return"movementY"in e?e.movementY:wc}}),fp=wn(Si),Pb=y({},Si,{dataTransfer:0}),Vb=wn(Pb),Fb=y({},Ql,{relatedTarget:0}),Cc=wn(Fb),Wb=y({},Ca,{animationName:0,elapsedTime:0,pseudoElement:0}),Gb=wn(Wb),qb=y({},Ca,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Yb=wn(qb),Kb=y({},Ca,{data:0}),pp=wn(Kb),Xb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qb={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"},Zb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Jb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Zb[e])?!!n[e]:!1}function Ec(){return Jb}var e1=y({},Ql,{key:function(e){if(e.key){var n=Xb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=yi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Qb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ec,charCode:function(e){return e.type==="keypress"?yi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?yi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),t1=wn(e1),n1=y({},Si,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mp=wn(n1),r1=y({},Ql,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ec}),a1=wn(r1),l1=y({},Ca,{propertyName:0,elapsedTime:0,pseudoElement:0}),s1=wn(l1),i1=y({},Si,{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}),o1=wn(i1),c1=y({},Ca,{newState:0,oldState:0}),u1=wn(c1),d1=[9,13,27,32],Nc=wr&&"CompositionEvent"in window,Jl=null;wr&&"documentMode"in document&&(Jl=document.documentMode);var f1=wr&&"TextEvent"in window&&!Jl,hp=wr&&(!Nc||Jl&&8<Jl&&11>=Jl),xp=" ",gp=!1;function vp(e,n){switch(e){case"keyup":return d1.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ll=!1;function p1(e,n){switch(e){case"compositionend":return yp(n);case"keypress":return n.which!==32?null:(gp=!0,xp);case"textInput":return e=n.data,e===xp&&gp?null:e;default:return null}}function m1(e,n){if(ll)return e==="compositionend"||!Nc&&vp(e,n)?(e=up(),vi=Sc=Gr=null,ll=!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 hp&&n.locale!=="ko"?null:n.data;default:return null}}var h1={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 bp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!h1[e.type]:n==="textarea"}function jp(e,n,l,o){rl?al?al.push(o):al=[o]:rl=o,n=fo(n,"onChange"),0<n.length&&(l=new ji("onChange","change",null,l,o),e.push({event:l,listeners:n}))}var es=null,ts=null;function x1(e){rx(e,0)}function ki(e){var n=Yl(e);if(np(n))return e}function Sp(e,n){if(e==="change")return n}var kp=!1;if(wr){var Tc;if(wr){var Rc="oninput"in document;if(!Rc){var wp=document.createElement("div");wp.setAttribute("oninput","return;"),Rc=typeof wp.oninput=="function"}Tc=Rc}else Tc=!1;kp=Tc&&(!document.documentMode||9<document.documentMode)}function Cp(){es&&(es.detachEvent("onpropertychange",Ep),ts=es=null)}function Ep(e){if(e.propertyName==="value"&&ki(ts)){var n=[];jp(n,ts,e,yc(e)),cp(x1,n)}}function g1(e,n,l){e==="focusin"?(Cp(),es=n,ts=l,es.attachEvent("onpropertychange",Ep)):e==="focusout"&&Cp()}function v1(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ki(ts)}function y1(e,n){if(e==="click")return ki(n)}function b1(e,n){if(e==="input"||e==="change")return ki(n)}function j1(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Ln=typeof Object.is=="function"?Object.is:j1;function ns(e,n){if(Ln(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),o=Object.keys(n);if(l.length!==o.length)return!1;for(o=0;o<l.length;o++){var p=l[o];if(!ve.call(n,p)||!Ln(e[p],n[p]))return!1}return!0}function Np(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Tp(e,n){var l=Np(e);e=0;for(var o;l;){if(l.nodeType===3){if(o=e+l.textContent.length,e<=n&&o>=n)return{node:l,offset:n-e};e=o}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Np(l)}}function Rp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Rp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Ap(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=xi(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=xi(e.document)}return n}function Ac(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 S1=wr&&"documentMode"in document&&11>=document.documentMode,sl=null,Lc=null,rs=null,Mc=!1;function Lp(e,n,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Mc||sl==null||sl!==xi(o)||(o=sl,"selectionStart"in o&&Ac(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),rs&&ns(rs,o)||(rs=o,o=fo(Lc,"onSelect"),0<o.length&&(n=new ji("onSelect","select",null,n,l),e.push({event:n,listeners:o}),n.target=sl)))}function Ea(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var il={animationend:Ea("Animation","AnimationEnd"),animationiteration:Ea("Animation","AnimationIteration"),animationstart:Ea("Animation","AnimationStart"),transitionrun:Ea("Transition","TransitionRun"),transitionstart:Ea("Transition","TransitionStart"),transitioncancel:Ea("Transition","TransitionCancel"),transitionend:Ea("Transition","TransitionEnd")},zc={},Mp={};wr&&(Mp=document.createElement("div").style,"AnimationEvent"in window||(delete il.animationend.animation,delete il.animationiteration.animation,delete il.animationstart.animation),"TransitionEvent"in window||delete il.transitionend.transition);function Na(e){if(zc[e])return zc[e];if(!il[e])return e;var n=il[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in Mp)return zc[e]=n[l];return e}var zp=Na("animationend"),Dp=Na("animationiteration"),_p=Na("animationstart"),k1=Na("transitionrun"),w1=Na("transitionstart"),C1=Na("transitioncancel"),Op=Na("transitionend"),Bp=new Map,Dc="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(" ");Dc.push("scrollEnd");function rr(e,n){Bp.set(e,n),wa(n,[e])}var wi=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)},Wn=[],ol=0,_c=0;function Ci(){for(var e=ol,n=_c=ol=0;n<e;){var l=Wn[n];Wn[n++]=null;var o=Wn[n];Wn[n++]=null;var p=Wn[n];Wn[n++]=null;var g=Wn[n];if(Wn[n++]=null,o!==null&&p!==null){var S=o.pending;S===null?p.next=p:(p.next=S.next,S.next=p),o.pending=p}g!==0&&Ip(l,p,g)}}function Ei(e,n,l,o){Wn[ol++]=e,Wn[ol++]=n,Wn[ol++]=l,Wn[ol++]=o,_c|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Oc(e,n,l,o){return Ei(e,n,l,o),Ni(e)}function Ta(e,n){return Ei(e,null,null,n),Ni(e)}function Ip(e,n,l){e.lanes|=l;var o=e.alternate;o!==null&&(o.lanes|=l);for(var p=!1,g=e.return;g!==null;)g.childLanes|=l,o=g.alternate,o!==null&&(o.childLanes|=l),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(p=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,p&&n!==null&&(p=31-Kt(l),e=g.hiddenUpdates,o=e[p],o===null?e[p]=[n]:o.push(n),n.lane=l|536870912),g):null}function Ni(e){if(50<Cs)throw Cs=0,Wu=null,Error(i(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var cl={};function E1(e,n,l,o){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=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mn(e,n,l,o){return new E1(e,n,l,o)}function Bc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Cr(e,n){var l=e.alternate;return l===null?(l=Mn(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 $p(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 Ti(e,n,l,o,p,g){var S=0;if(o=e,typeof e=="function")Bc(e)&&(S=1);else if(typeof e=="string")S=L0(e,l,Q.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=Mn(31,l,n,p),e.elementType=z,e.lanes=g,e;case C:return Ra(l.children,p,g,n);case w:S=8,p|=24;break;case N:return e=Mn(12,l,n,p|2),e.elementType=N,e.lanes=g,e;case M:return e=Mn(13,l,n,p),e.elementType=M,e.lanes=g,e;case P:return e=Mn(19,l,n,p),e.elementType=P,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case A:S=10;break e;case T:S=9;break e;case B:S=11;break e;case E:S=14;break e;case O:S=16,o=null;break e}S=29,l=Error(i(130,e===null?"null":typeof e,"")),o=null}return n=Mn(S,l,n,p),n.elementType=e,n.type=o,n.lanes=g,n}function Ra(e,n,l,o){return e=Mn(7,e,o,n),e.lanes=l,e}function Ic(e,n,l){return e=Mn(6,e,null,n),e.lanes=l,e}function Up(e){var n=Mn(18,null,null,0);return n.stateNode=e,n}function $c(e,n,l){return n=Mn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Hp=new WeakMap;function Gn(e,n){if(typeof e=="object"&&e!==null){var l=Hp.get(e);return l!==void 0?l:(n={value:e,source:n,stack:ce(n)},Hp.set(e,n),n)}return{value:e,source:n,stack:ce(n)}}var ul=[],dl=0,Ri=null,as=0,qn=[],Yn=0,qr=null,fr=1,pr="";function Er(e,n){ul[dl++]=as,ul[dl++]=Ri,Ri=e,as=n}function Pp(e,n,l){qn[Yn++]=fr,qn[Yn++]=pr,qn[Yn++]=qr,qr=e;var o=fr;e=pr;var p=32-Kt(o)-1;o&=~(1<<p),l+=1;var g=32-Kt(n)+p;if(30<g){var S=p-p%5;g=(o&(1<<S)-1).toString(32),o>>=S,p-=S,fr=1<<32-Kt(n)+p|l<<p|o,pr=g+e}else fr=1<<g|l<<p|o,pr=e}function Uc(e){e.return!==null&&(Er(e,1),Pp(e,1,0))}function Hc(e){for(;e===Ri;)Ri=ul[--dl],ul[dl]=null,as=ul[--dl],ul[dl]=null;for(;e===qr;)qr=qn[--Yn],qn[Yn]=null,pr=qn[--Yn],qn[Yn]=null,fr=qn[--Yn],qn[Yn]=null}function Vp(e,n){qn[Yn++]=fr,qn[Yn++]=pr,qn[Yn++]=qr,fr=n.id,pr=n.overflow,qr=e}var ln=null,Nt=null,st=!1,Yr=null,Kn=!1,Pc=Error(i(519));function Kr(e){var n=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ls(Gn(n,e)),Pc}function Fp(e){var n=e.stateNode,l=e.type,o=e.memoizedProps;switch(n[Mt]=e,n[Ut]=o,l){case"dialog":nt("cancel",n),nt("close",n);break;case"iframe":case"object":case"embed":nt("load",n);break;case"video":case"audio":for(l=0;l<Ns.length;l++)nt(Ns[l],n);break;case"source":nt("error",n);break;case"img":case"image":case"link":nt("error",n),nt("load",n);break;case"details":nt("toggle",n);break;case"input":nt("invalid",n),rp(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":nt("invalid",n);break;case"textarea":nt("invalid",n),lp(n,o.value,o.defaultValue,o.children)}l=o.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||o.suppressHydrationWarning===!0||ix(n.textContent,l)?(o.popover!=null&&(nt("beforetoggle",n),nt("toggle",n)),o.onScroll!=null&&nt("scroll",n),o.onScrollEnd!=null&&nt("scrollend",n),o.onClick!=null&&(n.onclick=kr),n=!0):n=!1,n||Kr(e,!0)}function Wp(e){for(ln=e.return;ln;)switch(ln.tag){case 5:case 31:case 13:Kn=!1;return;case 27:case 3:Kn=!0;return;default:ln=ln.return}}function fl(e){if(e!==ln)return!1;if(!st)return Wp(e),st=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||sd(e.type,e.memoizedProps)),l=!l),l&&Nt&&Kr(e),Wp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));Nt=xx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));Nt=xx(e)}else n===27?(n=Nt,ca(e.type)?(e=dd,dd=null,Nt=e):Nt=n):Nt=ln?Qn(e.stateNode.nextSibling):null;return!0}function Aa(){Nt=ln=null,st=!1}function Vc(){var e=Yr;return e!==null&&(Tn===null?Tn=e:Tn.push.apply(Tn,e),Yr=null),e}function ls(e){Yr===null?Yr=[e]:Yr.push(e)}var Fc=L(null),La=null,Nr=null;function Xr(e,n,l){K(Fc,n._currentValue),n._currentValue=l}function Tr(e){e._currentValue=Fc.current,I(Fc)}function Wc(e,n,l){for(;e!==null;){var o=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),e===l)break;e=e.return}}function Gc(e,n,l,o){var p=e.child;for(p!==null&&(p.return=e);p!==null;){var g=p.dependencies;if(g!==null){var S=p.child;g=g.firstContext;e:for(;g!==null;){var R=g;g=p;for(var V=0;V<n.length;V++)if(R.context===n[V]){g.lanes|=l,R=g.alternate,R!==null&&(R.lanes|=l),Wc(g.return,l,e),o||(S=null);break e}g=R.next}}else if(p.tag===18){if(S=p.return,S===null)throw Error(i(341));S.lanes|=l,g=S.alternate,g!==null&&(g.lanes|=l),Wc(S,l,e),S=null}else S=p.child;if(S!==null)S.return=p;else for(S=p;S!==null;){if(S===e){S=null;break}if(p=S.sibling,p!==null){p.return=S.return,S=p;break}S=S.return}p=S}}function pl(e,n,l,o){e=null;for(var p=n,g=!1;p!==null;){if(!g){if((p.flags&524288)!==0)g=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var S=p.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var R=p.type;Ln(p.pendingProps.value,S.value)||(e!==null?e.push(R):e=[R])}}else if(p===ie.current){if(S=p.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(e!==null?e.push(Ms):e=[Ms])}p=p.return}e!==null&&Gc(n,e,l,o),n.flags|=262144}function Ai(e){for(e=e.firstContext;e!==null;){if(!Ln(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ma(e){La=e,Nr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function sn(e){return Gp(La,e)}function Li(e,n){return La===null&&Ma(e),Gp(e,n)}function Gp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},Nr===null){if(e===null)throw Error(i(308));Nr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else Nr=Nr.next=n;return l}var N1=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,o){e.push(o)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},T1=t.unstable_scheduleCallback,R1=t.unstable_NormalPriority,Ft={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qc(){return{controller:new N1,data:new Map,refCount:0}}function ss(e){e.refCount--,e.refCount===0&&T1(R1,function(){e.controller.abort()})}var is=null,Yc=0,ml=0,hl=null;function A1(e,n){if(is===null){var l=is=[];Yc=0,ml=Qu(),hl={status:"pending",value:void 0,then:function(o){l.push(o)}}}return Yc++,n.then(qp,qp),n}function qp(){if(--Yc===0&&is!==null){hl!==null&&(hl.status="fulfilled");var e=is;is=null,ml=0,hl=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function L1(e,n){var l=[],o={status:"pending",value:null,reason:null,then:function(p){l.push(p)}};return e.then(function(){o.status="fulfilled",o.value=n;for(var p=0;p<l.length;p++)(0,l[p])(n)},function(p){for(o.status="rejected",o.reason=p,p=0;p<l.length;p++)(0,l[p])(void 0)}),o}var Yp=D.S;D.S=function(e,n){Lh=He(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&A1(e,n),Yp!==null&&Yp(e,n)};var za=L(null);function Kc(){var e=za.current;return e!==null?e:bt.pooledCache}function Mi(e,n){n===null?K(za,za.current):K(za,n.pool)}function Kp(){var e=Kc();return e===null?null:{parent:Ft._currentValue,pool:e}}var xl=Error(i(460)),Xc=Error(i(474)),zi=Error(i(542)),Di={then:function(){}};function Xp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Qp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(kr,kr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Jp(e),e;default:if(typeof n.status=="string")n.then(kr,kr);else{if(e=bt,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=n,e.status="pending",e.then(function(o){if(n.status==="pending"){var p=n;p.status="fulfilled",p.value=o}},function(o){if(n.status==="pending"){var p=n;p.status="rejected",p.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Jp(e),e}throw _a=n,xl}}function Da(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(_a=l,xl):l}}var _a=null;function Zp(){if(_a===null)throw Error(i(459));var e=_a;return _a=null,e}function Jp(e){if(e===xl||e===zi)throw Error(i(483))}var gl=null,os=0;function _i(e){var n=os;return os+=1,gl===null&&(gl=[]),Qp(gl,e,n)}function cs(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Oi(e,n){throw n.$$typeof===b?Error(i(525)):(e=Object.prototype.toString.call(n),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function em(e){function n(X,G){if(e){var te=X.deletions;te===null?(X.deletions=[G],X.flags|=16):te.push(G)}}function l(X,G){if(!e)return null;for(;G!==null;)n(X,G),G=G.sibling;return null}function o(X){for(var G=new Map;X!==null;)X.key!==null?G.set(X.key,X):G.set(X.index,X),X=X.sibling;return G}function p(X,G){return X=Cr(X,G),X.index=0,X.sibling=null,X}function g(X,G,te){return X.index=te,e?(te=X.alternate,te!==null?(te=te.index,te<G?(X.flags|=67108866,G):te):(X.flags|=67108866,G)):(X.flags|=1048576,G)}function S(X){return e&&X.alternate===null&&(X.flags|=67108866),X}function R(X,G,te,fe){return G===null||G.tag!==6?(G=Ic(te,X.mode,fe),G.return=X,G):(G=p(G,te),G.return=X,G)}function V(X,G,te,fe){var ze=te.type;return ze===C?de(X,G,te.props.children,fe,te.key):G!==null&&(G.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===O&&Da(ze)===G.type)?(G=p(G,te.props),cs(G,te),G.return=X,G):(G=Ti(te.type,te.key,te.props,null,X.mode,fe),cs(G,te),G.return=X,G)}function ne(X,G,te,fe){return G===null||G.tag!==4||G.stateNode.containerInfo!==te.containerInfo||G.stateNode.implementation!==te.implementation?(G=$c(te,X.mode,fe),G.return=X,G):(G=p(G,te.children||[]),G.return=X,G)}function de(X,G,te,fe,ze){return G===null||G.tag!==7?(G=Ra(te,X.mode,fe,ze),G.return=X,G):(G=p(G,te),G.return=X,G)}function pe(X,G,te){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Ic(""+G,X.mode,te),G.return=X,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return te=Ti(G.type,G.key,G.props,null,X.mode,te),cs(te,G),te.return=X,te;case k:return G=$c(G,X.mode,te),G.return=X,G;case O:return G=Da(G),pe(X,G,te)}if(U(G)||F(G))return G=Ra(G,X.mode,te,null),G.return=X,G;if(typeof G.then=="function")return pe(X,_i(G),te);if(G.$$typeof===A)return pe(X,Li(X,G),te);Oi(X,G)}return null}function le(X,G,te,fe){var ze=G!==null?G.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return ze!==null?null:R(X,G,""+te,fe);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case j:return te.key===ze?V(X,G,te,fe):null;case k:return te.key===ze?ne(X,G,te,fe):null;case O:return te=Da(te),le(X,G,te,fe)}if(U(te)||F(te))return ze!==null?null:de(X,G,te,fe,null);if(typeof te.then=="function")return le(X,G,_i(te),fe);if(te.$$typeof===A)return le(X,G,Li(X,te),fe);Oi(X,te)}return null}function se(X,G,te,fe,ze){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return X=X.get(te)||null,R(G,X,""+fe,ze);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case j:return X=X.get(fe.key===null?te:fe.key)||null,V(G,X,fe,ze);case k:return X=X.get(fe.key===null?te:fe.key)||null,ne(G,X,fe,ze);case O:return fe=Da(fe),se(X,G,te,fe,ze)}if(U(fe)||F(fe))return X=X.get(te)||null,de(G,X,fe,ze,null);if(typeof fe.then=="function")return se(X,G,te,_i(fe),ze);if(fe.$$typeof===A)return se(X,G,te,Li(G,fe),ze);Oi(G,fe)}return null}function Ee(X,G,te,fe){for(var ze=null,ot=null,Re=G,Ye=G=0,at=null;Re!==null&&Ye<te.length;Ye++){Re.index>Ye?(at=Re,Re=null):at=Re.sibling;var ct=le(X,Re,te[Ye],fe);if(ct===null){Re===null&&(Re=at);break}e&&Re&&ct.alternate===null&&n(X,Re),G=g(ct,G,Ye),ot===null?ze=ct:ot.sibling=ct,ot=ct,Re=at}if(Ye===te.length)return l(X,Re),st&&Er(X,Ye),ze;if(Re===null){for(;Ye<te.length;Ye++)Re=pe(X,te[Ye],fe),Re!==null&&(G=g(Re,G,Ye),ot===null?ze=Re:ot.sibling=Re,ot=Re);return st&&Er(X,Ye),ze}for(Re=o(Re);Ye<te.length;Ye++)at=se(Re,X,Ye,te[Ye],fe),at!==null&&(e&&at.alternate!==null&&Re.delete(at.key===null?Ye:at.key),G=g(at,G,Ye),ot===null?ze=at:ot.sibling=at,ot=at);return e&&Re.forEach(function(ma){return n(X,ma)}),st&&Er(X,Ye),ze}function _e(X,G,te,fe){if(te==null)throw Error(i(151));for(var ze=null,ot=null,Re=G,Ye=G=0,at=null,ct=te.next();Re!==null&&!ct.done;Ye++,ct=te.next()){Re.index>Ye?(at=Re,Re=null):at=Re.sibling;var ma=le(X,Re,ct.value,fe);if(ma===null){Re===null&&(Re=at);break}e&&Re&&ma.alternate===null&&n(X,Re),G=g(ma,G,Ye),ot===null?ze=ma:ot.sibling=ma,ot=ma,Re=at}if(ct.done)return l(X,Re),st&&Er(X,Ye),ze;if(Re===null){for(;!ct.done;Ye++,ct=te.next())ct=pe(X,ct.value,fe),ct!==null&&(G=g(ct,G,Ye),ot===null?ze=ct:ot.sibling=ct,ot=ct);return st&&Er(X,Ye),ze}for(Re=o(Re);!ct.done;Ye++,ct=te.next())ct=se(Re,X,Ye,ct.value,fe),ct!==null&&(e&&ct.alternate!==null&&Re.delete(ct.key===null?Ye:ct.key),G=g(ct,G,Ye),ot===null?ze=ct:ot.sibling=ct,ot=ct);return e&&Re.forEach(function(P0){return n(X,P0)}),st&&Er(X,Ye),ze}function vt(X,G,te,fe){if(typeof te=="object"&&te!==null&&te.type===C&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case j:e:{for(var ze=te.key;G!==null;){if(G.key===ze){if(ze=te.type,ze===C){if(G.tag===7){l(X,G.sibling),fe=p(G,te.props.children),fe.return=X,X=fe;break e}}else if(G.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===O&&Da(ze)===G.type){l(X,G.sibling),fe=p(G,te.props),cs(fe,te),fe.return=X,X=fe;break e}l(X,G);break}else n(X,G);G=G.sibling}te.type===C?(fe=Ra(te.props.children,X.mode,fe,te.key),fe.return=X,X=fe):(fe=Ti(te.type,te.key,te.props,null,X.mode,fe),cs(fe,te),fe.return=X,X=fe)}return S(X);case k:e:{for(ze=te.key;G!==null;){if(G.key===ze)if(G.tag===4&&G.stateNode.containerInfo===te.containerInfo&&G.stateNode.implementation===te.implementation){l(X,G.sibling),fe=p(G,te.children||[]),fe.return=X,X=fe;break e}else{l(X,G);break}else n(X,G);G=G.sibling}fe=$c(te,X.mode,fe),fe.return=X,X=fe}return S(X);case O:return te=Da(te),vt(X,G,te,fe)}if(U(te))return Ee(X,G,te,fe);if(F(te)){if(ze=F(te),typeof ze!="function")throw Error(i(150));return te=ze.call(te),_e(X,G,te,fe)}if(typeof te.then=="function")return vt(X,G,_i(te),fe);if(te.$$typeof===A)return vt(X,G,Li(X,te),fe);Oi(X,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,G!==null&&G.tag===6?(l(X,G.sibling),fe=p(G,te),fe.return=X,X=fe):(l(X,G),fe=Ic(te,X.mode,fe),fe.return=X,X=fe),S(X)):l(X,G)}return function(X,G,te,fe){try{os=0;var ze=vt(X,G,te,fe);return gl=null,ze}catch(Re){if(Re===xl||Re===zi)throw Re;var ot=Mn(29,Re,null,X.mode);return ot.lanes=fe,ot.return=X,ot}finally{}}}var Oa=em(!0),tm=em(!1),Qr=!1;function Qc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Zc(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 Zr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Jr(e,n,l){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(dt&2)!==0){var p=o.pending;return p===null?n.next=n:(n.next=p.next,p.next=n),o.pending=n,n=Ni(e),Ip(e,null,l),n}return Ei(e,o,n,l),Ni(e)}function us(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,Se(e,l)}}function Jc(e,n){var l=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,l===o)){var p=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var S={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?p=g=S:g=g.next=S,l=l.next}while(l!==null);g===null?p=g=n:g=g.next=n}else p=g=n;l={baseState:o.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:o.shared,callbacks:o.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var eu=!1;function ds(){if(eu){var e=hl;if(e!==null)throw e}}function fs(e,n,l,o){eu=!1;var p=e.updateQueue;Qr=!1;var g=p.firstBaseUpdate,S=p.lastBaseUpdate,R=p.shared.pending;if(R!==null){p.shared.pending=null;var V=R,ne=V.next;V.next=null,S===null?g=ne:S.next=ne,S=V;var de=e.alternate;de!==null&&(de=de.updateQueue,R=de.lastBaseUpdate,R!==S&&(R===null?de.firstBaseUpdate=ne:R.next=ne,de.lastBaseUpdate=V))}if(g!==null){var pe=p.baseState;S=0,de=ne=V=null,R=g;do{var le=R.lane&-536870913,se=le!==R.lane;if(se?(rt&le)===le:(o&le)===le){le!==0&&le===ml&&(eu=!0),de!==null&&(de=de.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var Ee=e,_e=R;le=n;var vt=l;switch(_e.tag){case 1:if(Ee=_e.payload,typeof Ee=="function"){pe=Ee.call(vt,pe,le);break e}pe=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=_e.payload,le=typeof Ee=="function"?Ee.call(vt,pe,le):Ee,le==null)break e;pe=y({},pe,le);break e;case 2:Qr=!0}}le=R.callback,le!==null&&(e.flags|=64,se&&(e.flags|=8192),se=p.callbacks,se===null?p.callbacks=[le]:se.push(le))}else se={lane:le,tag:R.tag,payload:R.payload,callback:R.callback,next:null},de===null?(ne=de=se,V=pe):de=de.next=se,S|=le;if(R=R.next,R===null){if(R=p.shared.pending,R===null)break;se=R,R=se.next,se.next=null,p.lastBaseUpdate=se,p.shared.pending=null}}while(!0);de===null&&(V=pe),p.baseState=V,p.firstBaseUpdate=ne,p.lastBaseUpdate=de,g===null&&(p.shared.lanes=0),aa|=S,e.lanes=S,e.memoizedState=pe}}function nm(e,n){if(typeof e!="function")throw Error(i(191,e));e.call(n)}function rm(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)nm(l[e],n)}var vl=L(null),Bi=L(0);function am(e,n){e=Br,K(Bi,e),K(vl,n),Br=e|n.baseLanes}function tu(){K(Bi,Br),K(vl,vl.current)}function nu(){Br=Bi.current,I(vl),I(Bi)}var zn=L(null),Xn=null;function ea(e){var n=e.alternate;K(Ht,Ht.current&1),K(zn,e),Xn===null&&(n===null||vl.current!==null||n.memoizedState!==null)&&(Xn=e)}function ru(e){K(Ht,Ht.current),K(zn,e),Xn===null&&(Xn=e)}function lm(e){e.tag===22?(K(Ht,Ht.current),K(zn,e),Xn===null&&(Xn=e)):ta()}function ta(){K(Ht,Ht.current),K(zn,zn.current)}function Dn(e){I(zn),Xn===e&&(Xn=null),I(Ht)}var Ht=L(0);function Ii(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||cd(l)||ud(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 Rr=0,Ge=null,xt=null,Wt=null,$i=!1,yl=!1,Ba=!1,Ui=0,ps=0,bl=null,M1=0;function It(){throw Error(i(321))}function au(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!Ln(e[l],n[l]))return!1;return!0}function lu(e,n,l,o,p,g){return Rr=g,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,D.H=e===null||e.memoizedState===null?Pm:bu,Ba=!1,g=l(o,p),Ba=!1,yl&&(g=im(n,l,o,p)),sm(e),g}function sm(e){D.H=xs;var n=xt!==null&&xt.next!==null;if(Rr=0,Wt=xt=Ge=null,$i=!1,ps=0,bl=null,n)throw Error(i(300));e===null||Gt||(e=e.dependencies,e!==null&&Ai(e)&&(Gt=!0))}function im(e,n,l,o){Ge=e;var p=0;do{if(yl&&(bl=null),ps=0,yl=!1,25<=p)throw Error(i(301));if(p+=1,Wt=xt=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}D.H=Vm,g=n(l,o)}while(yl);return g}function z1(){var e=D.H,n=e.useState()[0];return n=typeof n.then=="function"?ms(n):n,e=e.useState()[0],(xt!==null?xt.memoizedState:null)!==e&&(Ge.flags|=1024),n}function su(){var e=Ui!==0;return Ui=0,e}function iu(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function ou(e){if($i){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}$i=!1}Rr=0,Wt=xt=Ge=null,yl=!1,ps=Ui=0,bl=null}function xn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Wt===null?Ge.memoizedState=Wt=e:Wt=Wt.next=e,Wt}function Pt(){if(xt===null){var e=Ge.alternate;e=e!==null?e.memoizedState:null}else e=xt.next;var n=Wt===null?Ge.memoizedState:Wt.next;if(n!==null)Wt=n,xt=e;else{if(e===null)throw Ge.alternate===null?Error(i(467)):Error(i(310));xt=e,e={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},Wt===null?Ge.memoizedState=Wt=e:Wt=Wt.next=e}return Wt}function Hi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ms(e){var n=ps;return ps+=1,bl===null&&(bl=[]),e=Qp(bl,e,n),n=Ge,(Wt===null?n.memoizedState:Wt.next)===null&&(n=n.alternate,D.H=n===null||n.memoizedState===null?Pm:bu),e}function Pi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ms(e);if(e.$$typeof===A)return sn(e)}throw Error(i(438,String(e)))}function cu(e){var n=null,l=Ge.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var o=Ge.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(p){return p.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Hi(),Ge.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),o=0;o<e;o++)l[o]=_;return n.index++,l}function Ar(e,n){return typeof n=="function"?n(e):n}function Vi(e){var n=Pt();return uu(n,xt,e)}function uu(e,n,l){var o=e.queue;if(o===null)throw Error(i(311));o.lastRenderedReducer=l;var p=e.baseQueue,g=o.pending;if(g!==null){if(p!==null){var S=p.next;p.next=g.next,g.next=S}n.baseQueue=p=g,o.pending=null}if(g=e.baseState,p===null)e.memoizedState=g;else{n=p.next;var R=S=null,V=null,ne=n,de=!1;do{var pe=ne.lane&-536870913;if(pe!==ne.lane?(rt&pe)===pe:(Rr&pe)===pe){var le=ne.revertLane;if(le===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),pe===ml&&(de=!0);else if((Rr&le)===le){ne=ne.next,le===ml&&(de=!0);continue}else pe={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},V===null?(R=V=pe,S=g):V=V.next=pe,Ge.lanes|=le,aa|=le;pe=ne.action,Ba&&l(g,pe),g=ne.hasEagerState?ne.eagerState:l(g,pe)}else le={lane:pe,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},V===null?(R=V=le,S=g):V=V.next=le,Ge.lanes|=pe,aa|=pe;ne=ne.next}while(ne!==null&&ne!==n);if(V===null?S=g:V.next=R,!Ln(g,e.memoizedState)&&(Gt=!0,de&&(l=hl,l!==null)))throw l;e.memoizedState=g,e.baseState=S,e.baseQueue=V,o.lastRenderedState=g}return p===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function du(e){var n=Pt(),l=n.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=e;var o=l.dispatch,p=l.pending,g=n.memoizedState;if(p!==null){l.pending=null;var S=p=p.next;do g=e(g,S.action),S=S.next;while(S!==p);Ln(g,n.memoizedState)||(Gt=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,o]}function om(e,n,l){var o=Ge,p=Pt(),g=st;if(g){if(l===void 0)throw Error(i(407));l=l()}else l=n();var S=!Ln((xt||p).memoizedState,l);if(S&&(p.memoizedState=l,Gt=!0),p=p.queue,mu(dm.bind(null,o,p,e),[e]),p.getSnapshot!==n||S||Wt!==null&&Wt.memoizedState.tag&1){if(o.flags|=2048,jl(9,{destroy:void 0},um.bind(null,o,p,l,n),null),bt===null)throw Error(i(349));g||(Rr&127)!==0||cm(o,n,l)}return l}function cm(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Ge.updateQueue,n===null?(n=Hi(),Ge.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function um(e,n,l,o){n.value=l,n.getSnapshot=o,fm(n)&&pm(e)}function dm(e,n,l){return l(function(){fm(n)&&pm(e)})}function fm(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!Ln(e,l)}catch{return!0}}function pm(e){var n=Ta(e,2);n!==null&&Rn(n,e,2)}function fu(e){var n=xn();if(typeof e=="function"){var l=e;if(e=l(),Ba){jn(!0);try{l()}finally{jn(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ar,lastRenderedState:e},n}function mm(e,n,l,o){return e.baseState=l,uu(e,xt,typeof o=="function"?o:Ar)}function D1(e,n,l,o,p){if(Gi(e))throw Error(i(485));if(e=n.action,e!==null){var g={payload:p,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};D.T!==null?l(!0):g.isTransition=!1,o(g),l=n.pending,l===null?(g.next=n.pending=g,hm(n,g)):(g.next=l.next,n.pending=l.next=g)}}function hm(e,n){var l=n.action,o=n.payload,p=e.state;if(n.isTransition){var g=D.T,S={};D.T=S;try{var R=l(p,o),V=D.S;V!==null&&V(S,R),xm(e,n,R)}catch(ne){pu(e,n,ne)}finally{g!==null&&S.types!==null&&(g.types=S.types),D.T=g}}else try{g=l(p,o),xm(e,n,g)}catch(ne){pu(e,n,ne)}}function xm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(o){gm(e,n,o)},function(o){return pu(e,n,o)}):gm(e,n,l)}function gm(e,n,l){n.status="fulfilled",n.value=l,vm(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,hm(e,l)))}function pu(e,n,l){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=l,vm(n),n=n.next;while(n!==o)}e.action=null}function vm(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function ym(e,n){return n}function bm(e,n){if(st){var l=bt.formState;if(l!==null){e:{var o=Ge;if(st){if(Nt){t:{for(var p=Nt,g=Kn;p.nodeType!==8;){if(!g){p=null;break t}if(p=Qn(p.nextSibling),p===null){p=null;break t}}g=p.data,p=g==="F!"||g==="F"?p:null}if(p){Nt=Qn(p.nextSibling),o=p.data==="F!";break e}}Kr(o)}o=!1}o&&(n=l[0])}}return l=xn(),l.memoizedState=l.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ym,lastRenderedState:n},l.queue=o,l=$m.bind(null,Ge,o),o.dispatch=l,o=fu(!1),g=yu.bind(null,Ge,!1,o.queue),o=xn(),p={state:n,dispatch:null,action:e,pending:null},o.queue=p,l=D1.bind(null,Ge,p,g,l),p.dispatch=l,o.memoizedState=e,[n,l,!1]}function jm(e){var n=Pt();return Sm(n,xt,e)}function Sm(e,n,l){if(n=uu(e,n,ym)[0],e=Vi(Ar)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=ms(n)}catch(S){throw S===xl?zi:S}else o=n;n=Pt();var p=n.queue,g=p.dispatch;return l!==n.memoizedState&&(Ge.flags|=2048,jl(9,{destroy:void 0},_1.bind(null,p,l),null)),[o,g,e]}function _1(e,n){e.action=n}function km(e){var n=Pt(),l=xt;if(l!==null)return Sm(n,l,e);Pt(),n=n.memoizedState,l=Pt();var o=l.queue.dispatch;return l.memoizedState=e,[n,o,!1]}function jl(e,n,l,o){return e={tag:e,create:l,deps:o,inst:n,next:null},n=Ge.updateQueue,n===null&&(n=Hi(),Ge.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(o=l.next,l.next=e,e.next=o,n.lastEffect=e),e}function wm(){return Pt().memoizedState}function Fi(e,n,l,o){var p=xn();Ge.flags|=e,p.memoizedState=jl(1|n,{destroy:void 0},l,o===void 0?null:o)}function Wi(e,n,l,o){var p=Pt();o=o===void 0?null:o;var g=p.memoizedState.inst;xt!==null&&o!==null&&au(o,xt.memoizedState.deps)?p.memoizedState=jl(n,g,l,o):(Ge.flags|=e,p.memoizedState=jl(1|n,g,l,o))}function Cm(e,n){Fi(8390656,8,e,n)}function mu(e,n){Wi(2048,8,e,n)}function O1(e){Ge.flags|=4;var n=Ge.updateQueue;if(n===null)n=Hi(),Ge.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function Em(e){var n=Pt().memoizedState;return O1({ref:n,nextImpl:e}),function(){if((dt&2)!==0)throw Error(i(440));return n.impl.apply(void 0,arguments)}}function Nm(e,n){return Wi(4,2,e,n)}function Tm(e,n){return Wi(4,4,e,n)}function Rm(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 Am(e,n,l){l=l!=null?l.concat([e]):null,Wi(4,4,Rm.bind(null,n,e),l)}function hu(){}function Lm(e,n){var l=Pt();n=n===void 0?null:n;var o=l.memoizedState;return n!==null&&au(n,o[1])?o[0]:(l.memoizedState=[e,n],e)}function Mm(e,n){var l=Pt();n=n===void 0?null:n;var o=l.memoizedState;if(n!==null&&au(n,o[1]))return o[0];if(o=e(),Ba){jn(!0);try{e()}finally{jn(!1)}}return l.memoizedState=[o,n],o}function xu(e,n,l){return l===void 0||(Rr&1073741824)!==0&&(rt&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=zh(),Ge.lanes|=e,aa|=e,l)}function zm(e,n,l,o){return Ln(l,n)?l:vl.current!==null?(e=xu(e,l,o),Ln(e,n)||(Gt=!0),e):(Rr&42)===0||(Rr&1073741824)!==0&&(rt&261930)===0?(Gt=!0,e.memoizedState=l):(e=zh(),Ge.lanes|=e,aa|=e,n)}function Dm(e,n,l,o,p){var g=$.p;$.p=g!==0&&8>g?g:8;var S=D.T,R={};D.T=R,yu(e,!1,n,l);try{var V=p(),ne=D.S;if(ne!==null&&ne(R,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var de=L1(V,o);hs(e,n,de,Bn(e))}else hs(e,n,o,Bn(e))}catch(pe){hs(e,n,{then:function(){},status:"rejected",reason:pe},Bn())}finally{$.p=g,S!==null&&R.types!==null&&(S.types=R.types),D.T=S}}function B1(){}function gu(e,n,l,o){if(e.tag!==5)throw Error(i(476));var p=_m(e).queue;Dm(e,p,n,W,l===null?B1:function(){return Om(e),l(o)})}function _m(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ar,lastRenderedState:W},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ar,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Om(e){var n=_m(e);n.next===null&&(n=e.alternate.memoizedState),hs(e,n.next.queue,{},Bn())}function vu(){return sn(Ms)}function Bm(){return Pt().memoizedState}function Im(){return Pt().memoizedState}function I1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Bn();e=Zr(l);var o=Jr(n,e,l);o!==null&&(Rn(o,n,l),us(o,n,l)),n={cache:qc()},e.payload=n;return}n=n.return}}function $1(e,n,l){var o=Bn();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Gi(e)?Um(n,l):(l=Oc(e,n,l,o),l!==null&&(Rn(l,e,o),Hm(l,n,o)))}function $m(e,n,l){var o=Bn();hs(e,n,l,o)}function hs(e,n,l,o){var p={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Gi(e))Um(n,p);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,R=g(S,l);if(p.hasEagerState=!0,p.eagerState=R,Ln(R,S))return Ei(e,n,p,0),bt===null&&Ci(),!1}catch{}finally{}if(l=Oc(e,n,p,o),l!==null)return Rn(l,e,o),Hm(l,n,o),!0}return!1}function yu(e,n,l,o){if(o={lane:2,revertLane:Qu(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Gi(e)){if(n)throw Error(i(479))}else n=Oc(e,l,o,2),n!==null&&Rn(n,e,2)}function Gi(e){var n=e.alternate;return e===Ge||n!==null&&n===Ge}function Um(e,n){yl=$i=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Hm(e,n,l){if((l&4194048)!==0){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,Se(e,l)}}var xs={readContext:sn,use:Pi,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useLayoutEffect:It,useInsertionEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useSyncExternalStore:It,useId:It,useHostTransitionStatus:It,useFormState:It,useActionState:It,useOptimistic:It,useMemoCache:It,useCacheRefresh:It};xs.useEffectEvent=It;var Pm={readContext:sn,use:Pi,useCallback:function(e,n){return xn().memoizedState=[e,n===void 0?null:n],e},useContext:sn,useEffect:Cm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Fi(4194308,4,Rm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Fi(4194308,4,e,n)},useInsertionEffect:function(e,n){Fi(4,2,e,n)},useMemo:function(e,n){var l=xn();n=n===void 0?null:n;var o=e();if(Ba){jn(!0);try{e()}finally{jn(!1)}}return l.memoizedState=[o,n],o},useReducer:function(e,n,l){var o=xn();if(l!==void 0){var p=l(n);if(Ba){jn(!0);try{l(n)}finally{jn(!1)}}}else p=n;return o.memoizedState=o.baseState=p,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:p},o.queue=e,e=e.dispatch=$1.bind(null,Ge,e),[o.memoizedState,e]},useRef:function(e){var n=xn();return e={current:e},n.memoizedState=e},useState:function(e){e=fu(e);var n=e.queue,l=$m.bind(null,Ge,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:hu,useDeferredValue:function(e,n){var l=xn();return xu(l,e,n)},useTransition:function(){var e=fu(!1);return e=Dm.bind(null,Ge,e.queue,!0,!1),xn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var o=Ge,p=xn();if(st){if(l===void 0)throw Error(i(407));l=l()}else{if(l=n(),bt===null)throw Error(i(349));(rt&127)!==0||cm(o,n,l)}p.memoizedState=l;var g={value:l,getSnapshot:n};return p.queue=g,Cm(dm.bind(null,o,g,e),[e]),o.flags|=2048,jl(9,{destroy:void 0},um.bind(null,o,g,l,n),null),l},useId:function(){var e=xn(),n=bt.identifierPrefix;if(st){var l=pr,o=fr;l=(o&~(1<<32-Kt(o)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Ui++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=M1++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:vu,useFormState:bm,useActionState:bm,useOptimistic:function(e){var n=xn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=yu.bind(null,Ge,!0,l),l.dispatch=n,[e,n]},useMemoCache:cu,useCacheRefresh:function(){return xn().memoizedState=I1.bind(null,Ge)},useEffectEvent:function(e){var n=xn(),l={impl:e};return n.memoizedState=l,function(){if((dt&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},bu={readContext:sn,use:Pi,useCallback:Lm,useContext:sn,useEffect:mu,useImperativeHandle:Am,useInsertionEffect:Nm,useLayoutEffect:Tm,useMemo:Mm,useReducer:Vi,useRef:wm,useState:function(){return Vi(Ar)},useDebugValue:hu,useDeferredValue:function(e,n){var l=Pt();return zm(l,xt.memoizedState,e,n)},useTransition:function(){var e=Vi(Ar)[0],n=Pt().memoizedState;return[typeof e=="boolean"?e:ms(e),n]},useSyncExternalStore:om,useId:Bm,useHostTransitionStatus:vu,useFormState:jm,useActionState:jm,useOptimistic:function(e,n){var l=Pt();return mm(l,xt,e,n)},useMemoCache:cu,useCacheRefresh:Im};bu.useEffectEvent=Em;var Vm={readContext:sn,use:Pi,useCallback:Lm,useContext:sn,useEffect:mu,useImperativeHandle:Am,useInsertionEffect:Nm,useLayoutEffect:Tm,useMemo:Mm,useReducer:du,useRef:wm,useState:function(){return du(Ar)},useDebugValue:hu,useDeferredValue:function(e,n){var l=Pt();return xt===null?xu(l,e,n):zm(l,xt.memoizedState,e,n)},useTransition:function(){var e=du(Ar)[0],n=Pt().memoizedState;return[typeof e=="boolean"?e:ms(e),n]},useSyncExternalStore:om,useId:Bm,useHostTransitionStatus:vu,useFormState:km,useActionState:km,useOptimistic:function(e,n){var l=Pt();return xt!==null?mm(l,xt,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:cu,useCacheRefresh:Im};Vm.useEffectEvent=Em;function ju(e,n,l,o){n=e.memoizedState,l=l(o,n),l=l==null?n:y({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Su={enqueueSetState:function(e,n,l){e=e._reactInternals;var o=Bn(),p=Zr(o);p.payload=n,l!=null&&(p.callback=l),n=Jr(e,p,o),n!==null&&(Rn(n,e,o),us(n,e,o))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var o=Bn(),p=Zr(o);p.tag=1,p.payload=n,l!=null&&(p.callback=l),n=Jr(e,p,o),n!==null&&(Rn(n,e,o),us(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Bn(),o=Zr(l);o.tag=2,n!=null&&(o.callback=n),n=Jr(e,o,l),n!==null&&(Rn(n,e,l),us(n,e,l))}};function Fm(e,n,l,o,p,g,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,g,S):n.prototype&&n.prototype.isPureReactComponent?!ns(l,o)||!ns(p,g):!0}function Wm(e,n,l,o){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,o),n.state!==e&&Su.enqueueReplaceState(n,n.state,null)}function Ia(e,n){var l=n;if("ref"in n){l={};for(var o in n)o!=="ref"&&(l[o]=n[o])}if(e=e.defaultProps){l===n&&(l=y({},l));for(var p in e)l[p]===void 0&&(l[p]=e[p])}return l}function Gm(e){wi(e)}function qm(e){console.error(e)}function Ym(e){wi(e)}function qi(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Km(e,n,l){try{var o=e.onCaughtError;o(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function ku(e,n,l){return l=Zr(l),l.tag=3,l.payload={element:null},l.callback=function(){qi(e,n)},l}function Xm(e){return e=Zr(e),e.tag=3,e}function Qm(e,n,l,o){var p=l.type.getDerivedStateFromError;if(typeof p=="function"){var g=o.value;e.payload=function(){return p(g)},e.callback=function(){Km(n,l,o)}}var S=l.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){Km(n,l,o),typeof p!="function"&&(la===null?la=new Set([this]):la.add(this));var R=o.stack;this.componentDidCatch(o.value,{componentStack:R!==null?R:""})})}function U1(e,n,l,o,p){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=l.alternate,n!==null&&pl(n,l,p,!0),l=zn.current,l!==null){switch(l.tag){case 31:case 13:return Xn===null?lo():l.alternate===null&&$t===0&&($t=3),l.flags&=-257,l.flags|=65536,l.lanes=p,o===Di?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([o]):n.add(o),Yu(e,o,p)),!1;case 22:return l.flags|=65536,o===Di?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([o]):l.add(o)),Yu(e,o,p)),!1}throw Error(i(435,l.tag))}return Yu(e,o,p),lo(),!1}if(st)return n=zn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=p,o!==Pc&&(e=Error(i(422),{cause:o}),ls(Gn(e,l)))):(o!==Pc&&(n=Error(i(423),{cause:o}),ls(Gn(n,l))),e=e.current.alternate,e.flags|=65536,p&=-p,e.lanes|=p,o=Gn(o,l),p=ku(e.stateNode,o,p),Jc(e,p),$t!==4&&($t=2)),!1;var g=Error(i(520),{cause:o});if(g=Gn(g,l),ws===null?ws=[g]:ws.push(g),$t!==4&&($t=2),n===null)return!0;o=Gn(o,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=p&-p,l.lanes|=e,e=ku(l.stateNode,o,e),Jc(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"&&(la===null||!la.has(g))))return l.flags|=65536,p&=-p,l.lanes|=p,p=Xm(p),Qm(p,e,l,o),Jc(l,p),!1}l=l.return}while(l!==null);return!1}var wu=Error(i(461)),Gt=!1;function on(e,n,l,o){n.child=e===null?tm(n,null,l,o):Oa(n,e.child,l,o)}function Zm(e,n,l,o,p){l=l.render;var g=n.ref;if("ref"in o){var S={};for(var R in o)R!=="ref"&&(S[R]=o[R])}else S=o;return Ma(n),o=lu(e,n,l,S,g,p),R=su(),e!==null&&!Gt?(iu(e,n,p),Lr(e,n,p)):(st&&R&&Uc(n),n.flags|=1,on(e,n,o,p),n.child)}function Jm(e,n,l,o,p){if(e===null){var g=l.type;return typeof g=="function"&&!Bc(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,eh(e,n,g,o,p)):(e=Ti(l.type,null,o,n,n.mode,p),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Mu(e,p)){var S=g.memoizedProps;if(l=l.compare,l=l!==null?l:ns,l(S,o)&&e.ref===n.ref)return Lr(e,n,p)}return n.flags|=1,e=Cr(g,o),e.ref=n.ref,e.return=n,n.child=e}function eh(e,n,l,o,p){if(e!==null){var g=e.memoizedProps;if(ns(g,o)&&e.ref===n.ref)if(Gt=!1,n.pendingProps=o=g,Mu(e,p))(e.flags&131072)!==0&&(Gt=!0);else return n.lanes=e.lanes,Lr(e,n,p)}return Cu(e,n,l,o,p)}function th(e,n,l,o){var p=o.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,e!==null){for(o=n.child=e.child,p=0;o!==null;)p=p|o.lanes|o.childLanes,o=o.sibling;o=p&~g}else o=0,n.child=null;return nh(e,n,g,l,o)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Mi(n,g!==null?g.cachePool:null),g!==null?am(n,g):tu(),lm(n);else return o=n.lanes=536870912,nh(e,n,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(Mi(n,g.cachePool),am(n,g),ta(),n.memoizedState=null):(e!==null&&Mi(n,null),tu(),ta());return on(e,n,p,l),n.child}function gs(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function nh(e,n,l,o,p){var g=Kc();return g=g===null?null:{parent:Ft._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&Mi(n,null),tu(),lm(n),e!==null&&pl(e,n,o,!0),n.childLanes=p,null}function Yi(e,n){return n=Xi({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function rh(e,n,l){return Oa(n,e.child,null,l),e=Yi(n,n.pendingProps),e.flags|=2,Dn(n),n.memoizedState=null,e}function H1(e,n,l){var o=n.pendingProps,p=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(st){if(o.mode==="hidden")return e=Yi(n,o),n.lanes=536870912,gs(null,e);if(ru(n),(e=Nt)?(e=hx(e,Kn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:qr!==null?{id:fr,overflow:pr}:null,retryLane:536870912,hydrationErrors:null},l=Up(e),l.return=n,n.child=l,ln=n,Nt=null)):e=null,e===null)throw Kr(n);return n.lanes=536870912,null}return Yi(n,o)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(ru(n),p)if(n.flags&256)n.flags&=-257,n=rh(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(i(558));else if(Gt||pl(e,n,l,!1),p=(l&e.childLanes)!==0,Gt||p){if(o=bt,o!==null&&(S=Ce(o,l),S!==0&&S!==g.retryLane))throw g.retryLane=S,Ta(e,S),Rn(o,e,S),wu;lo(),n=rh(e,n,l)}else e=g.treeContext,Nt=Qn(S.nextSibling),ln=n,st=!0,Yr=null,Kn=!1,e!==null&&Vp(n,e),n=Yi(n,o),n.flags|=4096;return n}return e=Cr(e.child,{mode:o.mode,children:o.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Ki(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(i(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function Cu(e,n,l,o,p){return Ma(n),l=lu(e,n,l,o,void 0,p),o=su(),e!==null&&!Gt?(iu(e,n,p),Lr(e,n,p)):(st&&o&&Uc(n),n.flags|=1,on(e,n,l,p),n.child)}function ah(e,n,l,o,p,g){return Ma(n),n.updateQueue=null,l=im(n,o,l,p),sm(e),o=su(),e!==null&&!Gt?(iu(e,n,g),Lr(e,n,g)):(st&&o&&Uc(n),n.flags|=1,on(e,n,l,g),n.child)}function lh(e,n,l,o,p){if(Ma(n),n.stateNode===null){var g=cl,S=l.contextType;typeof S=="object"&&S!==null&&(g=sn(S)),g=new l(o,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Su,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=o,g.state=n.memoizedState,g.refs={},Qc(n),S=l.contextType,g.context=typeof S=="object"&&S!==null?sn(S):cl,g.state=n.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(ju(n,l,S,o),g.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Su.enqueueReplaceState(g,g.state,null),fs(n,o,g,p),ds(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(e===null){g=n.stateNode;var R=n.memoizedProps,V=Ia(l,R);g.props=V;var ne=g.context,de=l.contextType;S=cl,typeof de=="object"&&de!==null&&(S=sn(de));var pe=l.getDerivedStateFromProps;de=typeof pe=="function"||typeof g.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,de||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(R||ne!==S)&&Wm(n,g,o,S),Qr=!1;var le=n.memoizedState;g.state=le,fs(n,o,g,p),ds(),ne=n.memoizedState,R||le!==ne||Qr?(typeof pe=="function"&&(ju(n,l,pe,o),ne=n.memoizedState),(V=Qr||Fm(n,l,V,o,le,ne,S))?(de||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=o,n.memoizedState=ne),g.props=o,g.state=ne,g.context=S,o=V):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{g=n.stateNode,Zc(e,n),S=n.memoizedProps,de=Ia(l,S),g.props=de,pe=n.pendingProps,le=g.context,ne=l.contextType,V=cl,typeof ne=="object"&&ne!==null&&(V=sn(ne)),R=l.getDerivedStateFromProps,(ne=typeof R=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==pe||le!==V)&&Wm(n,g,o,V),Qr=!1,le=n.memoizedState,g.state=le,fs(n,o,g,p),ds();var se=n.memoizedState;S!==pe||le!==se||Qr||e!==null&&e.dependencies!==null&&Ai(e.dependencies)?(typeof R=="function"&&(ju(n,l,R,o),se=n.memoizedState),(de=Qr||Fm(n,l,de,o,le,se,V)||e!==null&&e.dependencies!==null&&Ai(e.dependencies))?(ne||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(o,se,V),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(o,se,V)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=se),g.props=o,g.state=se,g.context=V,o=de):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),o=!1)}return g=o,Ki(e,n),o=(n.flags&128)!==0,g||o?(g=n.stateNode,l=o&&typeof l.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&o?(n.child=Oa(n,e.child,null,p),n.child=Oa(n,null,l,p)):on(e,n,l,p),n.memoizedState=g.state,e=n.child):e=Lr(e,n,p),e}function sh(e,n,l,o){return Aa(),n.flags|=256,on(e,n,l,o),n.child}var Eu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Nu(e){return{baseLanes:e,cachePool:Kp()}}function Tu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=On),e}function ih(e,n,l){var o=n.pendingProps,p=!1,g=(n.flags&128)!==0,S;if((S=g)||(S=e!==null&&e.memoizedState===null?!1:(Ht.current&2)!==0),S&&(p=!0,n.flags&=-129),S=(n.flags&32)!==0,n.flags&=-33,e===null){if(st){if(p?ea(n):ta(),(e=Nt)?(e=hx(e,Kn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:qr!==null?{id:fr,overflow:pr}:null,retryLane:536870912,hydrationErrors:null},l=Up(e),l.return=n,n.child=l,ln=n,Nt=null)):e=null,e===null)throw Kr(n);return ud(e)?n.lanes=32:n.lanes=536870912,null}var R=o.children;return o=o.fallback,p?(ta(),p=n.mode,R=Xi({mode:"hidden",children:R},p),o=Ra(o,p,l,null),R.return=n,o.return=n,R.sibling=o,n.child=R,o=n.child,o.memoizedState=Nu(l),o.childLanes=Tu(e,S,l),n.memoizedState=Eu,gs(null,o)):(ea(n),Ru(n,R))}var V=e.memoizedState;if(V!==null&&(R=V.dehydrated,R!==null)){if(g)n.flags&256?(ea(n),n.flags&=-257,n=Au(e,n,l)):n.memoizedState!==null?(ta(),n.child=e.child,n.flags|=128,n=null):(ta(),R=o.fallback,p=n.mode,o=Xi({mode:"visible",children:o.children},p),R=Ra(R,p,l,null),R.flags|=2,o.return=n,R.return=n,o.sibling=R,n.child=o,Oa(n,e.child,null,l),o=n.child,o.memoizedState=Nu(l),o.childLanes=Tu(e,S,l),n.memoizedState=Eu,n=gs(null,o));else if(ea(n),ud(R)){if(S=R.nextSibling&&R.nextSibling.dataset,S)var ne=S.dgst;S=ne,o=Error(i(419)),o.stack="",o.digest=S,ls({value:o,source:null,stack:null}),n=Au(e,n,l)}else if(Gt||pl(e,n,l,!1),S=(l&e.childLanes)!==0,Gt||S){if(S=bt,S!==null&&(o=Ce(S,l),o!==0&&o!==V.retryLane))throw V.retryLane=o,Ta(e,o),Rn(S,e,o),wu;cd(R)||lo(),n=Au(e,n,l)}else cd(R)?(n.flags|=192,n.child=e.child,n=null):(e=V.treeContext,Nt=Qn(R.nextSibling),ln=n,st=!0,Yr=null,Kn=!1,e!==null&&Vp(n,e),n=Ru(n,o.children),n.flags|=4096);return n}return p?(ta(),R=o.fallback,p=n.mode,V=e.child,ne=V.sibling,o=Cr(V,{mode:"hidden",children:o.children}),o.subtreeFlags=V.subtreeFlags&65011712,ne!==null?R=Cr(ne,R):(R=Ra(R,p,l,null),R.flags|=2),R.return=n,o.return=n,o.sibling=R,n.child=o,gs(null,o),o=n.child,R=e.child.memoizedState,R===null?R=Nu(l):(p=R.cachePool,p!==null?(V=Ft._currentValue,p=p.parent!==V?{parent:V,pool:V}:p):p=Kp(),R={baseLanes:R.baseLanes|l,cachePool:p}),o.memoizedState=R,o.childLanes=Tu(e,S,l),n.memoizedState=Eu,gs(e.child,o)):(ea(n),l=e.child,e=l.sibling,l=Cr(l,{mode:"visible",children:o.children}),l.return=n,l.sibling=null,e!==null&&(S=n.deletions,S===null?(n.deletions=[e],n.flags|=16):S.push(e)),n.child=l,n.memoizedState=null,l)}function Ru(e,n){return n=Xi({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Xi(e,n){return e=Mn(22,e,null,n),e.lanes=0,e}function Au(e,n,l){return Oa(n,e.child,null,l),e=Ru(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function oh(e,n,l){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n),Wc(e.return,n,l)}function Lu(e,n,l,o,p,g){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:l,tailMode:p,treeForkCount:g}:(S.isBackwards=n,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=l,S.tailMode=p,S.treeForkCount=g)}function ch(e,n,l){var o=n.pendingProps,p=o.revealOrder,g=o.tail;o=o.children;var S=Ht.current,R=(S&2)!==0;if(R?(S=S&1|2,n.flags|=128):S&=1,K(Ht,S),on(e,n,o,l),o=st?as:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&oh(e,l,n);else if(e.tag===19)oh(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(p){case"forwards":for(l=n.child,p=null;l!==null;)e=l.alternate,e!==null&&Ii(e)===null&&(p=l),l=l.sibling;l=p,l===null?(p=n.child,n.child=null):(p=l.sibling,l.sibling=null),Lu(n,!1,p,l,g,o);break;case"backwards":case"unstable_legacy-backwards":for(l=null,p=n.child,n.child=null;p!==null;){if(e=p.alternate,e!==null&&Ii(e)===null){n.child=p;break}e=p.sibling,p.sibling=l,l=p,p=e}Lu(n,!0,l,null,g,o);break;case"together":Lu(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function Lr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),aa|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(pl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(i(153));if(n.child!==null){for(e=n.child,l=Cr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=Cr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function Mu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Ai(e)))}function P1(e,n,l){switch(n.tag){case 3:Z(n,n.stateNode.containerInfo),Xr(n,Ft,e.memoizedState.cache),Aa();break;case 27:case 5:je(n);break;case 4:Z(n,n.stateNode.containerInfo);break;case 10:Xr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,ru(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(ea(n),n.flags|=128,null):(l&n.child.childLanes)!==0?ih(e,n,l):(ea(n),e=Lr(e,n,l),e!==null?e.sibling:null);ea(n);break;case 19:var p=(e.flags&128)!==0;if(o=(l&n.childLanes)!==0,o||(pl(e,n,l,!1),o=(l&n.childLanes)!==0),p){if(o)return ch(e,n,l);n.flags|=128}if(p=n.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),K(Ht,Ht.current),o)break;return null;case 22:return n.lanes=0,th(e,n,l,n.pendingProps);case 24:Xr(n,Ft,e.memoizedState.cache)}return Lr(e,n,l)}function uh(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Gt=!0;else{if(!Mu(e,l)&&(n.flags&128)===0)return Gt=!1,P1(e,n,l);Gt=(e.flags&131072)!==0}else Gt=!1,st&&(n.flags&1048576)!==0&&Pp(n,as,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(e=Da(n.elementType),n.type=e,typeof e=="function")Bc(e)?(o=Ia(e,o),n.tag=1,n=lh(null,n,e,o,l)):(n.tag=0,n=Cu(null,n,e,o,l));else{if(e!=null){var p=e.$$typeof;if(p===B){n.tag=11,n=Zm(null,n,e,o,l);break e}else if(p===E){n.tag=14,n=Jm(null,n,e,o,l);break e}}throw n=ee(e)||e,Error(i(306,n,""))}}return n;case 0:return Cu(e,n,n.type,n.pendingProps,l);case 1:return o=n.type,p=Ia(o,n.pendingProps),lh(e,n,o,p,l);case 3:e:{if(Z(n,n.stateNode.containerInfo),e===null)throw Error(i(387));o=n.pendingProps;var g=n.memoizedState;p=g.element,Zc(e,n),fs(n,o,null,l);var S=n.memoizedState;if(o=S.cache,Xr(n,Ft,o),o!==g.cache&&Gc(n,[Ft],l,!0),ds(),o=S.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:S.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=sh(e,n,o,l);break e}else if(o!==p){p=Gn(Error(i(424)),n),ls(p),n=sh(e,n,o,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(Nt=Qn(e.firstChild),ln=n,st=!0,Yr=null,Kn=!0,l=tm(n,null,o,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Aa(),o===p){n=Lr(e,n,l);break e}on(e,n,o,l)}n=n.child}return n;case 26:return Ki(e,n),e===null?(l=jx(n.type,null,n.pendingProps,null))?n.memoizedState=l:st||(l=n.type,e=n.pendingProps,o=po(J.current).createElement(l),o[Mt]=n,o[Ut]=e,cn(o,l,e),tn(o),n.stateNode=o):n.memoizedState=jx(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return je(n),e===null&&st&&(o=n.stateNode=vx(n.type,n.pendingProps,J.current),ln=n,Kn=!0,p=Nt,ca(n.type)?(dd=p,Nt=Qn(o.firstChild)):Nt=p),on(e,n,n.pendingProps.children,l),Ki(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&st&&((p=o=Nt)&&(o=v0(o,n.type,n.pendingProps,Kn),o!==null?(n.stateNode=o,ln=n,Nt=Qn(o.firstChild),Kn=!1,p=!0):p=!1),p||Kr(n)),je(n),p=n.type,g=n.pendingProps,S=e!==null?e.memoizedProps:null,o=g.children,sd(p,g)?o=null:S!==null&&sd(p,S)&&(n.flags|=32),n.memoizedState!==null&&(p=lu(e,n,z1,null,null,l),Ms._currentValue=p),Ki(e,n),on(e,n,o,l),n.child;case 6:return e===null&&st&&((e=l=Nt)&&(l=y0(l,n.pendingProps,Kn),l!==null?(n.stateNode=l,ln=n,Nt=null,e=!0):e=!1),e||Kr(n)),null;case 13:return ih(e,n,l);case 4:return Z(n,n.stateNode.containerInfo),o=n.pendingProps,e===null?n.child=Oa(n,null,o,l):on(e,n,o,l),n.child;case 11:return Zm(e,n,n.type,n.pendingProps,l);case 7:return on(e,n,n.pendingProps,l),n.child;case 8:return on(e,n,n.pendingProps.children,l),n.child;case 12:return on(e,n,n.pendingProps.children,l),n.child;case 10:return o=n.pendingProps,Xr(n,n.type,o.value),on(e,n,o.children,l),n.child;case 9:return p=n.type._context,o=n.pendingProps.children,Ma(n),p=sn(p),o=o(p),n.flags|=1,on(e,n,o,l),n.child;case 14:return Jm(e,n,n.type,n.pendingProps,l);case 15:return eh(e,n,n.type,n.pendingProps,l);case 19:return ch(e,n,l);case 31:return H1(e,n,l);case 22:return th(e,n,l,n.pendingProps);case 24:return Ma(n),o=sn(Ft),e===null?(p=Kc(),p===null&&(p=bt,g=qc(),p.pooledCache=g,g.refCount++,g!==null&&(p.pooledCacheLanes|=l),p=g),n.memoizedState={parent:o,cache:p},Qc(n),Xr(n,Ft,p)):((e.lanes&l)!==0&&(Zc(e,n),fs(n,null,null,l),ds()),p=e.memoizedState,g=n.memoizedState,p.parent!==o?(p={parent:o,cache:o},n.memoizedState=p,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=p),Xr(n,Ft,o)):(o=g.cache,Xr(n,Ft,o),o!==p.cache&&Gc(n,[Ft],l,!0))),on(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(i(156,n.tag))}function Mr(e){e.flags|=4}function zu(e,n,l,o,p){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(p&335544128)===p)if(e.stateNode.complete)e.flags|=8192;else if(Bh())e.flags|=8192;else throw _a=Di,Xc}else e.flags&=-16777217}function dh(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Ex(n))if(Bh())e.flags|=8192;else throw _a=Di,Xc}function Qi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?kn():536870912,e.lanes|=n,Cl|=n)}function vs(e,n){if(!st)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 o=null;l!==null;)l.alternate!==null&&(o=l),l=l.sibling;o===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Tt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,o=0;if(n)for(var p=e.child;p!==null;)l|=p.lanes|p.childLanes,o|=p.subtreeFlags&65011712,o|=p.flags&65011712,p.return=e,p=p.sibling;else for(p=e.child;p!==null;)l|=p.lanes|p.childLanes,o|=p.subtreeFlags,o|=p.flags,p.return=e,p=p.sibling;return e.subtreeFlags|=o,e.childLanes=l,n}function V1(e,n,l){var o=n.pendingProps;switch(Hc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tt(n),null;case 1:return Tt(n),null;case 3:return l=n.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),Tr(Ft),me(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(fl(n)?Mr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Vc())),Tt(n),null;case 26:var p=n.type,g=n.memoizedState;return e===null?(Mr(n),g!==null?(Tt(n),dh(n,g)):(Tt(n),zu(n,p,null,o,l))):g?g!==e.memoizedState?(Mr(n),Tt(n),dh(n,g)):(Tt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==o&&Mr(n),Tt(n),zu(n,p,e,o,l)),null;case 27:if(Te(n),l=J.current,p=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return Tt(n),null}e=Q.current,fl(n)?Fp(n):(e=vx(p,o,l),n.stateNode=e,Mr(n))}return Tt(n),null;case 5:if(Te(n),p=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return Tt(n),null}if(g=Q.current,fl(n))Fp(n);else{var S=po(J.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof o.is=="string"?S.createElement("select",{is:o.is}):S.createElement("select"),o.multiple?g.multiple=!0:o.size&&(g.size=o.size);break;default:g=typeof o.is=="string"?S.createElement(p,{is:o.is}):S.createElement(p)}}g[Mt]=n,g[Ut]=o;e:for(S=n.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===n)break e;for(;S.sibling===null;){if(S.return===null||S.return===n)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}n.stateNode=g;e:switch(cn(g,p,o),p){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Mr(n)}}return Tt(n),zu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(i(166));if(e=J.current,fl(n)){if(e=n.stateNode,l=n.memoizedProps,o=null,p=ln,p!==null)switch(p.tag){case 27:case 5:o=p.memoizedProps}e[Mt]=n,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||ix(e.nodeValue,l)),e||Kr(n,!0)}else e=po(e).createTextNode(o),e[Mt]=n,n.stateNode=e}return Tt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(o=fl(n),l!==null){if(e===null){if(!o)throw Error(i(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[Mt]=n}else Aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Tt(n),e=!1}else l=Vc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Dn(n),n):(Dn(n),null);if((n.flags&128)!==0)throw Error(i(558))}return Tt(n),null;case 13:if(o=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(p=fl(n),o!==null&&o.dehydrated!==null){if(e===null){if(!p)throw Error(i(318));if(p=n.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[Mt]=n}else Aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Tt(n),p=!1}else p=Vc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=p),p=!0;if(!p)return n.flags&256?(Dn(n),n):(Dn(n),null)}return Dn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=o!==null,e=e!==null&&e.memoizedState!==null,l&&(o=n.child,p=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(p=o.alternate.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==p&&(o.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Qi(n,n.updateQueue),Tt(n),null);case 4:return me(),e===null&&td(n.stateNode.containerInfo),Tt(n),null;case 10:return Tr(n.type),Tt(n),null;case 19:if(I(Ht),o=n.memoizedState,o===null)return Tt(n),null;if(p=(n.flags&128)!==0,g=o.rendering,g===null)if(p)vs(o,!1);else{if($t!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Ii(e),g!==null){for(n.flags|=128,vs(o,!1),e=g.updateQueue,n.updateQueue=e,Qi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)$p(l,e),l=l.sibling;return K(Ht,Ht.current&1|2),st&&Er(n,o.treeForkCount),n.child}e=e.sibling}o.tail!==null&&He()>no&&(n.flags|=128,p=!0,vs(o,!1),n.lanes=4194304)}else{if(!p)if(e=Ii(g),e!==null){if(n.flags|=128,p=!0,e=e.updateQueue,n.updateQueue=e,Qi(n,e),vs(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!st)return Tt(n),null}else 2*He()-o.renderingStartTime>no&&l!==536870912&&(n.flags|=128,p=!0,vs(o,!1),n.lanes=4194304);o.isBackwards?(g.sibling=n.child,n.child=g):(e=o.last,e!==null?e.sibling=g:n.child=g,o.last=g)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=He(),e.sibling=null,l=Ht.current,K(Ht,p?l&1|2:l&1),st&&Er(n,o.treeForkCount),e):(Tt(n),null);case 22:case 23:return Dn(n),nu(),o=n.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(l&536870912)!==0&&(n.flags&128)===0&&(Tt(n),n.subtreeFlags&6&&(n.flags|=8192)):Tt(n),l=n.updateQueue,l!==null&&Qi(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==l&&(n.flags|=2048),e!==null&&I(za),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Tr(Ft),Tt(n),null;case 25:return null;case 30:return null}throw Error(i(156,n.tag))}function F1(e,n){switch(Hc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Tr(Ft),me(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Te(n),null;case 31:if(n.memoizedState!==null){if(Dn(n),n.alternate===null)throw Error(i(340));Aa()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Dn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));Aa()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return I(Ht),null;case 4:return me(),null;case 10:return Tr(n.type),null;case 22:case 23:return Dn(n),nu(),e!==null&&I(za),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return Tr(Ft),null;case 25:return null;default:return null}}function fh(e,n){switch(Hc(n),n.tag){case 3:Tr(Ft),me();break;case 26:case 27:case 5:Te(n);break;case 4:me();break;case 31:n.memoizedState!==null&&Dn(n);break;case 13:Dn(n);break;case 19:I(Ht);break;case 10:Tr(n.type);break;case 22:case 23:Dn(n),nu(),e!==null&&I(za);break;case 24:Tr(Ft)}}function ys(e,n){try{var l=n.updateQueue,o=l!==null?l.lastEffect:null;if(o!==null){var p=o.next;l=p;do{if((l.tag&e)===e){o=void 0;var g=l.create,S=l.inst;o=g(),S.destroy=o}l=l.next}while(l!==p)}}catch(R){ht(n,n.return,R)}}function na(e,n,l){try{var o=n.updateQueue,p=o!==null?o.lastEffect:null;if(p!==null){var g=p.next;o=g;do{if((o.tag&e)===e){var S=o.inst,R=S.destroy;if(R!==void 0){S.destroy=void 0,p=n;var V=l,ne=R;try{ne()}catch(de){ht(p,V,de)}}}o=o.next}while(o!==g)}}catch(de){ht(n,n.return,de)}}function ph(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{rm(n,l)}catch(o){ht(e,e.return,o)}}}function mh(e,n,l){l.props=Ia(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){ht(e,n,o)}}function bs(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof l=="function"?e.refCleanup=l(o):l.current=o}}catch(p){ht(e,n,p)}}function mr(e,n){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(p){ht(e,n,p)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){ht(e,n,p)}else l.current=null}function hh(e){var n=e.type,l=e.memoizedProps,o=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&o.focus();break e;case"img":l.src?o.src=l.src:l.srcSet&&(o.srcset=l.srcSet)}}catch(p){ht(e,e.return,p)}}function Du(e,n,l){try{var o=e.stateNode;f0(o,e.type,l,n),o[Ut]=n}catch(p){ht(e,e.return,p)}}function xh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ca(e.type)||e.tag===4}function _u(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xh(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&&ca(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 Ou(e,n,l){var o=e.tag;if(o===5||o===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=kr));else if(o!==4&&(o===27&&ca(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Ou(e,n,l),e=e.sibling;e!==null;)Ou(e,n,l),e=e.sibling}function Zi(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(o!==4&&(o===27&&ca(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Zi(e,n,l),e=e.sibling;e!==null;)Zi(e,n,l),e=e.sibling}function gh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var o=e.type,p=n.attributes;p.length;)n.removeAttributeNode(p[0]);cn(n,o,l),n[Mt]=e,n[Ut]=l}catch(g){ht(e,e.return,g)}}var zr=!1,qt=!1,Bu=!1,vh=typeof WeakSet=="function"?WeakSet:Set,nn=null;function W1(e,n){if(e=e.containerInfo,ad=bo,e=Ap(e),Ac(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var o=l.getSelection&&l.getSelection();if(o&&o.rangeCount!==0){l=o.anchorNode;var p=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var S=0,R=-1,V=-1,ne=0,de=0,pe=e,le=null;t:for(;;){for(var se;pe!==l||p!==0&&pe.nodeType!==3||(R=S+p),pe!==g||o!==0&&pe.nodeType!==3||(V=S+o),pe.nodeType===3&&(S+=pe.nodeValue.length),(se=pe.firstChild)!==null;)le=pe,pe=se;for(;;){if(pe===e)break t;if(le===l&&++ne===p&&(R=S),le===g&&++de===o&&(V=S),(se=pe.nextSibling)!==null)break;pe=le,le=pe.parentNode}pe=se}l=R===-1||V===-1?null:{start:R,end:V}}else l=null}l=l||{start:0,end:0}}else l=null;for(ld={focusedElem:e,selectionRange:l},bo=!1,nn=n;nn!==null;)if(n=nn,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,nn=e;else for(;nn!==null;){switch(n=nn,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++)p=e[l],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,l=n,p=g.memoizedProps,g=g.memoizedState,o=l.stateNode;try{var Ee=Ia(l.type,p);e=o.getSnapshotBeforeUpdate(Ee,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(_e){ht(l,l.return,_e)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)od(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":od(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(i(163))}if(e=n.sibling,e!==null){e.return=n.return,nn=e;break}nn=n.return}}function yh(e,n,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:_r(e,l),o&4&&ys(5,l);break;case 1:if(_r(e,l),o&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(S){ht(l,l.return,S)}else{var p=Ia(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(p,n,e.__reactInternalSnapshotBeforeUpdate)}catch(S){ht(l,l.return,S)}}o&64&&ph(l),o&512&&bs(l,l.return);break;case 3:if(_r(e,l),o&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{rm(e,n)}catch(S){ht(l,l.return,S)}}break;case 27:n===null&&o&4&&gh(l);case 26:case 5:_r(e,l),n===null&&o&4&&hh(l),o&512&&bs(l,l.return);break;case 12:_r(e,l);break;case 31:_r(e,l),o&4&&Sh(e,l);break;case 13:_r(e,l),o&4&&kh(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=e0.bind(null,l),b0(e,l))));break;case 22:if(o=l.memoizedState!==null||zr,!o){n=n!==null&&n.memoizedState!==null||qt,p=zr;var g=qt;zr=o,(qt=n)&&!g?Or(e,l,(l.subtreeFlags&8772)!==0):_r(e,l),zr=p,qt=g}break;case 30:break;default:_r(e,l)}}function bh(e){var n=e.alternate;n!==null&&(e.alternate=null,bh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&pc(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 zt=null,Cn=!1;function Dr(e,n,l){for(l=l.child;l!==null;)jh(e,n,l),l=l.sibling}function jh(e,n,l){if(lt&&typeof lt.onCommitFiberUnmount=="function")try{lt.onCommitFiberUnmount(Bt,l)}catch{}switch(l.tag){case 26:qt||mr(l,n),Dr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:qt||mr(l,n);var o=zt,p=Cn;ca(l.type)&&(zt=l.stateNode,Cn=!1),Dr(e,n,l),Rs(l.stateNode),zt=o,Cn=p;break;case 5:qt||mr(l,n);case 6:if(o=zt,p=Cn,zt=null,Dr(e,n,l),zt=o,Cn=p,zt!==null)if(Cn)try{(zt.nodeType===9?zt.body:zt.nodeName==="HTML"?zt.ownerDocument.body:zt).removeChild(l.stateNode)}catch(g){ht(l,n,g)}else try{zt.removeChild(l.stateNode)}catch(g){ht(l,n,g)}break;case 18:zt!==null&&(Cn?(e=zt,px(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),zl(e)):px(zt,l.stateNode));break;case 4:o=zt,p=Cn,zt=l.stateNode.containerInfo,Cn=!0,Dr(e,n,l),zt=o,Cn=p;break;case 0:case 11:case 14:case 15:na(2,l,n),qt||na(4,l,n),Dr(e,n,l);break;case 1:qt||(mr(l,n),o=l.stateNode,typeof o.componentWillUnmount=="function"&&mh(l,n,o)),Dr(e,n,l);break;case 21:Dr(e,n,l);break;case 22:qt=(o=qt)||l.memoizedState!==null,Dr(e,n,l),qt=o;break;default:Dr(e,n,l)}}function Sh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{zl(e)}catch(l){ht(n,n.return,l)}}}function kh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{zl(e)}catch(l){ht(n,n.return,l)}}function G1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new vh),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new vh),n;default:throw Error(i(435,e.tag))}}function Ji(e,n){var l=G1(e);n.forEach(function(o){if(!l.has(o)){l.add(o);var p=t0.bind(null,e,o);o.then(p,p)}})}function En(e,n){var l=n.deletions;if(l!==null)for(var o=0;o<l.length;o++){var p=l[o],g=e,S=n,R=S;e:for(;R!==null;){switch(R.tag){case 27:if(ca(R.type)){zt=R.stateNode,Cn=!1;break e}break;case 5:zt=R.stateNode,Cn=!1;break e;case 3:case 4:zt=R.stateNode.containerInfo,Cn=!0;break e}R=R.return}if(zt===null)throw Error(i(160));jh(g,S,p),zt=null,Cn=!1,g=p.alternate,g!==null&&(g.return=null),p.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)wh(n,e),n=n.sibling}var ar=null;function wh(e,n){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:En(n,e),Nn(e),o&4&&(na(3,e,e.return),ys(3,e),na(5,e,e.return));break;case 1:En(n,e),Nn(e),o&512&&(qt||l===null||mr(l,l.return)),o&64&&zr&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?o:l.concat(o))));break;case 26:var p=ar;if(En(n,e),Nn(e),o&512&&(qt||l===null||mr(l,l.return)),o&4){var g=l!==null?l.memoizedState:null;if(o=e.memoizedState,l===null)if(o===null)if(e.stateNode===null){e:{o=e.type,l=e.memoizedProps,p=p.ownerDocument||p;t:switch(o){case"title":g=p.getElementsByTagName("title")[0],(!g||g[ql]||g[Mt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=p.createElement(o),p.head.insertBefore(g,p.querySelector("head > title"))),cn(g,o,l),g[Mt]=e,tn(g),o=g;break e;case"link":var S=wx("link","href",p).get(o+(l.href||""));if(S){for(var R=0;R<S.length;R++)if(g=S[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)){S.splice(R,1);break t}}g=p.createElement(o),cn(g,o,l),p.head.appendChild(g);break;case"meta":if(S=wx("meta","content",p).get(o+(l.content||""))){for(R=0;R<S.length;R++)if(g=S[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)){S.splice(R,1);break t}}g=p.createElement(o),cn(g,o,l),p.head.appendChild(g);break;default:throw Error(i(468,o))}g[Mt]=e,tn(g),o=g}e.stateNode=o}else Cx(p,e.type,e.stateNode);else e.stateNode=kx(p,o,e.memoizedProps);else g!==o?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,o===null?Cx(p,e.type,e.stateNode):kx(p,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Du(e,e.memoizedProps,l.memoizedProps)}break;case 27:En(n,e),Nn(e),o&512&&(qt||l===null||mr(l,l.return)),l!==null&&o&4&&Du(e,e.memoizedProps,l.memoizedProps);break;case 5:if(En(n,e),Nn(e),o&512&&(qt||l===null||mr(l,l.return)),e.flags&32){p=e.stateNode;try{nl(p,"")}catch(Ee){ht(e,e.return,Ee)}}o&4&&e.stateNode!=null&&(p=e.memoizedProps,Du(e,p,l!==null?l.memoizedProps:p)),o&1024&&(Bu=!0);break;case 6:if(En(n,e),Nn(e),o&4){if(e.stateNode===null)throw Error(i(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ee){ht(e,e.return,Ee)}}break;case 3:if(xo=null,p=ar,ar=mo(n.containerInfo),En(n,e),ar=p,Nn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{zl(n.containerInfo)}catch(Ee){ht(e,e.return,Ee)}Bu&&(Bu=!1,Ch(e));break;case 4:o=ar,ar=mo(e.stateNode.containerInfo),En(n,e),Nn(e),ar=o;break;case 12:En(n,e),Nn(e);break;case 31:En(n,e),Nn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ji(e,o)));break;case 13:En(n,e),Nn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(to=He()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ji(e,o)));break;case 22:p=e.memoizedState!==null;var V=l!==null&&l.memoizedState!==null,ne=zr,de=qt;if(zr=ne||p,qt=de||V,En(n,e),qt=de,zr=ne,Nn(e),o&8192)e:for(n=e.stateNode,n._visibility=p?n._visibility&-2:n._visibility|1,p&&(l===null||V||zr||qt||$a(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){V=l=n;try{if(g=V.stateNode,p)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{R=V.stateNode;var pe=V.memoizedProps.style,le=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;R.style.display=le==null||typeof le=="boolean"?"":(""+le).trim()}}catch(Ee){ht(V,V.return,Ee)}}}else if(n.tag===6){if(l===null){V=n;try{V.stateNode.nodeValue=p?"":V.memoizedProps}catch(Ee){ht(V,V.return,Ee)}}}else if(n.tag===18){if(l===null){V=n;try{var se=V.stateNode;p?mx(se,!0):mx(V.stateNode,!1)}catch(Ee){ht(V,V.return,Ee)}}}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}o&4&&(o=e.updateQueue,o!==null&&(l=o.retryQueue,l!==null&&(o.retryQueue=null,Ji(e,l))));break;case 19:En(n,e),Nn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ji(e,o)));break;case 30:break;case 21:break;default:En(n,e),Nn(e)}}function Nn(e){var n=e.flags;if(n&2){try{for(var l,o=e.return;o!==null;){if(xh(o)){l=o;break}o=o.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var p=l.stateNode,g=_u(e);Zi(e,g,p);break;case 5:var S=l.stateNode;l.flags&32&&(nl(S,""),l.flags&=-33);var R=_u(e);Zi(e,R,S);break;case 3:case 4:var V=l.stateNode.containerInfo,ne=_u(e);Ou(e,ne,V);break;default:throw Error(i(161))}}catch(de){ht(e,e.return,de)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Ch(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Ch(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function _r(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)yh(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:na(4,n,n.return),$a(n);break;case 1:mr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&mh(n,n.return,l),$a(n);break;case 27:Rs(n.stateNode);case 26:case 5:mr(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 Or(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,p=e,g=n,S=g.flags;switch(g.tag){case 0:case 11:case 15:Or(p,g,l),ys(4,g);break;case 1:if(Or(p,g,l),o=g,p=o.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ne){ht(o,o.return,ne)}if(o=g,p=o.updateQueue,p!==null){var R=o.stateNode;try{var V=p.shared.hiddenCallbacks;if(V!==null)for(p.shared.hiddenCallbacks=null,p=0;p<V.length;p++)nm(V[p],R)}catch(ne){ht(o,o.return,ne)}}l&&S&64&&ph(g),bs(g,g.return);break;case 27:gh(g);case 26:case 5:Or(p,g,l),l&&o===null&&S&4&&hh(g),bs(g,g.return);break;case 12:Or(p,g,l);break;case 31:Or(p,g,l),l&&S&4&&Sh(p,g);break;case 13:Or(p,g,l),l&&S&4&&kh(p,g);break;case 22:g.memoizedState===null&&Or(p,g,l),bs(g,g.return);break;case 30:break;default:Or(p,g,l)}n=n.sibling}}function Iu(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&&ss(l))}function $u(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ss(e))}function lr(e,n,l,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Eh(e,n,l,o),n=n.sibling}function Eh(e,n,l,o){var p=n.flags;switch(n.tag){case 0:case 11:case 15:lr(e,n,l,o),p&2048&&ys(9,n);break;case 1:lr(e,n,l,o);break;case 3:lr(e,n,l,o),p&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ss(e)));break;case 12:if(p&2048){lr(e,n,l,o),e=n.stateNode;try{var g=n.memoizedProps,S=g.id,R=g.onPostCommit;typeof R=="function"&&R(S,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(V){ht(n,n.return,V)}}else lr(e,n,l,o);break;case 31:lr(e,n,l,o);break;case 13:lr(e,n,l,o);break;case 23:break;case 22:g=n.stateNode,S=n.alternate,n.memoizedState!==null?g._visibility&2?lr(e,n,l,o):js(e,n):g._visibility&2?lr(e,n,l,o):(g._visibility|=2,Sl(e,n,l,o,(n.subtreeFlags&10256)!==0||!1)),p&2048&&Iu(S,n);break;case 24:lr(e,n,l,o),p&2048&&$u(n.alternate,n);break;default:lr(e,n,l,o)}}function Sl(e,n,l,o,p){for(p=p&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,S=n,R=l,V=o,ne=S.flags;switch(S.tag){case 0:case 11:case 15:Sl(g,S,R,V,p),ys(8,S);break;case 23:break;case 22:var de=S.stateNode;S.memoizedState!==null?de._visibility&2?Sl(g,S,R,V,p):js(g,S):(de._visibility|=2,Sl(g,S,R,V,p)),p&&ne&2048&&Iu(S.alternate,S);break;case 24:Sl(g,S,R,V,p),p&&ne&2048&&$u(S.alternate,S);break;default:Sl(g,S,R,V,p)}n=n.sibling}}function js(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,o=n,p=o.flags;switch(o.tag){case 22:js(l,o),p&2048&&Iu(o.alternate,o);break;case 24:js(l,o),p&2048&&$u(o.alternate,o);break;default:js(l,o)}n=n.sibling}}var Ss=8192;function kl(e,n,l){if(e.subtreeFlags&Ss)for(e=e.child;e!==null;)Nh(e,n,l),e=e.sibling}function Nh(e,n,l){switch(e.tag){case 26:kl(e,n,l),e.flags&Ss&&e.memoizedState!==null&&M0(l,ar,e.memoizedState,e.memoizedProps);break;case 5:kl(e,n,l);break;case 3:case 4:var o=ar;ar=mo(e.stateNode.containerInfo),kl(e,n,l),ar=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Ss,Ss=16777216,kl(e,n,l),Ss=o):kl(e,n,l));break;default:kl(e,n,l)}}function Th(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 ks(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];nn=o,Ah(o,e)}Th(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Rh(e),e=e.sibling}function Rh(e){switch(e.tag){case 0:case 11:case 15:ks(e),e.flags&2048&&na(9,e,e.return);break;case 3:ks(e);break;case 12:ks(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,eo(e)):ks(e);break;default:ks(e)}}function eo(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];nn=o,Ah(o,e)}Th(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:na(8,n,n.return),eo(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,eo(n));break;default:eo(n)}e=e.sibling}}function Ah(e,n){for(;nn!==null;){var l=nn;switch(l.tag){case 0:case 11:case 15:na(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var o=l.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:ss(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,nn=o;else e:for(l=e;nn!==null;){o=nn;var p=o.sibling,g=o.return;if(bh(o),o===l){nn=null;break e}if(p!==null){p.return=g,nn=p;break e}nn=g}}}var q1={getCacheForType:function(e){var n=sn(Ft),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return sn(Ft).controller.signal}},Y1=typeof WeakMap=="function"?WeakMap:Map,dt=0,bt=null,tt=null,rt=0,mt=0,_n=null,ra=!1,wl=!1,Uu=!1,Br=0,$t=0,aa=0,Ua=0,Hu=0,On=0,Cl=0,ws=null,Tn=null,Pu=!1,to=0,Lh=0,no=1/0,ro=null,la=null,Qt=0,sa=null,El=null,Ir=0,Vu=0,Fu=null,Mh=null,Cs=0,Wu=null;function Bn(){return(dt&2)!==0&&rt!==0?rt&-rt:D.T!==null?Qu():hn()}function zh(){if(On===0)if((rt&536870912)===0||st){var e=Pn;Pn<<=1,(Pn&3932160)===0&&(Pn=262144),On=e}else On=536870912;return e=zn.current,e!==null&&(e.flags|=32),On}function Rn(e,n,l){(e===bt&&(mt===2||mt===9)||e.cancelPendingCommit!==null)&&(Nl(e,0),ia(e,rt,On,!1)),rn(e,l),((dt&2)===0||e!==bt)&&(e===bt&&((dt&2)===0&&(Ua|=l),$t===4&&ia(e,rt,On,!1)),hr(e))}function Dh(e,n,l){if((dt&6)!==0)throw Error(i(327));var o=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Je(e,n),p=o?Q1(e,n):qu(e,n,!0),g=o;do{if(p===0){wl&&!o&&ia(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!K1(l)){p=qu(e,n,!1),g=!1;continue}if(p===2){if(g=n,e.errorRecoveryDisabledLanes&g)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){n=S;e:{var R=e;p=ws;var V=R.current.memoizedState.isDehydrated;if(V&&(Nl(R,S).flags|=256),S=qu(R,S,!1),S!==2){if(Uu&&!V){R.errorRecoveryDisabledLanes|=g,Ua|=g,p=4;break e}g=Tn,Tn=p,g!==null&&(Tn===null?Tn=g:Tn.push.apply(Tn,g))}p=S}if(g=!1,p!==2)continue}}if(p===1){Nl(e,0),ia(e,n,0,!0);break}e:{switch(o=e,g=p,g){case 0:case 1:throw Error(i(345));case 4:if((n&4194048)!==n)break;case 6:ia(o,n,On,!ra);break e;case 2:Tn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((n&62914560)===n&&(p=to+300-He(),10<p)){if(ia(o,n,On,!ra),Be(o,0,!0)!==0)break e;Ir=n,o.timeoutHandle=dx(_h.bind(null,o,l,Tn,ro,Pu,n,On,Ua,Cl,ra,g,"Throttled",-0,0),p);break e}_h(o,l,Tn,ro,Pu,n,On,Ua,Cl,ra,g,null,-0,0)}}break}while(!0);hr(e)}function _h(e,n,l,o,p,g,S,R,V,ne,de,pe,le,se){if(e.timeoutHandle=-1,pe=n.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:kr},Nh(n,g,pe);var Ee=(g&62914560)===g?to-He():(g&4194048)===g?Lh-He():0;if(Ee=z0(pe,Ee),Ee!==null){Ir=g,e.cancelPendingCommit=Ee(Vh.bind(null,e,n,g,l,o,p,S,R,V,de,pe,null,le,se)),ia(e,g,S,!ne);return}}Vh(e,n,g,l,o,p,S,R,V)}function K1(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 o=0;o<l.length;o++){var p=l[o],g=p.getSnapshot;p=p.value;try{if(!Ln(g(),p))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 ia(e,n,l,o){n&=~Hu,n&=~Ua,e.suspendedLanes|=n,e.pingedLanes&=~n,o&&(e.warmLanes|=n),o=e.expirationTimes;for(var p=n;0<p;){var g=31-Kt(p),S=1<<g;o[g]=-1,p&=~S}l!==0&&re(e,l,n)}function ao(){return(dt&6)===0?(Es(0),!1):!0}function Gu(){if(tt!==null){if(mt===0)var e=tt.return;else e=tt,Nr=La=null,ou(e),gl=null,os=0,e=tt;for(;e!==null;)fh(e.alternate,e),e=e.return;tt=null}}function Nl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,h0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Ir=0,Gu(),bt=e,tt=l=Cr(e.current,null),rt=n,mt=0,_n=null,ra=!1,wl=Je(e,n),Uu=!1,Cl=On=Hu=Ua=aa=$t=0,Tn=ws=null,Pu=!1,(n&8)!==0&&(n|=n&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=n;0<o;){var p=31-Kt(o),g=1<<p;n|=e[p],o&=~g}return Br=n,Ci(),l}function Oh(e,n){Ge=null,D.H=xs,n===xl||n===zi?(n=Zp(),mt=3):n===Xc?(n=Zp(),mt=4):mt=n===wu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,_n=n,tt===null&&($t=1,qi(e,Gn(n,e.current)))}function Bh(){var e=zn.current;return e===null?!0:(rt&4194048)===rt?Xn===null:(rt&62914560)===rt||(rt&536870912)!==0?e===Xn:!1}function Ih(){var e=D.H;return D.H=xs,e===null?xs:e}function $h(){var e=D.A;return D.A=q1,e}function lo(){$t=4,ra||(rt&4194048)!==rt&&zn.current!==null||(wl=!0),(aa&134217727)===0&&(Ua&134217727)===0||bt===null||ia(bt,rt,On,!1)}function qu(e,n,l){var o=dt;dt|=2;var p=Ih(),g=$h();(bt!==e||rt!==n)&&(ro=null,Nl(e,n)),n=!1;var S=$t;e:do try{if(mt!==0&&tt!==null){var R=tt,V=_n;switch(mt){case 8:Gu(),S=6;break e;case 3:case 2:case 9:case 6:zn.current===null&&(n=!0);var ne=mt;if(mt=0,_n=null,Tl(e,R,V,ne),l&&wl){S=0;break e}break;default:ne=mt,mt=0,_n=null,Tl(e,R,V,ne)}}X1(),S=$t;break}catch(de){Oh(e,de)}while(!0);return n&&e.shellSuspendCounter++,Nr=La=null,dt=o,D.H=p,D.A=g,tt===null&&(bt=null,rt=0,Ci()),S}function X1(){for(;tt!==null;)Uh(tt)}function Q1(e,n){var l=dt;dt|=2;var o=Ih(),p=$h();bt!==e||rt!==n?(ro=null,no=He()+500,Nl(e,n)):wl=Je(e,n);e:do try{if(mt!==0&&tt!==null){n=tt;var g=_n;t:switch(mt){case 1:mt=0,_n=null,Tl(e,n,g,1);break;case 2:case 9:if(Xp(g)){mt=0,_n=null,Hh(n);break}n=function(){mt!==2&&mt!==9||bt!==e||(mt=7),hr(e)},g.then(n,n);break e;case 3:mt=7;break e;case 4:mt=5;break e;case 7:Xp(g)?(mt=0,_n=null,Hh(n)):(mt=0,_n=null,Tl(e,n,g,7));break;case 5:var S=null;switch(tt.tag){case 26:S=tt.memoizedState;case 5:case 27:var R=tt;if(S?Ex(S):R.stateNode.complete){mt=0,_n=null;var V=R.sibling;if(V!==null)tt=V;else{var ne=R.return;ne!==null?(tt=ne,so(ne)):tt=null}break t}}mt=0,_n=null,Tl(e,n,g,5);break;case 6:mt=0,_n=null,Tl(e,n,g,6);break;case 8:Gu(),$t=6;break e;default:throw Error(i(462))}}Z1();break}catch(de){Oh(e,de)}while(!0);return Nr=La=null,D.H=o,D.A=p,dt=l,tt!==null?0:(bt=null,rt=0,Ci(),$t)}function Z1(){for(;tt!==null&&!Ne();)Uh(tt)}function Uh(e){var n=uh(e.alternate,e,Br);e.memoizedProps=e.pendingProps,n===null?so(e):tt=n}function Hh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=ah(l,n,n.pendingProps,n.type,void 0,rt);break;case 11:n=ah(l,n,n.pendingProps,n.type.render,n.ref,rt);break;case 5:ou(n);default:fh(l,n),n=tt=$p(n,Br),n=uh(l,n,Br)}e.memoizedProps=e.pendingProps,n===null?so(e):tt=n}function Tl(e,n,l,o){Nr=La=null,ou(n),gl=null,os=0;var p=n.return;try{if(U1(e,p,n,l,rt)){$t=1,qi(e,Gn(l,e.current)),tt=null;return}}catch(g){if(p!==null)throw tt=p,g;$t=1,qi(e,Gn(l,e.current)),tt=null;return}n.flags&32768?(st||o===1?e=!0:wl||(rt&536870912)!==0?e=!1:(ra=e=!0,(o===2||o===9||o===3||o===6)&&(o=zn.current,o!==null&&o.tag===13&&(o.flags|=16384))),Ph(n,e)):so(n)}function so(e){var n=e;do{if((n.flags&32768)!==0){Ph(n,ra);return}e=n.return;var l=V1(n.alternate,n,Br);if(l!==null){tt=l;return}if(n=n.sibling,n!==null){tt=n;return}tt=n=e}while(n!==null);$t===0&&($t=5)}function Ph(e,n){do{var l=F1(e.alternate,e);if(l!==null){l.flags&=32767,tt=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){tt=e;return}tt=e=l}while(e!==null);$t=6,tt=null}function Vh(e,n,l,o,p,g,S,R,V){e.cancelPendingCommit=null;do io();while(Qt!==0);if((dt&6)!==0)throw Error(i(327));if(n!==null){if(n===e.current)throw Error(i(177));if(g=n.lanes|n.childLanes,g|=_c,Xa(e,l,g,S,R,V),e===bt&&(tt=bt=null,rt=0),El=n,sa=e,Ir=l,Vu=g,Fu=p,Mh=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,n0(Lt,function(){return Yh(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=D.T,D.T=null,p=$.p,$.p=2,S=dt,dt|=4;try{W1(e,n,l)}finally{dt=S,$.p=p,D.T=o}}Qt=1,Fh(),Wh(),Gh()}}function Fh(){if(Qt===1){Qt=0;var e=sa,n=El,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=D.T,D.T=null;var o=$.p;$.p=2;var p=dt;dt|=4;try{wh(n,e);var g=ld,S=Ap(e.containerInfo),R=g.focusedElem,V=g.selectionRange;if(S!==R&&R&&R.ownerDocument&&Rp(R.ownerDocument.documentElement,R)){if(V!==null&&Ac(R)){var ne=V.start,de=V.end;if(de===void 0&&(de=ne),"selectionStart"in R)R.selectionStart=ne,R.selectionEnd=Math.min(de,R.value.length);else{var pe=R.ownerDocument||document,le=pe&&pe.defaultView||window;if(le.getSelection){var se=le.getSelection(),Ee=R.textContent.length,_e=Math.min(V.start,Ee),vt=V.end===void 0?_e:Math.min(V.end,Ee);!se.extend&&_e>vt&&(S=vt,vt=_e,_e=S);var X=Tp(R,_e),G=Tp(R,vt);if(X&&G&&(se.rangeCount!==1||se.anchorNode!==X.node||se.anchorOffset!==X.offset||se.focusNode!==G.node||se.focusOffset!==G.offset)){var te=pe.createRange();te.setStart(X.node,X.offset),se.removeAllRanges(),_e>vt?(se.addRange(te),se.extend(G.node,G.offset)):(te.setEnd(G.node,G.offset),se.addRange(te))}}}}for(pe=[],se=R;se=se.parentNode;)se.nodeType===1&&pe.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<pe.length;R++){var fe=pe[R];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}bo=!!ad,ld=ad=null}finally{dt=p,$.p=o,D.T=l}}e.current=n,Qt=2}}function Wh(){if(Qt===2){Qt=0;var e=sa,n=El,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=D.T,D.T=null;var o=$.p;$.p=2;var p=dt;dt|=4;try{yh(e,n.alternate,n)}finally{dt=p,$.p=o,D.T=l}}Qt=3}}function Gh(){if(Qt===4||Qt===3){Qt=0,qe();var e=sa,n=El,l=Ir,o=Mh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Qt=5:(Qt=0,El=sa=null,qh(e,e.pendingLanes));var p=e.pendingLanes;if(p===0&&(la=null),Ct(l),n=n.stateNode,lt&&typeof lt.onCommitFiberRoot=="function")try{lt.onCommitFiberRoot(Bt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=D.T,p=$.p,$.p=2,D.T=null;try{for(var g=e.onRecoverableError,S=0;S<o.length;S++){var R=o[S];g(R.value,{componentStack:R.stack})}}finally{D.T=n,$.p=p}}(Ir&3)!==0&&io(),hr(e),p=e.pendingLanes,(l&261930)!==0&&(p&42)!==0?e===Wu?Cs++:(Cs=0,Wu=e):Cs=0,Es(0)}}function qh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,ss(n)))}function io(){return Fh(),Wh(),Gh(),Yh()}function Yh(){if(Qt!==5)return!1;var e=sa,n=Vu;Vu=0;var l=Ct(Ir),o=D.T,p=$.p;try{$.p=32>l?32:l,D.T=null,l=Fu,Fu=null;var g=sa,S=Ir;if(Qt=0,El=sa=null,Ir=0,(dt&6)!==0)throw Error(i(331));var R=dt;if(dt|=4,Rh(g.current),Eh(g,g.current,S,l),dt=R,Es(0,!1),lt&&typeof lt.onPostCommitFiberRoot=="function")try{lt.onPostCommitFiberRoot(Bt,g)}catch{}return!0}finally{$.p=p,D.T=o,qh(e,n)}}function Kh(e,n,l){n=Gn(l,n),n=ku(e.stateNode,n,2),e=Jr(e,n,2),e!==null&&(rn(e,2),hr(e))}function ht(e,n,l){if(e.tag===3)Kh(e,e,l);else for(;n!==null;){if(n.tag===3){Kh(n,e,l);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(la===null||!la.has(o))){e=Gn(l,e),l=Xm(2),o=Jr(n,l,2),o!==null&&(Qm(l,o,n,e),rn(o,2),hr(o));break}}n=n.return}}function Yu(e,n,l){var o=e.pingCache;if(o===null){o=e.pingCache=new Y1;var p=new Set;o.set(n,p)}else p=o.get(n),p===void 0&&(p=new Set,o.set(n,p));p.has(l)||(Uu=!0,p.add(l),e=J1.bind(null,e,n,l),n.then(e,e))}function J1(e,n,l){var o=e.pingCache;o!==null&&o.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,bt===e&&(rt&l)===l&&($t===4||$t===3&&(rt&62914560)===rt&&300>He()-to?(dt&2)===0&&Nl(e,0):Hu|=l,Cl===rt&&(Cl=0)),hr(e)}function Xh(e,n){n===0&&(n=kn()),e=Ta(e,n),e!==null&&(rn(e,n),hr(e))}function e0(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Xh(e,l)}function t0(e,n){var l=0;switch(e.tag){case 31:case 13:var o=e.stateNode,p=e.memoizedState;p!==null&&(l=p.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(i(314))}o!==null&&o.delete(n),Xh(e,l)}function n0(e,n){return ye(e,n)}var oo=null,Rl=null,Ku=!1,co=!1,Xu=!1,oa=0;function hr(e){e!==Rl&&e.next===null&&(Rl===null?oo=Rl=e:Rl=Rl.next=e),co=!0,Ku||(Ku=!0,a0())}function Es(e,n){if(!Xu&&co){Xu=!0;do for(var l=!1,o=oo;o!==null;){if(e!==0){var p=o.pendingLanes;if(p===0)var g=0;else{var S=o.suspendedLanes,R=o.pingedLanes;g=(1<<31-Kt(42|e)+1)-1,g&=p&~(S&~R),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,ex(o,g))}else g=rt,g=Be(o,o===bt?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||Je(o,g)||(l=!0,ex(o,g));o=o.next}while(l);Xu=!1}}function r0(){Qh()}function Qh(){co=Ku=!1;var e=0;oa!==0&&m0()&&(e=oa);for(var n=He(),l=null,o=oo;o!==null;){var p=o.next,g=Zh(o,n);g===0?(o.next=null,l===null?oo=p:l.next=p,p===null&&(Rl=l)):(l=o,(e!==0||(g&3)!==0)&&(co=!0)),o=p}Qt!==0&&Qt!==5||Es(e),oa!==0&&(oa=0)}function Zh(e,n){for(var l=e.suspendedLanes,o=e.pingedLanes,p=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-Kt(g),R=1<<S,V=p[S];V===-1?((R&l)===0||(R&o)!==0)&&(p[S]=An(R,n)):V<=n&&(e.expiredLanes|=R),g&=~R}if(n=bt,l=rt,l=Be(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===n&&(mt===2||mt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&be(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Je(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(o!==null&&be(o),Ct(l)){case 2:case 8:l=St;break;case 32:l=Lt;break;case 268435456:l=Ze;break;default:l=Lt}return o=Jh.bind(null,e),l=ye(l,o),e.callbackPriority=n,e.callbackNode=l,n}return o!==null&&o!==null&&be(o),e.callbackPriority=2,e.callbackNode=null,2}function Jh(e,n){if(Qt!==0&&Qt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(io()&&e.callbackNode!==l)return null;var o=rt;return o=Be(e,e===bt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Dh(e,o,n),Zh(e,He()),e.callbackNode!=null&&e.callbackNode===l?Jh.bind(null,e):null)}function ex(e,n){if(io())return null;Dh(e,n,!0)}function a0(){x0(function(){(dt&6)!==0?ye(Ot,r0):Qh()})}function Qu(){if(oa===0){var e=ml;e===0&&(e=wt,wt<<=1,(wt&261888)===0&&(wt=256)),oa=e}return oa}function tx(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:gi(""+e)}function nx(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 l0(e,n,l,o,p){if(n==="submit"&&l&&l.stateNode===p){var g=tx((p[Ut]||null).action),S=o.submitter;S&&(n=(n=S[Ut]||null)?tx(n.formAction):S.getAttribute("formAction"),n!==null&&(g=n,S=null));var R=new ji("action","action",null,o,p);e.push({event:R,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(oa!==0){var V=S?nx(p,S):new FormData(p);gu(l,{pending:!0,data:V,method:p.method,action:g},null,V)}}else typeof g=="function"&&(R.preventDefault(),V=S?nx(p,S):new FormData(p),gu(l,{pending:!0,data:V,method:p.method,action:g},g,V))},currentTarget:p}]})}}for(var Zu=0;Zu<Dc.length;Zu++){var Ju=Dc[Zu],s0=Ju.toLowerCase(),i0=Ju[0].toUpperCase()+Ju.slice(1);rr(s0,"on"+i0)}rr(zp,"onAnimationEnd"),rr(Dp,"onAnimationIteration"),rr(_p,"onAnimationStart"),rr("dblclick","onDoubleClick"),rr("focusin","onFocus"),rr("focusout","onBlur"),rr(k1,"onTransitionRun"),rr(w1,"onTransitionStart"),rr(C1,"onTransitionCancel"),rr(Op,"onTransitionEnd"),el("onMouseEnter",["mouseout","mouseover"]),el("onMouseLeave",["mouseout","mouseover"]),el("onPointerEnter",["pointerout","pointerover"]),el("onPointerLeave",["pointerout","pointerover"]),wa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),wa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),wa("onBeforeInput",["compositionend","keypress","textInput","paste"]),wa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),wa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),wa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ns="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(" "),o0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ns));function rx(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var o=e[l],p=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var S=o.length-1;0<=S;S--){var R=o[S],V=R.instance,ne=R.currentTarget;if(R=R.listener,V!==g&&p.isPropagationStopped())break e;g=R,p.currentTarget=ne;try{g(p)}catch(de){wi(de)}p.currentTarget=null,g=V}else for(S=0;S<o.length;S++){if(R=o[S],V=R.instance,ne=R.currentTarget,R=R.listener,V!==g&&p.isPropagationStopped())break e;g=R,p.currentTarget=ne;try{g(p)}catch(de){wi(de)}p.currentTarget=null,g=V}}}}function nt(e,n){var l=n[an];l===void 0&&(l=n[an]=new Set);var o=e+"__bubble";l.has(o)||(ax(n,e,2,!1),l.add(o))}function ed(e,n,l){var o=0;n&&(o|=4),ax(l,e,o,n)}var uo="_reactListening"+Math.random().toString(36).slice(2);function td(e){if(!e[uo]){e[uo]=!0,Qf.forEach(function(l){l!=="selectionchange"&&(o0.has(l)||ed(l,!1,e),ed(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[uo]||(n[uo]=!0,ed("selectionchange",!1,n))}}function ax(e,n,l,o){switch(zx(n)){case 2:var p=O0;break;case 8:p=B0;break;default:p=xd}l=p.bind(null,n,l,e),p=void 0,!jc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(p=!0),o?p!==void 0?e.addEventListener(n,l,{capture:!0,passive:p}):e.addEventListener(n,l,!0):p!==void 0?e.addEventListener(n,l,{passive:p}):e.addEventListener(n,l,!1)}function nd(e,n,l,o,p){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var S=o.tag;if(S===3||S===4){var R=o.stateNode.containerInfo;if(R===p)break;if(S===4)for(S=o.return;S!==null;){var V=S.tag;if((V===3||V===4)&&S.stateNode.containerInfo===p)return;S=S.return}for(;R!==null;){if(S=Qa(R),S===null)return;if(V=S.tag,V===5||V===6||V===26||V===27){o=g=S;continue e}R=R.parentNode}}o=o.return}cp(function(){var ne=g,de=yc(l),pe=[];e:{var le=Bp.get(e);if(le!==void 0){var se=ji,Ee=e;switch(e){case"keypress":if(yi(l)===0)break e;case"keydown":case"keyup":se=t1;break;case"focusin":Ee="focus",se=Cc;break;case"focusout":Ee="blur",se=Cc;break;case"beforeblur":case"afterblur":se=Cc;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":se=fp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":se=Vb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":se=a1;break;case zp:case Dp:case _p:se=Gb;break;case Op:se=s1;break;case"scroll":case"scrollend":se=Hb;break;case"wheel":se=o1;break;case"copy":case"cut":case"paste":se=Yb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":se=mp;break;case"toggle":case"beforetoggle":se=u1}var _e=(n&4)!==0,vt=!_e&&(e==="scroll"||e==="scrollend"),X=_e?le!==null?le+"Capture":null:le;_e=[];for(var G=ne,te;G!==null;){var fe=G;if(te=fe.stateNode,fe=fe.tag,fe!==5&&fe!==26&&fe!==27||te===null||X===null||(fe=Kl(G,X),fe!=null&&_e.push(Ts(G,fe,te))),vt)break;G=G.return}0<_e.length&&(le=new se(le,Ee,null,l,de),pe.push({event:le,listeners:_e}))}}if((n&7)===0){e:{if(le=e==="mouseover"||e==="pointerover",se=e==="mouseout"||e==="pointerout",le&&l!==vc&&(Ee=l.relatedTarget||l.fromElement)&&(Qa(Ee)||Ee[Fr]))break e;if((se||le)&&(le=de.window===de?de:(le=de.ownerDocument)?le.defaultView||le.parentWindow:window,se?(Ee=l.relatedTarget||l.toElement,se=ne,Ee=Ee?Qa(Ee):null,Ee!==null&&(vt=u(Ee),_e=Ee.tag,Ee!==vt||_e!==5&&_e!==27&&_e!==6)&&(Ee=null)):(se=null,Ee=ne),se!==Ee)){if(_e=fp,fe="onMouseLeave",X="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(_e=mp,fe="onPointerLeave",X="onPointerEnter",G="pointer"),vt=se==null?le:Yl(se),te=Ee==null?le:Yl(Ee),le=new _e(fe,G+"leave",se,l,de),le.target=vt,le.relatedTarget=te,fe=null,Qa(de)===ne&&(_e=new _e(X,G+"enter",Ee,l,de),_e.target=te,_e.relatedTarget=vt,fe=_e),vt=fe,se&&Ee)t:{for(_e=c0,X=se,G=Ee,te=0,fe=X;fe;fe=_e(fe))te++;fe=0;for(var ze=G;ze;ze=_e(ze))fe++;for(;0<te-fe;)X=_e(X),te--;for(;0<fe-te;)G=_e(G),fe--;for(;te--;){if(X===G||G!==null&&X===G.alternate){_e=X;break t}X=_e(X),G=_e(G)}_e=null}else _e=null;se!==null&&lx(pe,le,se,_e,!1),Ee!==null&&vt!==null&&lx(pe,vt,Ee,_e,!0)}}e:{if(le=ne?Yl(ne):window,se=le.nodeName&&le.nodeName.toLowerCase(),se==="select"||se==="input"&&le.type==="file")var ot=Sp;else if(bp(le))if(kp)ot=b1;else{ot=v1;var Re=g1}else se=le.nodeName,!se||se.toLowerCase()!=="input"||le.type!=="checkbox"&&le.type!=="radio"?ne&&gc(ne.elementType)&&(ot=Sp):ot=y1;if(ot&&(ot=ot(e,ne))){jp(pe,ot,l,de);break e}Re&&Re(e,le,ne),e==="focusout"&&ne&&le.type==="number"&&ne.memoizedProps.value!=null&&xc(le,"number",le.value)}switch(Re=ne?Yl(ne):window,e){case"focusin":(bp(Re)||Re.contentEditable==="true")&&(sl=Re,Lc=ne,rs=null);break;case"focusout":rs=Lc=sl=null;break;case"mousedown":Mc=!0;break;case"contextmenu":case"mouseup":case"dragend":Mc=!1,Lp(pe,l,de);break;case"selectionchange":if(S1)break;case"keydown":case"keyup":Lp(pe,l,de)}var Ye;if(Nc)e:{switch(e){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else ll?vp(e,l)&&(at="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(at="onCompositionStart");at&&(hp&&l.locale!=="ko"&&(ll||at!=="onCompositionStart"?at==="onCompositionEnd"&&ll&&(Ye=up()):(Gr=de,Sc="value"in Gr?Gr.value:Gr.textContent,ll=!0)),Re=fo(ne,at),0<Re.length&&(at=new pp(at,e,null,l,de),pe.push({event:at,listeners:Re}),Ye?at.data=Ye:(Ye=yp(l),Ye!==null&&(at.data=Ye)))),(Ye=f1?p1(e,l):m1(e,l))&&(at=fo(ne,"onBeforeInput"),0<at.length&&(Re=new pp("onBeforeInput","beforeinput",null,l,de),pe.push({event:Re,listeners:at}),Re.data=Ye)),l0(pe,e,ne,l,de)}rx(pe,n)})}function Ts(e,n,l){return{instance:e,listener:n,currentTarget:l}}function fo(e,n){for(var l=n+"Capture",o=[];e!==null;){var p=e,g=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||g===null||(p=Kl(e,l),p!=null&&o.unshift(Ts(e,p,g)),p=Kl(e,n),p!=null&&o.push(Ts(e,p,g))),e.tag===3)return o;e=e.return}return[]}function c0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function lx(e,n,l,o,p){for(var g=n._reactName,S=[];l!==null&&l!==o;){var R=l,V=R.alternate,ne=R.stateNode;if(R=R.tag,V!==null&&V===o)break;R!==5&&R!==26&&R!==27||ne===null||(V=ne,p?(ne=Kl(l,g),ne!=null&&S.unshift(Ts(l,ne,V))):p||(ne=Kl(l,g),ne!=null&&S.push(Ts(l,ne,V)))),l=l.return}S.length!==0&&e.push({event:n,listeners:S})}var u0=/\r\n?/g,d0=/\u0000|\uFFFD/g;function sx(e){return(typeof e=="string"?e:""+e).replace(u0,`
|
|
50
|
+
`).replace(d0,"")}function ix(e,n){return n=sx(n),sx(e)===n}function gt(e,n,l,o,p,g){switch(l){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||nl(e,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&nl(e,""+o);break;case"className":hi(e,"class",o);break;case"tabIndex":hi(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":hi(e,l,o);break;case"style":ip(e,o,g);break;case"data":if(n!=="object"){hi(e,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=gi(""+o),e.setAttribute(l,o);break;case"action":case"formAction":if(typeof o=="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"&>(e,n,"name",p.name,p,null),gt(e,n,"formEncType",p.formEncType,p,null),gt(e,n,"formMethod",p.formMethod,p,null),gt(e,n,"formTarget",p.formTarget,p,null)):(gt(e,n,"encType",p.encType,p,null),gt(e,n,"method",p.method,p,null),gt(e,n,"target",p.target,p,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=gi(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=kr);break;case"onScroll":o!=null&&nt("scroll",e);break;case"onScrollEnd":o!=null&&nt("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(i(61));if(l=o.__html,l!=null){if(p.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}l=gi(""+o),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":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""+o):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":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":o===!0?e.setAttribute(l,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,o):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(l,o):e.removeAttribute(l);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(l):e.setAttribute(l,o);break;case"popover":nt("beforetoggle",e),nt("toggle",e),mi(e,"popover",o);break;case"xlinkActuate":Sr(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Sr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Sr(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Sr(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Sr(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Sr(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Sr(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Sr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Sr(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":mi(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=$b.get(l)||l,mi(e,l,o))}}function rd(e,n,l,o,p,g){switch(l){case"style":ip(e,o,g);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(i(61));if(l=o.__html,l!=null){if(p.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"children":typeof o=="string"?nl(e,o):(typeof o=="number"||typeof o=="bigint")&&nl(e,""+o);break;case"onScroll":o!=null&&nt("scroll",e);break;case"onScrollEnd":o!=null&&nt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=kr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Zf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(p=l.endsWith("Capture"),n=l.slice(2,p?l.length-7:void 0),g=e[Ut]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(n,g,p),typeof o=="function")){typeof g!="function"&&g!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,o,p);break e}l in e?e[l]=o:o===!0?e.setAttribute(l,""):mi(e,l,o)}}}function cn(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":nt("error",e),nt("load",e);var o=!1,p=!1,g;for(g in l)if(l.hasOwnProperty(g)){var S=l[g];if(S!=null)switch(g){case"src":o=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,n));default:gt(e,n,g,S,l,null)}}p&>(e,n,"srcSet",l.srcSet,l,null),o&>(e,n,"src",l.src,l,null);return;case"input":nt("invalid",e);var R=g=S=p=null,V=null,ne=null;for(o in l)if(l.hasOwnProperty(o)){var de=l[o];if(de!=null)switch(o){case"name":p=de;break;case"type":S=de;break;case"checked":V=de;break;case"defaultChecked":ne=de;break;case"value":g=de;break;case"defaultValue":R=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(i(137,n));break;default:gt(e,n,o,de,l,null)}}rp(e,g,R,V,ne,S,p,!1);return;case"select":nt("invalid",e),o=S=g=null;for(p in l)if(l.hasOwnProperty(p)&&(R=l[p],R!=null))switch(p){case"value":g=R;break;case"defaultValue":S=R;break;case"multiple":o=R;default:gt(e,n,p,R,l,null)}n=g,l=S,e.multiple=!!o,n!=null?tl(e,!!o,n,!1):l!=null&&tl(e,!!o,l,!0);return;case"textarea":nt("invalid",e),g=p=o=null;for(S in l)if(l.hasOwnProperty(S)&&(R=l[S],R!=null))switch(S){case"value":o=R;break;case"defaultValue":p=R;break;case"children":g=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(i(91));break;default:gt(e,n,S,R,l,null)}lp(e,o,p,g);return;case"option":for(V in l)if(l.hasOwnProperty(V)&&(o=l[V],o!=null))switch(V){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:gt(e,n,V,o,l,null)}return;case"dialog":nt("beforetoggle",e),nt("toggle",e),nt("cancel",e),nt("close",e);break;case"iframe":case"object":nt("load",e);break;case"video":case"audio":for(o=0;o<Ns.length;o++)nt(Ns[o],e);break;case"image":nt("error",e),nt("load",e);break;case"details":nt("toggle",e);break;case"embed":case"source":case"link":nt("error",e),nt("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(ne in l)if(l.hasOwnProperty(ne)&&(o=l[ne],o!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,n));default:gt(e,n,ne,o,l,null)}return;default:if(gc(n)){for(de in l)l.hasOwnProperty(de)&&(o=l[de],o!==void 0&&rd(e,n,de,o,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(o=l[R],o!=null&>(e,n,R,o,l,null))}function f0(e,n,l,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,g=null,S=null,R=null,V=null,ne=null,de=null;for(se in l){var pe=l[se];if(l.hasOwnProperty(se)&&pe!=null)switch(se){case"checked":break;case"value":break;case"defaultValue":V=pe;default:o.hasOwnProperty(se)||gt(e,n,se,null,o,pe)}}for(var le in o){var se=o[le];if(pe=l[le],o.hasOwnProperty(le)&&(se!=null||pe!=null))switch(le){case"type":g=se;break;case"name":p=se;break;case"checked":ne=se;break;case"defaultChecked":de=se;break;case"value":S=se;break;case"defaultValue":R=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(i(137,n));break;default:se!==pe&>(e,n,le,se,o,pe)}}hc(e,S,R,V,ne,de,g,p);return;case"select":se=S=R=le=null;for(g in l)if(V=l[g],l.hasOwnProperty(g)&&V!=null)switch(g){case"value":break;case"multiple":se=V;default:o.hasOwnProperty(g)||gt(e,n,g,null,o,V)}for(p in o)if(g=o[p],V=l[p],o.hasOwnProperty(p)&&(g!=null||V!=null))switch(p){case"value":le=g;break;case"defaultValue":R=g;break;case"multiple":S=g;default:g!==V&>(e,n,p,g,o,V)}n=R,l=S,o=se,le!=null?tl(e,!!l,le,!1):!!o!=!!l&&(n!=null?tl(e,!!l,n,!0):tl(e,!!l,l?[]:"",!1));return;case"textarea":se=le=null;for(R in l)if(p=l[R],l.hasOwnProperty(R)&&p!=null&&!o.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:gt(e,n,R,null,o,p)}for(S in o)if(p=o[S],g=l[S],o.hasOwnProperty(S)&&(p!=null||g!=null))switch(S){case"value":le=p;break;case"defaultValue":se=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==g&>(e,n,S,p,o,g)}ap(e,le,se);return;case"option":for(var Ee in l)if(le=l[Ee],l.hasOwnProperty(Ee)&&le!=null&&!o.hasOwnProperty(Ee))switch(Ee){case"selected":e.selected=!1;break;default:gt(e,n,Ee,null,o,le)}for(V in o)if(le=o[V],se=l[V],o.hasOwnProperty(V)&&le!==se&&(le!=null||se!=null))switch(V){case"selected":e.selected=le&&typeof le!="function"&&typeof le!="symbol";break;default:gt(e,n,V,le,o,se)}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 _e in l)le=l[_e],l.hasOwnProperty(_e)&&le!=null&&!o.hasOwnProperty(_e)&>(e,n,_e,null,o,le);for(ne in o)if(le=o[ne],se=l[ne],o.hasOwnProperty(ne)&&le!==se&&(le!=null||se!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(i(137,n));break;default:gt(e,n,ne,le,o,se)}return;default:if(gc(n)){for(var vt in l)le=l[vt],l.hasOwnProperty(vt)&&le!==void 0&&!o.hasOwnProperty(vt)&&rd(e,n,vt,void 0,o,le);for(de in o)le=o[de],se=l[de],!o.hasOwnProperty(de)||le===se||le===void 0&&se===void 0||rd(e,n,de,le,o,se);return}}for(var X in l)le=l[X],l.hasOwnProperty(X)&&le!=null&&!o.hasOwnProperty(X)&>(e,n,X,null,o,le);for(pe in o)le=o[pe],se=l[pe],!o.hasOwnProperty(pe)||le===se||le==null&&se==null||gt(e,n,pe,le,o,se)}function ox(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function p0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),o=0;o<l.length;o++){var p=l[o],g=p.transferSize,S=p.initiatorType,R=p.duration;if(g&&R&&ox(S)){for(S=0,R=p.responseEnd,o+=1;o<l.length;o++){var V=l[o],ne=V.startTime;if(ne>R)break;var de=V.transferSize,pe=V.initiatorType;de&&ox(pe)&&(V=V.responseEnd,S+=de*(V<R?1:(R-ne)/(V-ne)))}if(--o,n+=8*(g+S)/(p.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 ad=null,ld=null;function po(e){return e.nodeType===9?e:e.ownerDocument}function cx(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 ux(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 sd(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 id=null;function m0(){var e=window.event;return e&&e.type==="popstate"?e===id?!1:(id=e,!0):(id=null,!1)}var dx=typeof setTimeout=="function"?setTimeout:void 0,h0=typeof clearTimeout=="function"?clearTimeout:void 0,fx=typeof Promise=="function"?Promise:void 0,x0=typeof queueMicrotask=="function"?queueMicrotask:typeof fx<"u"?function(e){return fx.resolve(null).then(e).catch(g0)}:dx;function g0(e){setTimeout(function(){throw e})}function ca(e){return e==="head"}function px(e,n){var l=n,o=0;do{var p=l.nextSibling;if(e.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"||l==="/&"){if(o===0){e.removeChild(p),zl(n);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")Rs(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,Rs(l);for(var g=l.firstChild;g;){var S=g.nextSibling,R=g.nodeName;g[ql]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=S}}else l==="body"&&Rs(e.ownerDocument.body);l=p}while(l);zl(n)}function mx(e,n){var l=e;e=0;do{var o=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||""),o&&o.nodeType===8)if(l=o.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=o}while(l)}function od(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":od(l),pc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function v0(e,n,l,o){for(;e.nodeType===1;){var p=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[ql])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!==p.rel||e.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||e.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||e.getAttribute("title")!==(p.title==null?null:p.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(p.src==null?null:p.src)||e.getAttribute("type")!==(p.type==null?null:p.type)||e.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=p.name==null?null:""+p.name;if(p.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Qn(e.nextSibling),e===null)break}return null}function y0(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Qn(e.nextSibling),e===null))return null;return e}function hx(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Qn(e.nextSibling),e===null))return null;return e}function cd(e){return e.data==="$?"||e.data==="$~"}function ud(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function b0(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var o=function(){n(),l.removeEventListener("DOMContentLoaded",o)};l.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Qn(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 dd=null;function xx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Qn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function gx(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 vx(e,n,l){switch(n=po(l),e){case"html":if(e=n.documentElement,!e)throw Error(i(452));return e;case"head":if(e=n.head,!e)throw Error(i(453));return e;case"body":if(e=n.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Rs(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);pc(e)}var Zn=new Map,yx=new Set;function mo(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var $r=$.d;$.d={f:j0,r:S0,D:k0,C:w0,L:C0,m:E0,X:T0,S:N0,M:R0};function j0(){var e=$r.f(),n=ao();return e||n}function S0(e){var n=Za(e);n!==null&&n.tag===5&&n.type==="form"?Om(n):$r.r(e)}var Al=typeof document>"u"?null:document;function bx(e,n,l){var o=Al;if(o&&typeof n=="string"&&n){var p=Fn(n);p='link[rel="'+e+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),yx.has(p)||(yx.add(p),e={rel:e,crossOrigin:l,href:n},o.querySelector(p)===null&&(n=o.createElement("link"),cn(n,"link",e),tn(n),o.head.appendChild(n)))}}function k0(e){$r.D(e),bx("dns-prefetch",e,null)}function w0(e,n){$r.C(e,n),bx("preconnect",e,n)}function C0(e,n,l){$r.L(e,n,l);var o=Al;if(o&&e&&n){var p='link[rel="preload"][as="'+Fn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+Fn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+Fn(l.imageSizes)+'"]')):p+='[href="'+Fn(e)+'"]';var g=p;switch(n){case"style":g=Ll(e);break;case"script":g=Ml(e)}Zn.has(g)||(e=y({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Zn.set(g,e),o.querySelector(p)!==null||n==="style"&&o.querySelector(As(g))||n==="script"&&o.querySelector(Ls(g))||(n=o.createElement("link"),cn(n,"link",e),tn(n),o.head.appendChild(n)))}}function E0(e,n){$r.m(e,n);var l=Al;if(l&&e){var o=n&&typeof n.as=="string"?n.as:"script",p='link[rel="modulepreload"][as="'+Fn(o)+'"][href="'+Fn(e)+'"]',g=p;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ml(e)}if(!Zn.has(g)&&(e=y({rel:"modulepreload",href:e},n),Zn.set(g,e),l.querySelector(p)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Ls(g)))return}o=l.createElement("link"),cn(o,"link",e),tn(o),l.head.appendChild(o)}}}function N0(e,n,l){$r.S(e,n,l);var o=Al;if(o&&e){var p=Ja(o).hoistableStyles,g=Ll(e);n=n||"default";var S=p.get(g);if(!S){var R={loading:0,preload:null};if(S=o.querySelector(As(g)))R.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Zn.get(g))&&fd(e,l);var V=S=o.createElement("link");tn(V),cn(V,"link",e),V._p=new Promise(function(ne,de){V.onload=ne,V.onerror=de}),V.addEventListener("load",function(){R.loading|=1}),V.addEventListener("error",function(){R.loading|=2}),R.loading|=4,ho(S,n,o)}S={type:"stylesheet",instance:S,count:1,state:R},p.set(g,S)}}}function T0(e,n){$r.X(e,n);var l=Al;if(l&&e){var o=Ja(l).hoistableScripts,p=Ml(e),g=o.get(p);g||(g=l.querySelector(Ls(p)),g||(e=y({src:e,async:!0},n),(n=Zn.get(p))&&pd(e,n),g=l.createElement("script"),tn(g),cn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(p,g))}}function R0(e,n){$r.M(e,n);var l=Al;if(l&&e){var o=Ja(l).hoistableScripts,p=Ml(e),g=o.get(p);g||(g=l.querySelector(Ls(p)),g||(e=y({src:e,async:!0,type:"module"},n),(n=Zn.get(p))&&pd(e,n),g=l.createElement("script"),tn(g),cn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(p,g))}}function jx(e,n,l,o){var p=(p=J.current)?mo(p):null;if(!p)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=Ll(l.href),l=Ja(p).hoistableStyles,o=l.get(n),o||(o={type:"style",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Ll(l.href);var g=Ja(p).hoistableStyles,S=g.get(e);if(S||(p=p.ownerDocument||p,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,S),(g=p.querySelector(As(e)))&&!g._p&&(S.instance=g,S.state.loading=5),Zn.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},Zn.set(e,l),g||A0(p,e,l,S.state))),n&&o===null)throw Error(i(528,""));return S}if(n&&o!==null)throw Error(i(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Ml(l),l=Ja(p).hoistableScripts,o=l.get(n),o||(o={type:"script",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ll(e){return'href="'+Fn(e)+'"'}function As(e){return'link[rel="stylesheet"]['+e+"]"}function Sx(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function A0(e,n,l,o){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=e.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),cn(n,"link",l),tn(n),e.head.appendChild(n))}function Ml(e){return'[src="'+Fn(e)+'"]'}function Ls(e){return"script[async]"+e}function kx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var o=e.querySelector('style[data-href~="'+Fn(l.href)+'"]');if(o)return n.instance=o,tn(o),o;var p=y({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),tn(o),cn(o,"style",p),ho(o,l.precedence,e),n.instance=o;case"stylesheet":p=Ll(l.href);var g=e.querySelector(As(p));if(g)return n.state.loading|=4,n.instance=g,tn(g),g;o=Sx(l),(p=Zn.get(p))&&fd(o,p),g=(e.ownerDocument||e).createElement("link"),tn(g);var S=g;return S._p=new Promise(function(R,V){S.onload=R,S.onerror=V}),cn(g,"link",o),n.state.loading|=4,ho(g,l.precedence,e),n.instance=g;case"script":return g=Ml(l.src),(p=e.querySelector(Ls(g)))?(n.instance=p,tn(p),p):(o=l,(p=Zn.get(g))&&(o=y({},l),pd(o,p)),e=e.ownerDocument||e,p=e.createElement("script"),tn(p),cn(p,"link",o),e.head.appendChild(p),n.instance=p);case"void":return null;default:throw Error(i(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,ho(o,l.precedence,e));return n.instance}function ho(e,n,l){for(var o=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=o.length?o[o.length-1]:null,g=p,S=0;S<o.length;S++){var R=o[S];if(R.dataset.precedence===n)g=R;else if(g!==p)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function fd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function pd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var xo=null;function wx(e,n,l){if(xo===null){var o=new Map,p=xo=new Map;p.set(l,o)}else p=xo,o=p.get(l),o||(o=new Map,p.set(l,o));if(o.has(e))return o;for(o.set(e,null),l=l.getElementsByTagName(e),p=0;p<l.length;p++){var g=l[p];if(!(g[ql]||g[Mt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(n)||"";S=e+S;var R=o.get(S);R?R.push(g):o.set(S,[g])}}return o}function Cx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function L0(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 Ex(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function M0(e,n,l,o){if(l.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=Ll(o.href),g=n.querySelector(As(p));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=go.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,tn(g);return}g=n.ownerDocument||n,o=Sx(o),(p=Zn.get(p))&&fd(o,p),g=g.createElement("link"),tn(g);var S=g;S._p=new Promise(function(R,V){S.onload=R,S.onerror=V}),cn(g,"link",o),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=go.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var md=0;function z0(e,n){return e.stylesheets&&e.count===0&&yo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&yo(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&md===0&&(md=62500*p0());var p=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&yo(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>md?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(p)}}:null}function go(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var vo=null;function yo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,vo=new Map,n.forEach(D0,e),vo=null,go.call(e))}function D0(e,n){if(!(n.state.loading&4)){var l=vo.get(e);if(l)var o=l.get(null);else{l=new Map,vo.set(e,l);for(var p=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<p.length;g++){var S=p[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(l.set(S.dataset.precedence,S),o=S)}o&&l.set(null,o)}p=n.instance,S=p.getAttribute("data-precedence"),g=l.get(S)||o,g===o&&l.set(null,p),l.set(S,p),this.count++,o=go.bind(this),p.addEventListener("load",o),p.addEventListener("error",o),g?g.parentNode.insertBefore(p,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(p,e.firstChild)),n.state.loading|=4}}var Ms={$$typeof:A,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function _0(e,n,l,o,p,g,S,R,V){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=Vr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vr(0),this.hiddenUpdates=Vr(null),this.identifierPrefix=o,this.onUncaughtError=p,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function Nx(e,n,l,o,p,g,S,R,V,ne,de,pe){return e=new _0(e,n,l,S,V,ne,de,pe,R),n=1,g===!0&&(n|=24),g=Mn(3,null,null,n),e.current=g,g.stateNode=e,n=qc(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:n},Qc(g),e}function Tx(e){return e?(e=cl,e):cl}function Rx(e,n,l,o,p,g){p=Tx(p),o.context===null?o.context=p:o.pendingContext=p,o=Zr(n),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=Jr(e,o,n),l!==null&&(Rn(l,e,n),us(l,e,n))}function Ax(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function hd(e,n){Ax(e,n),(e=e.alternate)&&Ax(e,n)}function Lx(e){if(e.tag===13||e.tag===31){var n=Ta(e,67108864);n!==null&&Rn(n,e,67108864),hd(e,67108864)}}function Mx(e){if(e.tag===13||e.tag===31){var n=Bn();n=Xt(n);var l=Ta(e,n);l!==null&&Rn(l,e,n),hd(e,n)}}var bo=!0;function O0(e,n,l,o){var p=D.T;D.T=null;var g=$.p;try{$.p=2,xd(e,n,l,o)}finally{$.p=g,D.T=p}}function B0(e,n,l,o){var p=D.T;D.T=null;var g=$.p;try{$.p=8,xd(e,n,l,o)}finally{$.p=g,D.T=p}}function xd(e,n,l,o){if(bo){var p=gd(o);if(p===null)nd(e,n,o,jo,l),Dx(e,o);else if($0(p,e,n,l,o))o.stopPropagation();else if(Dx(e,o),n&4&&-1<I0.indexOf(e)){for(;p!==null;){var g=Za(p);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=Et(g.pendingLanes);if(S!==0){var R=g;for(R.pendingLanes|=2,R.entangledLanes|=2;S;){var V=1<<31-Kt(S);R.entanglements[1]|=V,S&=~V}hr(g),(dt&6)===0&&(no=He()+500,Es(0))}}break;case 31:case 13:R=Ta(g,2),R!==null&&Rn(R,g,2),ao(),hd(g,2)}if(g=gd(o),g===null&&nd(e,n,o,jo,l),g===p)break;p=g}p!==null&&o.stopPropagation()}else nd(e,n,o,null,l)}}function gd(e){return e=yc(e),vd(e)}var jo=null;function vd(e){if(jo=null,e=Qa(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=f(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 jo=e,null}function zx(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(jt()){case Ot:return 2;case St:return 8;case Lt:case xe:return 32;case Ze:return 268435456;default:return 32}default:return 32}}var yd=!1,ua=null,da=null,fa=null,zs=new Map,Ds=new Map,pa=[],I0="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 Dx(e,n){switch(e){case"focusin":case"focusout":ua=null;break;case"dragenter":case"dragleave":da=null;break;case"mouseover":case"mouseout":fa=null;break;case"pointerover":case"pointerout":zs.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ds.delete(n.pointerId)}}function _s(e,n,l,o,p,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:l,eventSystemFlags:o,nativeEvent:g,targetContainers:[p]},n!==null&&(n=Za(n),n!==null&&Lx(n)),e):(e.eventSystemFlags|=o,n=e.targetContainers,p!==null&&n.indexOf(p)===-1&&n.push(p),e)}function $0(e,n,l,o,p){switch(n){case"focusin":return ua=_s(ua,e,n,l,o,p),!0;case"dragenter":return da=_s(da,e,n,l,o,p),!0;case"mouseover":return fa=_s(fa,e,n,l,o,p),!0;case"pointerover":var g=p.pointerId;return zs.set(g,_s(zs.get(g)||null,e,n,l,o,p)),!0;case"gotpointercapture":return g=p.pointerId,Ds.set(g,_s(Ds.get(g)||null,e,n,l,o,p)),!0}return!1}function _x(e){var n=Qa(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,dr(e.priority,function(){Mx(l)});return}}else if(n===31){if(n=f(l),n!==null){e.blockedOn=n,dr(e.priority,function(){Mx(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 So(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=gd(e.nativeEvent);if(l===null){l=e.nativeEvent;var o=new l.constructor(l.type,l);vc=o,l.target.dispatchEvent(o),vc=null}else return n=Za(l),n!==null&&Lx(n),e.blockedOn=l,!1;n.shift()}return!0}function Ox(e,n,l){So(e)&&l.delete(n)}function U0(){yd=!1,ua!==null&&So(ua)&&(ua=null),da!==null&&So(da)&&(da=null),fa!==null&&So(fa)&&(fa=null),zs.forEach(Ox),Ds.forEach(Ox)}function ko(e,n){e.blockedOn===n&&(e.blockedOn=null,yd||(yd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,U0)))}var wo=null;function Bx(e){wo!==e&&(wo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){wo===e&&(wo=null);for(var n=0;n<e.length;n+=3){var l=e[n],o=e[n+1],p=e[n+2];if(typeof o!="function"){if(vd(o||l)===null)continue;break}var g=Za(l);g!==null&&(e.splice(n,3),n-=3,gu(g,{pending:!0,data:p,method:l.method,action:o},o,p))}}))}function zl(e){function n(V){return ko(V,e)}ua!==null&&ko(ua,e),da!==null&&ko(da,e),fa!==null&&ko(fa,e),zs.forEach(n),Ds.forEach(n);for(var l=0;l<pa.length;l++){var o=pa[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<pa.length&&(l=pa[0],l.blockedOn===null);)_x(l),l.blockedOn===null&&pa.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(o=0;o<l.length;o+=3){var p=l[o],g=l[o+1],S=p[Ut]||null;if(typeof g=="function")S||Bx(l);else if(S){var R=null;if(g&&g.hasAttribute("formAction")){if(p=g,S=g[Ut]||null)R=S.formAction;else if(vd(p)!==null)continue}else R=S.action;typeof R=="function"?l[o+1]=R:(l.splice(o,3),o-=3),Bx(l)}}}function Ix(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return p=S})},focusReset:"manual",scroll:"manual"})}function n(){p!==null&&(p(),p=null),o||setTimeout(l,20)}function l(){if(!o&&!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 o=!1,p=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),p!==null&&(p(),p=null)}}}function bd(e){this._internalRoot=e}Co.prototype.render=bd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(i(409));var l=n.current,o=Bn();Rx(l,o,e,n,null,null)},Co.prototype.unmount=bd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Rx(e.current,2,null,e,null,null),ao(),n[Fr]=null}};function Co(e){this._internalRoot=e}Co.prototype.unstable_scheduleHydration=function(e){if(e){var n=hn();e={blockedOn:null,target:e,priority:n};for(var l=0;l<pa.length&&n!==0&&n<pa[l].priority;l++);pa.splice(l,0,e),l===0&&_x(e)}};var $x=a.version;if($x!=="19.2.4")throw Error(i(527,$x,"19.2.4"));$.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=x(n),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var H0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Eo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Eo.isDisabled&&Eo.supportsFiber)try{Bt=Eo.inject(H0),lt=Eo}catch{}}return Bs.createRoot=function(e,n){if(!c(e))throw Error(i(299));var l=!1,o="",p=Gm,g=qm,S=Ym;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(p=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError)),n=Nx(e,1,!1,null,null,l,o,null,p,g,S,Ix),e[Fr]=n.current,td(e),new bd(n)},Bs.hydrateRoot=function(e,n,l){if(!c(e))throw Error(i(299));var o=!1,p="",g=Gm,S=qm,R=Ym,V=null;return l!=null&&(l.unstable_strictMode===!0&&(o=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(S=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(V=l.formState)),n=Nx(e,1,!0,n,l??null,o,p,V,g,S,R,Ix),n.context=Tx(null),l=n.current,o=Bn(),o=Xt(o),p=Zr(o),p.callback=null,Jr(l,p,o),l=o,n.current.lanes=l,rn(n,l),hr(n),e[Fr]=n.current,td(e),new Co(n)},Bs.version="19.2.4",Bs}var Kx;function X0(){if(Kx)return kd.exports;Kx=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(),kd.exports=K0(),kd.exports}var Q0=X0();/**
|
|
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 Xx="popstate";function Qx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function Z0(t={}){function a(c,u){let{pathname:d="/",search:f="",hash:h=""}=Pl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),sf("",{pathname:d,search:f,hash:h},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),f="";if(d&&d.getAttribute("href")){let h=c.location.href,x=h.indexOf("#");f=x===-1?h:h.slice(0,x)}return f+"#"+(typeof u=="string"?u:Qs(u))}function i(c,u){ir(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return ej(a,s,i,t)}function en(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function ir(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function J0(){return Math.random().toString(36).substring(2,10)}function Zx(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 sf(t,a,s=null,i,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Pl(a):a,state:s,key:a&&a.key||i||J0(),unstable_mask:c}}function Qs({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 Pl(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let i=t.indexOf("?");i>=0&&(a.search=t.substring(i),t=t.substring(0,i)),t&&(a.pathname=t)}return a}function ej(t,a,s,i={}){let{window:c=document.defaultView,v5Compat:u=!1}=i,d=c.history,f="POP",h=null,x=v();x==null&&(x=0,d.replaceState({...d.state,idx:x},""));function v(){return(d.state||{idx:null}).idx}function y(){f="POP";let w=v(),N=w==null?null:w-x;x=w,h&&h({action:f,location:C.location,delta:N})}function b(w,N){f="PUSH";let T=Qx(w)?w:sf(C.location,w,N);s&&s(T,w),x=v()+1;let A=Zx(T,x),B=C.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;c.location.assign(B)}u&&h&&h({action:f,location:C.location,delta:1})}function j(w,N){f="REPLACE";let T=Qx(w)?w:sf(C.location,w,N);s&&s(T,w),x=v();let A=Zx(T,x),B=C.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&h&&h({action:f,location:C.location,delta:0})}function k(w){return tj(w)}let C={get action(){return f},get location(){return t(c,d)},listen(w){if(h)throw new Error("A history only accepts one active listener");return c.addEventListener(Xx,y),h=w,()=>{c.removeEventListener(Xx,y),h=null}},createHref(w){return a(c,w)},createURL:k,encodeLocation(w){let N=k(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:j,go(w){return d.go(w)}};return C}function tj(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),en(s,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:Qs(t);return i=i.replace(/ $/,"%20"),!a&&i.startsWith("//")&&(i=s+i),new URL(i,s)}function Mv(t,a,s="/"){return nj(t,a,s,!1)}function nj(t,a,s,i){let c=typeof a=="string"?Pl(a):a,u=Hr(c.pathname||"/",s);if(u==null)return null;let d=zv(t);rj(d);let f=null;for(let h=0;f==null&&h<d.length;++h){let x=mj(u);f=fj(d[h],x,i)}return f}function zv(t,a=[],s=[],i="",c=!1){let u=(d,f,h=c,x)=>{let v={relativePath:x===void 0?d.path||"":x,caseSensitive:d.caseSensitive===!0,childrenIndex:f,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(i)&&h)return;en(v.relativePath.startsWith(i),`Absolute route path "${v.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(i.length)}let y=yr([i,v.relativePath]),b=s.concat(v);d.children&&d.children.length>0&&(en(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),zv(d.children,a,b,y,h)),!(d.path==null&&!d.index)&&a.push({path:y,score:uj(y,d.index),routesMeta:b})};return t.forEach((d,f)=>{var h;if(d.path===""||!((h=d.path)!=null&&h.includes("?")))u(d,f);else for(let x of Dv(d.path))u(d,f,!0,x)}),a}function Dv(t){let a=t.split("/");if(a.length===0)return[];let[s,...i]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(i.length===0)return c?[u,""]:[u];let d=Dv(i.join("/")),f=[];return f.push(...d.map(h=>h===""?u:[u,h].join("/"))),c&&f.push(...d),f.map(h=>t.startsWith("/")&&h===""?"/":h)}function rj(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:dj(a.routesMeta.map(i=>i.childrenIndex),s.routesMeta.map(i=>i.childrenIndex)))}var aj=/^:[\w-]+$/,lj=3,sj=2,ij=1,oj=10,cj=-2,Jx=t=>t==="*";function uj(t,a){let s=t.split("/"),i=s.length;return s.some(Jx)&&(i+=cj),a&&(i+=sj),s.filter(c=>!Jx(c)).reduce((c,u)=>c+(aj.test(u)?lj:u===""?ij:oj),i)}function dj(t,a){return t.length===a.length&&t.slice(0,-1).every((i,c)=>i===a[c])?t[t.length-1]-a[a.length-1]:0}function fj(t,a,s=!1){let{routesMeta:i}=t,c={},u="/",d=[];for(let f=0;f<i.length;++f){let h=i[f],x=f===i.length-1,v=u==="/"?a:a.slice(u.length)||"/",y=qo({path:h.relativePath,caseSensitive:h.caseSensitive,end:x},v),b=h.route;if(!y&&x&&s&&!i[i.length-1].route.index&&(y=qo({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},v)),!y)return null;Object.assign(c,y.params),d.push({params:c,pathname:yr([u,y.pathname]),pathnameBase:vj(yr([u,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(u=yr([u,y.pathnameBase]))}return d}function qo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,i]=pj(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),f=c.slice(1);return{params:i.reduce((x,{paramName:v,isOptional:y},b)=>{if(v==="*"){let k=f[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const j=f[b];return y&&!j?x[v]=void 0:x[v]=(j||"").replace(/%2F/g,"/"),x},{}),pathname:u,pathnameBase:d,pattern:t}}function pj(t,a=!1,s=!0){ir(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 i=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,f,h,x,v)=>{if(i.push({paramName:f,isOptional:h!=null}),h){let y=v.charAt(x+d.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(i.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),i]}function mj(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return ir(!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 Hr(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,i=t.charAt(s);return i&&i!=="/"?null:t.slice(s)||"/"}var hj=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function xj(t,a="/"){let{pathname:s,search:i="",hash:c=""}=typeof t=="string"?Pl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=eg(s.substring(1),"/"):u=eg(s,a)):u=a,{pathname:u,search:yj(i),hash:bj(c)}}function eg(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 Nd(t,a,s,i){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(i)}]. 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 gj(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function _v(t){let a=gj(t);return a.map((s,i)=>i===a.length-1?s.pathname:s.pathnameBase)}function Rf(t,a,s,i=!1){let c;typeof t=="string"?c=Pl(t):(c={...t},en(!c.pathname||!c.pathname.includes("?"),Nd("?","pathname","search",c)),en(!c.pathname||!c.pathname.includes("#"),Nd("#","pathname","hash",c)),en(!c.search||!c.search.includes("#"),Nd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,f;if(d==null)f=s;else{let y=a.length-1;if(!i&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),y-=1;c.pathname=b.join("/")}f=y>=0?a[y]:"/"}let h=xj(c,f),x=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&s.endsWith("/");return!h.pathname.endsWith("/")&&(x||v)&&(h.pathname+="/"),h}var yr=t=>t.join("/").replace(/\/\/+/g,"/"),vj=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),yj=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,bj=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,jj=class{constructor(t,a,s,i=!1){this.status=t,this.statusText=a||"",this.internal=i,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function Sj(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function kj(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Ov=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Bv(t,a){let s=t;if(typeof s!="string"||!hj.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let i=s,c=!1;if(Ov)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),f=Hr(d.pathname,a);d.origin===u.origin&&f!=null?s=f+d.search+d.hash:c=!0}catch{ir(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Iv=["POST","PUT","PATCH","DELETE"];new Set(Iv);var wj=["GET",...Iv];new Set(wj);var Vl=m.createContext(null);Vl.displayName="DataRouter";var tc=m.createContext(null);tc.displayName="DataRouterState";var Cj=m.createContext(!1),$v=m.createContext({isTransitioning:!1});$v.displayName="ViewTransition";var Ej=m.createContext(new Map);Ej.displayName="Fetchers";var Nj=m.createContext(null);Nj.displayName="Await";var nr=m.createContext(null);nr.displayName="Navigation";var nc=m.createContext(null);nc.displayName="Location";var Pr=m.createContext({outlet:null,matches:[],isDataRoute:!1});Pr.displayName="Route";var Af=m.createContext(null);Af.displayName="RouteError";var Uv="REACT_ROUTER_ERROR",Tj="REDIRECT",Rj="ROUTE_ERROR_RESPONSE";function Aj(t){if(t.startsWith(`${Uv}:${Tj}:{`))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 Lj(t){if(t.startsWith(`${Uv}:${Rj}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new jj(a.status,a.statusText,a.data)}catch{}}function Mj(t,{relative:a}={}){en(li(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:i}=m.useContext(nr),{hash:c,pathname:u,search:d}=si(t,{relative:a}),f=u;return s!=="/"&&(f=u==="/"?s:yr([s,u])),i.createHref({pathname:f,search:d,hash:c})}function li(){return m.useContext(nc)!=null}function ba(){return en(li(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(nc).location}var Hv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Pv(t){m.useContext(nr).static||m.useLayoutEffect(t)}function zj(){let{isDataRoute:t}=m.useContext(Pr);return t?Gj():Dj()}function Dj(){en(li(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(Vl),{basename:a,navigator:s}=m.useContext(nr),{matches:i}=m.useContext(Pr),{pathname:c}=ba(),u=JSON.stringify(_v(i)),d=m.useRef(!1);return Pv(()=>{d.current=!0}),m.useCallback((h,x={})=>{if(ir(d.current,Hv),!d.current)return;if(typeof h=="number"){s.go(h);return}let v=Rf(h,JSON.parse(u),c,x.relative==="path");t==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:yr([a,v.pathname])),(x.replace?s.replace:s.push)(v,x.state,x)},[a,s,u,c,t])}m.createContext(null);function si(t,{relative:a}={}){let{matches:s}=m.useContext(Pr),{pathname:i}=ba(),c=JSON.stringify(_v(s));return m.useMemo(()=>Rf(t,JSON.parse(c),i,a==="path"),[t,c,i,a])}function _j(t,a,s){en(li(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=m.useContext(nr),{matches:c}=m.useContext(Pr),u=c[c.length-1],d=u?u.params:{},f=u?u.pathname:"/",h=u?u.pathnameBase:"/",x=u&&u.route;{let w=x&&x.path||"";Fv(f,!x||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (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=ba(),y;y=v;let b=y.pathname||"/",j=b;if(h!=="/"){let w=h.replace(/^\//,"").split("/");j="/"+b.replace(/^\//,"").split("/").slice(w.length).join("/")}let k=Mv(t,{pathname:j});return ir(x||k!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),ir(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${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.`),Uj(k&&k.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:yr([h,i.encodeLocation?i.encodeLocation(w.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?h:yr([h,i.encodeLocation?i.encodeLocation(w.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,s)}function Oj(){let t=Wj(),a=Sj(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:u},"ErrorBoundary")," or"," ",m.createElement("code",{style:u},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},a),s?m.createElement("pre",{style:c},s):null,d)}var Bj=m.createElement(Oj,null),Vv=class extends m.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,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=Lj(t.digest);s&&(t=s)}let a=t!==void 0?m.createElement(Pr.Provider,{value:this.props.routeContext},m.createElement(Af.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(Ij,{error:t},a):a}};Vv.contextType=Cj;var Td=new WeakMap;function Ij({children:t,error:a}){let{basename:s}=m.useContext(nr);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=Aj(a.digest);if(i){let c=Td.get(a);if(c)throw c;let u=Bv(i.location,s);if(Ov&&!Td.get(a))if(u.isExternal||i.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:i.replace}));throw Td.set(a,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function $j({routeContext:t,match:a,children:s}){let i=m.useContext(Vl);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(Pr.Provider,{value:t},s)}function Uj(t,a=[],s){let i=s==null?void 0:s.state;if(t==null){if(!i)return null;if(i.errors)t=i.matches;else if(a.length===0&&!i.initialized&&i.matches.length>0)t=i.matches;else return null}let c=t,u=i==null?void 0:i.errors;if(u!=null){let v=c.findIndex(y=>y.route.id&&(u==null?void 0:u[y.route.id])!==void 0);en(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,f=-1;if(s&&i){d=i.renderFallback;for(let v=0;v<c.length;v++){let y=c[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(f=v),y.route.id){let{loaderData:b,errors:j}=i,k=y.route.loader&&!b.hasOwnProperty(y.route.id)&&(!j||j[y.route.id]===void 0);if(y.route.lazy||k){s.isStatic&&(d=!0),f>=0?c=c.slice(0,f+1):c=[c[0]];break}}}}let h=s==null?void 0:s.onError,x=i&&h?(v,y)=>{var b,j;h(v,{location:i.location,params:((j=(b=i.matches)==null?void 0:b[0])==null?void 0:j.params)??{},unstable_pattern:kj(i.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let j,k=!1,C=null,w=null;i&&(j=u&&y.route.id?u[y.route.id]:void 0,C=y.route.errorElement||Bj,d&&(f<0&&b===0?(Fv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,w=null):f===b&&(k=!0,w=y.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return j?A=C:k?A=w:y.route.Component?A=m.createElement(y.route.Component,null):y.route.element?A=y.route.element:A=v,m.createElement($j,{match:y,routeContext:{outlet:v,matches:N,isDataRoute:i!=null},children:A})};return i&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?m.createElement(Vv,{location:i.location,revalidation:i.revalidation,component:C,error:j,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:x}):T()},null)}function Lf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hj(t){let a=m.useContext(Vl);return en(a,Lf(t)),a}function Pj(t){let a=m.useContext(tc);return en(a,Lf(t)),a}function Vj(t){let a=m.useContext(Pr);return en(a,Lf(t)),a}function Mf(t){let a=Vj(t),s=a.matches[a.matches.length-1];return en(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Fj(){return Mf("useRouteId")}function Wj(){var i;let t=m.useContext(Af),a=Pj("useRouteError"),s=Mf("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function Gj(){let{router:t}=Hj("useNavigate"),a=Mf("useNavigate"),s=m.useRef(!1);return Pv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{ir(s.current,Hv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var tg={};function Fv(t,a,s){!a&&!tg[t]&&(tg[t]=!0,ir(!1,s))}m.memo(qj);function qj({routes:t,future:a,state:s,isStatic:i,onError:c}){return _j(t,void 0,{state:s,isStatic:i,onError:c})}function Yj({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){en(!li(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=t.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:f,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[f,c,u,d]);typeof s=="string"&&(s=Pl(s));let{pathname:x="/",search:v="",hash:y="",state:b=null,key:j="default",unstable_mask:k}=s,C=m.useMemo(()=>{let w=Hr(x,f);return w==null?null:{location:{pathname:w,search:v,hash:y,state:b,key:j,unstable_mask:k},navigationType:i}},[f,x,v,y,b,j,i,k]);return ir(C!=null,`<Router basename="${f}"> is not able to match the URL "${x}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:m.createElement(nr.Provider,{value:h},m.createElement(nc.Provider,{children:a,value:C}))}var Uo="get",Ho="application/x-www-form-urlencoded";function rc(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Kj(t){return rc(t)&&t.tagName.toLowerCase()==="button"}function Xj(t){return rc(t)&&t.tagName.toLowerCase()==="form"}function Qj(t){return rc(t)&&t.tagName.toLowerCase()==="input"}function Zj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Jj(t,a){return t.button===0&&(!a||a==="_self")&&!Zj(t)}var No=null;function eS(){if(No===null)try{new FormData(document.createElement("form"),0),No=!1}catch{No=!0}return No}var tS=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Rd(t){return t!=null&&!tS.has(t)?(ir(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ho}"`),null):t}function nS(t,a){let s,i,c,u,d;if(Xj(t)){let f=t.getAttribute("action");i=f?Hr(f,a):null,s=t.getAttribute("method")||Uo,c=Rd(t.getAttribute("enctype"))||Ho,u=new FormData(t)}else if(Kj(t)||Qj(t)&&(t.type==="submit"||t.type==="image")){let f=t.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=t.getAttribute("formaction")||f.getAttribute("action");if(i=h?Hr(h,a):null,s=t.getAttribute("formmethod")||f.getAttribute("method")||Uo,c=Rd(t.getAttribute("formenctype"))||Rd(f.getAttribute("enctype"))||Ho,u=new FormData(f,t),!eS()){let{name:x,type:v,value:y}=t;if(v==="image"){let b=x?`${x}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else x&&u.append(x,y)}}else{if(rc(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Uo,i=null,c=Ho,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:i,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function zf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function rS(t,a,s,i){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}_.${i}`:c.pathname=`${c.pathname}.${i}`:c.pathname==="/"?c.pathname=`_root.${i}`:a&&Hr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${i}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${i}`,c}async function aS(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 lS(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 sS(t,a,s){let i=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await aS(u,s);return d.links?d.links():[]}return[]}));return uS(i.flat(1).filter(lS).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function ng(t,a,s,i,c,u){let d=(h,x)=>s[x]?h.route.id!==s[x].route.id:!0,f=(h,x)=>{var v;return s[x].pathname!==h.pathname||((v=s[x].route.path)==null?void 0:v.endsWith("*"))&&s[x].params["*"]!==h.params["*"]};return u==="assets"?a.filter((h,x)=>d(h,x)||f(h,x)):u==="data"?a.filter((h,x)=>{var y;let v=i.routes[h.route.id];if(!v||!v.hasLoader)return!1;if(d(h,x)||f(h,x))return!0;if(h.route.shouldRevalidate){let b=h.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:h.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function iS(t,a,{includeHydrateFallback:s}={}){return oS(t.map(i=>{let c=a.routes[i.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 oS(t){return[...new Set(t)]}function cS(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function uS(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(cS(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Wv(){let t=m.useContext(Vl);return zf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function dS(){let t=m.useContext(tc);return zf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Df=m.createContext(void 0);Df.displayName="FrameworkContext";function Gv(){let t=m.useContext(Df);return zf(t,"You must render this element inside a <HydratedRouter> element"),t}function fS(t,a){let s=m.useContext(Df),[i,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:f,onBlur:h,onMouseEnter:x,onMouseLeave:v,onTouchStart:y}=a,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let C=N=>{N.forEach(T=>{d(T.isIntersecting)})},w=new IntersectionObserver(C,{threshold:.5});return b.current&&w.observe(b.current),()=>{w.disconnect()}}},[t]),m.useEffect(()=>{if(i){let C=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(C)}}},[i]);let j=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Is(f,j),onBlur:Is(h,k),onMouseEnter:Is(x,j),onMouseLeave:Is(v,k),onTouchStart:Is(y,j)}]:[!1,b,{}]}function Is(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function pS({page:t,...a}){let{router:s}=Wv(),i=m.useMemo(()=>Mv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?m.createElement(hS,{page:t,matches:i,...a}):null}function mS(t){let{manifest:a,routeModules:s}=Gv(),[i,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return sS(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function hS({page:t,matches:a,...s}){let i=ba(),{future:c,manifest:u,routeModules:d}=Gv(),{basename:f}=Wv(),{loaderData:h,matches:x}=dS(),v=m.useMemo(()=>ng(t,a,x,u,i,"data"),[t,a,x,u,i]),y=m.useMemo(()=>ng(t,a,x,u,i,"assets"),[t,a,x,u,i]),b=m.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let C=new Set,w=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!v.some(M=>M.route.id===T.route.id)&&T.route.id in h&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?w=!0:C.add(T.route.id))}),C.size===0)return[];let N=rS(t,f,c.unstable_trailingSlashAwareDataRequests,"data");return w&&C.size>0&&N.searchParams.set("_routes",a.filter(T=>C.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[f,c.unstable_trailingSlashAwareDataRequests,h,i,u,v,a,t,d]),j=m.useMemo(()=>iS(y,u),[y,u]),k=mS(y);return m.createElement(m.Fragment,null,b.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...s})),j.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...s})),k.map(({key:C,link:w})=>m.createElement("link",{key:C,nonce:s.nonce,...w,crossOrigin:w.crossOrigin??s.crossOrigin})))}function xS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var gS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{gS&&(window.__reactRouterVersion="7.13.1")}catch{}function vS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=m.useRef();c.current==null&&(c.current=Z0({window:i,v5Compat:!0}));let u=c.current,[d,f]=m.useState({action:u.action,location:u.location}),h=m.useCallback(x=>{s===!1?f(x):m.startTransition(()=>f(x))},[s]);return m.useLayoutEffect(()=>u.listen(h),[u,h]),m.createElement(Yj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var qv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yv=m.forwardRef(function({onClick:a,discover:s="render",prefetch:i="none",relative:c,reloadDocument:u,replace:d,unstable_mask:f,state:h,target:x,to:v,preventScrollReset:y,viewTransition:b,unstable_defaultShouldRevalidate:j,...k},C){let{basename:w,navigator:N,unstable_useTransitions:T}=m.useContext(nr),A=typeof v=="string"&&qv.test(v),B=Bv(v,w);v=B.to;let M=Mj(v,{relative:c}),P=ba(),E=null;if(f){let U=Rf(f,[],P.unstable_mask?P.unstable_mask.pathname:"/",!0);w!=="/"&&(U.pathname=U.pathname==="/"?w:yr([w,U.pathname])),E=N.createHref(U)}let[O,z,_]=fS(i,k),H=SS(v,{replace:d,unstable_mask:f,state:h,target:x,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:j,unstable_useTransitions:T});function F(U){a&&a(U),U.defaultPrevented||H(U)}let q=!(B.isExternal||u),ee=m.createElement("a",{...k,..._,href:(q?E:void 0)||B.absoluteURL||M,onClick:q?F:a,ref:xS(C,z),target:x,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,ee,m.createElement(pS,{page:M})):ee});Yv.displayName="Link";var yS=m.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:i="",end:c=!1,style:u,to:d,viewTransition:f,children:h,...x},v){let y=si(d,{relative:x.relative}),b=ba(),j=m.useContext(tc),{navigator:k,basename:C}=m.useContext(nr),w=j!=null&&NS(y)&&f===!0,N=k.encodeLocation?k.encodeLocation(y).pathname:y.pathname,T=b.pathname,A=j&&j.navigation&&j.navigation.location?j.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&C&&(A=Hr(A,C)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let M=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",P=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),E={isActive:M,isPending:P,isTransitioning:w},O=M?a:void 0,z;typeof i=="function"?z=i(E):z=[i,M?"active":null,P?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(E):u;return m.createElement(Yv,{...x,"aria-current":O,className:z,ref:v,style:_,to:d,viewTransition:f},typeof h=="function"?h(E):h)});yS.displayName="NavLink";var bS=m.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Uo,action:f,onSubmit:h,relative:x,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...j},k)=>{let{unstable_useTransitions:C}=m.useContext(nr),w=CS(),N=ES(f,{relative:x}),T=d.toLowerCase()==="get"?"get":"post",A=typeof f=="string"&&qv.test(f),B=M=>{if(h&&h(M),M.defaultPrevented)return;M.preventDefault();let P=M.nativeEvent.submitter,E=(P==null?void 0:P.getAttribute("formmethod"))||d,O=()=>w(P||M.currentTarget,{fetcherKey:a,method:E,navigate:s,replace:c,state:u,relative:x,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});C&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:k,method:T,action:N,onSubmit:i?h:B,...j,"data-discover":!A&&t==="render"?"true":void 0})});bS.displayName="Form";function jS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kv(t){let a=m.useContext(Vl);return en(a,jS(t)),a}function SS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:h,unstable_useTransitions:x}={}){let v=zj(),y=ba(),b=si(t,{relative:d});return m.useCallback(j=>{if(Jj(j,a)){j.preventDefault();let k=s!==void 0?s:Qs(y)===Qs(b),C=()=>v(t,{replace:k,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:h});x?m.startTransition(()=>C()):C()}},[y,v,b,s,i,c,a,t,u,d,f,h,x])}var kS=0,wS=()=>`__${String(++kS)}__`;function CS(){let{router:t}=Kv("useSubmit"),{basename:a}=m.useContext(nr),s=Fj(),i=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:f,method:h,encType:x,formData:v,body:y}=nS(u,a);if(d.navigate===!1){let b=d.fetcherKey||wS();await i(b,s,d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||h,formEncType:d.encType||x,flushSync:d.flushSync})}else await c(d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||h,formEncType:d.encType||x,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,c,a,s])}function ES(t,{relative:a}={}){let{basename:s}=m.useContext(nr),i=m.useContext(Pr);en(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...si(t||".",{relative:a})},d=ba();if(t==null){u.search=d.search;let f=new URLSearchParams(u.search),h=f.getAll("index");if(h.some(v=>v==="")){f.delete("index"),h.filter(y=>y).forEach(y=>f.append("index",y));let v=f.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:yr([s,u.pathname])),Qs(u)}function NS(t,{relative:a}={}){let s=m.useContext($v);en(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Kv("useViewTransitionState"),c=si(t,{relative:a});if(!s.isTransitioning)return!1;let u=Hr(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Hr(s.nextLocation.pathname,i)||s.nextLocation.pathname;return qo(c.pathname,d)!=null||qo(c.pathname,u)!=null}var ac=Lv();const TS=Av(ac),RS="modulepreload",AS=function(t){return"/"+t},rg={},Fl=function(a,s,i){let c=Promise.resolve();if(s&&s.length>0){let d=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),h=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));c=d(s.map(x=>{if(x=AS(x),x in rg)return;rg[x]=!0;const v=x.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":RS,v||(b.as="script"),b.crossOrigin="",b.href=x,h&&b.setAttribute("nonce",h),document.head.appendChild(b),v)return new Promise((j,k)=>{b.addEventListener("load",j),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return c.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return a().catch(u)})},LS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function To(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!LS.test(a)||a==="0.0.0"?null:a}function Xv(t){if(t.preferInstalled){const c=To(t.installedCurrentVersion);if(c)return{version:c,versionSource:"registry"}}const a=To(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=To(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=To(t.pluginVersion);return i?{version:i,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const ag={own:"authoring-project",installed:"available-project",global:"available-personal"},of=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function MS(t){if(typeof t=="string"){if(of.has(t))return t;if(Object.prototype.hasOwnProperty.call(ag,t))return ag[t]}return"authoring-project"}function zS(t){return t.startsWith("available-")?"available":"authoring"}function DS(t){const a=t.indexOf("-");return t.slice(a+1)}const Jn="";class va extends Error{constructor(a,s,i){super(a),this.name="ApiError",this.status=s,this.details=i}}async function Oe(t,a){const s=await fetch(`${Jn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new va((i==null?void 0:i.error)||`HTTP ${s.status}`,s.status,c)}return s.json()}async function lg(t,a){const s=await fetch(t,a);return s.status>=502&&s.status<=504?(await new Promise(i=>setTimeout(i,250)),fetch(t,a)):s}const sg=100;function ig(t,a){if(t.length===0||a<=0)return[];const s=[];for(let i=0;i<t.length;i+=a)s.push(t.slice(i,i+a));return s}function Vt(t){return typeof t=="string"&&t.length>0?t:null}function _S(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Ol(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){if(!t||typeof t!="object")return null;const a=t,s=Vt(a.python)??void 0,i=Ol(a.pip)??void 0,c=Vt(a.node)??void 0;return!s&&!i&&!c?null:{python:s,pip:i,node:c}}function BS(t){if(!t||typeof t!="object")return null;const a=t,s=a.runner;return s!=="vitest"&&s!=="pytest"&&s!=="none"?null:{runner:s,file:Vt(a.file)??void 0,requires:Ol(a.requires)??void 0}}function IS(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 i;a.scope==="own"||a.scope==="installed"||a.scope==="global"?i=a.scope:i=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=i==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&of.has(a.scopeV2)?a.scopeV2:MS(a.scope),d=zS(u),f=DS(u),h=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let x;a.shadowedBy===null?x=null:typeof a.shadowedBy=="string"&&of.has(a.shadowedBy)?x=a.shadowedBy:x=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:i,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:Vt(a.symlinkTarget),installMethod:c,sourcePath:Vt(a.sourcePath),scopeV2:u,group:d,source:f,pluginName:Vt(a.pluginName),pluginNamespace:Vt(a.pluginNamespace),pluginMarketplace:Vt(a.pluginMarketplace),pluginManifestPath:Vt(a.pluginManifestPath),pluginVersion:Vt(a.pluginVersion),...typeof a.pluginDisplay=="string"&&a.pluginDisplay?{pluginDisplay:a.pluginDisplay}:{},precedenceRank:h,shadowedBy:x,description:Vt(a.description),version:Vt(a.version),category:Vt(a.category),author:Vt(a.author),license:Vt(a.license),homepage:Vt(a.homepage),repoUrl:Vt(a.repoUrl),skillPath:Vt(a.skillPath),tags:Ol(a.tags),deps:Ol(a.deps),mcpDeps:Ol(a.mcpDeps),entryPoint:Vt(a.entryPoint),lastModified:Vt(a.lastModified),sizeBytes:_S(a.sizeBytes),sourceAgent:Vt(a.sourceAgent),secrets:Ol(a.secrets),runtime:OS(a.runtime),integrationTests:BS(a.integrationTests)};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=Xv({frontmatterVersion:v.version??null,registryCurrentVersion:v.currentVersion??null,pluginVersion:v.pluginVersion??null,installedCurrentVersion:v.currentVersion??null,preferInstalled:v.origin==="installed"});return v.resolvedVersion=y.version,v.versionSource=y.versionSource,v}const ke={getConfig(){return Oe("/api/config")},setConfig(t,a){return Oe("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},revealInEditor(t,a,s){return Oe("/api/skills/reveal-in-editor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{plugin:t,skill:a,file:s}:{plugin:t,skill: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(),i=await Oe(`/api/skills${s?"?"+s:""}`);return Array.isArray(i)?i.map(IS):[]},async convertToPlugin(t){return Oe("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getAgents(){return Oe("/api/agents")},getSkillDetail(t,a){return Oe(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Oe(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:i,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Oe(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Oe(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Jn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new va(i.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const i=new URLSearchParams;s!=null&&s.model&&i.set("model",s.model),s!=null&&s.type&&i.set("type",s.type),s!=null&&s.from&&i.set("from",s.from),s!=null&&s.to&&i.set("to",s.to);const c=i.toString();return Oe(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,i){return Oe(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(i)}`)},getCaseHistory(t,a,s,i){const c=new URLSearchParams;i&&c.set("model",i);const u=c.toString();return Oe(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Oe(`/api/skills/${t}/${a}`,{method:"DELETE"})},uninstallSkill(t,a){return Oe(`/api/skills/${t}/${a}/uninstall`,{method:"POST"})},improveSkill(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Oe(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Oe(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Oe(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Oe("/api/project-layout")},getProjectGitHubStatus(){return Oe("/api/project/github-status")},createSkill(t){return Oe("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Oe("/api/studio/detect-engines")},saveDraft(t){return Oe("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Oe("/api/skill-creator-status")},generateSkill(t){return Oe("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Oe(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Oe(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,i){return Oe(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:i})})},getLeaderboard(t,a){return Oe(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const i=`${Jn}/api/skills/${t}/${a}/sweep`,c=new EventSource(i);return fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return Oe(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,i){return Oe(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:i})})},getParams(t,a){return Oe(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const i=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Oe(`/api/credentials/${t}/${a}/params?${i}`)},searchModels(){return Oe("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Oe(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,i){return Oe(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${i}`)},startBatchUpdate(t){const a=`${Jn}/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=`${Jn}/api/skills/${t}/${a}/update`,i=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),i},async postSkillUpdate(t,a,s){let i,c;if(s&&typeof s.aborted=="boolean")i=s;else if(s&&typeof s=="object"){const v=s;i=v.signal,c=v.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Jn}/api/skills/${t}/${a}/update${u}`,f=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:i});let h,x="";if(f.body){const v=f.body.getReader(),y=new TextDecoder;let b=!1,j="";for(;!b;){const C=await v.read();if(b=C.done,C.value){const w=y.decode(C.value,{stream:!b});j+=w,x.length<200&&(x+=w)}}const k=j.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(k)try{h=JSON.parse(k[1]).version}catch{}x=x.slice(0,200)}else{const v=await f.text();x=v.slice(0,200);const y=v.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{h=JSON.parse(y[1]).version}catch{}}return{ok:f.ok,status:f.status,body:x,version:h}},async rescanSkill(t,a){const s=`${t}/${a}`,i=await fetch(`${Jn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`rescan failed: HTTP ${i.status}`);return await i.json()},async getSkillUpdates(){try{const t=await fetch(`${Jn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];const a=[...t].sort(),s=ig(a,sg),i=async u=>{try{const d=await lg(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:u.map(h=>({name:h,currentVersion:"0.0.0"}))})});if(!d.ok)return[];const f=await d.json().catch(()=>null);return Array.isArray(f)?f:f&&typeof f=="object"&&Array.isArray(f.results)?f.results.map(h=>({skillId:typeof h.skillId=="string"?h.skillId:typeof h.name=="string"?h.name:"",version:typeof h.version=="string"?h.version:typeof h.latest=="string"?h.latest:"",eventId:typeof h.eventId=="string"?h.eventId:"",publishedAt:typeof h.publishedAt=="string"?h.publishedAt:"",diffSummary:typeof h.diffSummary=="string"?h.diffSummary:void 0,trackedForUpdates:typeof h.trackedForUpdates=="boolean"?h.trackedForUpdates:void 0,updateAvailable:typeof h.updateAvailable=="boolean"?h.updateAvailable:void 0,installed:typeof h.installed=="string"&&h.installed!=="0.0.0"?h.installed:void 0,latest:typeof h.latest=="string"?h.latest:void 0,name:typeof h.name=="string"?h.name:void 0})):[]}catch{return[]}};return(await Promise.all(s.map(i))).flat()},async resolveInstalledSkillIds(t){if(t.length===0)return[];const a=ig(t,sg),s=async i=>{try{const c=await lg(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:i.map(f=>({name:f.name,currentVersion:f.currentVersion??"0.0.0"}))})});if(!c.ok)return new Map;const u=await c.json().catch(()=>null),d=Array.isArray(u)?u:Array.isArray(u==null?void 0:u.results)?u.results:[];return new Map(d.map(f=>[f.name,f]))}catch{return new Map}};try{const i=await Promise.all(a.map(s)),c=new Map;for(const u of i)for(const[d,f]of u)c.set(d,f);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(c=>({plugin:c.plugin,skill:c.skill}))}},promoteSkill(t,a,s){const i=s!=null&&s.overwrite?"?overwrite=true":"";return Ad(`/api/skills/${t}/${a}/promote${i}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const i=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&i.set("dest","global"),s!=null&&s.overwrite&&i.set("overwrite","true");const c=i.toString();return Ad(`/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 Ad(`/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 Oe(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Oe(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Jn}/api/studio/ops/stream`)},gitRemote(){return Oe("/api/git/remote")},gitDiff(){return Oe("/api/git/diff",{method:"POST"})},gitStatus(){return Oe("/api/git/status")},gitCommitMessage(t){return Oe("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return Oe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function Ad(t,a,s){const i=await fetch(`${Jn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!i.ok||!i.body){let v=`HTTP ${i.status}`,y;try{const j=await i.json();j.error&&(v=j.error),typeof j.code=="string"&&(y=j.code)}catch{}const b=new va(v,i.status);throw y&&(b.code=y),b}const c=i.body.getReader(),u=new TextDecoder;let d="",f="",h=null,x=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 j of b)if(j.startsWith("event: "))f=j.slice(7).trim();else if(j.startsWith("data: ")){let k={};try{k=JSON.parse(j.slice(6))}catch{f="";continue}if(f==="started"||f==="copied"||f==="deleted"||f==="indexed"||f==="done"||f==="error"){const C={type:f,...k};a==null||a(C),C.type==="done"&&(h=C),C.type==="error"&&(x=C)}f=""}}if(x){const v=new va(x.message,500);throw v.code=x.code,v}if(!h)throw new va("Transfer stream ended without 'done' event",500);return h}function $S(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,f]=i.map(Number),[,h,x,v]=c.map(Number);return u!==h?u>h:d!==x?d>x:f>=v}function US(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.set(d,c),u.length>=1){const f=u[u.length-1];s.set(`${f}/${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=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!$S(c.version,u.latest),f=u.installed&&u.installed!=="0.0.0"?u.installed:null,h={...c,updateAvailable:d,currentVersion:f??c.currentVersion,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(h.trackedForUpdates=u.trackedForUpdates);const x=Xv({frontmatterVersion:h.version??null,registryCurrentVersion:h.currentVersion??null,pluginVersion:h.pluginVersion??null,installedCurrentVersion:h.currentVersion??null,preferInstalled:!0});return h.resolvedVersion=x.version,h.versionSource=x.versionSource,h})}const Po=new Map,Pa=new Map,Ps=new Map;function $n(t){Po.delete(t),Pa.delete(t);const a=Ps.get(t);if(a)for(const s of a)s()}function Ga(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=m.useState(0),[d,f]=m.useState(void 0),[h,x]=m.useState(0),v=m.useRef(!0),y=m.useRef(t);y.current=t;const b=()=>{f(void 0),$n(t),x(C=>C+1)};m.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),m.useEffect(()=>{if(!c)return;const C=()=>{v.current&&x(w=>w+1)};return Ps.has(t)||Ps.set(t,new Set),Ps.get(t).add(C),()=>{var w;(w=Ps.get(t))==null||w.delete(C)}},[t,c]),m.useEffect(()=>{if(!c)return;const C=Po.get(t);if(!(!C||Date.now()-C.fetchedAt>i))return;if(Pa.has(t)){const A=Pa.get(t),B=()=>{v.current&&y.current===t&&u(M=>M+1)};A.subscribers.push(B);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(A=>{Po.set(t,{data:A,fetchedAt:Date.now()}),Pa.delete(t),v.current&&y.current===t&&(f(void 0),u(B=>B+1));for(const B of N.subscribers)B()},A=>{Pa.delete(t);const B=A instanceof Error?A:new Error(String(A));v.current&&y.current===t&&(f(B),u(M=>M+1));for(const M of N.subscribers)M()});N.promise=T,Pa.set(t,N)},[t,a,i,c,h]);const j=Po.get(t),k=c&&!j&&!d&&Pa.has(t);return{data:j==null?void 0:j.data,loading:k,error:d,revalidate:b}}function HS(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const PS=500,cf="vskill.updates.seenLastId";function VS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(cf)}catch{return null}}function Ld(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(cf):window.localStorage.setItem(cf,t)}catch{}}function FS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=VS();c&&(s.add(c),i.push(c));function u(){t=new Map(t);for(const f of Array.from(a))f()}function d(f){if(!s.has(f)){if(s.add(f),i.push(f),i.length>PS){const h=i.shift();h&&s.delete(h)}c=f,Ld(f)}}return{getSnapshot(){return t},subscribe(f){return a.add(f),()=>{a.delete(f)}},ingest(f){return s.has(f.eventId)?"duplicate":(d(f.eventId),t.set(f.skillId,{skillId:f.skillId,version:f.version,diffSummary:f.diffSummary,eventId:f.eventId,publishedAt:f.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(f){t.has(f)&&(t.delete(f),u())},clearSeen(){s.clear(),i.length=0,c=null,Ld(null)},mergeBulk(f){if(f.length!==0){for(const h of f)t.set(h.skillId,h);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Ld(null),u()}}}const Ha=FS(),WS=3e5,GS=500,qS=15e3,YS=6e4,KS=6e4,XS="/api/v1/skills/stream";function og(t){const a=new Map;for(const i of t)a.set(i.name,i);const s=new Map;for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&s.set(c,(s.get(c)??0)+1)}for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&((s.get(c)??0)>1||a.has(c)||a.set(c,i))}return a}function cg(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function QS(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 ZS(t){const a=(t==null?void 0:t.intervalMs)??WS,s=(t==null?void 0:t.debounceMs)??GS,i=(t==null?void 0:t.timeoutMs)??qS,c=(t==null?void 0:t.staleAfterMs)??YS,u=(t==null?void 0:t.disconnectFallbackMs)??KS,d=(t==null?void 0:t.streamUrlBase)??XS,f=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),h=m.useMemo(()=>{const L=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return L.length===0?"":[...L].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[x,v]=m.useState([]),[y,b]=m.useState(()=>new Map),[j,k]=m.useState(0),[C,w]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),M=m.useRef(null),P=m.useRef(null),E=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[_,H]=m.useState(()=>f?"connecting":"fallback"),F=m.useRef(_);F.current=_;const q=m.useSyncExternalStore(L=>Ha.subscribe(L),()=>Ha.getSnapshot(),()=>Ha.getSnapshot()),ee=q.size,U=m.useCallback(async()=>{w(!0);const L=new AbortController,I=setTimeout(()=>L.abort(),i);try{const K=await Promise.race([ke.getSkillUpdates(),new Promise((Q,ue)=>{L.signal.addEventListener("abort",()=>{ue(new Error("TIMEOUT"))})})]);if(K==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;v(K),b(og(K)),k(cg(K)),P.current=Date.now(),T(P.current),B(null)}catch(K){if(!z.current)return;B(K instanceof Error?K:new Error(String(K)))}finally{clearTimeout(I),z.current&&w(!1)}},[i]),D=m.useCallback(()=>{if(M.current)return M.current;const L=U().finally(()=>{M.current=null});return M.current=L,L},[U]),$=m.useCallback(()=>{E.current==null&&(E.current=setInterval(()=>{D()},a))},[a,D]),W=m.useCallback(()=>{E.current!=null&&(clearInterval(E.current),E.current=null)},[]);m.useEffect(()=>{z.current=!0,(P.current==null||Date.now()-P.current>c)&&D(),(typeof document>"u"||document.visibilityState!=="hidden")&&$();const K=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){W();return}O.current=setTimeout(()=>{O.current=null,(P.current==null||Date.now()-P.current>c)&&D(),$()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",K),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",K),O.current&&clearTimeout(O.current),W()}},[]);const Y=m.useCallback(async L=>{if(L.length!==0)try{const I=await ke.checkSkillUpdates(L);if(!z.current||I.length===0)return;const K=Date.now(),Q=I.filter(J=>J.skillId&&J.eventId&&J.version).map(J=>({skillId:J.skillId,version:J.version,eventId:J.eventId,publishedAt:J.publishedAt,diffSummary:J.diffSummary,receivedAt:K}));Q.length>0&&Ha.mergeBulk(Q);const ue=I.filter(J=>typeof J.trackedForUpdates=="boolean"||typeof J.updateAvailable=="boolean").map(J=>({name:J.name??J.skillId,installed:J.installed??"",latest:J.latest??null,updateAvailable:J.updateAvailable??!1,trackedForUpdates:typeof J.trackedForUpdates=="boolean"?J.trackedForUpdates:void 0}));ue.length>0&&v(J=>{const ie=new Map;for(const je of J)ie.set(je.name,je);let Z=0;for(const je of ue){const Te=je.name,Me=ie.get(Te);if(Me){const Fe={...Me};Me.trackedForUpdates===void 0&&je.trackedForUpdates!==void 0&&(Fe.trackedForUpdates=je.trackedForUpdates),ie.set(Te,Fe)}else ie.set(Te,{name:je.name,installed:je.installed??"",latest:je.latest??null,updateAvailable:je.updateAvailable??!1,trackedForUpdates:je.trackedForUpdates}),Z+=1}if(Z===0&&ie.size===J.length)return J;const me=[...ie.values()];return b(og(me)),k(cg(me)),me})}catch{}},[]);m.useEffect(()=>{const L=f||h;if(!L){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const I=L.split(","),K=`${d}?skills=${encodeURIComponent(L)}`;let Q=null,ue=null,J=null;const ie=()=>{ue==null&&(ue=setTimeout(()=>{ue=null,z.current&&F.current!=="connected"&&H("fallback")},u))},Z=()=>{ue!=null&&(clearTimeout(ue),ue=null)};ie();const me=1e3,je=()=>{z.current&&J==null&&(J=setTimeout(()=>{if(J=null,!!z.current&&!(Q&&Q.readyState!==EventSource.CLOSED)){if(Q)try{Q.close()}catch{}Fe()}},me))},Te=Ue=>{if(!z.current)return;let De;try{De=JSON.parse(Ue.data)}catch{return}if(!QS(De)||Ha.ingest(De)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const ce=`${De.skillId} updated to ${De.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:ce,severity:"info",skillId:De.skillId,version:De.version,eventId:De.eventId}}))}},Me=()=>{z.current&&(Ha.clearSeen(),Y(I))},Fe=()=>{z.current&&(Q=new EventSource(K),Q.onopen=()=>{z.current&&(Z(),H("connected"))},Q.onerror=()=>{z.current&&(ie(),Q&&Q.readyState===EventSource.CLOSED&&je())},Q.onmessage=Te,Q.addEventListener("gone",Me))};return Fe(),()=>{if(Z(),J!=null&&(clearTimeout(J),J=null),Q){try{Q.removeEventListener("gone",Me)}catch{}try{Q.close()}catch{}}}},[f,h,d,u,Y]),m.useEffect(()=>{if(!h)return;const L=h.split(",");Y(L)},[h,Y]);const oe=m.useCallback(L=>{Ha.dismiss(L)},[]);return{updates:x,updatesMap:y,updateCount:j,isRefreshing:C,lastFetchAt:N,error:A,refresh:D,updatesById:q,pushUpdateCount:ee,status:_,dismiss:oe}}function JS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const e2={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function t2(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 Qv=m.createContext(null),Zv=Qv;function cr(){const t=m.useContext(Zv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function n2({children:t}){const[a,s]=m.useReducer(t2,e2),i=HS("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=m.useState(()=>{try{const Y=window.localStorage.getItem("vskill.studio.prefs");if(!Y)return null;const oe=JSON.parse(Y);return typeof oe.activeAgent=="string"?oe.activeAgent:null}catch{return null}}),[d,f]=m.useState(c!==null);m.useEffect(()=>{function Y(oe){if(!(oe instanceof CustomEvent))return;const L=oe.detail;L!=null&&L.agentId&&(u(L.agentId),f(!0))}return window.addEventListener("studio:agent-changed",Y),()=>window.removeEventListener("studio:agent-changed",Y)},[]),m.useEffect(()=>{if(d)return;let Y=!1;return ke.getAgents().then(oe=>{if(Y)return;const L=(oe==null?void 0:oe.suggested)??"claude-code";u(I=>I??L),f(!0)}).catch(()=>{Y||(u(oe=>oe??"claude-code"),f(!0))}),()=>{Y=!0}},[d]);const h=m.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const Y={agent:c};return ke.getSkills(Y).then(oe=>{s({type:"SET_SKILLS",skills:oe});const L=window.location.hash,I=L.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(I){const[,Q,ue,J]=I,ie=Q,Z=oe.find(je=>je.plugin===ue&&je.skill===J&&je.source===ie);if(Z){s({type:"SELECT_SKILL",skill:{plugin:ue,skill:J,origin:Z.origin,source:Z.source}});return}const me=oe.find(je=>je.plugin===ue&&je.skill===J);me&&s({type:"SELECT_SKILL",skill:{plugin:ue,skill:J,origin:me.origin,source:me.source}});return}const K=L.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,Q,ue]=K,J=oe.find(ie=>ie.plugin===Q&&ie.skill===ue);J&&s({type:"SELECT_SKILL",skill:{plugin:Q,skill:ue,origin:J.origin,source:J.source}})}}).catch(oe=>s({type:"SET_SKILLS_ERROR",error:oe.message}))},[c,d]);m.useEffect(()=>{h()},[h]);const x=m.useCallback(Y=>{s({type:"SELECT_SKILL",skill:Y}),window.location.hash=Y.source?`/skills/${Y.source}/${Y.plugin}/${Y.skill}`:`/skills/${Y.plugin}/${Y.skill}`},[]),v=m.useRef(a.skills);m.useEffect(()=>{v.current=a.skills},[a.skills]);const y=m.useCallback((Y,oe)=>{const L=v.current,I=Y?L.find(J=>J.plugin===Y&&J.skill===oe):L.find(J=>J.skill===oe&&J.source!=="plugin");if(!Y&&!I){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${oe}" not yet in state — skipping reveal`);return}const K=(I==null?void 0:I.plugin)??Y,Q=(I==null?void 0:I.origin)??"source",ue=I==null?void 0:I.source;s({type:"REVEAL_SKILL",skill:{plugin:K,skill:oe,origin:Q,source:ue}}),window.location.hash=ue?`/skills/${ue}/${K}/${oe}`:`/skills/${K}/${oe}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),j=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(Y=>{s({type:"SET_MODE",mode:Y})},[]),C=m.useCallback(Y=>{s({type:"SET_SEARCH",query:Y})},[]),w=m.useCallback(Y=>{s({type:"SET_MOBILE_VIEW",view:Y})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[M,P]=m.useState(""),E=m.useMemo(()=>a.skills.map(Y=>`${Y.plugin}/${Y.skill}`),[a.skills]),O=m.useMemo(()=>M?M.split(",").filter(Boolean):[],[M]),z=ZS({skillIds:O,trackingSkillIds:E}),_=m.useRef("");m.useEffect(()=>{const Y=a.skills.filter(Q=>Q.origin==="installed");if(Y.length===0){P(""),_.current="";return}const oe=new Map;for(const Q of z.updates)oe.set(Q.name.split("/").pop()||Q.name,Q);const L=Y.map(Q=>{const ue=oe.get(Q.skill),J=Q.currentVersion??(ue==null?void 0:ue.installed)??Q.version??Q.pluginVersion??"1.0.0";return{plugin:Q.plugin,skill:Q.skill,name:(ue==null?void 0:ue.name)??Q.skill,currentVersion:J}}),I=L.map(Q=>`${Q.plugin}/${Q.skill}@${Q.currentVersion}#${Q.name}`).sort().join("|");if(I===_.current)return;_.current=I;let K=!1;return ke.resolveInstalledSkillIds(L).then(Q=>{if(K)return;const ie=[...JS(Q).flatMap(Z=>[Z.uuid,Z.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(Q.map(Z=>[`${Z.plugin}/${Z.skill}`,{uuid:Z.uuid,slug:Z.slug}])),P(ie))}).catch(Q=>{if(K||(_.current=""),!B.current){B.current=!0;const ue=Q instanceof Error?Q.message:String(Q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",ue)}}),()=>{K=!0}},[a.skills,z.updates]);const H=m.useMemo(()=>{const Y=a.skills.map(oe=>{if(!oe.updateAvailable&&oe.latestVersion===void 0&&oe.trackedForUpdates===void 0)return oe;const L={...oe};return delete L.updateAvailable,delete L.currentVersion,delete L.latestVersion,delete L.trackedForUpdates,L});return US(Y,z.updates)},[a.skills,z.updates]),F=m.useMemo(()=>{const Y={source:0,installed:0};for(const oe of H)oe.updateAvailable&&(Y[oe.origin]+=1);return Y},[H]),q=m.useMemo(()=>({...a,skills:H}),[a,H]),ee=z.updateCount,U=z.refresh,D=z.isRefreshing,$=m.useCallback((Y,oe)=>{U(),h(),$n(`versions/${Y}/${oe}`),z.dismiss(`${Y}/${oe}`)},[U,h,z]),W=m.useMemo(()=>({state:q,selectSkill:x,clearSelection:j,setMode:k,setSearch:C,setMobileView:w,refreshSkills:h,updateCount:ee,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:F,isRefreshingUpdates:D,refreshUpdates:U,revealSkill:y,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss,activeAgent:c,onSkillUpdated:$}),[q,x,j,k,C,w,h,ee,N,z.updates,F,D,U,y,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss,c,$]);return r.jsx(Zv.Provider,{value:W,children:t})}const r2={config:null,loading:!0};function a2(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 Jv=m.createContext(null);function qa(){const t=m.useContext(Jv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function l2({children:t}){const[a,s]=m.useReducer(a2,r2),i=m.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{i()},[i]);const c=m.useCallback(async(d,f)=>{const h=await ke.setConfig(d,f);return s({type:"SET_CONFIG",config:h}),h},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Jv.Provider,{value:u,children:t})}function s2({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:f=320,sidebarHidden:h=!1}){const x={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${f}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:h?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:x,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:[!h&&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}),!h&&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:i}),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 i2={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}`},o2={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"},c2={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"},u2={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},d2={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"},f2={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"},p2={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",openingInEditor:"Opening in editor…",noEditor:"No editor found. Set $VISUAL or $EDITOR, or install code/cursor.",openFailed:"Could not open in editor.",skillNotFound:"Skill not found on disk.",uninstallNotImplemented:"Uninstall is not yet available from this menu.",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."},m2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},h2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},x2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},g2={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"},v2={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)."}},y2={subscriptionBilling:"· subscription",free:"· free"},b2={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`},j2={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.`},S2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",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}`},k2={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.`},w2={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"},C2={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."},E2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},N2={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"}},ae={sidebar:i2,shell:o2,detail:c2,actions:u2,palette:d2,shortcuts:f2,toasts:p2,connection:m2,forms:h2,errors:x2,picker:g2,providers:v2,models:y2,settings:b2,statusBar:j2,scopePicker:S2,scopeSection:k2,claudeCodeLabel:w2,setupDrawer:C2,setupProviders:N2,scopeLabels:E2},ug=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],T2={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},R2={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},A2={"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"},L2={"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 M2(t,a){var f,h;const s=T2[t.id]??null,i=R2[t.id]??null,c=s?!!((f=a==null?void 0:a.wrapperFolders)!=null&&f[s]):!1,u=i?!!((h=a==null?void 0:a.binaries)!=null&&h[i]):!0,d=t.models.map(x=>({id:x.id,displayName:x.label,billingMode:L2[t.id]??"per-token",...x.pricing?{pricing:x.pricing}:{},...x.resolvedId?{resolvedId:x.resolvedId}:{}}));return{id:t.id,displayName:z2(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:A2[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function z2(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 D2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of ug){const c=a.get(i);c&&s.push(c)}for(const i of t)ug.includes(i.id)||s.push(i);return s}function _2(t){const[a,s]=m.useState(null),[i,c]=m.useState("loading"),[u,d]=m.useState(null),[f,h]=m.useState(null),x=m.useRef(null),v=m.useRef(0),y=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.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 j=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=D2((A.providers||[]).map(M=>M2(M,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{j()},[j]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-v.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&h(`OpenRouter catalog fetch failed (${B.status})`);return}const M=await B.json();v.current=T,h(null),s(O=>{if(!O)return O;const z=O.agents.map(_=>{if(_.id!=="openrouter")return _;const H=M.models.map(q=>({id:q.id,displayName:q.name,contextWindow:q.contextWindow,pricing:q.pricing,billingMode:"per-token"}));return{..._,models:H,catalogAgeMs:M.ageSec?M.ageSec*1e3:0,cacheStale:!!M.stale}});return{...O,agents:z}});const P=M.ageSec??0;(M.stale===!0||P>600)&&((A=y.current)==null||A.call(y,"openrouter",P*1e3))}catch(B){h(`OpenRouter catalog unreachable: ${B.message}`)}},[]),C=m.useCallback(T=>{x.current=T,T==="openrouter"&&k()},[k]),w=m.useCallback(()=>{v.current=0,j()},[j]),N=m.useCallback(async(T,A)=>{var P,E;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(P=b.current)==null||P.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let M=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(M=O.error)}catch{}(E=b.current)==null||E.call(b,M)},[]);return{status:i,catalog:a,error:u,openRouterError:f,focusAgent:C,refresh:w,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function Md({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(f){if(f.stopPropagation(),t==="cli-install"&&i){window.open(i,"_blank","noopener,noreferrer");return}s()}function d(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u(f))}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 uf({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 O2=new Set(["claude-cli","claude-code"]);function dg(t){return O2.has(t)}const fg=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function B2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(h=>fg.has(h.id)),f=t.filter(h=>!fg.has(h.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(h=>r.jsx(pg,{agent:h,isActive:h.id===a,isFocused:h.id===s,onFocus:i,onSelect:c,onOpenSettings:u},h.id)),f.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),f.map(h=>r.jsx(pg,{agent:h,isActive:h.id===a,isFocused:h.id===s,onFocus:i,onSelect:c,onOpenSettings:u},h.id))]})}function pg({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=ae,f={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},h={"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}},x=dg(t.id),v={minHeight:36,height:x?"auto":36,padding:x?"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:()=>i(t.id),onFocus:()=>i(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}),dg(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ae.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ae.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(uf,{unlocked:!0,size:10}):r.jsx(uf,{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:ae.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Md,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&h[t.id]&&r.jsx(Md,{variant:"cli-install",label:h[t.id].label,installUrl:h[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Md,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),f[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:f[t.id]})]})}function I2(t,a,s,i){const d=t>=80,f=m.useRef(null),[h,x]=m.useState(0),v=m.useCallback(j=>{x(j.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const j=Math.max(0,Math.floor(h/a)-4),k=Math.ceil(s/a)+8,C=Math.min(t,j+k);return{visibleStart:j,visibleEnd:C}},[d,h,a,s,t,4]);return{visibleStart:y,visibleEnd:b,totalHeight:t*a,offsetTop:y*a,virtualised:d,containerProps:{onScroll:v,ref:f,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const ey=44,$2=352,U2=60,mg=480;function H2(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 ${ae.models.subscriptionBilling}`:ae.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,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function P2(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),f=u.displayName.toLowerCase().indexOf(s);return d!==f?d-f:c.displayName.length-u.displayName.length})}function V2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=m.useState(""),[f,h]=m.useState(""),x=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>h(u),U2);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&x.current&&x.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:mg,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:ae.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:ae.providers.openrouter.addKeyCta})]});const v=m.useMemo(()=>P2(t.models,f),[t.models,f]),y=I2(v.length,ey,$2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:mg,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:x,type:"text",placeholder:ae.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ae.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&&f?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:ae.picker.noMatches(f)}),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:ae.picker.clearSearch})]}):v.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ae.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,j)=>{const k=y.visibleStart+j;return r.jsx(W2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function F2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function W2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=H2(t),d=F2(t.id,c,t.resolvedId),f=d!==null,h=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",x=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:i,title:t.id,style:{width:"100%",minHeight:ey,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:h,borderLeft:x,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}),f&&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 hg={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function G2(){const[t,a]=m.useState(null),[s,i]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{i(!0);try{const x=await fetch("/api/settings/keys");if(!x.ok)throw new Error(`GET /api/settings/keys returned ${x.status}`);const v=await x.json();a({...hg,...v}),u(null)}catch(x){u(x.message),a(hg)}finally{i(!1)}},[]);m.useEffect(()=>{d()},[d]);const f=m.useCallback(async(x,v)=>{const y=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x,key:v})});if(!y.ok){const j=await y.json().catch(()=>({error:y.statusText}));throw new Error(j.error||`POST /api/settings/keys returned ${y.status}`)}const b=await y.json();return await d(),b},[d]),h=m.useCallback(async x=>{const v=await fetch(`/api/settings/keys/${x}`,{method:"DELETE"});if(!v.ok)throw new Error(`DELETE /api/settings/keys/${x} returned ${v.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:f,remove:h,refresh:d}}function q2({onMigrated:t,fetchImpl:a}){const[s,i]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var x;try{const v=await c("/api/settings/migration-status");if(!v.ok){i({kind:"hidden"});return}const y=await v.json();y.pending&&(((x=y.darwinKeys)==null?void 0:x.length)??0)>0?i({kind:"visible",darwinKeys:y.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{i({kind:"working"});try{const x=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!x.ok){i({kind:"error",message:`Migration failed (${x.status})`});return}const v=await x.json().catch(()=>({migrated:[]}));t==null||t(v.migrated??[]),await u()}catch(x){i({kind:"error",message:x.message})}},[c,u,t]),f=m.useCallback(async()=>{i({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:zd,children:"Retry"})]});const h=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:h,"data-testid":"migration-migrate",style:{...zd,background:"var(--accent, var(--color-accent))",color:"white",opacity:h?.6:1},children:h?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void f(),"data-testid":"migration-dismiss",style:{...zd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const zd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Y2=[{id:"anthropic",name:ae.providers.anthropic.name,keyIssuanceUrl:ae.providers.anthropic.keyIssuanceUrl,prefix:ae.providers.anthropic.keyPrefix,placeholder:`Paste ${ae.providers.anthropic.name} key`},{id:"openai",name:ae.providers.openai.name,keyIssuanceUrl:ae.providers.openai.keyIssuanceUrl,prefix:ae.providers.openai.keyPrefix,placeholder:ae.providers.openai.pastePlaceholder},{id:"openrouter",name:ae.providers.openrouter.name,keyIssuanceUrl:ae.providers.openrouter.keyIssuanceUrl,prefix:ae.providers.openrouter.keyPrefix,placeholder:`Paste ${ae.providers.openrouter.name} key`}];function K2(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 ty({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:f}=G2(),h=m.useRef(null),x=m.useRef(null),[v,y]=m.useState(null);m.useEffect(()=>{if(!t)return;let j=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const C=await k.json();j||y(C.path??null)}catch{j||y(null)}})(),()=>{j=!0}},[t]),m.useEffect(()=>{if(!t)return;const j=document.activeElement,k=setTimeout(()=>{var N;const C=s?`input[data-provider="${s}"]`:"input[data-provider]",w=(N=h.current)==null?void 0:N.querySelector(C);w==null||w.focus()},0);return()=>{var C;clearTimeout(k),(C=j==null?void 0:j.focus)==null||C.call(j)}},[t,s]),m.useEffect(()=>{if(!t)return;const j=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&h.current){const C=h.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(C.length===0)return;const w=C[0],N=C[C.length-1];k.shiftKey&&document.activeElement===w?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),w.focus())}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,a]);const b=m.useCallback(async()=>{var j,k;if(v)try{await((k=(j=navigator.clipboard)==null?void 0:j.writeText)==null?void 0:k.call(j,v)),i==null||i(ae.settings.pathCopied)}catch{}},[i,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:j=>{j.target===j.currentTarget&&a()},children:r.jsxs("div",{ref:h,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:j=>j.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ae.settings.title}),r.jsx(q2,{onMigrated:()=>{f()}}),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:ae.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:ae.settings.sectionApiKeys}),Y2.map(j=>r.jsx(X2,{providerId:j.id,providerName:j.name,keyIssuanceUrl:j.keyIssuanceUrl,prefix:j.prefix,placeholder:j.placeholder,metadata:c==null?void 0:c[j.id],onSave:async k=>{const C=await u(j.id,k);return i==null||i(ae.settings.keySaved(j.name)),C},onRemove:async()=>{await d(j.id),i==null||i(ae.settings.keyRemoved(j.name))},inputRef:j.id===(s??"anthropic")?x:void 0},j.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?ae.settings.storagePath(v):ae.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Va,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:ae.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 X2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:f,inputRef:h}){const[x,v]=m.useState(""),[y,b]=m.useState(!1),[j,k]=m.useState(!1),[C,w]=m.useState(!1),[N,T]=m.useState(null),A=x.trim(),B=A.length===0,M=A.length>0&&!A.startsWith(i),P=m.useCallback(async()=>{if(B)return;k(!0);const z=A;v("");try{const _=await d(z);_.warning?T(_.warning):T(null)}finally{k(!1)}},[B,d,A]),E=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const _=await navigator.clipboard.readText();v(_)}catch{}},[]),O=m.useCallback(async()=>{w(!1),await f()},[f]);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:h,type:y?"text":"password",value:x,onChange:z=>{v(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!y),style:Va,children:y?ae.settings.hide:ae.settings.show}),r.jsx("button",{type:"button",onClick:E,style:Va,children:ae.settings.paste})]}),M&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:xg,children:ae.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:xg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:P,disabled:B||j,"data-testid":`save-${t}`,style:{...Va,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ae.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:C?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ae.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Va,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>w(!1),style:Va,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>w(!0),"data-testid":`remove-${t}`,style:{...Va,color:"var(--text-muted)"},children:ae.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?ae.settings.keyStoredAt(K2(u.updatedAt)):ae.settings.noKey})]})]})}const Va={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},xg={fontSize:11,color:"var(--warning, var(--text-muted))"};function Q2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Z2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=_2({onStaleCatalog:(_,H)=>{const F=Math.round(H/6e4);t==null||t(`Using cached ${_} catalog (${F} min old)`)},onSetActiveError:_=>t==null?void 0:t(_)}),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[x,v]=m.useState(),[y,b]=m.useState(null),[j,k]=m.useState("agents"),[C,w]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var _;s&&!y&&b(s.activeAgent??((_=s.agents[0])==null?void 0:_.id)??null)},[s,y]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(_=>_.id===y)??T[0],[T,y]);m.useEffect(()=>{w(0)},[y]);const B=m.useCallback(()=>{var _;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((_=T[0])==null?void 0:_.id)??null),w(0)},[s,T]),M=m.useCallback(()=>{var _;d(!1),(_=N.current)==null||_.focus()},[]);m.useEffect(()=>{const _=H=>{var q;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const F=(q=document.activeElement)==null?void 0:q.tagName;F==="INPUT"||F==="TEXTAREA"||(H.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),m.useEffect(()=>{if(!u)return;const _=F=>{if(F.key==="Escape"){F.preventDefault(),M();return}if(F.key==="ArrowDown"){F.preventDefault(),H(1);return}if(F.key==="ArrowUp"){F.preventDefault(),H(-1);return}if(F.key==="ArrowRight"&&j==="agents"){F.preventDefault(),k("models"),w(q=>{const ee=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(q,Math.max(0,ee)))});return}if(F.key==="ArrowLeft"&&j==="models"){F.preventDefault(),k("agents");return}if(F.key==="Enter"){if(F.preventDefault(),j==="agents"&&A)k("models"),w(0);else if(j==="models"&&A){const q=Math.max(0,Math.min(A.models.length-1,C)),ee=A.models[q];ee&&(c(A.id,ee.id),M())}return}};function H(F){if(j==="agents"){const q=T.findIndex(U=>U.id===y),ee=T[Math.max(0,Math.min(T.length-1,q+F))];ee&&(b(ee.id),i(ee.id));return}if(j==="models"&&A){const q=A.models.length;if(q===0)return;w(ee=>{const U=ee+F;return Math.max(0,Math.min(q-1,U))})}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u,j,T,y,A,C,M,i,c]);const P=m.useCallback(_=>{v(_==="anthropic"||_==="openrouter"?_:void 0),h(!0),d(!1)},[]),E=T.find(_=>_.id===(s==null?void 0:s.activeAgent)),O=E==null?void 0:E.models.find(_=>_.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const _=(E==null?void 0:E.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${_} · ${H}`},[a,s,E,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?M():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[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:z})]}),u&&typeof document<"u"&&ac.createPortal(r.jsxs(J2,{reducedMotion:Q2(),onClickOutside:M,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(B2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:_=>{b(_),i(_)},onSelect:_=>{b(_),i(_),k("models")},onOpenSettings:P}),A&&r.jsx(V2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:j==="models"?C:-1,onSelect:_=>{c(A.id,_),M()},onOpenSettings:P})]}),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:()=>P(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ae.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ae.picker.footerHint})]})]}),document.body),r.jsx(ty,{open:f,onClose:()=>h(!1),initialProvider:x,onToast:t})]})}function J2({children:t,reducedMotion:a,onClickOutside:s}){const i=m.useRef(null);return m.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"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
|
+
}`})]})}const ek="/assets/skill-studio-logo-CRyKgIrg.png";function gg(){typeof window>"u"||(window.location.hash="#/")}function tk({onHome:t}){const[a,s]=m.useState(!1),[i,c]=m.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),gg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),gg(),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:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("img",{src:ek,alt:"","aria-hidden":"true",width:28,height:28,style:{display:"block",objectFit:"contain",flexShrink:0}}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const vg=m.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(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 nk({toast:t,onDismiss:a}){const[s,i]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!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 rk({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(vg,{politeness:"polite",message:s}),r.jsx(vg,{politeness:"assertive",message:i}),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(nk,{toast:c,onDismiss:a})},c.id))})]})}const ny=m.createContext(null);function lc(){const t=m.useContext(ny);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function ak({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=m.useState([]),[u,d]=m.useState(""),[f,h]=m.useState(""),x=m.useRef(new Map),v=m.useCallback(w=>{const N=x.current.get(w);N&&(clearTimeout(N),x.current.delete(w)),c(T=>T.filter(A=>A.id!==w))},[]),y=m.useCallback((w,N)=>{if(N<=0)return;const T=setTimeout(()=>{v(w)},N);x.current.set(w,T)},[v]),b=m.useCallback(w=>{const N=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(A=>[...A,T]),T.severity==="error"?h(T.message):d(T.message),y(N,T.durationMs),N},[s,y]),j=m.useCallback(()=>{for(const w of x.current.values())clearTimeout(w);x.current.clear(),c([])},[]);m.useEffect(()=>{function w(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],M=x.current.get(B.id);return M&&(clearTimeout(M),x.current.delete(B.id)),T.filter(P=>P.id!==B.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]),m.useEffect(()=>()=>{for(const w of x.current.values())clearTimeout(w);x.current.clear()},[]);const k=i.slice(0,a),C=m.useMemo(()=>({toast:b,dismiss:v,clear:j}),[b,v,j]);return r.jsxs(ny.Provider,{value:C,children:[t,r.jsx(rk,{toasts:k,onDismiss:v,liveMessage:u,liveAssertiveMessage:f})]})}function lk(){const{data:t,loading:a}=Ga("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const sk=m.lazy(()=>Fl(()=>import("./UpdateDropdown-Celf0_Cr.js"),__vite__mapDeps([0,1])));function ik(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:h}=cr(),{toast:x}=lc(),{data:v}=lk(),y=(v==null?void 0:v.degraded)===!0,b=m.useMemo(()=>{if(!f||f.size===0)return;const P=new Map;for(const[E,O]of f)O.diffSummary&&P.set(E,O.diffSummary);return P.size>0?P:void 0},[f]),[j,k]=m.useState(!1),C=m.useRef(null),w=m.useCallback(()=>k(!1),[]),N=y?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),A=t===0?"No updates available":`${t} updates available, open summary`,B=y?`${A} — platform crawler degraded`:A,M=y?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:C,type:"button","data-testid":"update-bell","aria-label":B,"aria-haspopup":"dialog","aria-expanded":j,title:M,onClick:()=>k(P=>!P),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:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||y?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),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:T})]}),j&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(sk,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:P=>{const E=P.localSkill??P.name.split("/").pop()??"",O=P.localPlugin??"";if(u)u(O,E);else{const _=P.name.split("/"),H=_.length>=2?_[_.length-2]:_[0];c({plugin:H,skill:E,origin:"installed"})}if(!(d??[]).some(_=>_.skill===E&&(O===""||_.plugin===O))){const _=P.installLocations??[];if(_.length>0){const H=h?_.filter(q=>q.agent===h):[],F=h?_.filter(q=>q.agent!==h):_;if(H.length>0&&F.length>0){const q=F.length>=2?`Also installed under ${F.length} other locations.`:`Also installed under ${F[0].agentLabel}.`;x({severity:"info",message:q})}else{const q=_[0].agentLabel;x({severity:"info",message:`Skill installed under ${q} — switch to ${q} to view details.`})}}}w()},onViewAll:()=>{window.location.hash="#/updates",w()},onClose:w,anchorRef:C})})]})}function yg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function ok(t){return t.source==="project"?ae.scopeLabels.sourceProject:t.source==="personal"?ae.scopeLabels.sourcePersonal:t.source==="plugin"?ae.scopeLabels.sourcePlugin:t.origin==="installed"?ae.scopeLabels.sourcePersonal:ae.scopeLabels.sourceProject}function ck(t){return t.source==="project"?"var(--status-installed)":t.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function uk({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?ok(a):null,f=a?ck(a):"var(--text-secondary)";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(tk,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):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&&d&&r.jsxs(r.Fragment,{children:[r.jsx(bg,{segment:"origin",onClick:()=>yg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:f},children:d}),r.jsx(jg,{}),r.jsx(bg,{segment:"plugin",onClick:()=>yg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(jg,{}),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:12,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"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",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(Z2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(ik,{})})]})]})]})}function bg({segment:t,onClick:a,style:s,children:i}){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:i})}function jg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const sc="vskill-theme";function ry(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function dk(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function fk(t){try{const a=t.getItem(sc);return ry(a)}catch{return"auto"}}function pk(t,a){try{t.setItem(sc,a)}catch{}}function mk(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function hk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ay=m.createContext(null);function xk({storage:t,matchMedia:a,target:s,children:i}){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),[f,h]=m.useState(()=>c?fk(c):"auto"),[x,v]=m.useState(()=>hk(u)),y=m.useMemo(()=>dk(f,x),[f,x]);m.useEffect(()=>{d&&mk(d,f,y)},[d,f,y]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),C=N=>v(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const w=k;return w.addListener(C),()=>w.removeListener(C)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=C=>{C.key===sc&&h(ry(C.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const C=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};C(k.matches);const w=T=>C(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",w),()=>k.removeEventListener("change",w);const N=k;return N.addListener(w),()=>N.removeListener(w)},[u,d]);const b=m.useCallback(k=>{h(k),c&&pk(c,k)},[c]),j=m.useMemo(()=>({mode:f,resolvedTheme:y,setTheme:b}),[f,y,b]);return r.jsx(ay.Provider,{value:j,children:i})}function ly(){const t=m.useContext(ay);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const Sg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function gk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of Sg){const c=a.get(i);c&&s.push(c)}for(const i of t)Sg.includes(i.id)||s.push(i);return s}function vk(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function yk({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=gk(t),c=vk(640),[u,d]=m.useState(!1),f=m.useCallback(h=>{h.available||h.kind==="api-key"?a==null||a(h.id):s==null||s(h.id)},[a,s]);if(c){const h=i.filter(x=>x.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":ae.statusBar.providerSummary(h,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ae.statusBar.providerSummary(h,i.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:i.map(x=>r.jsx(kg,{p:x,onClick:f},x.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(h=>r.jsx(kg,{p:h,onClick:f,compact:!0},h.id))})}function kg({p:t,onClick:a,compact:s}){const i=t.available?ae.statusBar.unlocked(t.label):t.kind==="cli-install"?ae.statusBar.lockedCli(t.label):ae.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,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(uf,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function bk(){try{return typeof localStorage>"u"?null:localStorage.getItem(sc)}catch{return null}}function jk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:h,setTheme:x}=ly(),y=bk()==="auto",b=Sk(f,h,y),j=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(wg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(kk,{color:j}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(wg,{}),r.jsx(yk,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>x(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${f} — 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(wk,{mode:f}),r.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function Sk(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function kk({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function wg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function wk({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 df=new Set;function sy(){for(const t of df)t()}const Ck=5,Ek=1e3,Nk=6e4;function Tk(){const[t,a]=m.useState(void 0),[s,i]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),f=m.useRef(null),h=m.useRef(null),x=m.useRef(!0),v=m.useRef(0),[y,b]=m.useState(0),j=()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},k=m.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),C=m.useCallback(async()=>{if(!x.current||document.visibilityState==="hidden")return;k();const N=new AbortController;f.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!x.current)return;const A=await T.json();if(!x.current)return;d.current=0,a(A.plugins??[]),u(!1),i(!1),h.current=setTimeout(()=>{x.current&&b(B=>B+1)},Nk)}catch(T){if(!x.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>Ck){i(!0);return}const A=Ek*Math.pow(2,d.current-1);h.current=setTimeout(()=>{x.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(x.current=!0,()=>{x.current=!1,j(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(j(),C())},[y,C]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(j(),k()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const w=m.useCallback(()=>{d.current=0,i(!1),j(),v.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(df.add(w),()=>{df.delete(w)}),[w]),{plugins:t,paused:s,loading:c,retry:w}}const ic=0,ja=1,Wl=2,iy=4;function Cg(t){return()=>t}function Rk(t){t()}function oy(t,a){return s=>t(a(s))}function Eg(t,a){return()=>t(a)}function Ak(t,a){return s=>t(a,s)}function _f(t){return t!==void 0}function Lk(...t){return()=>{t.map(Rk)}}function Gl(){}function oc(t,a){return a(t),t}function Mk(t,a){return a(t)}function At(...t){return t}function pt(t,a){return t(ja,a)}function Ke(t,a){t(ic,a)}function Of(t){t(Wl)}function _t(t){return t(iy)}function Le(t,a){return pt(t,Ak(a,ic))}function sr(t,a){const s=t(ja,i=>{s(),a(i)});return s}function Ng(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function cy(t,a){return t===a}function Rt(t=cy){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function $e(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>oy(a,t)}function xr(t){return a=>()=>{a(t)}}function he(t,...a){const s=zk(...a);return((i,c)=>{switch(i){case Wl:Of(t);return;case ja:return pt(t,s(c))}})}function vr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function Ur(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Qe(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,h=>{const x=s;s|=f,a[d]=h,x!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const f=()=>{u([d].concat(a))};s===c?f():i=f}}function zk(...t){return a=>t.reduceRight(Mk,a)}function Dk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ja:return u?s===u?void 0:(i(),s=u,a=pt(t,u),a):(i(),Gl);case Wl:i(),s=null;return}}}function ge(t){let a=t;const s=it();return((i,c)=>{switch(i){case ic:a=c;break;case ja:{c(a);break}case iy:return a}return s(i,c)})}function pn(t,a){return oc(ge(a),s=>Le(t,s))}function it(){const t=[];return((a,s)=>{switch(a){case ic:t.slice().forEach(i=>{i(s)});return;case Wl:t.splice(0,t.length);return;case ja:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function Un(t){return oc(it(),a=>Le(t,a))}function ut(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:_k(),singleton:s}}const _k=()=>Symbol();function Ok(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const f=i(c.map(h=>s(h)));return d&&a.set(u,f),f};return s(t)}function Yt(...t){const a=it(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,h=>{s[d]=h,i|=f,i===c&&Ke(a,s)})}),function(u,d){switch(u){case Wl:{Of(a);return}case ja:return i===c&&d(s),pt(a,d)}}}function Ie(t,a=cy){return he(t,Rt(a))}function ff(...t){return function(a,s){switch(a){case Wl:return;case ja:return Lk(...t.map(i=>pt(i,s)))}}}const Jt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Bk={[Jt.DEBUG]:"debug",[Jt.ERROR]:"error",[Jt.INFO]:"log",[Jt.WARN]:"warn"},Ik=()=>typeof globalThis>"u"?window:globalThis,Sa=ut(()=>{const t=ge(Jt.ERROR);return{log:ge((a,s,i=Jt.INFO)=>{const c=Ik().VIRTUOSO_LOG_LEVEL??_t(t);i>=c&&console[Bk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ya(t,a,s){return Bf(t,a,s).callbackRef}function Bf(t,a,s){const i=Ae.useRef(null);let c=d=>{};const u=Ae.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const f=()=>{const h=d[0].target;h.offsetParent!==null&&t(h)};s?f():requestAnimationFrame(f)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function $k(t,a,s,i,c,u,d,f,h){const x=Ae.useCallback(v=>{const y=Uk(v.children,a,f?"offsetWidth":"offsetHeight",c);let b=v.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const j=b.lastElementChild.dataset.viewportType==="window";let k;j&&(k=b.ownerDocument.defaultView);const C=d?f?d.scrollLeft:d.scrollTop:j?f?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:f?b.scrollLeft:b.scrollTop,w=d?f?d.scrollWidth:d.scrollHeight:j?f?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,N=d?f?d.offsetWidth:d.offsetHeight:j?f?k.innerWidth:k.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:w,scrollTop:Math.max(C,0),viewportHeight:N}),u==null||u(f?Tg("column-gap",getComputedStyle(v).columnGap,c):Tg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,i,f]);return Bf(x,s,h)}function Uk(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const f=t.item(d);if(f.dataset.index===void 0)continue;const h=parseInt(f.dataset.index),x=parseFloat(f.dataset.knownSize),v=a(f,s);if(v===0&&i("Zero-sized element, this should not happen",{child:f},Jt.ERROR),v===x)continue;const y=u[u.length-1];u.length===0||y.size!==v||y.endIndex!==h-1?u.push({endIndex:h,size:v,startIndex:h}):u[u.length-1].endIndex++}return u}function Tg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Jt.WARN),a==="normal"?0:parseInt(a??"0",10)}function uy(t,a,s){const i=Ae.useRef(null),c=Ae.useCallback(h=>{if(!(h!=null&&h.offsetParent))return;const x=h.getBoundingClientRect(),v=x.width;let y,b;if(a){const j=a.getBoundingClientRect(),k=x.top-j.top;b=j.height-Math.max(0,k),y=k+a.scrollTop}else{const j=d.current.ownerDocument.defaultView;b=j.innerHeight-Math.max(0,x.top),y=x.top+j.scrollY}i.current={listHeight:x.height,offsetTop:y,visibleHeight:b,visibleWidth:v},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Bf(c,!0,s),f=Ae.useCallback(()=>{c(d.current)},[c,d]);return Ae.useEffect(()=>{var x;if(a){a.addEventListener("scroll",f);const v=new ResizeObserver(()=>{requestAnimationFrame(f)});return v.observe(a),()=>{a.removeEventListener("scroll",f),v.unobserve(a)}}const h=(x=d.current)==null?void 0:x.ownerDocument.defaultView;return h==null||h.addEventListener("scroll",f),h==null||h.addEventListener("resize",f),()=>{h==null||h.removeEventListener("scroll",f),h==null||h.removeEventListener("resize",f)}},[f,a,d]),u}const yn=ut(()=>{const t=it(),a=it(),s=ge(0),i=it(),c=ge(0),u=it(),d=it(),f=ge(0),h=ge(0),x=ge(0),v=ge(0),y=it(),b=it(),j=ge(!1),k=ge(!1),C=ge(!1);return Le(he(t,we(({scrollTop:w})=>w)),a),Le(he(t,we(({scrollHeight:w})=>w)),d),Le(a,c),{deviation:s,fixedFooterHeight:x,fixedHeaderHeight:h,footerHeight:v,headerHeight:f,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:j,scrollTo:y,scrollTop:a,skipAnimationFrameInResizeObserver:C,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Zs={lvl:0};function dy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:f,value:h}=a(t[d]);u.push({end:f-1,start:i,value:c}),i=f,c=h}return u.push({end:1/0,start:i,value:c}),u}function yt(t){return t===Zs}function Js(t,a){if(!yt(t))return a===t.k?t.v:a<t.k?Js(t.l,a):Js(t.r,a)}function or(t,a,s="k"){if(yt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function In(t,a,s){return yt(t)?my(a,s,1):a===t.k?Zt(t,{k:a,v:s}):a<t.k?Rg(Zt(t,{l:In(t.l,a,s)})):Rg(Zt(t,{r:In(t.r,a,s)}))}function Bl(){return Zs}function Il(t,a,s){if(yt(t))return[];const i=or(t,a)[0];return Hk(mf(t,i,s))}function pf(t,a){if(yt(t))return Zs;const{k:s,l:i,r:c}=t;if(a===s){if(yt(i))return c;if(yt(c))return i;const[u,d]=py(i);return Vo(Zt(t,{k:u,l:fy(i),v:d}))}return a<s?Vo(Zt(t,{l:pf(i,a)})):Vo(Zt(t,{r:pf(c,a)}))}function Fa(t){return yt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function mf(t,a,s){if(yt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(mf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(mf(u,a,s))),f}function Vo(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(Dd(a))return hy(Zt(t,{lvl:s-1}));if(!yt(a)&&!yt(a.r))return Zt(a.r,{l:Zt(a,{r:a.r.l}),lvl:s,r:Zt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Dd(t))return hf(Zt(t,{lvl:s-1}));if(!yt(i)&&!yt(i.l)){const c=i.l,u=Dd(c)?i.lvl-1:i.lvl;return Zt(c,{l:Zt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:hf(Zt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Zt(t,a){return my(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 fy(t){return yt(t.r)?t.l:Vo(Zt(t,{r:fy(t.r)}))}function Dd(t){return yt(t)||t.lvl>t.r.lvl}function py(t){return yt(t.r)?[t.k,t.v]:py(t.r)}function my(t,a,s,i=Zs,c=Zs){return{k:t,l:i,lvl:s,r:c,v:a}}function Rg(t){return hf(hy(t))}function hy(t){const{l:a}=t;return!yt(a)&&a.lvl===t.lvl?Zt(a,{r:Zt(t,{l:a.r})}):t}function hf(t){const{lvl:a,r:s}=t;return!yt(s)&&!yt(s.r)&&s.lvl===a&&s.r.lvl===a?Zt(s,{l:Zt(t,{r:s.l}),lvl:a+1}):t}function Hk(t){return dy(t,({k:a,v:s})=>({index:a,value:s}))}function xy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function ei(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const If=ut(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function gy(t,a,s){return t[Yo(t,a,s)]}function Yo(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],f=s(d,a);if(f===0)return u;if(f===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Pk(t,a,s,i){const c=Yo(t,a,i),u=Yo(t,s,i,c);return t.slice(c,u+1)}function ya(t,a){return Math.round(t.getBoundingClientRect()[a])}function cc(t){return!yt(t.groupOffsetTree)}function $f({index:t},a){return a===t?0:a<t?-1:1}function Vk(){return{groupIndices:[],groupOffsetTree:Bl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Bl()}}function Fk(t,a){let s=yt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),yt(t)){t=In(t,0,u);continue}const f=Il(t,d-1,c+1);if(f.some(Qk(i)))continue;let h=!1,x=!1;for(const{end:v,start:y,value:b}of f)h?(c>=y||u===b)&&(t=pf(t,y)):(x=b!==u,h=!0),v>c&&c>=y&&b!==u&&(t=In(t,c+1,b));x&&(t=In(t,d,u))}return[t,s]}function Wk(t){return typeof t.groupIndex<"u"}function Gk({offset:t},a){return a===t?0:a<t?-1:1}function ti(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=gy(a,t,$f),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function vy(t,a){if(!cc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function yy(t,a,s){if(Wk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=vy(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function qk(t,a,s,i=0){return i>0&&(a=Math.max(a,gy(t,i,$f).offset)),dy(Pk(t,a,s,Gk),Xk)}function Yk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Jt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&yt(u)&&a.length===2){const b=a[0].size,j=a[1].size;d=s.reduce((k,C)=>In(In(k,C,b),C+1,j),d)}else[d,f]=Fk(d,a);if(d===u)return t;const{lastIndex:h,lastOffset:x,lastSize:v,offsetTree:y}=xf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,j)=>In(b,j,ti(j,y,c)),Bl()),lastIndex:h,lastOffset:x,lastSize:v,offsetTree:y,sizeTree:d}}function Kk(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Ag(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function xf(t,a,s,i){let c=t,u=0,d=0,f=0,h=0;if(a!==0){h=Yo(c,a-1,$f),f=c[h].offset;const x=or(s,a-1);u=x[0],d=x[1],c.length&&c[h].size===or(s,a)[1]&&(h-=1),c=c.slice(0,h+1)}else c=[];for(const{start:x,value:v}of Il(s,a,1/0)){const y=x-u,b=y*d+f+y*i;c.push({index:x,offset:b,size:v}),u=x,f=b,d=v}return{lastIndex:u,lastOffset:f,lastSize:d,offsetTree:c}}function Xk(t){return{index:t.index,value:t}}function Qk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Zk={offsetHeight:"height",offsetWidth:"width"},jr=ut(([{log:t},{recalcInProgress:a}])=>{const s=it(),i=it(),c=pn(i,0),u=it(),d=it(),f=ge(0),h=ge([]),x=ge(void 0),v=ge(void 0),y=ge(void 0),b=ge(void 0),j=ge((E,O)=>ya(E,Zk[O])),k=ge(void 0),C=ge(0),w=Vk(),N=pn(he(s,Qe(h,t,C),vr(Yk,w),Rt()),w),T=pn(he(h,Rt(),vr((E,O)=>({current:O,prev:E.current}),{current:[],prev:[]}),we(({prev:E})=>E)),[]);Le(he(h,$e(E=>E.length>0),Qe(N,C),we(([E,O,z])=>{const _=E.reduce((H,F,q)=>In(H,F,ti(F,O.offsetTree,z)||q),Bl());return{...O,groupIndices:E,groupOffsetTree:_}})),N),Le(he(i,Qe(N),$e(([E,{lastIndex:O}])=>E<O),we(([E,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:E}])),s),Le(x,v);const A=pn(he(x,we(E=>E===void 0)),!0);Le(he(v,$e(E=>E!==void 0&&yt(_t(N).sizeTree)),we(E=>{const O=_t(y),z=_t(h).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:E,startIndex:1}]:[]:[{endIndex:0,size:E,startIndex:0}]})),s),Le(he(b,$e(E=>E!==void 0&&E.length>0&&yt(_t(N).sizeTree)),we(E=>{const O=[];let z=E[0],_=0;for(let H=1;H<E.length;H++){const F=E[H];F!==z&&(O.push({endIndex:H-1,size:z,startIndex:_}),z=F,_=H)}return O.push({endIndex:E.length-1,size:z,startIndex:_}),O})),s),Le(he(h,Qe(y,v),$e(([,E,O])=>E!==void 0&&O!==void 0),we(([E,O,z])=>{const _=[];for(let H=0;H<E.length;H++){const F=E[H],q=E[H+1];_.push({startIndex:F,endIndex:F,size:O}),q!==void 0&&_.push({startIndex:F+1,endIndex:q-1,size:z})}return _})),s);const B=Un(he(s,Qe(N),vr(({sizes:E},[O,z])=>({changed:z!==E,sizes:z}),{changed:!1,sizes:w}),we(E=>E.changed)));pt(he(f,vr((E,O)=>({diff:E.prev-O,prev:O}),{diff:0,prev:0}),we(E=>E.diff)),E=>{const{groupIndices:O}=_t(N);if(E>0)Ke(a,!0),Ke(u,E+Ag(E,O));else if(E<0){const z=_t(T);z.length>0&&(E-=Ag(-E,z)),Ke(d,E)}}),pt(he(f,Qe(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:f},Jt.ERROR)});const M=Un(u);Le(he(u,Qe(N),we(([E,O])=>{const z=O.groupIndices.length>0,_=[],H=O.lastSize;if(z){const F=Js(O.sizeTree,0);let q=0,ee=0;for(;q<E;){const D=O.groupIndices[ee],$=O.groupIndices.length===ee+1?1/0:O.groupIndices[ee+1]-D-1;_.push({endIndex:D,size:F,startIndex:D}),_.push({endIndex:D+1+$-1,size:H,startIndex:D+1}),ee++,q+=$+1}const U=Fa(O.sizeTree);return q!==E&&U.shift(),U.reduce((D,{k:$,v:W})=>{let Y=D.ranges;return D.prevSize!==0&&(Y=[...D.ranges,{endIndex:$+E-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:$+E,prevSize:W,ranges:Y}},{prevIndex:E,prevSize:0,ranges:_}).ranges}return Fa(O.sizeTree).reduce((F,{k:q,v:ee})=>({prevIndex:q+E,prevSize:ee,ranges:[...F.ranges,{endIndex:q+E-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const P=Un(he(d,Qe(N,C),we(([E,{offsetTree:O},z])=>{const _=-E;return ti(_,O,z)})));return Le(he(d,Qe(N,C),we(([E,O,z])=>{if(O.groupIndices.length>0){if(yt(O.sizeTree))return O;let H=Bl();const F=_t(T);let q=0,ee=0,U=0;for(;q<-E;){U=F[ee];const D=F[ee+1]-U-1;ee++,q+=D+1}if(H=Fa(O.sizeTree).reduce((D,{k:$,v:W})=>In(D,Math.max(0,$+E),W),H),q!==-E){const D=Js(O.sizeTree,U);H=In(H,0,D);const $=or(O.sizeTree,-E+1)[1];H=In(H,1,$)}return{...O,sizeTree:H,...xf(O.offsetTree,0,H,z)}}const _=Fa(O.sizeTree).reduce((H,{k:F,v:q})=>In(H,Math.max(0,F+E),q),Bl());return{...O,sizeTree:_,...xf(O.offsetTree,0,_,z)}})),N),{beforeUnshiftWith:M,data:k,defaultItemSize:v,firstItemIndex:f,fixedItemSize:x,fixedGroupSize:y,gap:C,groupIndices:h,heightEstimates:b,itemSize:j,listRefresh:B,shiftWith:d,shiftWithOffset:P,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:A,unshiftWith:u}},At(Sa,If),{singleton:!0});function Jk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const by=ut(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=it(),d=it(),f=Un(he(u,we(Jk)));return Le(he(f,we(h=>h.totalCount)),s),Le(he(f,we(h=>h.groupIndices)),t),Le(he(Yt(c,a,i),$e(([h,x])=>cc(x)),we(([h,x,v])=>or(x.groupOffsetTree,Math.max(h-v,0),"v")[0]),Rt(),we(h=>[h])),d),{groupCounts:u,topItemsIndexes:d}},At(jr,yn)),ka=ut(([{log:t}])=>{const a=ge(!1),s=Un(he(a,$e(i=>i),Rt()));return pt(a,i=>{i&&_t(t)("props updated",{},Jt.DEBUG)}),{didMount:s,propsReady:a}},At(Sa),{singleton:!0}),ew=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function jy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!ew)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ii=ut(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:f,scrollingInProgress:h,scrollTo:x,smoothScrollTargetReached:v,viewportHeight:y},{log:b}])=>{const j=it(),k=it(),C=ge(0);let w=null,N=null,T=null;function A(){w!==null&&(w(),w=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Ke(h,!1)}return Le(he(j,Qe(s,y,i,C,f,d,b),Qe(t,u,c),we(([[B,M,P,E,O,z,_,H],F,q,ee])=>{const U=jy(B),{align:D,behavior:$,offset:W}=U,Y=E-1,oe=yy(U,M,Y);let L=ti(oe,M.offsetTree,F)+z;D==="end"?(L+=q+or(M.sizeTree,oe)[1]-P+ee,oe===Y&&(L+=_)):D==="center"?L+=(q+or(M.sizeTree,oe)[1]-P+ee)/2:L-=O,W!==void 0&&W!==0&&(L+=W);const I=K=>{A(),K?(H("retrying to scroll to",{location:B},Jt.DEBUG),Ke(j,B)):(Ke(k,!0),H("list did not change, scroll successful",{},Jt.DEBUG))};if(A(),$==="smooth"){let K=!1;T=pt(a,Q=>{K=K||Q}),w=sr(v,()=>{I(K)})}else w=sr(he(a,tw(150)),I);return N=setTimeout(()=>{A()},1200),Ke(h,!0),H("scrolling from index to",{behavior:$,index:oe,top:L},Jt.DEBUG),{behavior:$,top:L}})),x),{scrollTargetReached:k,scrollToIndex:j,topListHeight:C}},At(jr,yn,Sa),{singleton:!0});function tw(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Uf(t,a){t===0?a():requestAnimationFrame(()=>{Uf(t-1,a)})}function Hf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const oi=ut(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const f=ge(!0),h=ge(0),x=ge(!0);return Le(he(d,Qe(h),$e(([v,y])=>y!==0),xr(!1)),f),Le(he(d,Qe(h),$e(([v,y])=>y!==0),xr(!1)),x),pt(he(Yt(a,d),Qe(f,s,t,x),$e(([[,v],y,{sizeTree:b},j,k])=>v&&(!yt(b)||_f(j))&&!y&&!k),Qe(h)),([,v])=>{sr(c,()=>{Ke(x,!0)}),Uf(4,()=>{sr(i,()=>{Ke(f,!0)}),Ke(u,v)})}),{initialItemFinalLocationReached:x,initialTopMostItemIndex:h,scrolledToInitialItem:f}},At(jr,yn,ii,ka),{singleton:!0});function Sy(t,a){return Math.abs(t-a)<1.01}const ni="up",Gs="down",nw="none",rw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},aw=0,ci=ut(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),f=ge(!0),h=it(),x=it(),v=ge(4),y=ge(aw),b=pn(he(ff(he(Ie(c),Wa(1),xr(!0)),he(Ie(c),Wa(1),xr(!1),Ng(100))),Rt()),!1),j=pn(he(ff(he(s,xr(!0)),he(s,xr(!1),Ng(200))),Rt()),!1);Le(he(Yt(Ie(c),Ie(y)),we(([T,A])=>T<=A),Rt()),f),Le(he(f,Ur(50)),x);const k=Un(he(Yt(i,Ie(u),Ie(a),Ie(t),Ie(v)),vr((T,[{scrollHeight:A,scrollTop:B},M,P,E,O])=>{const z=B+M-A>-O,_={scrollHeight:A,scrollTop:B,viewportHeight:M};if(z){let F,q;return B>T.state.scrollTop?(F="SCROLLED_DOWN",q=T.state.scrollTop-B):(F="SIZE_DECREASED",q=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:q,state:_}}let H;return _.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":M<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:_}},rw),Rt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),C=pn(he(i,vr((T,{scrollHeight:A,scrollTop:B,viewportHeight:M})=>{if(!Sy(T.scrollHeight,A)){const P=A-(B+M)<1;return T.scrollTop!==B&&P?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),$e(T=>T.changed),we(T=>T.jump)),0);Le(he(k,we(T=>T.atBottom)),d),Le(he(d,Ur(50)),h);const w=ge(Gs);Le(he(i,we(({scrollTop:T})=>T),Rt(),vr((T,A)=>_t(j)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?ni:Gs,prevScrollTop:A},{direction:Gs,prevScrollTop:0}),we(T=>T.direction)),w),Le(he(i,Ur(50),xr(nw)),w);const N=ge(0);return Le(he(b,$e(T=>!T),xr(0)),N),Le(he(c,Ur(100),Qe(b),$e(([T,A])=>A),vr(([T,A],[B])=>[A,B],[0,0]),we(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:h,atBottomThreshold:v,atTopStateChange:x,atTopThreshold:y,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:C,scrollDirection:w,scrollVelocity:N}},At(yn)),ri="top",ai="bottom",Lg="none";function Mg(t,a,s){return typeof t=="number"?s===ni&&a===ri||s===Gs&&a===ai?t:0:s===ni?a===ri?t.main:t.reverse:a===ai?t.main:t.reverse}function zg(t,a){return typeof t=="number"?t:t[a]??0}const Pf=ut(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=it(),d=ge(0),f=ge(0),h=ge(0),x=pn(he(Yt(Ie(i),Ie(c),Ie(s),Ie(u,ei),Ie(h),Ie(d),Ie(a),Ie(t),Ie(f)),we(([v,y,b,[j,k],C,w,N,T,A])=>{const B=v-T,M=w+N,P=Math.max(b-B,0);let E=Lg;const O=zg(A,ri),z=zg(A,ai);return j-=T,j+=b+N,k+=b+N,k-=T,j>v+M-O&&(E=ni),k<v-P+y+z&&(E=Gs),E!==Lg?[Math.max(B-b-Mg(C,ri,E)-O,0),B-P-N+y+Mg(C,ai,E)+z]:null}),$e(v=>v!==null),Rt(ei)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:h,topListHeight:d,visibleRange:x}},At(yn),{singleton:!0});function lw(t,a,s){if(cc(a)){const i=vy(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const _d={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Fo(t,a,s,i,c,u){const{lastIndex:d,lastOffset:f,lastSize:h}=c;let x=0,v=0;if(t.length>0){x=t[0].offset;const C=t[t.length-1];v=C.offset+C.size}const y=s-d,b=f+y*h+(y-1)*i,j=x,k=b-v;return{bottom:v,firstItemIndex:u,items:Dg(t,c,u),offsetBottom:k,offsetTop:x,top:j,topItems:Dg(a,c,u),topListHeight:a.reduce((C,w)=>w.size+C,0),totalCount:s}}function ky(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const v of s.groupIndices){if(v-d>=t)break;d++}const f=t+d,h=Hf(a,f),x=Array.from({length:f}).map((v,y)=>({data:u[y+h],index:y+h,offset:0,size:0}));return Fo(x,[],f,c,s,i)}function Dg(t,a,s){if(t.length===0)return[];if(!cc(a))return t.map(x=>({...x,index:x.index+s,originalIndex:x.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Il(a.groupOffsetTree,i,c);let f,h=0;for(const x of t){(!f||f.end<x.index)&&(f=d.shift(),h=a.groupIndices.indexOf(f.start));let v;x.index===f.start?v={index:h,type:"group"}:v={groupIndex:h,index:x.index-(h+1)+s},u.push({...v,data:x.data,offset:x.offset,originalIndex:x.index,size:x.size})}return u}function _g(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Ka=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:f,visibleRange:h},{initialTopMostItemIndex:x,scrolledToInitialItem:v},{topListHeight:y},b,{didMount:j},{recalcInProgress:k}])=>{const C=ge([]),w=ge(0),N=it(),T=ge(0);Le(u.topItemsIndexes,C);const A=pn(he(Yt(j,k,Ie(h,ei),Ie(c),Ie(i),Ie(x),v,Ie(C),Ie(a),Ie(s),Ie(T),t),$e(([E,O,,z,,,,,,,,_])=>{const H=_!==void 0&&_.length!==z;return E&&!O&&!H}),we(([,,[E,O],z,_,H,F,q,ee,U,D,$])=>{var me,je;const W=_,{offsetTree:Y,sizeTree:oe}=W,L=_t(w);if(z===0)return{..._d,totalCount:z};if(E===0&&O===0)return L===0?{..._d,totalCount:z}:ky(L,H,_,ee,U,$||[]);if(yt(oe))return L>0?null:Fo(lw(Hf(H,z),W,$),[],z,U,W,ee);const I=[];if(q.length>0){const Te=q[0],Me=q[q.length-1];let Fe=0;for(const Ue of Il(oe,Te,Me)){const De=Ue.value,We=Math.max(Ue.start,Te),ft=Math.min(Ue.end,Me);for(let ce=We;ce<=ft;ce++)I.push({data:$==null?void 0:$[ce],index:ce,offset:Fe,size:De}),Fe+=De}}if(!F)return Fo([],I,z,U,W,ee);const K=q.length>0?q[q.length-1]+1:0,Q=qk(Y,E,O,K);if(Q.length===0)return null;const ue=z-1,J=oc([],Te=>{for(const Me of Q){const Fe=Me.value;let Ue=Fe.offset,De=Me.start;const We=Fe.size;if(Fe.offset<E){De+=Math.floor((E-Fe.offset+U)/(We+U));const ce=De-Me.start;Ue+=ce*We+ce*U}De<K&&(Ue+=(K-De)*We,De=K);const ft=Math.min(Me.end,ue);for(let ce=De;ce<=ft&&!(Ue>=O);ce++)Te.push({data:$==null?void 0:$[ce],index:ce,offset:Ue,size:We}),Ue+=We+U}}),ie=_g(D,ri),Z=_g(D,ai);if(J.length>0&&(ie>0||Z>0)){const Te=J[0],Me=J[J.length-1];if(ie>0&&Te.index>K){const Fe=Math.min(ie,Te.index-K),Ue=[];let De=Te.offset;for(let We=Te.index-1;We>=Te.index-Fe;We--){const ft=((me=Il(oe,We,We)[0])==null?void 0:me.value)??Te.size;De-=ft+U,Ue.unshift({data:$==null?void 0:$[We],index:We,offset:De,size:ft})}J.unshift(...Ue)}if(Z>0&&Me.index<ue){const Fe=Math.min(Z,ue-Me.index);let Ue=Me.offset+Me.size+U;for(let De=Me.index+1;De<=Me.index+Fe;De++){const We=((je=Il(oe,De,De)[0])==null?void 0:je.value)??Me.size;J.push({data:$==null?void 0:$[De],index:De,offset:Ue,size:We}),Ue+=We+U}}}return Fo(J,I,z,U,W,ee)}),$e(E=>E!==null),Rt()),_d);Le(he(t,$e(_f),we(E=>E==null?void 0:E.length)),c),Le(he(A,we(E=>E.topListHeight)),y),Le(y,f),Le(he(A,we(E=>[E.top,E.bottom])),d),Le(he(A,we(E=>E.items)),N);const B=Un(he(A,$e(({items:E})=>E.length>0),Qe(c,t),$e(([{items:E},O])=>E[E.length-1].originalIndex===O-1),we(([,E,O])=>[E-1,O]),Rt(ei),we(([E])=>E))),M=Un(he(A,Ur(200),$e(({items:E,topItems:O})=>E.length>0&&E[0].originalIndex===O.length),we(({items:E})=>E[0].index),Rt())),P=Un(he(A,$e(({items:E})=>E.length>0),we(({items:E})=>{let O=0,z=E.length-1;for(;E[O].type==="group"&&O<z;)O++;for(;E[z].type==="group"&&z>O;)z--;return{endIndex:E[z].index,startIndex:E[O].index}}),Rt(xy)));return{endReached:B,initialItemCount:w,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:P,startReached:M,topItemsIndexes:C,...b}},At(jr,by,Pf,oi,ii,ci,ka,If),{singleton:!0}),wy=ut(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=it(),d=pn(he(Yt(s,t,i,a,c),we(([f,h,x,v,y])=>f+h+x+v+y.offsetBottom+y.bottom)),0);return Le(Ie(d),u),{totalListHeight:d,totalListHeightChanged:u}},At(yn,Ka),{singleton:!0}),sw=ut(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=pn(he(Yt(s,t,a),$e(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Ur(0),Rt()),0);return{alignToBottom:s,paddingTopAddition:i}},At(yn,wy),{singleton:!0}),Cy=ut(()=>({context:ge(null)})),iw=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,Ey=ut(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:h},{scrollToIndex:x}])=>{const v=it();return Le(he(v,Qe(a,h,s,u,c,i,f),Qe(t),we(([[y,b,j,k,C,w,N,T],A])=>{const{calculateViewLocation:B=iw,done:M,...P}=y,E=yy(y,b,k-1),O=ti(E,b.offsetTree,A)+C+w,z=O+or(b.sizeTree,E)[1],_=T+w,H=T+j-N,F=B({itemBottom:z,itemTop:O,locationParams:P,viewportBottom:H,viewportTop:_});return F!==null?M&&sr(he(d,$e(q=>!q),Wa(_t(d)?1:2)),M):M==null||M(),F}),$e(y=>y!==null)),x),{scrollIntoView:v}},At(jr,yn,ii,Ka,Sa),{singleton:!0});function Og(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const ow=(t,a)=>typeof t=="function"?Og(t(a)):a&&Og(t),cw=ut(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:f},{didMount:h,propsReady:x},{log:v},{scrollingInProgress:y},{context:b},{scrollIntoView:j}])=>{const k=ge(!1),C=it();let w=null;function N(M){Ke(d,{align:"end",behavior:M,index:"LAST"})}pt(he(Yt(he(Ie(a),Wa(1)),h),Qe(Ie(k),u,f,y),we(([[M,P],E,O,z,_])=>{let H=P&&z,F="auto";return H&&(F=ow(E,O||_),H=H&&F!==!1),{followOutputBehavior:F,shouldFollow:H,totalCount:M}}),$e(({shouldFollow:M})=>M)),({followOutputBehavior:M,totalCount:P})=>{w!==null&&(w(),w=null),_t(s)!==void 0?requestAnimationFrame(()=>{_t(v)("following output to ",{totalCount:P},Jt.DEBUG),N(M)}):w=sr(t,()=>{_t(v)("following output to ",{totalCount:P},Jt.DEBUG),N(M),w=null})});function T(M){const P=sr(c,E=>{M&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(_t(v)("scrolling to bottom due to increased size",{},Jt.DEBUG),N("auto"))});setTimeout(P,100)}pt(he(Yt(Ie(k),a,x),$e(([M,,P])=>M!==!1&&P),vr(({value:M},[,P])=>({refreshed:M===P,value:P}),{refreshed:!1,value:0}),$e(({refreshed:M})=>M),Qe(k,a)),([,M])=>{_t(f)&&T(M!==!1)}),pt(C,()=>{T(_t(k)!==!1)}),pt(Yt(Ie(k),c),([M,P])=>{M!==!1&&!P.atBottom&&P.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ge(null),B=it();return Le(ff(he(Ie(i),we(M=>(M==null?void 0:M.length)??0)),he(Ie(a))),B),pt(he(Yt(he(B,Wa(1)),h),Qe(Ie(A),f,y,b),we(([[M,P],E,O,z,_])=>P&&O&&(E==null?void 0:E({context:_,totalCount:M,scrollingInProgress:z}))),$e(M=>!!M),Ur(0)),M=>{w!==null&&(w(),w=null),_t(s)!==void 0?requestAnimationFrame(()=>{_t(v)("scrolling into view",{}),Ke(j,M)}):w=sr(t,()=>{_t(v)("scrolling into view",{}),Ke(j,M),w=null})}),{autoscrollToBottom:C,followOutput:k,scrollIntoViewOnChange:A}},At(jr,ci,ii,oi,ka,Sa,yn,Cy,Ey)),uw=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Le(he(f,Qe(u),$e(([,h])=>h!==0),Qe(c,i,a,s,t),we(([[,h],x,v,y,b,j=[]])=>ky(h,x,v,y,b,j))),d),{}),At(jr,oi,Ka,ka),{singleton:!0}),dw=ut(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return pt(he(t,Qe(i),$e(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(he(s,Wa(1),$e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Ke(a,c)})})}),{initialScrollTop:i}},At(ka,yn,Ka),{singleton:!0}),Ny=ut(([{scrollVelocity:t}])=>{const a=ge(!1),s=it(),i=ge(!1);return Le(he(t,Qe(i,a,s),$e(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,f])=>{const{enter:h,exit:x}=u;if(d){if(x(c,f))return!1}else if(h(c,f))return!0;return d}),Rt()),a),pt(he(Yt(a,t,s),Qe(i)),([[c,u,d],f])=>{c&&f!==!1&&f!==void 0&&f.change&&f.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},At(ci),{singleton:!0}),Vf=ut(([{scrollContainerState:t,scrollTo:a}])=>{const s=it(),i=it(),c=it(),u=ge(!1),d=ge(void 0);return Le(he(Yt(s,i),we(([{scrollTop:f,viewportHeight:h},{offsetTop:x,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,f-x),viewportHeight:h}))),t),Le(he(a,Qe(i),we(([f,{offsetTop:h}])=>({...f,top:f.top+h}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},At(yn)),fw=ut(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:h}])=>{const x=it(),v=ge(void 0),y=ge(null),b=ge(null);return Le(f,y),Le(h,b),pt(he(x,Qe(a,i,d,y,b,s)),([j,k,C,w,N,T,A])=>{const B=Kk(k.sizeTree);w&&N!==null&&T!==null&&(C=N.scrollTop-T.offsetTop),C-=A,j({ranges:B,scrollTop:C})}),Le(he(v,$e(_f),we(pw)),c),Le(he(u,Qe(v),$e(([,j])=>j!==void 0),Rt(),we(([,j])=>j.ranges)),t),{getState:x,restoreStateFrom:v}},At(jr,yn,oi,ka,Vf));function pw(t){return{align:"start",index:0,offset:t.scrollTop}}const mw=ut(([{topItemsIndexes:t}])=>{const a=ge(0);return Le(he(a,$e(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},At(Ka));function Ty(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const hw=Ty(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),xw=ut(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:f},{listState:h},{beforeUnshiftWith:x,gap:v,shiftWithOffset:y,sizes:b},{log:j},{recalcInProgress:k}])=>{const C=Un(he(h,Qe(d),vr(([,N,T,A],[{bottom:B,items:M,offsetBottom:P,totalCount:E},O])=>{const z=B+P;let _=0;return T===E&&N.length>0&&M.length>0&&(M[0].originalIndex===0&&N[0].originalIndex===0||(_=z-A,_!==0&&(_+=O))),[_,M,E,z]},[0,[],0,0]),$e(([N])=>N!==0),Qe(i,f,s,c,j,k),$e(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===ni),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Jt.DEBUG),N))));function w(N){N>0?(Ke(a,{behavior:"auto",top:-N}),Ke(t,0)):(Ke(t,0),Ke(a,{behavior:"auto",top:-N}))}return pt(he(C,Qe(t,u)),([N,T,A])=>{A&&hw()?Ke(t,T-N):w(-N)}),pt(he(Yt(pn(u,!1),t,k),$e(([N,T,A])=>!N&&!A&&T!==0),we(([N,T])=>T),Ur(1)),w),Le(he(y,we(N=>({top:-N}))),a),pt(he(x,Qe(b,v),we(([N,{groupIndices:T,lastSize:A,sizeTree:B},M])=>{function P(H){return H*(A+M)}if(T.length===0)return P(N);let E=0;const O=Js(B,0);let z=0,_=0;for(;z<N;){z++,E+=O;let H=T.length===_+1?1/0:T[_+1]-T[_]-1;z+H>N&&(E-=O,H=N-z+1),z+=H,E+=P(H),_++}return E})),N=>{Ke(t,N),requestAnimationFrame(()=>{Ke(a,{top:N}),requestAnimationFrame(()=>{Ke(t,0),Ke(k,!1)})})}),{deviation:t}},At(yn,ci,Ka,jr,Sa,If)),gw=ut(([t,a,s,i,c,u,d,f,h,x,v])=>({...t,...a,...s,...i,...c,...u,...d,...f,...h,...x,...v}),At(Pf,uw,ka,Ny,wy,dw,sw,Vf,Ey,Sa,Cy)),Ry=ut(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:f,itemSize:h,sizeRanges:x,sizes:v,statefulTotalCount:y,totalCount:b,trackItemSizes:j},{initialItemFinalLocationReached:k,initialTopMostItemIndex:C,scrolledToInitialItem:w},N,T,A,B,{scrollToIndex:M},P,{topItemCount:E},{groupCounts:O},z])=>{const{listState:_,minOverscanItemCount:H,topItemsIndexes:F,rangeChanged:q,...ee}=B;return Le(q,z.scrollSeekRangeChanged),Le(he(z.windowViewportRect,we(U=>U.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:f,initialItemFinalLocationReached:k,initialTopMostItemIndex:C,scrolledToInitialItem:w,sizeRanges:x,topItemCount:E,topItemsIndexes:F,totalCount:b,...A,groupIndices:d,itemSize:h,listState:_,minOverscanItemCount:H,scrollToIndex:M,statefulTotalCount:y,trackItemSizes:j,rangeChanged:q,...ee,...z,...N,sizes:v,...T}},At(jr,oi,yn,fw,cw,Ka,ii,xw,mw,by,gw));function vw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const Ro=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Ay(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),f=Ae.createContext({});function h(w,N){w.propsReady!==void 0&&Ke(w.propsReady,!1);for(const T of i){const A=w[a.required[T]];Ke(A,N[T])}for(const T of c)if(T in N){const A=w[a.optional[T]];Ke(A,N[T])}w.propsReady!==void 0&&Ke(w.propsReady,!0)}function x(w){return u.reduce((N,T)=>(N[T]=A=>{const B=w[a.methods[T]];Ke(B,A)},N),{})}function v(w){return d.reduce((N,T)=>(N[T]=Dk(w[a.events[T]]),N),{})}const y=Ae.forwardRef(function(w,N){const{children:T,...A}=w,[B]=Ae.useState(()=>oc(Ok(t),E=>{h(E,A)})),[M]=Ae.useState(Eg(v,B));Ro(()=>{for(const E of d)E in A&&pt(M[E],A[E]);return()=>{Object.values(M).map(Of)}},[A,M,B]),Ro(()=>{h(B,A)}),Ae.useImperativeHandle(N,Cg(x(B)));const P=s;return r.jsx(f.Provider,{value:B,children:s!==void 0?r.jsx(P,{...vw([...i,...c,...d],A),children:T}):T})}),b=w=>{const N=Ae.useContext(f);return Ae.useCallback(T=>{Ke(N[w],T)},[N,w])},j=w=>{const N=Ae.useContext(f)[w],T=Ae.useCallback(A=>pt(N,A),[N]);return Ae.useSyncExternalStore(T,()=>_t(N),()=>_t(N))},k=w=>{const N=Ae.useContext(f)[w],[T,A]=Ae.useState(Eg(_t,N));return Ro(()=>pt(N,B=>{B!==T&&A(Cg(B))}),[N,T]),T},C=parseInt(Ae.version)>=18?j:k;return{Component:y,useEmitter:(w,N)=>{const T=Ae.useContext(f)[w];Ro(()=>pt(T,N),[N,T])},useEmitterValue:C,usePublisher:b}}const Ly=Ae.createContext(void 0),My=Ae.createContext(void 0),Od="-webkit-sticky",Bg="sticky",Ff=Ty(()=>{if(typeof document>"u")return Bg;const t=document.createElement("div");return t.style.position=Od,t.style.position===Od?Od:Bg}),zy=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Bd(t){return"self"in t}function yw(t){return"body"in t}function Dy(t,a,s,i=Gl,c,u){const d=Ae.useRef(null),f=Ae.useRef(null),h=Ae.useRef(null),x=Ae.useCallback(b=>{let j,k,C;const w=b.target;if(yw(w)||Bd(w)){const T=Bd(w)?w:w.defaultView;C=u===!0?T.scrollX:T.scrollY,j=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else C=u===!0?w.scrollLeft:w.scrollTop,j=u===!0?w.scrollWidth:w.scrollHeight,k=u===!0?w.offsetWidth:w.offsetHeight;const N=()=>{t({scrollHeight:j,scrollTop:Math.max(C,0),viewportHeight:k})};b.suppressFlushSync===!0?N():TS.flushSync(N),f.current!==null&&(C===f.current||C<=0||C===j-k)&&(f.current=null,a(!0),h.current&&(clearTimeout(h.current),h.current=null))},[t,a,u]);Ae.useEffect(()=>{const b=c||d.current;return i(c||d.current),x({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",x,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",x)}},[d,x,s,i,c]);function v(b){const j=d.current;if(!j||(u===!0?"offsetWidth"in j&&j.offsetWidth===0:"offsetHeight"in j&&j.offsetHeight===0))return;const k=b.behavior==="smooth";let C,w,N;Bd(j)?(w=Math.max(ya(j.document.documentElement,u===!0?"width":"height"),u===!0?j.document.documentElement.scrollWidth:j.document.documentElement.scrollHeight),C=u===!0?j.innerWidth:j.innerHeight,N=u===!0?window.scrollX:window.scrollY):(w=j[u===!0?"scrollWidth":"scrollHeight"],C=ya(j,u===!0?"width":"height"),N=j[u===!0?"scrollLeft":"scrollTop"]);const T=w-C;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Sy(C,w)||b.top===N){t({scrollHeight:w,scrollTop:N,viewportHeight:C}),k&&a(!0);return}k?(f.current=b.top,h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,f.current=null,a(!0)},1e3)):f.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),j.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 Wf(t){return t}const bw=ut(()=>{const t=ge(f=>`Item ${f}`),a=ge(f=>`Group ${f}`),s=ge({}),i=ge(Wf),c=ge("div"),u=ge(Gl),d=(f,h=null)=>pn(he(s,we(x=>x[f]),Rt()),h);return{components:s,computeItemKey:i,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")}}),jw=ut(([t,a])=>({...t,...a}),At(Ry,bw)),Sw=({height:t})=>r.jsx("div",{style:{height:t}}),kw={overflowAnchor:"none",position:Ff(),zIndex:1},_y={overflowAnchor:"none"},ww={..._y,display:"inline-block",height:"100%"},Ig=Ae.memo(function({showTopList:t=!1}){const a=Ve("listState"),s=er("sizeRanges"),i=Ve("useWindowScroll"),c=Ve("customScrollParent"),u=er("windowScrollContainerState"),d=er("scrollContainerState"),f=c||i?u:d,h=Ve("itemContent"),x=Ve("context"),v=Ve("groupContent"),y=Ve("trackItemSizes"),b=Ve("itemSize"),j=Ve("log"),k=er("gap"),C=Ve("horizontalDirection"),{callbackRef:w}=$k(s,b,y,t?Gl:f,j,k,c,C,Ve("skipAnimationFrameInResizeObserver")),[N,T]=Ae.useState(0);Gf("deviation",ee=>{N!==ee&&T(ee)});const A=Ve("EmptyPlaceholder"),B=Ve("ScrollSeekPlaceholder")??Sw,M=Ve("ListComponent"),P=Ve("ItemComponent"),E=Ve("GroupComponent"),O=Ve("computeItemKey"),z=Ve("isSeeking"),_=Ve("groupIndices").length>0,H=Ve("alignToBottom"),F=Ve("initialItemFinalLocationReached"),q=t?{}:{boxSizing:"border-box",...C?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...F?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...fn(A,x)}):r.jsx(M,{...fn(M,x),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:q,children:(t?a.topItems:a.items).map(ee=>{const U=ee.originalIndex,D=O(U+a.firstItemIndex,ee.data,x);return z?m.createElement(B,{...fn(B,x),height:ee.size,index:ee.index,key:D,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?m.createElement(E,{...fn(E,x),"data-index":U,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:kw},v(ee.index,x)):m.createElement(P,{...fn(P,x),...Tw(P,ee.data),"data-index":U,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:C?ww:_y},_?h(ee.index,ee.groupIndex,ee.data,x):h(ee.index,ee.data,x))})})}),Cw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ew={outline:"none",overflowX:"auto",position:"relative"},uc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Nw={position:Ff(),top:0,width:"100%",zIndex:1};function fn(t,a){if(typeof t!="string")return{context:a}}function Tw(t,a){return{item:typeof t=="string"?void 0:a}}const Rw=Ae.memo(function(){const t=Ve("HeaderComponent"),a=er("headerHeight"),s=Ve("HeaderFooterTag"),i=Ya(Ae.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Aw=Ae.memo(function(){const t=Ve("FooterComponent"),a=er("footerHeight"),s=Ve("HeaderFooterTag"),i=Ya(Ae.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null});function Oy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("scrollContainerState"),h=a("ScrollerComponent"),x=s("smoothScrollTargetReached"),v=a("scrollerRef"),y=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:j,scrollToCallback:k}=Dy(f,x,h,v,void 0,y);return t("scrollTo",k),t("scrollBy",b),r.jsx(h,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:j,style:{...y?Ew:Cw,...c},tabIndex:0,...d,...fn(h,u),children:i})})}function By({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("windowScrollContainerState"),h=a("ScrollerComponent"),x=s("smoothScrollTargetReached"),v=a("totalListHeight"),y=a("deviation"),b=a("customScrollParent"),j=Ae.useRef(null),k=a("scrollerRef"),{scrollByCallback:C,scrollerRef:w,scrollToCallback:N}=Dy(f,x,h,k,b);return zy(()=>{var T;return w.current=b||((T=j.current)==null?void 0:T.ownerDocument.defaultView),()=>{w.current=null}},[w,b]),t("windowScrollTo",N),t("scrollBy",C),r.jsx(h,{ref:j,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...fn(h,u),children:i})})}const Lw=({children:t})=>{const a=Ae.useContext(Ly),s=er("viewportHeight"),i=er("fixedItemHeight"),c=Ve("alignToBottom"),u=Ve("horizontalDirection"),d=Ae.useMemo(()=>oy(s,h=>ya(h,u?"width":"height")),[s,u]),f=Ya(d,!0,Ve("skipAnimationFrameInResizeObserver"));return Ae.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:f,style:uc(c),children:t})},Mw=({children:t})=>{const a=Ae.useContext(Ly),s=er("windowViewportRect"),i=er("fixedItemHeight"),c=Ve("customScrollParent"),u=uy(s,c,Ve("skipAnimationFrameInResizeObserver")),d=Ve("alignToBottom");return Ae.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:uc(d),children:t})},zw=({children:t})=>{const a=Ve("TopItemListComponent")??"div",s=Ve("headerHeight"),i={...Nw,marginTop:`${s}px`},c=Ve("context");return r.jsx(a,{style:i,...fn(a,c),children:t})},Dw=Ae.memo(function(t){const a=Ve("useWindowScroll"),s=Ve("topItemsIndexes").length>0,i=Ve("customScrollParent"),c=Ve("context");return r.jsxs(i||a?Bw:Ow,{...t,context:c,children:[s&&r.jsx(zw,{children:r.jsx(Ig,{showTopList:!0})}),r.jsxs(i||a?Mw:Lw,{children:[r.jsx(Rw,{}),r.jsx(Ig,{}),r.jsx(Aw,{})]})]})}),{Component:_w,useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}=Ay(jw,{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"}},Dw),Ow=Oy({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Bw=By({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Iw=_w,$w=ut(()=>{const t=ge(x=>r.jsxs("td",{children:["Item $",x]})),a=ge(null),s=ge(x=>r.jsxs("td",{colSpan:1e3,children:["Group ",x]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Wf),f=ge(Gl),h=(x,v=null)=>pn(he(u,we(y=>y[x]),Rt()),v);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:h("EmptyPlaceholder"),FillerRow:h("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:h("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:h("ScrollSeekPlaceholder"),TableBodyComponent:h("TableBody","tbody"),TableComponent:h("Table","table"),TableFooterComponent:h("TableFoot","tfoot"),TableHeadComponent:h("TableHead","thead"),TableRowComponent:h("TableRow","tr"),GroupComponent:h("Group","tr")}});At(Ry,$w);Ff();const $g={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Uw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ug,floor:Ko,max:qs,min:Id,round:Hg}=Math;function Pg(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Hw(t){return{...Uw,items:t}}function Ao(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Pw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Vw=ut(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:f,scrollTo:h,scrollTop:x,smoothScrollTargetReached:v,viewportHeight:y},b,j,{didMount:k,propsReady:C},{customScrollParent:w,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},M])=>{const P=ge(0),E=ge(0),O=ge($g),z=ge({height:0,width:0}),_=ge({height:0,width:0}),H=it(),F=it(),q=ge(0),ee=ge(null),U=ge({column:0,row:0}),D=it(),$=it(),W=ge(!1),Y=ge(0),oe=ge(!0),L=ge(!1),I=ge(!1);pt(he(k,Qe(Y),$e(([Z,me])=>me!==0)),()=>{Ke(oe,!1)}),pt(he(Yt(k,oe,_,z,Y,L),$e(([Z,me,je,Te,,Me])=>Z&&!me&&je.height!==0&&Te.height!==0&&!Me)),([,,,,Z])=>{Ke(L,!0),Uf(1,()=>{Ke(H,Z)}),sr(he(x),()=>{Ke(a,[0,0]),Ke(oe,!0)})}),Le(he($,$e(Z=>Z!=null&&Z.scrollTop>0),xr(0)),E),pt(he(k,Qe($),$e(([,Z])=>Z!=null)),([,Z])=>{Z&&(Ke(z,Z.viewport),Ke(_,Z.item),Ke(U,Z.gap),Z.scrollTop>0&&(Ke(W,!0),sr(he(x,Wa(1)),me=>{Ke(W,!1)}),Ke(h,{top:Z.scrollTop})))}),Le(he(z,we(({height:Z})=>Z)),y),Le(he(Yt(Ie(z,Ao),Ie(_,Ao),Ie(U,(Z,me)=>Z!==void 0&&Z.column===me.column&&Z.row===me.row),Ie(x)),we(([Z,me,je,Te])=>({gap:je,item:me,scrollTop:Te,viewport:Z}))),D),Le(he(Yt(Ie(P),i,Ie(U,Pw),Ie(_,Ao),Ie(z,Ao),Ie(ee),Ie(E),Ie(W),Ie(oe),Ie(Y)),$e(([,,,,,,,Z])=>!Z),we(([Z,[me,je],Te,Me,Fe,Ue,De,,We,ft])=>{const{column:ce,row:ve}=Te,{height:ye,width:be}=Me,{width:Ne}=Fe;if(De===0&&(Z===0||Ne===0))return $g;if(be===0){const Xe=Hf(ft,Z),kt=Xe+Math.max(De-1,0);return Hw(Pg(Xe,kt,Ue))}const qe=Iy(Ne,be,ce);let He,jt;We?me===0&&je===0&&De>0?(He=0,jt=De-1):(He=qe*Ko((me+ve)/(ye+ve)),jt=qe*Ug((je+ve)/(ye+ve))-1,jt=Id(Z-1,qs(jt,qe-1)),He=Id(jt,qs(0,He))):(He=0,jt=-1);const Ot=Pg(He,jt,Ue),{bottom:St,top:Lt}=Vg(Fe,Te,Me,Ot),xe=Ug(Z/qe),Ze=xe*ye+(xe-1)*ve-St;return{bottom:St,itemHeight:ye,items:Ot,itemWidth:be,offsetBottom:Ze,offsetTop:Lt,top:Lt}})),O),Le(he(ee,$e(Z=>Z!==null),we(Z=>Z.length)),P),Le(he(Yt(z,_,O,U),$e(([Z,me,{items:je}])=>je.length>0&&me.height!==0&&Z.height!==0),we(([Z,me,{items:je},Te])=>{const{bottom:Me,top:Fe}=Vg(Z,Te,me,je);return[Fe,Me]}),Rt(ei)),a);const K=ge(!1);Le(he(x,Qe(K),we(([Z,me])=>me||Z!==0)),K);const Q=Un(he(Yt(O,P),$e(([{items:Z}])=>Z.length>0),Qe(K),$e(([[Z,me],je])=>{const Te=Z.items[Z.items.length-1].index===me-1;return(je||Z.bottom>0&&Z.itemHeight>0&&Z.offsetBottom===0&&Z.items.length===me)&&Te}),we(([[,Z]])=>Z-1),Rt())),ue=Un(he(Ie(O),$e(({items:Z})=>Z.length>0&&Z[0].index===0),xr(0),Rt())),J=Un(he(Ie(O),Qe(W),$e(([{items:Z},me])=>Z.length>0&&!me),we(([{items:Z}])=>({endIndex:Z[Z.length-1].index,startIndex:Z[0].index})),Rt(xy),Ur(0)));Le(J,j.scrollSeekRangeChanged),Le(he(H,Qe(z,_,P,U),we(([Z,me,je,Te,Me])=>{const Fe=jy(Z),{align:Ue,behavior:De,offset:We}=Fe;let ft=Fe.index;ft==="LAST"&&(ft=Te-1),ft=qs(0,ft,Id(Te-1,ft));let ce=gf(me,Me,je,ft);return Ue==="end"?ce=Hg(ce-me.height+je.height):Ue==="center"&&(ce=Hg(ce-me.height/2+je.height/2)),We!==void 0&&We!==0&&(ce+=We),{behavior:De,top:ce}})),h);const ie=pn(he(O,we(Z=>Z.offsetBottom+Z.bottom)),0);return Le(he(B,we(Z=>({height:Z.visibleHeight,width:Z.visibleWidth}))),z),{customScrollParent:w,data:ee,deviation:q,footerHeight:c,gap:U,headerHeight:u,increaseViewportBy:t,initialItemCount:E,itemDimensions:_,overscan:s,restoreStateFrom:$,scrollBy:d,scrollContainerState:f,scrollHeight:F,scrollTo:h,scrollToIndex:H,scrollTop:x,smoothScrollTargetReached:v,totalCount:P,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...j,gridState:O,horizontalDirection:I,initialTopMostItemIndex:Y,totalListHeight:ie,...b,endReached:Q,propsReady:C,rangeChanged:J,startReached:ue,stateChanged:D,stateRestoreInProgress:W,...M}},At(Pf,yn,ci,Ny,ka,Vf,Sa));function Iy(t,a,s){return qs(1,Ko((t+s)/(Ko(a)+s)))}function Vg(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=gf(t,a,s,i[0].index);return{bottom:gf(t,a,s,i[i.length-1].index)+c,top:u}}function gf(t,a,s,i){const c=Iy(t.width,s.width,a.column),u=Ko(i/c),d=u*s.height+qs(0,u-1)*a.row;return d>0?d+a.row:d}const Fw=ut(()=>{const t=ge(y=>`Item ${y}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Wf),d=ge("div"),f=ge(Gl),h=(y,b=null)=>pn(he(a,we(j=>j[y]),Rt()),b),x=ge(!1),v=ge(!1);return Le(Ie(v),x),{components:a,computeItemKey:u,context:s,FooterComponent:h("Footer"),HeaderComponent:h("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:h("Item","div"),itemContent:t,listClassName:c,ListComponent:h("List","div"),readyStateChanged:x,reportReadyState:v,ScrollerComponent:h("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:h("ScrollSeekPlaceholder","div")}}),Ww=ut(([t,a])=>({...t,...a}),At(Vw,Fw)),Gw=Ae.memo(function(){const t=Dt("gridState"),a=Dt("listClassName"),s=Dt("itemClassName"),i=Dt("itemContent"),c=Dt("computeItemKey"),u=Dt("isSeeking"),d=tr("scrollHeight"),f=Dt("ItemComponent"),h=Dt("ListComponent"),x=Dt("ScrollSeekPlaceholder"),v=Dt("context"),y=tr("itemDimensions"),b=tr("gap"),j=Dt("log"),k=Dt("stateRestoreInProgress"),C=tr("reportReadyState"),w=Ya(Ae.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:M}=A.getBoundingClientRect();y({height:B,width:M})}b({column:Fg("column-gap",getComputedStyle(N).columnGap,j),row:Fg("row-gap",getComputedStyle(N).rowGap,j)})},[d,y,b,j]),!0,!1);return zy(()=>{t.itemHeight>0&&t.itemWidth>0&&C(!0)},[t]),k?null:r.jsx(h,{className:a,ref:w,...fn(h,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,v);return u?r.jsx(x,{...fn(x,v),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(f,{...fn(f,v),className:s,"data-index":N.index,key:T},i(N.index,N.data,v))})})}),qw=Ae.memo(function(){const t=Dt("HeaderComponent"),a=tr("headerHeight"),s=Dt("headerFooterTag"),i=Ya(Ae.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,!1),c=Dt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Yw=Ae.memo(function(){const t=Dt("FooterComponent"),a=tr("footerHeight"),s=Dt("headerFooterTag"),i=Ya(Ae.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,!1),c=Dt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Kw=({children:t})=>{const a=Ae.useContext(My),s=tr("itemDimensions"),i=tr("viewportDimensions"),c=Ya(Ae.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Ae.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:uc(!1),children:t})},Xw=({children:t})=>{const a=Ae.useContext(My),s=tr("windowViewportRect"),i=tr("itemDimensions"),c=Dt("customScrollParent"),u=uy(s,c,!1);return Ae.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:uc(!1),children:t})},Qw=Ae.memo(function({...t}){const a=Dt("useWindowScroll"),s=Dt("customScrollParent"),i=s||a?Jw:Zw,c=s||a?Xw:Kw,u=Dt("context");return r.jsx(i,{...t,...fn(i,u),children:r.jsxs(c,{children:[r.jsx(qw,{}),r.jsx(Gw,{}),r.jsx(Yw,{})]})})}),{useEmitter:$y,useEmitterValue:Dt,usePublisher:tr}=Ay(Ww,{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"}},Qw),Zw=Oy({useEmitter:$y,useEmitterValue:Dt,usePublisher:tr}),Jw=By({useEmitter:$y,useEmitterValue:Dt,usePublisher:tr});function Fg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Jt.WARN),a==="normal"?0:parseInt(a??"0",10)}const eC={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Uy={source:"Own",installed:"Installed"};function tC(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 nC(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Wg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=eC[t],[d,f]=m.useState(()=>tC(u)),h=m.useCallback(()=>{f(b=>{const j=!b;return nC(u,j),j})},[u]),x=Uy[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:h,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(aC,{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:x}),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})`}),i!=null&&i>0&&r.jsx(rC,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function rC({origin:t,updateCount:a}){const[s,i]=m.useState(!1),c=Uy[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:()=>i(!0),onBlur:()=>i(!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 aC({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 qf(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 lC({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return m.useEffect(()=>{function h(x){var b;if(x.key!=="/")return;const v=x.target;if(!v)return;const y=v.tagName;y==="INPUT"||y==="TEXTAREA"||v.isContentEditable||(x.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[]),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":f?!0:void 0,"aria-describedby":f?d:void 0,value:t,placeholder:s,onChange:h=>a(h.currentTarget.value),onKeyDown:h=>{h.key==="Escape"&&(a(""),h.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"}}),f&&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 sC({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,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 iC({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"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 oC({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Qv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.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 cC(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 ui(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",f=d===""||d==="0.0.0"?"1.0.0":d,h=s&&!f.startsWith("v")?`v${f}`:f,x=i==="sm"?10:12,v=i==="sm"?1:2,y=i==="sm"?5:8,b=c==="registry"||c==="plugin",j=cC(c,f,u),k=t.title??j,C={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:x,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(C.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:k,style:C,children:h})}function uC({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(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(ui,{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(sC,{target:t.symlinkTarget??null}),r.jsx(iC,{skill:t}),r.jsx(oC,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Ys=m.memo(uC);function dC({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){var v;const d=[...a].sort((y,b)=>y.skill.localeCompare(b.skill)),f=(v=a[0])==null?void 0:v.pluginDisplay,h=t.replace(/^\./,"").toLowerCase(),x=!!f&&f.toLowerCase()!==h;return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",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,")"]}),x&&r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary, var(--text-secondary))",opacity:.75,fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f,children:f})]}),r.jsx("div",{role:"list",children:d.map(y=>{const b=!!s&&s.plugin===y.plugin&&s.skill===y.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Ys,{skill:y,isSelected:b,onSelect:()=>i(y),onContextMenu:c,dirty:u==null?void 0:u.has(`${y.plugin}/${y.skill}`)})},`${y.plugin}/${y.skill}`)})})]})}function fC(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 $d({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var j;const f=a??((j=t[0])==null?void 0:j.pluginName)??"unknown-plugin",[h,x]=m.useState(()=>fC(i,s)),v=d?!1:h,y=m.useCallback(()=>{x(k=>{const C=!k;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(C))}catch{}return C})},[i]),b=v?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${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:f}),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(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}function Wo({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const h=m.useRef(null),x=m.useRef(null),v=m.useRef(null);if(m.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=x.current)==null||k.focus()}),()=>{var k,C;(C=(k=v.current)==null?void 0:k.focus)==null||C.call(k),v.current=null}},[t]),m.useEffect(()=>{if(!t)return;function k(C){if(C.key==="Escape"){C.preventDefault(),f();return}if(C.key==="Tab"&&h.current){const w=h.current.querySelectorAll("button:not([disabled])");if(w.length===0)return;const N=w[0],T=w[w.length-1];C.shiftKey&&document.activeElement===N?(C.preventDefault(),T.focus()):!C.shiftKey&&document.activeElement===T&&(C.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,f]),!t)return null;const y="confirm-dialog-title",b="confirm-dialog-body",j=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:k=>{k.target===k.currentTarget&&f()},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:h,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:x,type:"button","data-testid":"confirm-dialog-cancel",onClick:f,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,...j},children:i})]})]})})}function pC(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Ud(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function mC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,h]=m.useState(null),[x,v]=m.useState(!1),y=m.useRef(null);m.useEffect(()=>{if(!i)return;function k(C){y.current&&!y.current.contains(C.target)&&c(!1)}return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[i]);async function b(k){d(k),h(null);try{const C=await fetch(`/api/plugins/${encodeURIComponent(t)}/${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),w=await C.json().catch(()=>({}));if(!C.ok||!w.ok){const N=w.error??`${k} failed (${C.status})`;h(N),k==="uninstall"&&Ud(`Failed to uninstall ${t}: ${N}`,"error");return}if(k==="uninstall"){const N=w.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Ud(N,"success")}$n("skills"),sy(),s==null||s(),c(!1)}catch(C){const w=C instanceof Error?C.message:String(C);h(w),k==="uninstall"&&Ud(`Failed to uninstall ${t}: ${w}`,"error")}finally{d(null)}}function j(){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:k=>{k.stopPropagation(),c(C=>!C)},"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:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:k=>{k.currentTarget.style.color="var(--text-primary)",k.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:k=>{k.currentTarget.style.color="var(--text-tertiary)",k.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&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(Hd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Hd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Hd,{onClick:j,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&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:f})]}),r.jsx(Wo,{open:x,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 Hd({onClick:t,disabled:a,busy:s,label:i,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?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const hC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function xC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=m.useState(s),[h,x]=m.useState(i??""),[v,y]=m.useState(!1),[b,j]=m.useState(null),[k,C]=m.useState(null),w=hC.test(d),N=v||!w,T=m.useCallback(async A=>{if(A.preventDefault(),!N){y(!0),j(null),C(null);try{const B=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:h.trim()});c({pluginDir:B.pluginDir,manifestPath:B.manifestPath,validation:B.validation})}catch(B){if(B instanceof va){j(B.message);const M=B.details;M&&typeof M.stderr=="string"&&C(M.stderr)}else j(B instanceof Error?B.message:String(B));y(!1)}}},[N,t,d,h,c]);return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"vskill-convert-dialog-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:A=>{A.target===A.currentTarget&&!v&&u()},children:r.jsxs("form",{onSubmit:T,style:{background:"var(--bg-primary, #fff)",color:"var(--text-primary, #111)",borderRadius:8,padding:20,width:"min(540px, 92vw)",boxShadow:"0 12px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-sans)"},children:[r.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",r.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),r.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),r.jsx("input",{type:"text",value:d,onChange:A=>f(A.target.value),disabled:v,autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontSize:13,fontFamily:"var(--font-mono)",boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),!w&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),r.jsx("input",{type:"text",value:h,onChange:A=>x(A.target.value),disabled:v,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&r.jsxs("div",{role:"alert",style:{marginTop:12,padding:8,fontSize:12,background:"var(--color-error-bg, #fee)",color:"var(--color-error, #c00)",borderRadius:4},children:[r.jsx("div",{style:{fontWeight:500},children:b}),k&&r.jsx("pre",{style:{marginTop:6,padding:6,fontSize:11,fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",background:"rgba(0,0,0,0.04)",borderRadius:3,maxHeight:160,overflow:"auto"},children:k})]}),r.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{type:"button",onClick:u,disabled:v,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:v?"not-allowed":"pointer"},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:N,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",opacity:N?.5:1},children:v?"Converting…":"Convert"})]})]})})}function Gg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const f=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",h=i==="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))",x=typeof u=="function",v={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:h,borderLeft:`3px solid ${f}`,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:x?"pointer":"default",border:"none",textAlign:"left"},y=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[x&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:f,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(gC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return x?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 gC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},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 vC(){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 yC(t){const a=t.key.split("+").map(f=>f.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const f of a.slice(0,-1)){const h=f.toLowerCase();h==="cmd"||h==="meta"||h==="⌘"?s=!0:h==="ctrl"||h==="control"?i=!0:h==="shift"?c=!0:(h==="alt"||h==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function bC(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 jC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function vf(t,a={}){const{enabled:s=!0,target:i}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(yC),m.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(h){const x=h,v=bC(x.target);for(const y of c.current){if(!jC(x,y))continue;const b=y.meta||y.ctrl||y.alt;if(!(v&&!y.allowInInputs&&!b)){y.handler(x);return}}}return d.addEventListener("keydown",f),()=>{d.removeEventListener("keydown",f)}},[s,i])}function Hy(){const{data:t,loading:a,error:s,revalidate:i}=Ga("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function SC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function kC({projectRoot:t}){const{status:a,loading:s}=Hy();if(s||!a||a.status==="github"||SC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const wC=200;function CC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function EC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const d of t){const f=d.scopeV2??(d.scope==="installed"?"available-project":d.scope==="global"?"available-personal":"authoring-project");f==="available-project"?s.availableProject.push(d):f==="available-personal"?s.availablePersonal.push(d):f==="available-plugin"?s.availablePlugin.push(d):f==="authoring-plugin"?s.authoringPlugin.push(d):s.authoringProject.push(d)}function i(d){const f=d.filter(v=>qf(v,a)),h={};for(const v of f){const y=v.pluginName??v.plugin;(h[y]||(h[y]=[])).push(v)}const x=Object.entries(h).sort((v,y)=>v[0].localeCompare(y[0]));return{total:d.length,filtered:f.length,byPlugin:x}}const c=i(s.authoringProject),u=c.byPlugin.filter(([d,f])=>f.length>=2&&d.trim().length>=2).map(([d,f])=>({groupKey:d,skills:f,anchorSkillDir:f[0].dir}));return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:c,authoringPlugin:i(s.authoringPlugin),authoringCandidatePlugins:u}}function NC(t,a){const s=[],i=[],c=[];for(const d of t){const f=CC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var v;const f=d.filter(y=>qf(y,a)),h={};for(const y of f)(h[v=y.plugin]||(h[v]=[])).push(y);const x=Object.entries(h).sort((y,b)=>y[0].localeCompare(b[0]));return{total:d.length,filtered:f.length,byPlugin:x}}return{own:u(s),installed:u(i),global:u(c)}}function TC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var x;const d=u.filter(v=>qf(v,a)),f={};for(const v of d)(f[x=v.plugin]||(f[x]=[])).push(v);const h=Object.entries(f).sort((v,y)=>v[0].localeCompare(y[0]));return{total:u.length,filtered:d.length,byPlugin:h}}return{own:c(s),installed:c(i)}}function RC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:f,activeAgentId:h,outdatedByScope:x,topSlot:v,revealSkillId:y,onRevealComplete:b,dirtySkillIds:j,onSkillsChanged:k}){const[C,w]=m.useState(null),N=!!h||t.some(ie=>ie.scope!==void 0&&ie.scope!==null),T=h??"claude-cli",[A,B]=m.useState(""),M=m.useDeferredValue(A),P=m.useMemo(()=>NC(t,M),[t,M]),E=m.useMemo(()=>EC(t,M),[t,M]),O=T==="claude-code",{plugins:z}=Tk(),_=O?{plugins:z??[]}:void 0,H=m.useMemo(()=>{const ie=new Map;for(const Z of(_==null?void 0:_.plugins)??[]){const me=ie.get(Z.name);ie.set(Z.name,!!me||!!Z.enabled)}return ie},[_==null?void 0:_.plugins]),[F,q]=m.useState(()=>yf(`vskill-sidebar-${T}-group-available-collapsed`)),[ee,U]=m.useState(()=>yf(`vskill-sidebar-${T}-group-authoring-collapsed`)),D=m.useCallback(ie=>{q(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-available-collapsed`,String(ie))}catch{}},[T]),$=m.useCallback(ie=>{U(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-authoring-collapsed`,String(ie))}catch{}},[T]),{own:W,installed:Y}=m.useMemo(()=>TC(t,M),[t,M]),L=P.own.filtered+P.installed.filtered+P.global.filtered>=wC,I=m.useMemo(()=>{const ie=Z=>{const me=[];for(const[,je]of Z){const Te=[...je].sort((Me,Fe)=>Me.skill.localeCompare(Fe.skill));me.push(...Te)}return me};return N?[...ie(P.own.byPlugin),...ie(P.installed.byPlugin),...ie(P.global.byPlugin)]:[...ie(W.byPlugin),...ie(Y.byPlugin)]},[N,P.own.byPlugin,P.installed.byPlugin,P.global.byPlugin,W.byPlugin,Y.byPlugin]),K=m.useMemo(()=>a?I.findIndex(ie=>ie.plugin===a.plugin&&ie.skill===a.skill):-1,[I,a]),Q=m.useCallback(ie=>{if(I.length===0)return;const Z=K<0?ie>0?0:I.length-1:Math.min(Math.max(K+ie,0),I.length-1);s(I[Z])},[I,K,s]),ue=m.useMemo(()=>{if(!y)return null;const[ie,Z]=y.split("/");if(!ie||!Z)return null;const me=t.find(Me=>Me.plugin===ie&&Me.skill===Z);if(!me)return{plugin:ie,skill:Z,bucket:null,pluginName:null};const je=me.source==="plugin"?"plugin":"project",Te=je==="plugin"?me.pluginName??ie:null;return{plugin:ie,skill:Z,bucket:je,pluginName:Te}},[y,t]),J=m.useRef(null);return m.useEffect(()=>{if(!y){J.current=null;return}if(J.current===y)return;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),Z=document.querySelector(`[data-skill-id="${ie}"]`);Z&&(J.current=y,Z.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),vf([{key:"j",handler:()=>Q(1)},{key:"k",handler:()=>Q(-1)},{key:"Enter",handler:()=>{K>=0&&s(I[K])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,r.jsx(lC,{value:A,onChange:B}),i&&r.jsx(OC,{}),!i&&c&&r.jsx(BC,{error:c,onRetry:u}),!i&&!c&&N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Gg,{name:ae.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:F,onToggle:D,count:E.availableProject.total+E.availablePersonal.total+E.availablePlugin.total}),!F&&r.jsxs(r.Fragment,{children:[r.jsx($s,{label:ae.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${T}-available-project-collapsed`,count:E.availableProject.total,filteredCount:A?E.availableProject.filtered:null,updateCount:(x==null?void 0:x.installed)??(f==null?void 0:f.installed),headerRightSlot:O?r.jsx(kC,{projectRoot:T}):null,children:E.availableProject.filtered===0?r.jsx(Yg,{queryActive:!!A,agentId:T}):r.jsx(Us,{items:E.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:L,dirtySkillIds:j})}),r.jsx($s,{label:ae.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${T}-available-personal-collapsed`,count:E.availablePersonal.total,filteredCount:A?E.availablePersonal.filtered:null,updateCount:x==null?void 0:x.global,children:E.availablePersonal.filtered===0?r.jsx(LC,{queryActive:!!A,agentId:T}):r.jsx(Us,{items:E.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:L,dirtySkillIds:j})}),O&&r.jsxs($s,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-available-plugin-collapsed`,count:E.availablePlugin.total,filteredCount:A?E.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…"]}),E.availablePlugin.filtered===0?r.jsx(MC,{queryActive:!!A,hasInstalled:E.availablePlugin.total>0}):E.availablePlugin.byPlugin.map(([ie,Z])=>r.jsx($d,{pluginName:ie,skills:Z,persistKey:`vskill-plugin-available-${ie}-collapsed`,headerActionSlot:O?r.jsx(mC,{pluginName:ie,enabled:H.get(ie)??!0}):void 0,renderSkill:me=>r.jsx(Ys,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:j==null?void 0:j.has(`${me.plugin}/${me.skill}`)})},`available-${ie}`))]})]}),r.jsx(_C,{}),r.jsx(Gg,{name:ae.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:ue?!1:ee,onToggle:$,count:E.authoringProject.total+E.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"}}))}}}),(!ee||ue)&&r.jsxs(r.Fragment,{children:[r.jsx($s,{label:ae.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${T}-authoring-project-collapsed`,count:E.authoringProject.total,filteredCount:A?E.authoringProject.filtered:null,updateCount:(x==null?void 0:x.own)??(f==null?void 0:f.source),forceOpen:(ue==null?void 0:ue.bucket)==="project",children:E.authoringProject.filtered===0?r.jsx(qg,{queryActive:!!A}):r.jsxs(r.Fragment,{children:[E.authoringCandidatePlugins.map(ie=>r.jsx($d,{pluginName:ie.groupKey,skills:ie.skills,persistKey:`vskill-candidate-plugin-${ie.groupKey}-collapsed`,headerActionSlot:r.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),w({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})},title:"Write .claude-plugin/plugin.json into this folder so Claude Code recognizes it as a plugin",style:{fontSize:10,fontWeight:500,padding:"2px 8px",borderRadius:10,border:"1px solid var(--border-subtle, rgba(128,128,128,0.3))",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Not a plugin yet · Convert →"}),renderSkill:Z=>r.jsx(Ys,{skill:Z,isSelected:(a==null?void 0:a.plugin)===Z.plugin&&(a==null?void 0:a.skill)===Z.skill,onSelect:()=>s(Z),onContextMenu:d,dirty:j==null?void 0:j.has(`${Z.plugin}/${Z.skill}`)})},`candidate-${ie.groupKey}`)),r.jsx(Us,{items:E.authoringProject.byPlugin.filter(([ie])=>!E.authoringCandidatePlugins.some(Z=>Z.groupKey===ie)),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:L,dirtySkillIds:j})]})}),O&&r.jsx($s,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-authoring-plugin-collapsed`,count:E.authoringPlugin.total,filteredCount:A?E.authoringPlugin.filtered:null,forceOpen:(ue==null?void 0:ue.bucket)==="plugin",children:E.authoringPlugin.filtered===0?r.jsx(zC,{queryActive:!!A,hasSources:E.authoringPlugin.total>0,candidates:E.authoringCandidatePlugins,onPromote:ie=>w({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})}):E.authoringPlugin.byPlugin.map(([ie,Z])=>r.jsx($d,{pluginName:ie,skills:Z,persistKey:`vskill-plugin-authoring-${ie}-collapsed`,forceOpen:(ue==null?void 0:ue.bucket)==="plugin"&&ue.pluginName===ie,renderSkill:me=>r.jsx(Ys,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:j==null?void 0:j.has(`${me.plugin}/${me.skill}`)})},`authoring-${ie}`))})]})]}),!i&&!c&&!N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Wg,{origin:"source",count:W.total,filteredCount:A?W.filtered:null,updateCount:f==null?void 0:f.source,children:W.filtered===0?r.jsx(qg,{queryActive:!!A}):r.jsx(Us,{items:W.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:L,dirtySkillIds:j})}),r.jsx(DC,{}),r.jsx(Wg,{origin:"installed",count:Y.total,filteredCount:A?Y.filtered:null,updateCount:f==null?void 0:f.installed,children:Y.filtered===0?r.jsx(Yg,{queryActive:!!A}):r.jsx(Us,{items:Y.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:L,dirtySkillIds:j})})]}),C&&r.jsx(xC,{anchorSkillDir:C.anchorSkillDir,candidateLabel:C.candidateLabel,initialName:C.initialName,onCancel:()=>w(null),onConverted:ie=>{w(null),k==null||k(),ie.validation==="skipped"&&window.alert("Plugin manifest written, but schema validation was skipped because the 'claude' CLI is not on PATH. Install Claude Code to enable plugin schema validation.")}})]})}function yf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function $s({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[h,x]=m.useState(()=>yf(a)),v=d?!1:h,y=m.useCallback(()=>{x(j=>{const k=!j;if(typeof window<"u")try{window.localStorage.setItem(a,String(k))}catch{}return k})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,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:v?"▸":"▾"}),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:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!v&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function AC(t){const a=[];for(const[s,i]of t){const c=[...i].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 Us({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=AC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Iw,{overscan:4,totalCount:d.length,itemContent:f=>{const h=d[f];if(!h)return null;if(h.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:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const x=h.skill,v=!!a&&a.plugin===x.plugin&&a.skill===x.skill;return r.jsx(Ys,{skill:x,isSelected:v,onSelect:()=>s(x),onContextMenu:i,dirty:u==null?void 0:u.has(`${x.plugin}/${x.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>r.jsx(dC,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function qg({queryActive:t}){return t?r.jsx(br,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(br,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Ul,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Yg({queryActive:t,agentId:a}){return t?r.jsx(br,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(br,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Ul,{children:"vskill install <skill>"})," to add one."]})})}function LC({queryActive:t,agentId:a}){return t?r.jsx(br,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(br,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Ul,{children:"vskill install --global <skill>"})," to add one."]})})}function MC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(br,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(br,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx(Ul,{children:"Browse marketplaces…"})," above to add one."]})})}function zC({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?r.jsx(br,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsxs(r.Fragment,{children:[r.jsx(br,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx(Ul,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",r.jsx(Ul,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&r.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>r.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(c),title:`Promote ${c.groupKey}/ to a Claude Code plugin`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"6px 8px",fontSize:12,background:"transparent",border:"1px dashed var(--border-subtle, rgba(128,128,128,0.35))",borderRadius:4,color:"var(--text-primary)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)"},children:[r.jsxs("span",{children:[c.groupKey,"/ ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),r.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function br({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 Ul({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 DC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function _C(){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 OC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(vC,{},t))})}function BC({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:IC(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 IC(t){const a=t.split(`
|
|
66
|
+
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const Py=240,Vy=480,Fy="vskill-sidebar-width",Ks=320;function Yf(t){return Number.isFinite(t)?Math.round(Math.max(Py,Math.min(Vy,t))):Ks}function $C(){try{const t=localStorage.getItem(Fy);if(!t)return Ks;const a=Number(t);return Number.isFinite(a)?Yf(a):Ks}catch{return Ks}}function UC(t){try{localStorage.setItem(Fy,String(Yf(t)))}catch{}}function HC({initialWidth:t,onChange:a}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),i=m.useRef(t);return m.useEffect(()=>{i.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const f=d.clientX-s.current.startX,h=Yf(s.current.startWidth+f);i.current=h,a(h)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,UC(i.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":Py,"aria-valuemax":Vy,"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=i.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 PC=/^[ MADRCU?!]{1,2} +/;function VC(t){return t.replace(PC,"")}function FC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function WC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>VC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const f=FC(s,d);if(f===null)continue;const h=`${u.plugin}/${u.skill}`;if(f===""){c.length>0&&i.add(h);continue}const x=f+"/";for(const v of c)if(v===f||v.startsWith(x)){i.add(h);break}}return i}const GC=5e3;function qC(t,a,s=GC){const[i,c]=m.useState([]),u=m.useRef(t);return u.current=t,m.useEffect(()=>{if(!a){c([]);return}let d=!1,f=null;const h=async()=>{try{const v=await ke.gitStatus();d||c(v.paths??[])}catch{d||c([])}d||(f=setTimeout(h,s))};h();const x=()=>{h()};return typeof window<"u"&&window.addEventListener("studio:content-saved",x),()=>{d=!0,f&&clearTimeout(f),typeof window<"u"&&window.removeEventListener("studio:content-saved",x)}},[a,s]),a?WC(u.current,i,a):new Set}function YC({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 Wy(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 Gy(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,(i,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 Pd(){const[t,a]=m.useState([]),[s,i]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(null),h=m.useRef(null),x=m.useCallback(async(y,b)=>{a([]),i(!0),u(!1),f(null);const j=new AbortController;h.current=j;try{const k=Gy(b),C=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:j.signal});if(!C.ok||!C.body){let B=`HTTP ${C.status}`,M;try{M=await C.json(),M&&typeof M=="object"&&"error"in M&&typeof M.error=="string"&&(B=M.error)}catch{}throw Wy(C.status,M),new Error(B)}const w=C.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:M}=await w.read();if(B)break;T+=N.decode(M,{stream:!0});const P=T.split(`
|
|
67
|
+
`);T=P.pop()||"";for(const E of P)if(E.startsWith("event: "))A=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),z={event:A,data:O};A==="done"?(u(!0),a(_=>[..._,z])):a(_=>[..._,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&f(k.message)}finally{i(!1),h.current=null}},[]),v=m.useCallback(()=>{var y;(y=h.current)==null||y.abort()},[]);return{events:t,running:s,done:c,error:d,start:x,stop:v}}function KC(t){const a=m.useRef(t);a.current=t;const[s,i]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(x,v,y)=>{var j;(j=c.current.get(x))==null||j.abort();const b=new AbortController;c.current.set(x,b),i(k=>{const C=new Set(k);return C.add(x),C});try{const k=Gy(y),C=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!C.ok||!C.body){let B=`HTTP ${C.status}`,M;try{M=await C.json(),M&&typeof M=="object"&&"error"in M&&typeof M.error=="string"&&(B=M.error)}catch{}throw Wy(C.status,M),new Error(B)}const w=C.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:M}=await w.read();if(B)break;T+=N.decode(M,{stream:!0});const P=T.split(`
|
|
68
|
+
`);T=P.pop()||"";for(const E of P)if(E.startsWith("event: "))A=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),z={event:A,data:O};a.current.onEvent(x,z)}catch{}A=""}}a.current.onDone(x)}catch(k){k.name!=="AbortError"&&a.current.onError(x,k.message)}finally{i(k=>{const C=new Set(k);return C.delete(x),C}),c.current.delete(x)}},[]),d=m.useCallback(x=>{var v;(v=c.current.get(x))==null||v.abort()},[]),f=m.useCallback(()=>{for(const x of c.current.values())x.abort()},[]),h=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:f,isAnyCaseRunning:h}}const XC={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,activationPromptsSource:null,activationPromptsCanonical:"",savingTestCases:!1,savingTestCasesError:null,savingTestCasesSuccess:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function QC(t,a){var s,i;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(f=>({assertion_id:f.id,text:f.text,pass:f.pass,reasoning:f.reasoning}))});const u=((i=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:i.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":{const c=a.prompts===t.activationPromptsCanonical;return{...t,activationPrompts:a.prompts,activationPromptsSource:c?t.activationPromptsSource:t.activationPromptsSource===null||t.activationPromptsSource==="skill-md"||t.activationPromptsSource==="ai-generated"?"user-typed":t.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...t,activationPromptsSource:a.source,activationPromptsCanonical:a.canonical??t.activationPromptsCanonical};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"SAVE_TEST_CASES_START":return{...t,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...t,savingTestCases:!1,savingTestCasesSuccess:`Saved ${a.count} test case${a.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:t.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...t,savingTestCases:!1,savingTestCasesError:a.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...t,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function ZC(t,a){if(!t)return{canEdit:!1,canRun:!1};const s=t.origin==="source",i=a.exists&&a.cases.length>0;return{canEdit:s,canRun:i}}function JC(t){if(t==="unit"||t==="integration")return t}function eE(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 i={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===i.assertion_id)||t.assertions.push(i)}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 qy=m.createContext(null);function bn(){const t=m.useContext(qy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function tE({plugin:t,skill:a,origin:s,children:i}){var ft;const c=s==="installed",{config:u}=qa(),[d,f]=m.useReducer(QC,{...XC,plugin:t,skill:a}),h=ZC({origin:s},{exists:d.evals!=null,cases:((ft=d.evals)==null?void 0:ft.evals)??[]}),x=h.canEdit,v=h.canRun,y=m.useRef(new Set),b=m.useRef(new Set),j=m.useRef(new Map),k=m.useCallback((ce,ve)=>{let ye=j.current.get(ce);ye||(ye={assertions:[]},j.current.set(ce,ye)),eE(ye,ve),f({type:"UPDATE_INLINE_RESULT",evalId:ce,result:{...ye,assertions:[...ye.assertions]}})},[]),C=m.useCallback(ce=>{if(b.current.has(ce))return;b.current.add(ce);const ve=j.current.get(ce)??{assertions:[]};f({type:"CASE_RUN_COMPLETE",caseId:ce,result:{...ve,assertions:[...ve.assertions]}}),y.current.has(ce)&&(y.current.delete(ce),y.current.size===0&&ke.getLatestBenchmark(t,a).then(ye=>f({type:"BULK_RUN_COMPLETE",benchmark:ye})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),w=m.useCallback((ce,ve)=>{b.current.has(ce)||(b.current.add(ce),f({type:"CASE_RUN_ERROR",caseId:ce,error:ve}),y.current.has(ce)&&(y.current.delete(ce),y.current.size===0&&ke.getLatestBenchmark(t,a).then(ye=>f({type:"BULK_RUN_COMPLETE",benchmark:ye})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:N,stopCase:T,stopAll:A}=KC({onEvent:k,onDone:C,onError:w});m.useEffect(()=>()=>{A()},[A]);const B=m.useCallback(async()=>{try{const ce=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ce.ok){if(ce.status===404){f({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const ve=await ce.json();f({type:"ACTIVATION_HISTORY_LOADED",runs:ve.runs||[]})}catch{}},[t,a]);m.useEffect(()=>{let ce=!1;async function ve(){try{const[ye,be,Ne]=await Promise.allSettled([ke.getSkillDetail(t,a),ke.getEvals(t,a),ke.getLatestBenchmark(t,a)]);if(ce)return;let qe=null,He=null;if(be.status==="fulfilled")qe=be.value;else{const jt=be.reason;He=(jt==null?void 0:jt.message)??"Failed to load test cases"}f({type:"INIT_DATA",skillContent:ye.status==="fulfilled"?ye.value.skillContent:"",evals:qe,evalsError:He,benchmark:Ne.status==="fulfilled"?Ne.value:null})}catch(ye){ce||f({type:"SET_ERROR",error:ye.message})}}return ve(),B(),()=>{ce=!0}},[t,a,B]);const M=m.useCallback(async ce=>{if(c)return;const ve=ce??d.skillContent;try{await ke.applyImprovement(t,a,ve),ce!==void 0&&ce!==d.skillContent&&f({type:"SET_CONTENT",content:ce}),f({type:"CONTENT_SAVED"})}catch(ye){f({type:"SET_ERROR",error:ye.message})}},[c,t,a,d.skillContent]),P=m.useCallback(async ce=>{if(!c)try{const ve=await ke.saveEvals(t,a,ce);f({type:"SET_EVALS",evals:ve})}catch(ve){f({type:"SET_ERROR",error:ve.message})}},[c,t,a]),E=m.useCallback((ce,ve="benchmark")=>{const ye=d.caseRunStates.get(ce);if((ye==null?void 0:ye.status)==="running")return;j.current.delete(ce),b.current.delete(ce),f({type:"CASE_RUN_START",caseId:ce,mode:ve});const be=ve==="comparison"?{eval_ids:[ce]}:ve==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(be.provider=u.provider),u!=null&&u.model&&(be.model=u.model),ve==="comparison"){const Ne=`/api/skills/${t}/${a}/compare`;N(ce,Ne,be)}else{const Ne=`/api/skills/${t}/${a}/benchmark/case/${ce}`;N(ce,Ne,Object.keys(be).length>0?be:void 0)}},[t,a,d.caseRunStates,N,u]),O=m.useCallback((ce="benchmark")=>{var be;const ve=((be=d.evals)==null?void 0:be.evals)??[];if(ve.length===0)return;const ye=ve.map(Ne=>Ne.id);for(const Ne of ye)j.current.delete(Ne),b.current.delete(Ne);f({type:"BULK_RUN_START",caseIds:ye,mode:ce}),y.current=new Set(ye);for(const Ne of ye){const qe=ce==="comparison"?{eval_ids:[Ne]}:ce==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(qe.provider=u.provider),u!=null&&u.model&&(qe.model=u.model),ce==="comparison")N(Ne,`/api/skills/${t}/${a}/compare`,qe);else{const He=`/api/skills/${t}/${a}/benchmark/case/${Ne}`;N(Ne,He,Object.keys(qe).length>0?qe:void 0)}}},[t,a,d.evals,N,u]),z=m.useCallback(ce=>{T(ce),f({type:"CASE_RUN_CANCEL",caseId:ce}),y.current.delete(ce),b.current.add(ce)},[T]),_=m.useCallback(()=>{A(),f({type:"CANCEL_ALL"}),y.current.clear()},[A]),H=m.useCallback(async(ce,ve)=>{f({type:"OPEN_IMPROVE",evalId:ce})},[]),F=m.useCallback(async(ce,ve)=>{try{await ke.applyImprovement(t,a,ve),f({type:"SET_CONTENT",content:ve}),f({type:"CONTENT_SAVED"}),f({type:"CLOSE_IMPROVE"}),E(ce,"benchmark")}catch(ye){f({type:"SET_ERROR",error:ye.message})}},[t,a,E]),q=Pd(),ee=m.useRef(null),U=m.useRef(0);m.useEffect(()=>{const ce=q.events;for(let ve=U.current;ve<ce.length;ve++){const ye=ce[ve],be=ye.data;if(ye.event==="progress"&&f({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),ye.event==="done"){const Ne=be.improved,qe=be.reasoning,He=be.evalChanges??[];f({type:"AI_EDIT_RESULT",improved:Ne,reasoning:qe,evalChanges:He})}if(ye.event==="error"){const Ne=be;f({type:"AI_EDIT_ERROR",message:Ne.description||"Unknown error",classified:Ne})}}U.current=ce.length},[q.events]),m.useEffect(()=>{q.error&&f({type:"AI_EDIT_ERROR",message:q.error})},[q.error]),m.useEffect(()=>()=>{q.stop()},[q.stop]);const D=m.useCallback(async(ce,ve,ye)=>{c||(U.current=0,f({type:"AI_EDIT_LOADING"}),ee.current=q.stop,q.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ce,content:d.skillContent,evals:d.evals??{skill_name:a,evals:[]},provider:ve,model:ye}))},[c,t,a,d.skillContent,d.evals,q]),$=m.useCallback(()=>{q.stop(),f({type:"AI_EDIT_ERROR",message:"Cancelled"})},[q]),W=m.useCallback(async()=>{const ce=d.aiEditResult;if(ce!=null&&ce.improved)try{if(await ke.applyImprovement(t,a,ce.improved),f({type:"SET_CONTENT",content:ce.improved}),f({type:"CONTENT_SAVED"}),d.aiEditEvalChanges.length>0&&Array.from(d.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:ye}=await Fl(async()=>{const{mergeEvalChanges:qe}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:qe}},[]),be=d.evals??{skill_name:a,evals:[]},Ne=ye(be,d.aiEditEvalChanges,d.aiEditEvalSelections);try{const qe=await ke.saveEvals(t,a,Ne);f({type:"SET_EVALS",evals:qe})}catch(qe){f({type:"SET_EVALS_RETRY",evalsFile:Ne}),f({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${qe.message}. You can retry from the AI Edit panel.`});return}}f({type:"CLOSE_AI_EDIT"})}catch(ve){f({type:"SET_ERROR",error:ve.message})}},[t,a,d.aiEditResult,d.evals,d.aiEditEvalChanges,d.aiEditEvalSelections]),Y=m.useCallback(()=>{f({type:"CLOSE_AI_EDIT"})},[]),oe=m.useCallback(ce=>{f({type:"TOGGLE_EVAL_CHANGE",index:ce})},[]),L=m.useCallback(()=>{f({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=m.useCallback(()=>{f({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),K=m.useCallback(async()=>{const ce=d.aiEditEvalsRetry;if(ce)try{const ve=await ke.saveEvals(t,a,ce);f({type:"SET_EVALS",evals:ve}),f({type:"SET_ERROR",error:null}),f({type:"CLOSE_AI_EDIT"})}catch(ve){f({type:"SET_ERROR",error:`Retry failed: ${ve.message}`})}},[t,a,d.aiEditEvalsRetry]),Q=m.useCallback(async()=>{try{const ce=await ke.getSkillDetail(t,a);f({type:"SET_CONTENT",content:ce.skillContent}),f({type:"CONTENT_SAVED"})}catch{}},[t,a]),ue=Pd(),J=m.useRef(0);m.useEffect(()=>{const ce=ue.events;for(let ve=J.current;ve<ce.length;ve++){const ye=ce[ve],be=ye.data;if(ye.event==="progress"&&f({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),ye.event==="done"){const Ne=be;ke.saveEvals(t,a,Ne).then(qe=>f({type:"GENERATE_EVALS_DONE",evals:qe})).catch(qe=>f({type:"SET_ERROR",error:qe.message}))}ye.event==="error"&&f({type:"GENERATE_EVALS_ERROR",classified:be})}J.current=ce.length},[ue.events,t,a]),m.useEffect(()=>{ue.error&&f({type:"SET_ERROR",error:ue.error})},[ue.error]),m.useEffect(()=>()=>{ue.stop()},[ue.stop]);const ie=m.useCallback(async ce=>{if(c)return;J.current=0,f({type:"GENERATE_EVALS_START"});const ve={};u!=null&&u.provider&&(ve.provider=u.provider),u!=null&&u.model&&(ve.model=u.model);const ye=JC(ce==null?void 0:ce.testType);ye&&(ve.testType=ye),ue.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(ve).length>0?ve:void 0)},[c,t,a,ue,u]),Z=Pd(),me=m.useRef(0);m.useEffect(()=>()=>{Z.stop()},[Z.stop]),m.useEffect(()=>{const ce=Z.events;for(let ve=me.current;ve<ce.length;ve++){const ye=ce[ve];if(ye.event==="classifying"){const be=ye.data;f({type:"ACTIVATION_CLASSIFYING",index:be.index,total:be.total})}if(ye.event==="prompt_result"&&f({type:"ACTIVATION_RESULT",result:ye.data}),ye.event==="done"){je.current&&(clearTimeout(je.current),je.current=null);const be=ye.data;if(be.error)f({type:"ACTIVATION_ERROR",error:be.error});else{f({type:"ACTIVATION_DONE",summary:be});const Ne={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(u==null?void 0:u.model)||"unknown",provider:(u==null?void 0:u.provider)||"unknown",promptCount:be.total,summary:{precision:be.precision,recall:be.recall,reliability:be.reliability,tp:be.tp,tn:be.tn,fp:be.fp,fn:be.fn}};f({type:"ACTIVATION_HISTORY_LOADED",runs:[Ne,...d.activationHistory??[]]})}}}me.current=ce.length},[Z.events,u,d.activationHistory]),m.useEffect(()=>{Z.error&&(je.current&&(clearTimeout(je.current),je.current=null),f({type:"ACTIVATION_ERROR",error:Z.error}))},[Z.error]);const je=m.useRef(null),Te=m.useCallback(()=>{je.current&&(clearTimeout(je.current),je.current=null),Z.stop(),f({type:"ACTIVATION_CANCEL",totalPrompts:0})},[Z]),Me=m.useCallback(ce=>{const ye=ce.trim().split(`
|
|
69
|
+
`).filter(Boolean).map(Ne=>Ne.startsWith("!")?{prompt:Ne.slice(1).trim(),expected:"should_not_activate"}:Ne.startsWith("+")?{prompt:Ne.slice(1).trim(),expected:"should_activate"}:{prompt:Ne.trim(),expected:"auto"});me.current=0,f({type:"ACTIVATION_START"}),f({type:"SET_ACTIVATION_PROMPTS",prompts:ce});const be={prompts:ye};u!=null&&u.provider&&(be.provider=u.provider),u!=null&&u.model&&(be.model=u.model),Z.start(`/api/skills/${t}/${a}/activation-test`,be),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{Z.stop(),f({type:"ACTIVATION_TIMEOUT"}),je.current=null},12e4)},[t,a,Z,u]),Fe=m.useCallback(async(ce=8)=>{f({type:"GENERATE_PROMPTS_START"});try{const ve={count:ce};u!=null&&u.provider&&(ve.provider=u.provider),u!=null&&u.model&&(ve.model=u.model);const ye=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ve)});if(!ye.ok){let St=`HTTP ${ye.status}`;try{const Lt=await ye.json();Lt.error&&(St=Lt.error)}catch{}throw new Error(St)}const be=ye.body.getReader(),Ne=new TextDecoder;let qe="",He="",jt=[];for(;;){const{done:St,value:Lt}=await be.read();if(St)break;qe+=Ne.decode(Lt,{stream:!0});const xe=qe.split(`
|
|
70
|
+
`);qe=xe.pop()||"";for(const Ze of xe)if(Ze.startsWith("event: "))He=Ze.slice(7).trim();else if(Ze.startsWith("data: ")){try{const Xe=JSON.parse(Ze.slice(6));if(He==="done"){if(Xe.error)throw new Error(Xe.error);jt=Xe.prompts||[]}if(He==="error")throw new Error(Xe.message||Xe.description||"Generation failed")}catch(Xe){if(!(Xe instanceof SyntaxError))throw Xe}He=""}}const Ot=jt.map(St=>`${St.expected==="should_activate"?"+":"!"}${St.prompt}`).join(`
|
|
71
|
+
`);f({type:"SET_PROMPTS_SOURCE",source:"ai-generated",canonical:Ot}),f({type:"SET_ACTIVATION_PROMPTS",prompts:Ot}),f({type:"GENERATE_PROMPTS_DONE"})}catch(ve){f({type:"GENERATE_PROMPTS_ERROR",error:ve.message})}},[t,a,u]),Ue=m.useCallback(async()=>{try{const ce=await fetch(`/api/skills/${t}/${a}/test-cases`);if(!ce.ok)return;const ve=await ce.json();if(!ve.prompts||ve.prompts.length===0)return;const ye=ve.prompts.map(be=>be.expected==="should_activate"?`+${be.prompt}`:be.expected==="should_not_activate"?`!${be.prompt}`:be.prompt).join(`
|
|
72
|
+
`);f({type:"SET_PROMPTS_SOURCE",source:"skill-md",canonical:ye}),f({type:"SET_ACTIVATION_PROMPTS",prompts:ye})}catch{}},[t,a]),De=m.useCallback(async()=>{f({type:"SAVE_TEST_CASES_START"});try{const ve=d.activationPrompts.split(`
|
|
73
|
+
`).map(Ne=>Ne.trim()).filter(Boolean).map(Ne=>Ne.startsWith("!")?{prompt:Ne.slice(1).trim(),expected:"should_not_activate"}:Ne.startsWith("+")?{prompt:Ne.slice(1).trim(),expected:"should_activate"}:{prompt:Ne,expected:"auto"}),ye=await fetch(`/api/skills/${t}/${a}/test-cases`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompts:ve})}),be=await ye.json().catch(()=>({}));if(!ye.ok||!be.ok)throw new Error(be.error||`HTTP ${ye.status}`);f({type:"SAVE_TEST_CASES_SUCCESS",count:be.count??ve.length}),setTimeout(()=>f({type:"CLEAR_SAVE_TEST_CASES_FEEDBACK"}),3e3)}catch(ce){f({type:"SAVE_TEST_CASES_ERROR",error:ce.message})}},[t,a,d.activationPrompts]),We=m.useMemo(()=>({state:d,dispatch:f,isReadOnly:c,canEdit:x,canRun:v,saveContent:M,saveEvals:P,runCase:E,runAll:O,cancelCase:z,cancelAll:_,improveForCase:H,applyImproveAndRerun:F,refreshSkillContent:Q,generateEvals:ie,runActivationTest:Me,cancelActivation:Te,generateActivationPrompts:Fe,fetchActivationHistory:B,loadTestCasesFromSkillMd:Ue,saveTestCasesToSkillMd:De,submitAiEdit:D,cancelAiEdit:$,applyAiEdit:W,discardAiEdit:Y,toggleEvalChange:oe,selectAllEvalChanges:L,deselectAllEvalChanges:I,retryEvalsSave:K}),[d,c,x,v,M,P,E,O,z,_,H,F,Q,ie,Me,Te,Fe,B,Ue,De,D,$,W,Y,oe,L,I,K]);return r.jsx(qy.Provider,{value:We,children:i})}function Yy(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],i=a[2].trim(),c={},u=s.split(`
|
|
74
|
+
`);let d="",f=!1;for(const h of u){const x=h.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(x&&d&&f){const b=x[1],j=x[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!j)k[b]=[];else{const C=j.match(/^\[(.+)\]$/);C?k[b]=C[1].split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=j.replace(/^["']|["']$/g,"")}continue}const v=h.match(/^\s+-\s+(.+)$/);if(v&&d){f=!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=h.match(/^([\w-]+):\s*(.*)$/);if(y){d=y[1];const b=y[2].trim();if(f=!1,!b){c[d]={},f=!0;continue}const j=b.match(/^\[(.+)\]$/);if(j){c[d]=j[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:i}}function di(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=nE(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 nE(t){const a=t.split(`
|
|
75
|
+
`),s=[];let i=0;for(;i<a.length;)if(a[i].trim().startsWith("|")&&i+1<a.length&&a[i+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[i+1])){const c=Kg(a[i]);i+=2;const u=[];for(;i<a.length&&a[i].trim().startsWith("|");)u.push(Kg(a[i])),i++;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)"',f='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let h='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';h+="<thead><tr>";for(const x of c)h+=`<th ${d}>${x}</th>`;h+="</tr></thead><tbody>";for(const x of u){h+="<tr>";for(const v of x)h+=`<td ${f}>${v}</td>`;h+="</tr>"}h+="</tbody></table>",s.push(h)}else s.push(a[i]),i++;return s.join(`
|
|
76
|
+
`)}function Kg(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function dc(t,a){const s=t.split(`
|
|
77
|
+
`),i=a.split(`
|
|
78
|
+
`);if(s.length>1e3||i.length>1e3)return[...s.map(v=>({type:"unchanged",content:v}))];const c=s.length,u=i.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]===i[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 f=[];let h=c,x=u;for(;h>0||x>0;)h>0&&x>0&&s[h-1]===i[x-1]?(f.push({type:"unchanged",content:s[h-1]}),h--,x--):x>0&&(h===0||d[h][x-1]>=d[h-1][x])?(f.push({type:"added",content:i[x-1]}),x--):(f.push({type:"removed",content:s[h-1]}),h--);return f.reverse()}function rE(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 i=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:i.has(t)?"var(--accent)":"var(--green)"}})}function fi({entries:t,isRunning:a}){const[s,i]=m.useState(!1),c=m.useRef(null);return m.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:()=>i(!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 f=d===t.length-1&&a,h=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:f?1:.7},children:[rE(u.phase,f),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:h}),r.jsx("span",{style:{color:f?"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 Xg={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 fc({error:t,onRetry:a,onDismiss:s}){const[i,c]=m.useState(null),u=m.useRef(null);m.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),m.useEffect(()=>{if(!(i==null||i<=0))return u.current=setInterval(()=>{c(h=>h==null||h<=1?(u.current&&clearInterval(u.current),0):h-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[i!=null&&i>0]);const d=Xg[t.category]||Xg.unknown,f=i!=null&&i>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||i!=null)&&r.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&r.jsx("button",{onClick:a,disabled:f,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:f?.5:1},children:f?`Retry in ${i}s`:"Retry"})})]})]})}function aE({plugin:t,skill:a,skillContent:s,onApplied:i}){const[c,u]=m.useState("closed"),{config:d}=qa(),[f,h]=m.useState("claude-cli"),[x,v]=m.useState("opus"),[y,b]=m.useState([]),[j,k]=m.useState(""),[C,w]=m.useState(""),[N,T]=m.useState(null),[A,B]=m.useState(null),[M,P]=m.useState([]),[E,O]=m.useState(!1),z=m.useRef(null);m.useEffect(()=>{if(!d)return;d.providers.find($=>$.id==="claude-cli"&&$.available)&&(h("claude-cli"),v("opus"))},[d]),m.useEffect(()=>()=>{var D;(D=z.current)==null||D.abort()},[]);function _(){return d==null?void 0:d.providers.find(D=>D.id===f&&D.available)}const H=m.useCallback(()=>{var D;(D=z.current)==null||D.abort(),u("open")},[]);async function F(){u("loading"),T(null),B(null),P([]);const D=new AbortController;z.current=D;try{const $=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(a)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:f,model:x}),signal:D.signal});if(!$.ok||!$.body){let I=`HTTP ${$.status}`;try{const K=await $.json();K.error&&(I=K.error)}catch{}throw new Error(I)}const W=$.body.getReader(),Y=new TextDecoder;let oe="",L="";for(;;){const{done:I,value:K}=await W.read();if(I)break;oe+=Y.decode(K,{stream:!0});const Q=oe.split(`
|
|
79
|
+
`);oe=Q.pop()||"";for(const ue of Q)if(ue.startsWith("event: "))L=ue.slice(7).trim();else if(ue.startsWith("data: ")){try{const J=JSON.parse(ue.slice(6));L==="progress"?P(ie=>[...ie,{phase:J.phase,message:J.message,timestamp:Date.now()}]):L==="done"||L==="complete"?(k(J.improved),w(J.reasoning||""),b(dc(J.original||s,J.improved)),u("diff_shown")):L==="error"&&(T(J.message||J.description||"Unknown error"),J.category&&B(J),u("open"))}catch{}L=""}}}catch($){$.name!=="AbortError"&&(T($.message),u("open"))}finally{z.current=null}}async function q(){O(!0);try{await ke.applyImprovement(t,a,j),i(j),u("closed")}catch(D){T(D.message)}finally{O(!1)}}function ee(){u("closed"),b([]),k(""),w(""),T(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 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: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"})]})})]}),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:f,onChange:D=>{h(D.target.value);const $=d==null?void 0:d.providers.find(W=>W.id===D.target.value);$!=null&&$.models[0]&&v($.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(D=>D.available).map(D=>r.jsx("option",{value:D.id,children:D.label},D.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:x,onChange:D=>v(D.target.value),disabled:c==="loading",children:U==null?void 0:U.models.map(D=>r.jsx("option",{value:D.id,children:D.label},D.id))})]}),c==="loading"?r.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:F,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&M.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(fi,{entries:M,isRunning:!0})})]}),N&&r.jsx("div",{className:"mb-4",children:A?r.jsx(fc,{error:A,onRetry:F,onDismiss:()=>{T(null),B(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[C&&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: "}),C]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:y.map((D,$)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:D.type==="added"?"rgba(34,197,94,0.1)":D.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:D.type==="added"?"var(--green)":D.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:D.type==="added"?"3px solid var(--green)":D.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:D.type==="added"?"+":D.type==="removed"?"-":" "}),D.content]},$))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:q,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 Qg={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"}},lE={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function sE({change:t,index:a,selected:s,onToggle:i,originalEval:c}){var y;const[u,d]=m.useState(!1),f=Qg[t.action]??Qg.add,h=lE[t.action]??"var(--border-subtle)",x=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((y=t.eval)==null?void 0:y.name)??"Unnamed",v=m.useCallback(()=>i(a),[i,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 ${h}`,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:f.bg,color:f.color,padding:"1px 6px"},children:f.label}),r.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:x}),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(iE,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(oE,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(cE,{evalCase:c})]})]})}function iE({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(bf,{label:"Prompt",value:t.prompt}),r.jsx(bf,{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 oE({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 i=t.assertions??[],c=a.assertions??[],u=new Set(i.map(x=>x.text)),d=new Set(c.map(x=>x.text)),f=c.filter(x=>!u.has(x.text)),h=i.filter(x=>!d.has(x.text));return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(x=>r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:x.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:["- ",jf(x.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",jf(x.new,120)]})]})]},x.label)),(f.length>0||h.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:[h.map(x=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",x.text]},x.id)),f.map(x=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",x.text]},x.id))]})]}),s.length===0&&f.length===0&&h.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function cE({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(bf,{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 bf({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:jf(a,300)})]})}function jf(t,a){return t.length>a?t.slice(0,a)+"...":t}const Zg={remove:0,modify:1,add:2};function uE({changes:t,selections:a,currentEvals:s,onToggle:i,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((h,x)=>({change:h,originalIndex:x}));d.sort((h,x)=>(Zg[h.change.action]??2)-(Zg[x.change.action]??2));const f=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:["(",f,"/",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:h=>{h.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:h=>{h.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:h=>{h.currentTarget.style.background="var(--surface-3)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:h,originalIndex:x})=>r.jsx(sE,{change:h,index:x,selected:a.get(x)??!1,onToggle:i,originalEval:h.evalId!=null?s.find(v=>v.id===h.evalId):void 0},x))})]})}function dE(){var D;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:i,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:f,deselectAllEvalChanges:h,retryEvalsSave:x}=bn(),{aiEditLoading:v,aiEditResult:y,aiEditError:b,aiEditClassifiedError:j,aiEditProgress:k,aiEditEvalChanges:C,aiEditEvalSelections:w,aiEditEvalsRetry:N}=t,[T,A]=m.useState(""),{config:B}=qa(),[M,P]=m.useState("claude-cli"),[E,O]=m.useState("opus"),z=m.useRef(null);m.useEffect(()=>{var $;($=z.current)==null||$.focus()},[]),m.useEffect(()=>{if(!B)return;B.providers.find(W=>W.id==="claude-cli"&&W.available)&&(P("claude-cli"),O("opus"))},[B]);const _=B==null?void 0:B.providers.find($=>$.id===M&&$.available),H=m.useCallback(()=>{const $=T.trim();!$||v||s($,M,E)},[T,v,s,M,E]),F=m.useCallback($=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),H()),$.key==="Escape"&&($.preventDefault(),v?u():c())},[H,v,u,c]),q=m.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),ee=y?dc(t.skillContent,y.improved):[],U=((D=t.evals)==null?void 0:D.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:$=>{$.currentTarget.style.background="var(--surface-3)"},onMouseLeave:$=>{$.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:z,value:T,onChange:$=>A($.target.value),onKeyDown:F,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:M,onChange:$=>{P($.target.value);const W=B==null?void 0:B.providers.find(Y=>Y.id===$.target.value);W!=null&&W.models[0]&&O(W.models[0].id)},disabled:v,style:{width:"100%"},children:B==null?void 0:B.providers.filter($=>$.available).map($=>r.jsx("option",{value:$.id,children:$.label},$.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:$=>O($.target.value),disabled:v,style:{width:"100%"},children:_==null?void 0:_.models.map($=>r.jsx("option",{value:$.id,children:$.label},$.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:H,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),v&&k.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(fi,{entries:k,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:j?r.jsx(fc,{error:j,onRetry:q,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(($,W)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:$.type==="added"?"rgba(34,197,94,0.1)":$.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:$.type==="added"?"var(--green)":$.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:$.type==="added"?"3px solid var(--green)":$.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:$.type==="added"?"+":$.type==="removed"?"-":" "}),$.content]},W))}),r.jsx(uE,{changes:C,selections:w,currentEvals:U,onToggle:d,onSelectAll:f,onDeselectAll:h}),N&&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:x,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:i,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:q,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function fE(t,a){const[s,i]=m.useState([]),[c,u]=m.useState("SKILL.md"),[d,f]=m.useState(null),[h,x]=m.useState(!1),[v,y]=m.useState(null),[b,j]=m.useState(null),k=m.useCallback(async()=>{try{const N=await ke.getSkillFiles(t,a);i(N.files),j(null)}catch(N){i([]),j(N.message??"Unable to load skill files")}},[t,a]);m.useEffect(()=>{u("SKILL.md"),f(null),y(null),j(null),k()},[t,a,k]);const C=m.useCallback(async N=>{if(u(N),N==="SKILL.md"){f(null),y(null);return}x(!0),y(null);try{const T=await ke.getSkillFile(t,a,N);f(T)}catch(T){y(`Unable to open file: ${T.message}`),f(null)}finally{x(!1)}},[t,a]),w=m.useCallback(()=>{k()},[k]);return{files:s,activeFile:c,secondaryContent:d,loading:h,error:v,loadError:b,selectFile:C,refresh:w,isSkillMd:c==="SKILL.md"}}function pE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function mE(t){const a=[],s=new Map;for(const i of t){const c=i.path.split("/"),d={name:c[c.length-1],path:i.path,type:i.type,size:i.size,children:[]};s.set(i.path,d)}for(const i of t){const c=i.path.split("/");if(c.length===1){const u=s.get(i.path);u&&a.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),f=s.get(i.path);d&&f&&d.children.push(f)}}return a}function Ky({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 Xy(){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 hE(){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 xE(){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 Qy({node:t,depth:a,activeFile:s,onSelect:i}){const[c,u]=m.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(Ky,{expanded:c}),r.jsx(Xy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(f=>r.jsx(Qy,{node:f,depth:a+1,activeFile:s,onSelect:i},f.path))]}):r.jsxs("button",{onClick:()=>i(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(hE,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:pE(t.size)})]})}function gE({files:t,activeFile:a,onSelect:s,onRefresh:i,loadError:c}){const[u,d]=m.useState(!1),f=m.useMemo(()=>mE(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:()=>d(!u),children:[r.jsx(Ky,{expanded:u}),r.jsx(Xy,{}),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(),i()},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(xE,{})})]}),u&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:c?r.jsx("div",{style:{fontSize:11,color:"var(--text-warning, var(--text-tertiary))",padding:"4px 8px"},title:c,children:"Skill files not accessible from this workspace"}):f.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):f.map(h=>r.jsx(Qy,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function Lo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function vE(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function yE(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Jg({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 ev({content:t,fileType:a}){if(a==="json"){const s=vE(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:di(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 tv(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,i)=>`: <span style="color:#fb923c">${i}</span>`).replace(/:\s*(true|false|null)/g,(s,i)=>`: <span style="color:#a855f7">${i}</span>`)}catch{return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}}function bE({file:t,loading:a,error:s,viewMode:i,plugin:c,skill:u,onSaved:d,onDirtyChange:f}){const[h,x]=m.useState(i),[v,y]=m.useState(!1),[b,j]=m.useState(""),[k,C]=m.useState(!1),[w,N]=m.useState(null),T=i!==h?i:h;m.useEffect(()=>{f==null||f(v)},[v,f]);const A=m.useCallback(()=>{(t==null?void 0:t.content)!=null&&(j(t.content),y(!0))},[t]),B=m.useCallback(()=>{y(!1)},[]),M=m.useCallback(async()=>{if(!(!c||!u||!t)){C(!0);try{await ke.saveSkillFile(c,u,t.path,b),N("Saved"),y(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{C(!1)}}},[c,u,t,b,d]);if(m.useEffect(()=>{if(!v)return;const O=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),M())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[v,M]),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 (",Lo(t.size),") — cannot be displayed"]});const P=t.content??"",E=yE(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 ",Lo(512*1024)," — ",Lo(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:()=>x(O),style:{padding:"2px 8px",fontSize:11,background:T===O?"var(--accent-muted)":"none",color:T===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[Lo(t.size),c&&u&&!t.binary&&!v&&r.jsx("button",{onClick:A,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),v&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:M,disabled:k,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),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=>j(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:M,disabled:k,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&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(Jg,{content:P})}),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:tv(P)}}):r.jsx(ev,{content:P,fileType:E})})]}):T==="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:tv(P)}}):r.jsx(ev,{content:P,fileType:E}):r.jsx(Jg,{content:P})})]})}const jE=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,SE=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function kE(t){const a=t.trim();if(!a)throw new Error("normalizeRemoteUrl: empty input");let s=a.match(jE);if(s)return`https://github.com/${s[1]}/${s[2]}`;if(s=a.match(SE),s)return`https://github.com/${s[1]}/${s[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${t}`)}function Zy(t){const a=kE(t);return`https://verified-skill.com/submit?repo=${encodeURIComponent(a)}`}function nv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function wE({remoteUrl:t,fileCount:a,provider:s,model:i,onClose:c,defaultMode:u="manual"}){const[d,f]=m.useState(u),[h,x]=m.useState(""),[v,y]=m.useState(!1),[b,j]=m.useState(!1),[k,C]=m.useState(null),[w,N]=m.useState(null),T=m.useCallback(async()=>{y(!0),C(null);try{const ee=await ke.gitCommitMessage({provider:s,model:i});x(ee.message)}catch(ee){const U=ee instanceof Error?ee.message:String(ee);C(U)}finally{y(!1)}},[s,i]);m.useEffect(()=>{u==="ai"&&!h&&T()},[]);const A=m.useCallback(()=>{f("ai"),N(null),h.trim()||T()},[h,T]),B=m.useCallback(()=>{f("manual"),C(null)},[]),M=m.useCallback(async()=>{const ee=h.trim();if(!(!ee||b)){j(!0),N(null);try{const U=await ke.gitPublish({commitMessage:ee}),D=U.remoteUrl??t,$=Zy(D);window.open($,"_blank","noopener,noreferrer");const W=(U.commitSha??"").slice(0,7),Y=U.branch??"";nv(`Opening verified-skill.com — ${W} on ${Y}`,"info"),c()}catch(U){const D=U instanceof Error?U.message:String(U),$=D.length>200?D.slice(0,200)+"…":D;N($),nv(`Publish failed: ${$}`,"error")}finally{j(!1)}}},[h,b,t,c]),P=h.trim().length>0&&!b&&!v,E="#E6EDF3",O="#9CA3AF",z="rgba(255,255,255,0.12)",_="#0F1115",H={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:O,fontFamily:"var(--font-mono, monospace)",marginBottom:6,display:"block"},F={flex:1,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,fontFamily:"var(--font-mono, monospace)",background:"transparent",color:O,border:"none",cursor:"pointer",transition:"background 120ms ease, color 120ms ease"},q={...F,background:"rgba(255,255,255,0.08)",color:E,fontWeight:600};return r.jsxs(r.Fragment,{children:[r.jsx("div",{"aria-hidden":"true",onClick:b?void 0:c,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",zIndex:999,animation:"publishDrawerBackdropIn 150ms ease-out"}}),r.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:24,pointerEvents:"none"},children:r.jsxs("div",{role:"dialog","aria-label":"Publish","aria-modal":"true",style:{pointerEvents:"auto",width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"80vh",overflowY:"auto",background:"#1A1D24",border:`1px solid ${z}`,borderRadius:10,padding:24,boxShadow:"0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05)",color:E,fontFamily:"var(--font-mono, monospace)",animation:"publishDrawerIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[r.jsx("strong",{style:{fontSize:16,fontWeight:700,letterSpacing:"-0.01em",color:E,fontFamily:"var(--font-sans, var(--font-mono, sans-serif))"},children:"Publish skill"}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:b?void 0:c,disabled:b,style:{background:"none",border:"none",color:O,fontSize:22,lineHeight:1,cursor:b?"not-allowed":"pointer",padding:0,opacity:b?.4:1},children:"×"})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:O,fontVariantNumeric:"tabular-nums",marginBottom:18},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"#F59E0B",fontFamily:"monospace"},children:"▮"}),r.jsxs("span",{children:[a," file",a===1?"":"s"," changed"]})]}),r.jsx("div",{style:{height:1,background:z,margin:"0 -24px 18px"}}),r.jsx("span",{style:H,children:"Mode"}),r.jsxs("div",{role:"tablist","aria-label":"Commit message mode","data-testid":"publish-mode-toggle",style:{display:"flex",border:`1px solid ${z}`,borderRadius:6,overflow:"hidden",marginBottom:16,background:_},children:[r.jsx("button",{type:"button",role:"tab","aria-selected":d==="manual","data-testid":"publish-mode-manual",onClick:B,disabled:b,style:d==="manual"?q:F,children:"Write yourself"}),r.jsx("div",{style:{width:1,background:z}}),r.jsx("button",{type:"button",role:"tab","aria-selected":d==="ai","data-testid":"publish-mode-ai",onClick:A,disabled:b,style:d==="ai"?q:F,children:v&&d==="ai"?"Generating…":"Generate with AI"})]}),r.jsx("label",{htmlFor:"commit-message",style:H,children:"Commit message"}),r.jsx("textarea",{id:"commit-message",value:h,onChange:ee=>x(ee.target.value),rows:5,disabled:v||b,placeholder:v?"Generating with AI…":d==="ai"?"Click Generate to draft a message":"Type your commit message…",style:{width:"100%",background:_,border:`1px solid ${z}`,borderRadius:6,padding:"10px 12px",fontFamily:"var(--font-mono, monospace)",fontSize:13,lineHeight:1.6,color:E,resize:"vertical",outline:"none"}}),d==="ai"&&r.jsx("button",{type:"button",onClick:T,disabled:v||b,"data-testid":"publish-generate-button",style:{marginTop:10,padding:"8px 14px",background:v?"rgba(255,255,255,0.06)":"#2563EB",color:v?O:"#FFFFFF",border:"1px solid "+(v?z:"#2563EB"),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:600,cursor:v||b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:v?"Generating…":"Generate with AI"}),k&&d==="ai"&&r.jsxs("div",{role:"alert","data-testid":"publish-error-generate",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[r.jsx("strong",{style:{fontWeight:600},children:"AI generation failed."})," ",k," ",r.jsx("button",{type:"button",onClick:T,disabled:v,style:{background:"none",border:"none",color:"var(--color-accent)",cursor:v?"not-allowed":"pointer",fontFamily:"inherit",fontSize:"inherit",textDecoration:"underline",padding:0},children:"Retry"})]}),w&&r.jsxs("div",{role:"alert","data-testid":"publish-error-push",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[r.jsx("strong",{style:{fontWeight:600},children:"Publish failed."})," ",w]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:18,gap:6},children:[r.jsx("div",{style:{minHeight:28},children:d==="ai"&&r.jsx("button",{type:"button","aria-label":"Regenerate",onClick:T,disabled:v||b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:v?"Generating…":"Regenerate"})}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{type:"button","aria-label":"Cancel",onClick:c,disabled:b,style:{padding:"8px 14px",background:"transparent",color:E,border:`1px solid ${z}`,borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:500,cursor:b?"not-allowed":"pointer",opacity:b?.5:1},children:"Cancel"}),r.jsx("button",{type:"button","aria-label":"Commit & Push",onClick:M,disabled:!P,"data-testid":"publish-commit-push",style:{padding:"8px 16px",background:P?"#22C55E":"rgba(255,255,255,0.06)",color:P?"#0B0F12":O,border:"1px solid "+(P?"#22C55E":z),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:700,cursor:P?"pointer":"not-allowed"},children:b?"Publishing…":"Commit & Push"})]})]})]})}),r.jsx("style",{children:`
|
|
80
|
+
@keyframes publishDrawerBackdropIn { from { opacity: 0 } to { opacity: 1 } }
|
|
81
|
+
@keyframes publishDrawerIn {
|
|
82
|
+
from { opacity: 0; transform: translateY(4px) }
|
|
83
|
+
to { opacity: 1; transform: translateY(0) }
|
|
84
|
+
}
|
|
85
|
+
@media (prefers-reduced-motion: reduce) {
|
|
86
|
+
[role="dialog"][aria-label="Publish"],
|
|
87
|
+
[role="dialog"][aria-label="Publish"] + * { animation: none !important }
|
|
88
|
+
}
|
|
89
|
+
`})]})}function rv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Jy({remoteUrl:t,provider:a,model:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(!1),[f,h]=m.useState(0),x=m.useCallback(async()=>{if(!(i||u)){c(!0);try{let y=!1,b=0;try{const T=await ke.gitDiff();y=!!T.hasChanges,b=T.fileCount??0}catch{}if(y){h(b),d(!0);return}const j=await ke.gitPublish(),k=j.remoteUrl??t,C=Zy(k);window.open(C,"_blank","noopener,noreferrer");const w=(j.commitSha??"").slice(0,7),N=j.branch??"";rv(`Opening verified-skill.com — ${w} on ${N}`,"info")}catch(y){const b=y instanceof Error?y.message:String(y),j=b.length>200?b.slice(0,200)+"…":b;rv(`Publish failed: ${j}`,"error")}finally{c(!1)}}},[i,u,t]),v=m.useCallback(()=>d(!1),[]);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Publish",onClick:x,disabled:i,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},title:"Push committed changes and open verified-skill.com to submit",children:i?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Publishing…"]}):"Publish"}),u&&r.jsx(wE,{remoteUrl:t,fileCount:f,provider:a,model:s,onClose:v})]})}const CE={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function EE(){const[t,a]=m.useState(CE);return m.useEffect(()=>{let s=!1;return ke.gitRemote().then(i=>{s||a({hasRemote:!!i.hasRemote,remoteUrl:i.remoteUrl??null,branch:i.branch??null,loading:!1,error:null})}).catch(i=>{s||a({hasRemote:!1,remoteUrl:null,branch:null,loading:!1,error:i instanceof Error?i:new Error(String(i))})}),()=>{s=!0}},[]),t}const NE=/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Sf(t){if(typeof t!="string")return null;const a=t.trim().match(NE);return a?{major:Number(a[1]),minor:Number(a[2]),patch:Number(a[3])}:null}function Vs(t,a){const s=Sf(t);if(!s)throw new Error(`bumpVersion: not a valid semver: ${JSON.stringify(t)}`);switch(a){case"patch":return`${s.major}.${s.minor}.${s.patch+1}`;case"minor":return`${s.major}.${s.minor+1}.0`;case"major":return`${s.major+1}.0.0`}}function TE(t,a){const s=Sf(a);if(!s)return{valid:!1,reason:`Invalid semver: ${JSON.stringify(a)}`};if(t==null)return{valid:!0};const i=Sf(t);return i?i.major===s.major&&i.minor===s.minor&&i.patch===s.patch?{valid:!0}:s.major<i.major||s.major===i.major&&s.minor<i.minor||s.major===i.major&&s.minor===i.minor&&s.patch<i.patch?{valid:!1,reason:`Version cannot decrease (from ${t} → ${a}). Use the same or higher version.`}:s.major!==i.major?s.major!==i.major+1?{valid:!1,reason:`Major version can only increase by 1 at a time (got ${i.major} → ${s.major}).`}:s.minor!==0||s.patch!==0?{valid:!1,reason:`When bumping major, minor and patch must be reset to 0 (got ${a}; expected ${s.major}.0.0).`}:{valid:!0}:s.minor!==i.minor?s.minor!==i.minor+1?{valid:!1,reason:`Minor version can only increase by 1 at a time (got ${i.minor} → ${s.minor}).`}:s.patch!==0?{valid:!1,reason:`When bumping minor, patch must be reset to 0 (got ${a}; expected ${s.major}.${s.minor}.0).`}:{valid:!0}:s.patch!==i.patch+1?{valid:!1,reason:`Patch version can only increase by 1 at a time (got ${i.patch} → ${s.patch}).`}:{valid:!0}:{valid:!0}}const eb=/^---\n([\s\S]*?)\n---(?:\n|$)/,kf=/^version:\s*["']?([^"'\n]+?)["']?\s*$/m;function Xo(t){const a=t.match(eb);if(!a)return null;const s=a[1].match(kf);return s&&s[1].trim()||null}function tb(t,a){const s=`version: "${a}"`,i=t.match(eb);if(!i)return`---
|
|
90
|
+
${s}
|
|
91
|
+
---
|
|
92
|
+
${t}`;const c=i[1],u=(i.index??0)+i[0].length,d=t.slice(u),f=t.slice(0,i.index??0);let h;kf.test(c)?h=c.replace(kf,s):h=`${s}
|
|
93
|
+
${c}`;const x=i[0].endsWith(`---
|
|
94
|
+
`)?`---
|
|
95
|
+
`:"---";return`${f}---
|
|
96
|
+
${h}
|
|
97
|
+
${x}${d}`}function RE(t,a){const s=Xo(a),i=Xo(t);if(s!==null&&i!==null&&s===i)try{const c=Vs(s,"patch");return{contentToSave:tb(t,c),version:c,fromVersion:s}}catch{return{contentToSave:t,version:i,fromVersion:s}}return{contentToSave:t,version:i,fromVersion:s}}function Dl(t){return t.testType==="integration"?"integration":"unit"}function Hl(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function nb(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 rb(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const AE=new Set(["benchmark","comparison","baseline"]);function av(t,a,s,i){return t.map(({rate:c,idx:u,total:d})=>{const f=i+u/(d-1)*(a-i*2),h=i+(s-i*2)-c*(s-i*2);return`${f},${h}`})}function ab({entries:t}){const a=t.filter(y=>AE.has(y.type)).slice().reverse(),s=a.map((y,b,j)=>({rate:y.pass_rate,idx:b,total:j.length})).filter((y,b)=>{const j=a[b].type;return j==="benchmark"||j==="comparison"}),i=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&&i.length<2)return null;const c=80,u=24,d=2,f=s.length>=2?av(s,c,u,d):[],h=i.length>=2?av(i,c,u,d):[],x=f[f.length-1],v=h[h.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[h.length>0&&r.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),f.length>0&&r.jsx("polyline",{points:f.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)"}),x&&r.jsx("circle",{cx:parseFloat(x.split(",")[0]),cy:parseFloat(x.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function lb(t,a,s){const i=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&i>=.7){const x=c.length>0?` Met criteria: ${c.map(v=>v.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${i.toFixed(2)}): evaluation met expectations.${x}`}}if(t==="FAIL"||t==="DEGRADING"){const x=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 ${i.toFixed(2)}): evaluation did not meet expectations.${x}`,recommendations:v}}if(t==="INEFFECTIVE"){if(i<.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 ${i.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:v}}const x=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return x.length===0&&x.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${i.toFixed(2)}): below expectations but showing some capability.`,recommendations:x}}if(t==="MARGINAL"){const x=[...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`),...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return x.length===0&&x.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 ${i.toFixed(2)}): moderate improvement detected.`,recommendations:x}}if(t==="EMERGING"){const x=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return x.length===0&&x.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 ${i.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:x}}const f=c.length>0?` Passing: ${c.map(x=>x.criterion).join(", ")}.`:"",h=d.length>0?` Needs improvement: ${d.map(x=>x.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${i.toFixed(2)}): mixed results.${f}${h}`}}const sb={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function LE(t){return Object.hasOwn(sb,t)}function ME(t){return LE(t)?sb[t]:t}function zE(){const{state:t}=bn(),{plugin:a,skill:s}=t,[i,c]=m.useState([]),[u,d]=m.useState([]),[f,h]=m.useState(!0),[x,v]=m.useState(null),[y,b]=m.useState(new Set),[j,k]=m.useState({}),[C,w]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState(!1),[M,P]=m.useState(""),[E,O]=m.useState(""),z=m.useCallback(async()=>{h(!0),v(null);try{const[U,D]=await Promise.all([ke.getCredentials(a,s),ke.getParams(a,s)]);c(U.credentials),d(D.params)}catch(U){v(U instanceof Error?U.message:"Failed to load parameters"),c([]),d([])}finally{h(!1)}},[a,s]);m.useEffect(()=>{z()},[z]);const _=m.useCallback(async(U,D)=>{B(!0),v(null);try{await ke.setCredential(a,s,U,D),w(null),T(""),await z()}catch($){v($ instanceof Error?$.message:`Failed to save ${U}`)}finally{B(!1)}},[a,s,z]),H=m.useCallback(async()=>{const U=M.trim().toUpperCase(),D=E.trim();if(!(!U||!D)){B(!0),v(null);try{await ke.setCredential(a,s,U,D),P(""),O(""),await z()}catch($){v($ instanceof Error?$.message:`Failed to add ${U}`)}finally{B(!1)}}},[a,s,M,E,z]),F=m.useCallback(async U=>{if(y.has(U)){b(D=>{const $=new Set(D);return $.delete(U),$}),k(D=>{const $={...D};return delete $[U],$});return}try{const $=(await ke.getParamsRevealed(a,s,U)).params.find(W=>W.name===U);$!=null&&$.value&&(k(W=>({...W,[U]:$.value})),b(W=>new Set(W).add(U)))}catch{}},[a,s,y]),q=new Set(i.map(U=>U.name)),ee=[...i.map(U=>{const D=u.find($=>$.name===U.name);return{name:U.name,status:U.status,maskedValue:(D==null?void 0:D.maskedValue)??""}}),...u.filter(U=>!q.has(U.name)).map(U=>({name:U.name,status:U.status,maskedValue:U.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"}),x&&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:x}),f&&ee.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!f&&ee.length===0&&!x&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),ee.map(U=>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:U.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:U.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:U.status==="ready"?"var(--green)":"var(--red)"},children:U.status}),(U.maskedValue||U.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[y.has(U.name)?j[U.name]??U.maskedValue:U.maskedValue||"***",r.jsx("button",{onClick:()=>F(U.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${y.has(U.name)?"Hide":"Reveal"} value for ${U.name}`,children:y.has(U.name)?"hide":"show"})]}),C===U.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:N,onChange:D=>T(D.target.value),onKeyDown:D=>{D.key==="Enter"&&N.trim()&&_(U.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${U.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>_(U.name,N),disabled:A||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{w(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{w(U.name),T("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},U.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:M,onChange:U=>P(U.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:U=>O(U.target.value),onKeyDown:U=>{U.key==="Enter"&&M.trim()&&E.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:H,disabled:A||!M.trim()||!E.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:A?"not-allowed":"pointer"},children:"Add"})]})]})]})}function ib(t,a,s){const[i,c]=m.useState(null),[u,d]=m.useState(!1),f=m.useRef("");m.useEffect(()=>{const x=`${t}/${a}/${s}`;f.current!==x&&(f.current=x,d(!0),ke.getCaseHistory(t,a,s).then(v=>c(v)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const h=m.useCallback(()=>{d(!0),f.current="",ke.getCaseHistory(t,a,s).then(x=>c(x)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:i,loading:u,refetch:h}}function DE(t,a,s){const i={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return i;const u=s.slice(0,10).map(h=>h.assertions.find(x=>x.id===t)).filter(Boolean);if(u.length>=2){const x=u.filter(v=>v.pass).length/u.length;x>=.3&&x<=.7&&(i.flaky=!0)}const d=s.find(h=>h.type==="benchmark"),f=s.find(h=>h.type==="baseline");if(d&&f){const h=d.assertions.find(v=>v.id===t),x=f.assertions.find(v=>v.id===t);h!=null&&h.pass&&(x!=null&&x.pass)&&(i.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const x=s[0].assertions.find(v=>v.id===t);x!=null&&x.pass&&(i.regression=!0)}return i}function ob({embedded:t=!1}={}){var L;const{state:a,dispatch:s,saveEvals:i,runCase:c,runAll:u,cancelCase:d,cancelAll:f,generateEvals:h,canEdit:x,canRun:v}=bn(),{evals:y,evalsError:b,selectedCaseId:j,inlineResults:k,caseRunStates:C,generateEvalsLoading:w,generateEvalsProgress:N,generateEvalsError:T}=a,A=m.useMemo(()=>{for(const I of C.values())if(I.status==="running"||I.status==="queued")return!0;return!1},[C]),[B,M]=m.useState(!1),[P,E]=m.useState("all"),O={skill_name:a.skill,evals:[]},z=y??O,_=z.evals,H=m.useMemo(()=>P==="all"?_:_.filter(I=>Dl(I)===P),[P,_]),F=H.find(I=>I.id===j)??null;m.useEffect(()=>{j!==null&&!H.find(I=>I.id===j)&&s({type:"SELECT_CASE",caseId:H.length>0?H[0].id:null})},[H,j,s]);const[q,ee]=m.useState([]),U=m.useMemo(()=>_.some(I=>Dl(I)==="integration"),[_]);m.useEffect(()=>{U&&ke.getCredentials(a.plugin,a.skill).then(I=>ee(I.credentials)).catch(()=>ee([]))},[a.plugin,a.skill,U]);const D=m.useMemo(()=>new Set(q.filter(I=>I.status==="missing").map(I=>I.name)),[q]),[$,W]=m.useState(!1),Y=m.useCallback(I=>{W(!1),h(I?{testType:I}:void 0)},[h]);if(!y||_.length===0)return 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:b?"var(--red-muted)":"var(--accent-muted)"},children:b?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:b?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:b}),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"})]})}),x&&r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>M(!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:()=>Y("unit"),disabled:w,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:w?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:()=>W(!$),disabled:w,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"})})})]}),$&&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:()=>Y("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:I=>{I.currentTarget.style.background="var(--surface-2)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),w&&N.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(fi,{entries:N,isRunning:!0})}),T&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(fc,{error:T,onRetry:()=>Y()})}),B&&r.jsx(lv,{evals:z,onSave:I=>{i(I),M(!1)},onCancel:()=>M(!1)})]});const oe=!x&&!t&&y!=null&&r.jsxs("div",{role:"status","data-testid":"tests-readonly-banner",style:{padding:"10px 16px",background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:["Read-only — to author or modify tests, install this skill as source via"," ",r.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[oe,r.jsxs("div",{className:"eval-cases-grid",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 (",H.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:!t&&(A?r.jsx("button",{onClick:f,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:()=>u("benchmark"),disabled:!v,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),x&&r.jsx("button",{onClick:()=>u("comparison"),disabled:!v,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(I=>r.jsx("button",{onClick:()=>E(I),style:{padding:"2px 8px",fontSize:10,fontWeight:P===I?600:400,background:P===I?"var(--accent-muted)":"transparent",color:P===I?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:I==="all"?`All (${_.length})`:I==="unit"?`Unit (${_.filter(K=>Dl(K)==="unit").length})`:`Integration (${_.filter(K=>Dl(K)==="integration").length})`},I))}),r.jsxs("div",{className:"py-1",children:[H.length===0&&_.length>0&&r.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",P==="all"?"":P+" ","tests yet"]}),H.map(I=>{var J;const K=k.get(I.id),Q=j===I.id,ue=Dl(I);return r.jsxs("button",{onClick:()=>s({type:"SELECT_CASE",caseId:I.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:Q?"var(--accent-muted)":"transparent",borderLeft:Q?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:ie=>{Q||(ie.currentTarget.style.background="var(--surface-2)")},onMouseLeave:ie=>{Q||(ie.currentTarget.style.background="transparent")},children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5 min-w-0",children:[r.jsxs("span",{className:"text-[12px] font-medium flex items-center gap-1.5 min-w-0 flex-1",style:{color:Q?"var(--text-primary)":"var(--text-secondary)"},children:[r.jsxs("span",{className:"truncate min-w-0 flex-1",children:["#",I.id," ",I.name]}),r.jsx("span",{title:ue==="unit"?"Unit test":"Integration test","aria-label":ue==="unit"?"Unit test":"Integration test",style:{flexShrink:0,fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:ue==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:ue==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap",letterSpacing:"0.02em"},children:ue==="unit"?"U":"I"}),ue==="integration"&&((J=I.requiredCredentials)==null?void 0:J.some(ie=>D.has(ie)))&&r.jsx("span",{title:"Configure credentials to run",style:{flexShrink:0,display:"inline-flex"},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(cb,{result:K})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[I.assertions.length," assertion",I.assertions.length!==1?"s":"",(K==null?void 0:K.passRate)!=null&&r.jsx(BE,{passRate:K.passRate})]})]},I.id)})]}),r.jsx("div",{className:"px-3 py-2",children:x&&r.jsx("button",{onClick:()=>M(!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:I=>{I.currentTarget.style.borderColor="var(--accent)",I.currentTarget.style.color="var(--accent)"},onMouseLeave:I=>{I.currentTarget.style.borderColor="var(--border-default)",I.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(zE,{})})]}),r.jsx("div",{className:"overflow-auto",children:F?r.jsx(_E,{evalCase:F,result:k.get(F.id),evals:y,caseStatus:((L=C.get(F.id))==null?void 0:L.status)??"idle",onSaveEvals:i,onRun:I=>c(I,"benchmark"),onCompare:I=>c(I,"comparison"),onCancel:I=>d(I),onImprove:I=>s({type:"OPEN_IMPROVE",evalId:I}),embedded:t}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),B&&r.jsx(lv,{evals:z,onSave:I=>{i(I),M(!1)},onCancel:()=>M(!1)})]})]})}function _E({evalCase:t,result:a,evals:s,caseStatus:i,onSaveEvals:c,onRun:u,onCompare:d,onCancel:f,onImprove:h,embedded:x=!1}){const{state:v,canEdit:y,canRun:b}=bn(),{plugin:j,skill:k}=v,{entries:C,loading:w}=ib(j,k,t.id),[N,T]=m.useState(!1),[A,B]=m.useState(t.prompt),[M,P]=m.useState(!1),[E,O]=m.useState(t.expected_output);m.useState(()=>{B(t.prompt),O(t.expected_output)});const z=m.useCallback(L=>{c({...s,evals:s.evals.map(I=>I.id===L.id?L:I)})},[s,c]),_=m.useCallback(()=>{z({...t,prompt:A}),T(!1)},[t,A,z]),H=m.useCallback(()=>{z({...t,expected_output:E}),P(!1)},[t,E,z]),F=m.useCallback(()=>{z({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,z]),q=m.useCallback((L,I)=>{z({...t,assertions:t.assertions.map(K=>K.id===L?{...K,text:I}:K)})},[t,z]),ee=m.useCallback(L=>{z({...t,assertions:t.assertions.filter(I=>I.id!==L)})},[t,z]),U=m.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(L=>L.id!==t.id)})},[s,t.id,c]),D=a&&a.assertions.length>0&&a.assertions.every(L=>L.pass),$=a&&a.assertions.some(L=>!L.pass),W=Dl(t),Y=t.requiredCredentials??[],oe=W==="integration"&&Y.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]}),y?r.jsx("button",{onClick:()=>{if((W==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:I,requirements:K,cleanup:Q,...ue}=t;z({...ue,testType:"unit"})}else z({...t,testType:"integration"})},title:`Click to switch to ${W==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:W==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:W==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:W==="unit"?"Unit":"Integration"}):r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:W==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:W==="unit"?"var(--accent)":"var(--orange)"},children:W==="unit"?"Unit":"Integration"}),r.jsx(cb,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[!x&&(i==="running"||i==="queued"?r.jsxs("button",{onClick:()=>f(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:!b,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),y&&r.jsx("button",{onClick:()=>d(t.id),disabled:!b,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]})),$&&y&&i!=="running"&&i!=="queued"&&r.jsx("button",{onClick:()=>h(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),y&&i!=="running"&&i!=="queued"&&r.jsx("button",{onClick:U,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"})]})})]})]}),!y&&W==="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"})]}),D&&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"})]}),oe&&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:Y.map(L=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:L},L))})]}),y&&W==="integration"&&r.jsx($E,{evalCase:t,onUpdate:z}),r.jsx(Mo,{title:"Prompt",children:N?r.jsxs("div",{children:[r.jsx("textarea",{value:A,onChange:L=>B(L.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:_,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{B(t.prompt),T(!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:y?"pointer":"default"},onClick:()=>{y&&T(!0)},onMouseEnter:L=>{y&&(L.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:L=>{L.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"Click to edit prompt...":"No prompt"})})}),r.jsx(Mo,{title:"Expected Output",children:M?r.jsxs("div",{children:[r.jsx("textarea",{value:E,onChange:L=>O(L.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:H,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{O(t.expected_output),P(!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:y?"pointer":"default"},onClick:()=>{y&&P(!0)},onMouseEnter:L=>{y&&(L.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:L=>{L.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:y?"Click to edit expected output...":"No expected output"})})}),r.jsx(Mo,{title:`Assertions (${t.assertions.length})`,action:y?r.jsx("button",{onClick:F,className:"btn btn-ghost text-[11px]",children:"+ Add"}):void 0,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(L=>{const I=a==null?void 0:a.assertions.find(Q=>Q.assertion_id===L.id),K=DE(L.id,I,C);return r.jsx(OE,{assertion:L,result:I,badges:K,isReadOnly:!y,onUpdate:Q=>q(L.id,Q),onDelete:()=>ee(L.id)},L.id)})})}),(a==null?void 0:a.output)&&r.jsx(IE,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const L=lb("INEFFECTIVE",a.passRate);return L.recommendations&&L.recommendations.length>0?r.jsx(Mo,{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:L.recommendations.map((I,K)=>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:"•"}),I]},K))})]})}):null})(),!x&&r.jsx(ub,{evalId:t.id,sharedEntries:C,sharedLoading:w})]},t.id)}function OE({assertion:t,result:a,badges:s,isReadOnly:i,onUpdate:c,onDelete:u}){const[d,f]=m.useState(!1),[h,x]=m.useState(t.text),[v,y]=m.useState(!1),b=()=>{c(h),f(!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:h,onChange:j=>x(j.target.value),onKeyDown:j=>{j.key==="Enter"&&b(),j.key==="Escape"&&f(!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:i?"default":"pointer"},onClick:()=>{i||(x(t.text),f(!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})]}),!i&&r.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:j=>{j.currentTarget.style.color="var(--red)",j.currentTarget.style.opacity="1"},onMouseLeave:j=>{j.currentTarget.style.color="var(--text-tertiary)",j.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 Mo({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 cb({result:t}){const[a,s]=m.useState(!1),i={padding:"2px 8px",borderRadius:9999,flexShrink:0,minWidth:44,justifyContent:"center",position:"relative",cursor:"default"};if(!t||t.status==null)return r.jsx("span",{className:"pill text-[10px]",title:"Not run yet","aria-label":"Not run yet",style:{...i,background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const c=t.status==="pass",u=t.passRate??0,d=c?"PASS":"FAIL",f=lb(d,u),h=t.passRate!=null?`${Math.round(t.passRate*100)}%`:d;return r.jsxs("span",{className:"pill text-[10px]",style:{...i,background:c?"var(--green-muted)":"var(--red-muted)",color:c?"var(--green)":"var(--red)",fontWeight:600},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-label":`${d} ${h}`,"aria-describedby":a?"verdict-tooltip":void 0,children:[h,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:f.explanation})]})}function BE({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 IE({output:t,durationMs:a,tokens:s}){const[i,c]=m.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:()=>c(!i),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:i?"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)"]})]}),i&&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 Vd(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Fd({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:nb(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:Hl(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:rb(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",i=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:[i,(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 ub({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:i,dispatch:c}=bn(),{plugin:u,skill:d}=i,[f,h]=m.useState(!0),x=a??null,v=s??!1,y=m.useCallback(()=>{h(C=>!C)},[]),b=x?x.slice(0,10):[],j=b.some(C=>{const w=Vd(C.type);return w==="left"||w==="full"}),k=b.some(C=>{const w=Vd(C.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:f?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",x&&x.length>0&&r.jsxs("span",{style:{fontWeight:400},children:["(",x.length," run",x.length!==1?"s":"",")"]})]}),f&&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..."})]}):!x||x.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(ab,{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"}),!j&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((C,w)=>{const N=Vd(C.type);return N==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(Fd,{entry:C})},w):N==="left"?r.jsxs(m.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(Fd,{entry:C})}),r.jsx("div",{style:{gridColumn:"2"}})]},w):r.jsxs(m.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(Fd,{entry:C})})]},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:C=>{C.currentTarget.style.textDecoration="underline"},onMouseLeave:C=>{C.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function lv({evals:t,onSave:a,onCancel:s}){const[i,c]=m.useState(""),[u,d]=m.useState(""),[f,h]=m.useState(""),[x,v]=m.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[y,b]=m.useState("unit"),[j,k]=m.useState(""),[C,w]=m.useState([]),[N,T]=m.useState(""),[A,B]=m.useState(""),M=Math.max(0,...t.evals.map(z=>z.id))+1,P=z=>{b(z),z==="unit"&&(w([]),k(""),T(""),B(""))},E=()=>{const z=j.trim().toUpperCase();z&&!C.includes(z)&&w([...C,z]),k("")},O=()=>{if(!i.trim()||!u.trim())return;const z={id:M,name:i.trim(),prompt:u.trim(),expected_output:f.trim(),files:[],assertions:x.filter(_=>_.text.trim()),...y==="integration"?{testType:"integration",...C.length>0?{requiredCredentials:C}:{},...N||A?{requirements:{...N?{platform:N}:{},...A?{chromeProfile:A}:{}}}:{}}:{}};a({...t,evals:[...t.evals,z]})};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(z=>r.jsx("button",{onClick:()=>P(z),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:y===z?z==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:y===z?z==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:z},z))})]}),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:i,onChange:z=>c(z.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:z=>d(z.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:f,onChange:z=>h(z.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"}),x.map((z,_)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:z.text,onChange:H=>v(x.map((F,q)=>q===_?{...F,text:H.target.value}:F)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),x.length>1&&r.jsx("button",{onClick:()=>v(x.filter((H,F)=>F!==_)),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"})]})})]},z.id)),r.jsx("button",{onClick:()=>v([...x,{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:C.map(z=>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:[z,r.jsx("button",{onClick:()=>w(C.filter(_=>_!==z)),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"})]})})]},z))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:j,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),E())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),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:N,onChange:z=>T(z.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:A,onChange:z=>B(z.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:!i.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function $E({evalCase:t,onUpdate:a}){var d,f;const[s,i]=m.useState(""),c=()=>{const h=s.trim().toUpperCase();h&&!(t.requiredCredentials??[]).includes(h)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],h]}),i("")},u=h=>{const x=(t.requiredCredentials??[]).filter(v=>v!==h);a({...t,requiredCredentials:x.length>0?x: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(h=>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:[h,r.jsx("button",{onClick:()=>u(h),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"})]})})]},h))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.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:h=>a({...t,requirements:{...t.requirements,platform:h.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:((f=t.requirements)==null?void 0:f.chromeProfile)??"",onChange:h=>a({...t,requirements:{...t.requirements,chromeProfile:h.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Wd(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function UE({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 HE({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 PE({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 VE({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 Gd({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 FE(){const{state:t,dispatch:a,saveContent:s,isReadOnly:i}=bn(),{plugin:c,skill:u,skillContent:d,isDirty:f,improveTarget:h,aiEditOpen:x}=t,[v,y]=m.useState("split"),[b,j]=m.useState(!1),k=m.useRef(null),[C,w]=m.useState(!1),[N,T]=m.useState(""),[A,B]=m.useState(!1),[M,P]=m.useState(null),[E,O]=m.useState([]),[z,_]=m.useState([]),[H,F]=m.useState(null),q=m.useRef(null),{config:ee}=qa(),U=EE(),{files:D,activeFile:$,secondaryContent:W,loading:Y,error:oe,loadError:L,selectFile:I,refresh:K,isSkillMd:Q}=fE(c??"",u??""),[ue,J]=m.useState(!1),ie=m.useCallback(xe=>{ue&&!window.confirm("You have unsaved changes. Discard?")||I(xe)},[ue,I]);m.useEffect(()=>()=>{var xe;(xe=q.current)==null||xe.abort()},[]);const{metadata:Z,body:me}=Yy(d),je=Z["allowed-tools"],Te=Array.isArray(je)?je:typeof je=="string"?[je]:[],Me=Z.name,Fe=Z.description,Ue=Z.metadata,De=typeof Ue=="object"&&!Array.isArray(Ue)?Ue:null,We=Z.version||(De==null?void 0:De.version),ft=Z.tags||(De==null?void 0:De.tags),ce=Array.isArray(ft)?ft:typeof ft=="string"?ft.split(",").map(xe=>xe.trim()).filter(Boolean):[],ve=new Set(["name","description","metadata","allowed-tools","version","tags"]),ye=Object.entries(Z).filter(([xe])=>!ve.has(xe)),be=m.useCallback(async()=>{const{contentToSave:xe,version:Ze,fromVersion:Xe}=RE(d,t.savedContent);if(Ze!==null){const kt=TE(Xe,Ze);if(!kt.valid){Wd(`Save blocked: ${kt.reason??"invalid version transition"}`,"error");return}}j(!0),await s(xe),j(!1),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:content-saved",{detail:{plugin:c,skill:u,version:Ze}}))},[s,d,t.savedContent,c,u]),Ne=m.useCallback(xe=>{const Ze=Xo(d)??"1.0.0";let Xe;try{Xe=Vs(Ze,xe)}catch(Bt){const lt=Bt instanceof Error?Bt.message:String(Bt);Wd(`Bump failed: ${lt}`,"error");return}const kt=tb(d,Xe);a({type:"SET_CONTENT",content:kt}),Wd(`Bumped to v${Xe} (${xe}). Click Save to commit.`,"info")},[d,a]),qe=m.useCallback(xe=>{(xe.ctrlKey||xe.metaKey)&&xe.key==="s"&&(xe.preventDefault(),xe.stopPropagation(),f&&be()),(xe.ctrlKey||xe.metaKey)&&xe.key==="i"&&(xe.preventDefault(),xe.stopPropagation(),a({type:x?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[f,be,x,a]),He=m.useCallback(async()=>{var Ze,Xe;if(!N.trim())return;(Ze=q.current)==null||Ze.abort();const xe=new AbortController;q.current=xe,B(!0),F(null),_([]),P(null),O([]);try{const kt=(ee==null?void 0:ee.provider)||"claude-cli",Bt=(ee==null?void 0:ee.model)||"sonnet",lt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:kt,model:Bt}),signal:xe.signal});if(!lt.ok||!lt.body){let ur=`HTTP ${lt.status}`;try{const wt=await lt.json();wt.error&&(ur=wt.error)}catch{}throw new Error(ur)}const jn=lt.body.getReader(),Kt=new TextDecoder;let mn="",un="";for(;;){const{done:ur,value:wt}=await jn.read();if(ur)break;mn+=Kt.decode(wt,{stream:!0});const Pn=mn.split(`
|
|
98
|
+
`);mn=Pn.pop()||"";for(const Sn of Pn)if(Sn.startsWith("event: "))un=Sn.slice(7).trim();else if(Sn.startsWith("data: ")){try{const Et=JSON.parse(Sn.slice(6));if(un==="progress")_(Be=>[...Be,{phase:Et.phase,message:Et.message,timestamp:Date.now()}]);else if(un==="done"||un==="complete"){const Be=["---"];Et.name&&Be.push(`name: ${Et.name}`),Et.description&&Be.push(`description: "${Et.description.replace(/"/g,'\\"')}"`),Et.model&&Be.push(`model: ${Et.model}`),(Xe=Et.allowedTools)!=null&&Xe.trim()&&Be.push(`allowed-tools: ${Et.allowedTools.trim()}`),Be.push("---","",Et.body||"");const Je=Be.join(`
|
|
99
|
+
`);P(Je),O(dc(d,Je)),B(!1)}else un==="error"&&(F(Et.message||Et.description||"Generation failed"),B(!1))}catch{}un=""}}}catch(kt){kt.name!=="AbortError"&&F(kt.message)}finally{B(!1),q.current=null}},[N,ee,d]),jt=m.useCallback(()=>{M&&a({type:"SET_CONTENT",content:M}),w(!1),P(null),O([]),T(""),_([])},[M,a]),Ot=m.useCallback(()=>{w(!1),P(null),O([]),T(""),_([]),F(null)},[]),St=m.useCallback(()=>{var xe;C?((xe=q.current)==null||xe.abort(),Ot()):(x&&a({type:"CLOSE_AI_EDIT"}),w(!0))},[C,x,a,Ot]),Lt=[{mode:"raw",icon:r.jsx(UE,{}),label:"Editor"},{mode:"split",icon:r.jsx(HE,{}),label:"Split"},{mode:"preview",icon:r.jsx(PE,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col",style:{height:"100%",overflow:"auto"},onKeyDown:qe,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:Lt.map(({mode:xe,icon:Ze,label:Xe})=>r.jsxs("button",{onClick:()=>y(xe),title:Xe,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:v===xe?"var(--surface-4)":"transparent",color:v===xe?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:v===xe?600:400,border:"none",cursor:"pointer"},children:[Ze,r.jsx("span",{style:{letterSpacing:"0.01em"},children:Xe})]},xe))}),Q?i?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:()=>{x?a({type:"CLOSE_AI_EDIT"}):(C&&Ot(),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:x?600:400,border:"none",cursor:"pointer",color:x?"var(--purple)":"var(--text-tertiary)",background:x?"var(--purple-muted)":"transparent"},children:[r.jsx(VE,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:St,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:C?600:400,border:"none",cursor:"pointer",color:C?"var(--purple)":"var(--text-tertiary)",background:C?"var(--purple-muted)":"transparent"},children:[r.jsx(Gd,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),!i&&(()=>{const xe=Xo(d)??"1.0.0";let Ze=xe,Xe=xe,kt=xe;try{Ze=Vs(xe,"patch"),Xe=Vs(xe,"minor"),kt=Vs(xe,"major")}catch{}const Bt={padding:"4px 8px"};return r.jsxs("div",{style:{display:"inline-flex",gap:2,alignItems:"center"},"aria-label":"Version bump","data-testid":"version-bump-controls",children:[r.jsx("button",{type:"button",onClick:()=>Ne("patch"),title:`Bump patch: ${xe} → ${Ze}`,"aria-label":"Bump patch version",className:"btn btn-ghost text-[11px]",style:Bt,children:"+patch"}),r.jsx("button",{type:"button",onClick:()=>Ne("minor"),title:`Bump minor: ${xe} → ${Xe}`,"aria-label":"Bump minor version",className:"btn btn-ghost text-[11px]",style:Bt,children:"+minor"}),r.jsx("button",{type:"button",onClick:()=>Ne("major"),title:`Bump major: ${xe} → ${kt}`,"aria-label":"Bump major version",className:"btn btn-ghost text-[11px]",style:Bt,children:"+major"})]})})(),f&&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:be,disabled:!f||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"}),U.hasRemote&&U.remoteUrl&&r.jsx(Jy,{remoteUrl:U.remoteUrl,provider:ee==null?void 0:ee.provider,model:ee==null?void 0:ee.model})]}):null]}),c&&u&&r.jsx(gE,{files:D,activeFile:$,onSelect:ie,onRefresh:K,loadError:L}),!Q&&r.jsx(bE,{file:W,loading:Y,error:oe,viewMode:v,plugin:c??void 0,skill:u??void 0,onSaved:()=>{I($),K()},onDirtyChange:J}),Q&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:v==="raw"||v==="preview"?"1fr":"1fr 1fr",minHeight:"60vh"},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:k,value:d,onChange:xe=>{!i&&!b&&a({type:"SET_CONTENT",content:xe.target.value})},onKeyDown:qe,spellCheck:!1,readOnly:i||b,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:i?.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:[(Me||We||Fe)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Me&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Me}),We&&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",We]})]}),Fe&&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:Fe})]}),ce.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:ce.map(xe=>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:xe},xe))}),Te.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"}),Te.map(xe=>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:xe},xe))]})}),ye.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:ye.map(([xe,Ze],Xe)=>{const kt=Array.isArray(Ze)?Ze.join(", "):typeof Ze=="object"?Object.entries(Ze).map(([Bt,lt])=>`${Bt}: ${Array.isArray(lt)?lt.join(", "):lt}`).join(" | "):Ze;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Xe>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:xe}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:kt})]},xe)})}),(Me||Fe||ce.length>0||Te.length>0||ye.length>0)&&me&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),me&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:di(me)}})]})})]}),Q&&x&&r.jsx(dE,{}),Q&&C&&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:[!M&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Gd,{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:N,onChange:xe=>T(xe.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:A,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:A?.5:1},onKeyDown:xe=>{xe.key==="Enter"&&(xe.ctrlKey||xe.metaKey)&&N.trim()&&!A&&(xe.preventDefault(),He())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("button",{onClick:()=>{var xe;(xe=q.current)==null||xe.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:He,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Ot,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),A&&z.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(fi,{entries:z,isRunning:!0})}),H&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,r.jsx("button",{onClick:He,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),M&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Gd,{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((xe,Ze)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:xe.type==="added"?"var(--green-muted)":xe.type==="removed"?"var(--red-muted)":"transparent",color:xe.type==="added"?"var(--green)":xe.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:xe.type==="added"?"3px solid var(--green)":xe.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:xe.type==="added"?"+":xe.type==="removed"?"-":" "}),xe.content]},Ze))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:jt,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:Ot,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Q&&h!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(aE,{plugin:c,skill:u,skillContent:d,onApplied:xe=>{a({type:"SET_CONTENT",content:xe}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})}),Q&&r.jsx(WE,{})]})}function WE(){var h;const[t,a]=m.useState(()=>{var x;return typeof window>"u"?!1:((x=window.localStorage)==null?void 0:x.getItem("vskill:editor-eval-cases-open"))==="1"}),{state:s,canEdit:i}=bn(),c=((h=s.evals)==null?void 0:h.evals)??[],u=x=>{var y;const v=x.currentTarget.open;if(a(v),typeof window<"u")try{(y=window.localStorage)==null||y.setItem("vskill:editor-eval-cases-open",v?"1":"0")}catch{}},d=m.useCallback(x=>{var b;if((b=x.preventDefault)==null||b.call(x),typeof window>"u")return;const v=new URLSearchParams(window.location.search);v.set("tab","run"),v.set("mode","benchmark"),v.set("autorun","1");const y=`${window.location.pathname}?${v.toString()}${window.location.hash}`;window.history.replaceState(null,"",y),window.dispatchEvent(new PopStateEvent("popstate"))},[]),f=i&&c.length>0;return r.jsxs("details",{"data-testid":"editor-eval-cases-section",open:t,onToggle:u,style:{borderTop:"1px solid var(--border-subtle)",background:"var(--bg-canvas)"},children:[r.jsxs("summary",{style:{padding:"10px 16px",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--text-primary)",cursor:"pointer",userSelect:"none",background:"var(--surface-1)",borderBottom:t?"1px solid var(--border-subtle)":"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[r.jsx("span",{children:"Eval cases"}),f&&r.jsx("button",{type:"button","data-testid":"editor-eval-cases-run-all",onClick:d,title:"Run all → opens Run tab",className:"btn btn-primary text-[11px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run all"})]}),t&&r.jsx("div",{"data-testid":"editor-eval-cases-body",style:{height:520,overflow:"hidden"},children:r.jsx(ob,{embedded:!0})})]})}function GE(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`}const qE={vskill:{label:"vskill",bg:"var(--accent-muted, #e0f2fe)",fg:"var(--accent, #0369a1)",border:"var(--accent, #0369a1)"},anthropic:{label:"Anthropic",bg:"var(--orange-muted, #fff1e0)",fg:"var(--orange, #c2410c)",border:"var(--orange, #c2410c)"},local:{label:"Local",bg:"var(--surface-3, #e5e5e5)",fg:"var(--text-tertiary, #666)",border:"var(--border-default, #ccc)"}};function wf({provider:t,size:a="sm"}){if(!t)return null;const s=qE[t],i=a==="md"?11:9;return r.jsx("span",{"data-testid":`provider-chip-${t}`,"data-provider":t,style:{display:"inline-flex",alignItems:"center",padding:a==="md"?"2px 8px":"1.5px 6px",fontSize:i,fontWeight:500,fontFamily:"var(--font-sans)",background:s.bg,color:s.fg,border:`1px solid ${s.border}`,borderRadius:999,lineHeight:1.4,whiteSpace:"nowrap"},children:s.label})}function YE({content:t,defaultExpanded:a=!0}){const[s,i]=m.useState(a),{metadata:c,body:u}=Yy(t);if(!t.trim())return null;const d=Object.keys(c).length>0,f=c["allowed-tools"],h=Array.isArray(f)?f:typeof f=="string"?[f]:[],x=Object.entries(c).filter(([v])=>v!=="allowed-tools");return r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("button",{onClick:()=>i(!s),className:"w-full flex items-center justify-between px-5 py-3.5 text-left transition-colors duration-150",style:{background:"var(--surface-2)"},onMouseEnter:v=>{v.currentTarget.style.background="var(--surface-3)"},onMouseLeave:v=>{v.currentTarget.style.background="var(--surface-2)"},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("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",style:{transform:s?"rotate(180deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),s&&r.jsxs("div",{className:"px-5 py-4 animate-fade-in",children:[d&&r.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:x.map(([v,y])=>{const b=Array.isArray(y)?y.join(", "):typeof y=="object"?Object.entries(y).map(([j,k])=>`${j}: ${Array.isArray(k)?k.join(", "):k}`).join(" | "):y;return r.jsxs("div",{className:"px-3 py-2.5 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--text-tertiary)"},children:v}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-primary)"},children:b})]},v)})}),h.length>0&&r.jsxs("div",{className:"mb-4",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(v=>r.jsx("span",{className:"px-2 py-1 rounded-md text-[11px] font-mono",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:v},v))})]}),u&&r.jsx("div",{className:"text-[12px] leading-relaxed p-4 rounded-lg overflow-x-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:di(u)}})]})]})}function KE(t){const a={name:"",path:"",type:"dir",size:0,children:[]};for(const i of t){if(i.type!=="file")continue;const c=i.path.split("/");let u=a;for(let d=0;d<c.length;d++){const f=c[d],h=d===c.length-1;let x=u.children.find(v=>v.name===f);x||(x={name:f,path:c.slice(0,d+1).join("/"),type:h?"file":"dir",size:h?i.size:0,children:[]},u.children.push(x)),u=x}}const s=i=>{i.children.sort((c,u)=>c.type!==u.type?c.type==="dir"?-1:1:c.name.localeCompare(u.name)),i.children.forEach(s)};return s(a),a}function XE(t){const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}function QE(t){const a=XE(t);return t==="SKILL.md"?"📘":a==="md"?"📄":a==="ts"||a==="tsx"||a==="js"||a==="jsx"?"📜":a==="json"||a==="yaml"||a==="yml"||a==="toml"?"🔧":a==="sh"||a==="bash"?"🖥":a==="png"||a==="jpg"||a==="jpeg"||a==="gif"||a==="webp"||a==="svg"?"🖼":"📄"}function db({node:t,depth:a,activePath:s,focusedPath:i,onSelect:c,expanded:u,onToggle:d}){if(t.type==="dir"){const x=u.has(t.path),v=t.path===i;return r.jsxs("div",{children:[r.jsxs("button",{type:"button","data-testid":"source-tree-item","data-path":t.path,"data-type":"dir","data-focused":v?"true":"false",role:"treeitem","aria-expanded":x,onClick:()=>d(t.path),style:{width:"100%",textAlign:"left",background:v?"var(--surface-2)":"transparent",border:"none",padding:`4px 8px 4px ${a*12+8}px`,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[r.jsx("span",{style:{width:10,display:"inline-block"},children:x?"▾":"▸"}),r.jsx("span",{children:"📁"}),r.jsx("span",{children:t.name})]}),x&&r.jsx("div",{role:"group",children:t.children.map(y=>r.jsx(db,{node:y,depth:a+1,activePath:s,focusedPath:i,onSelect:c,expanded:u,onToggle:d},y.path))})]})}const f=t.path===s,h=t.path===i;return r.jsxs("button",{type:"button","data-testid":"source-tree-item","data-path":t.path,"data-type":"file","data-active":f?"true":"false","data-focused":h?"true":"false",role:"treeitem","aria-selected":f,onClick:()=>c(t.path),style:{width:"100%",textAlign:"left",background:f?"var(--surface-3)":h?"var(--surface-2)":"transparent",border:"none",padding:`4px 8px 4px ${a*12+8}px`,color:f?"var(--text-primary)":"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:f?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[r.jsx("span",{style:{width:10,display:"inline-block"},children:" "}),r.jsx("span",{children:QE(t.name)}),r.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]})}function ZE({files:t,activePath:a,onSelect:s}){const i=m.useMemo(()=>KE(t),[t]),c=m.useMemo(()=>{const j=new Set;if(a&&a.includes("/")){const k=a.split("/");for(let C=1;C<k.length;C++)j.add(k.slice(0,C).join("/"))}return i.children.forEach(k=>{k.type==="dir"&&j.add(k.path)}),j},[i,a]),[u,d]=m.useState(c);m.useEffect(()=>{d(j=>{const k=new Set(j);let C=!1;return c.forEach(w=>{k.has(w)||(k.add(w),C=!0)}),C?k:j})},[c]);const f=j=>{d(k=>{const C=new Set(k);return C.has(j)?C.delete(j):C.add(j),C})},h=m.useMemo(()=>{const j=[],k=C=>{for(const w of C)j.push({path:w.path,type:w.type}),w.type==="dir"&&u.has(w.path)&&k(w.children)};return k(i.children),j},[i,u]),x=m.useRef(null),[v,y]=m.useState(()=>Math.max(0,h.findIndex(j=>j.path===a)));m.useEffect(()=>{const j=h.findIndex(k=>k.path===a);j>=0&&y(j)},[a,h]);const b=j=>{var k;if(h.length!==0)if(j.key==="ArrowDown")j.preventDefault(),y(C=>Math.min(h.length-1,C+1));else if(j.key==="ArrowUp")j.preventDefault(),y(C=>Math.max(0,C-1));else if(j.key==="Enter"){j.preventDefault();const C=h[v];if(!C)return;C.type==="dir"?f(C.path):s(C.path)}else j.key==="Escape"&&(j.preventDefault(),(k=x.current)==null||k.blur())};return i.children.length===0?r.jsx("div",{"data-testid":"source-tree-empty",style:{padding:16,fontSize:12,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:"No files found."}):r.jsx("div",{"data-testid":"source-file-tree",ref:x,tabIndex:0,onKeyDown:b,role:"tree","aria-label":"Skill files",style:{paddingTop:4,paddingBottom:4,outline:"none"},children:i.children.map(j=>{var k;return r.jsx(db,{node:j,depth:0,activePath:a,focusedPath:(k=h[v])==null?void 0:k.path,onSelect:s,expanded:u,onToggle:f},j.path)})})}const JE=new Set(["md","txt","json","yaml","yml","toml","ini","env","ts","tsx","js","jsx","mjs","cjs","py","rb","go","rs","java","c","cc","cpp","h","hpp","sh","bash","zsh","fish","html","css","scss","less","xml","csv","tsv","log","diff","patch","lock","gitignore","dockerfile"]),eN=new Set(["png","jpg","jpeg","gif","webp","ico"]);function tN(t){const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}function nN(t){const a=tN(t);return a==="md"?"markdown":eN.has(a)?"image":JE.has(a)?"text":"binary"}function rN({content:t}){return r.jsx("div",{"data-testid":"source-md-viewer",children:r.jsx(YE,{content:t})})}function aN({content:t,path:a}){const s=t.split(`
|
|
100
|
+
`),i=s.length>5e3,c=i?s.slice(0,5e3).join(`
|
|
101
|
+
`):t;return r.jsxs("div",{"data-testid":"source-text-viewer",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:"70vh"},children:[r.jsxs("div",{style:{padding:"8px 12px",background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)"},children:[a," · ",s.length," ",s.length===1?"line":"lines",i&&" (truncated for display)"]}),r.jsx("pre",{style:{margin:0,padding:12,fontFamily:"var(--font-mono, monospace)",fontSize:12,lineHeight:1.5,color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:c})]})}function lN({plugin:t,skill:a,path:s}){const i=`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}&raw=1`;return r.jsxs("div",{"data-testid":"source-image-viewer",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16,display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[r.jsx("img",{src:i,alt:s,style:{maxWidth:"100%",maxHeight:"60vh",objectFit:"contain"}}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:s})]})}function sN({path:t,size:a}){return r.jsxs("div",{"data-testid":"source-binary-placeholder",style:{background:"var(--surface-1)",border:"1px dashed var(--border-default)",borderRadius:8,padding:24,textAlign:"center",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:13},children:[r.jsxs("div",{style:{fontSize:14,fontWeight:500,marginBottom:6},children:["Binary file — ",GE(a)]}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)"},children:t})]})}function iN({plugin:t,skill:a,provider:s}){const[i,c]=m.useState([]),[u,d]=m.useState("SKILL.md"),[f,h]=m.useState(null),[x,v]=m.useState(!0),[y,b]=m.useState(null),[j,k]=m.useState(null),C=s??j;m.useEffect(()=>{if(s!==void 0)return;let N=!1;return ke.getSkillVersionsEnvelope(t,a).then(T=>{N||k(T.provider??null)}).catch(()=>{}),()=>{N=!0}},[t,a,s]),m.useEffect(()=>{let N=!1;return v(!0),b(null),ke.getSkillFiles(t,a).then(T=>{var M;if(N)return;c(T.files);const B=T.files.some(P=>P.path==="SKILL.md")?"SKILL.md":((M=T.files.find(P=>P.type==="file"))==null?void 0:M.path)??"";d(B),B||v(!1)}).catch(T=>{N||(b(T instanceof Error?T.message:String(T)),v(!1))}),()=>{N=!0}},[t,a]),m.useEffect(()=>{if(!u)return;let N=!1;return v(!0),b(null),ke.getSkillFile(t,a,u).then(T=>{N||(h(T),v(!1))}).catch(T=>{N||(b(T instanceof Error?T.message:String(T)),v(!1))}),()=>{N=!0}},[t,a,u]);const w=()=>{if(y)return r.jsxs("div",{"data-testid":"source-error",style:{padding:16,color:"var(--danger, #c00)",fontFamily:"var(--font-sans)",fontSize:13},children:["Failed to load: ",y]});if(x||!f)return r.jsx("div",{"data-testid":"source-loading",style:{padding:16,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",fontSize:13},children:"Loading…"});const N=nN(u);return N==="markdown"?r.jsx(rN,{content:f.content??""}):N==="text"&&!f.binary?r.jsx(aN,{content:f.content??"",path:u}):N==="image"?r.jsx(lN,{plugin:t,skill:a,path:u}):r.jsx(sN,{path:u,size:f.size})};return r.jsxs("div",{"data-testid":"source-panel",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:400,gap:12},children:[C&&r.jsxs("div",{"data-testid":"source-panel-header",style:{display:"flex",alignItems:"center",gap:8,paddingLeft:4},children:[r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Provider:"}),r.jsx(wf,{provider:C})]}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"260px 1fr",gap:16,flex:1,minHeight:0},children:[r.jsx("aside",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:"75vh"},children:r.jsx(ZE,{files:i,activePath:u,onSelect:d})}),r.jsx("main",{style:{minWidth:0},children:w()})]})]})}function Hn(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 fb(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function oN({evalId:t}){const{state:a}=bn(),{entries:s,loading:i}=ib(a.plugin,a.skill,t),c=!!s&&s.length>0;return!i&&!c?null:r.jsx("div",{"data-testid":`run-case-history-${t}`,className:"mt-2 ml-3 pl-3",style:{borderLeft:"1px solid var(--border-subtle)"},children:r.jsx(ub,{evalId:t,sharedEntries:s,sharedLoading:i})})}function cN(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function uN(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 dN(t,a,s){const i=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${i}`;const c=Math.round(Math.abs(t)*a);if(c===0)return`Your skill performs the same as the baseline across ${s} ${i}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${i}`}function sv(t,a){const s=i=>{const c=i/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(a)}}function fN(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function pN(t,a){const s=t+a,i=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(i)}–${u(c)}`}const mN={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function hN(t,a){if(!t)return null;const s=mN[t];if(s==null||s===0)return null;const i=s*a*.5,c=s*a*2;return`${Hn(i)}–${Hn(c)}`}function xN(){const{state:t,runCase:a,runAll:s,cancelCase:i,cancelAll:c,canEdit:u,canRun:d}=bn(),{evals:f,caseRunStates:h,bulkRunActive:x,latestBenchmark:v,inlineResults:y}=t,{config:b}=qa(),j=(f==null?void 0:f.evals)??[],k=m.useMemo(()=>{for(const O of h.values())if(O.status==="running"||O.status==="queued")return!0;return!1},[h]),C=j.filter(O=>{const z=h.get(O.id);return z&&(z.status==="complete"||z.status==="error"||z.status==="cancelled")}).length,w=j.filter(O=>{const z=h.get(O.id);return z&&(z.status==="running"||z.status==="queued")}).length,N=m.useRef(null),[T,A]=m.useState(0);m.useEffect(()=>{if(k&&!N.current&&(N.current=Date.now()),!k){N.current=null,A(0);return}const O=setInterval(()=>{N.current&&A(Math.round((Date.now()-N.current)/1e3))},1e3);return()=>clearInterval(O)},[k]);const B=j.reduce((O,z)=>O+z.assertions.length,0),M=j.length+B,P=m.useMemo(()=>pN(j.length,B),[j.length,B]),E=m.useMemo(()=>hN((b==null?void 0:b.provider)??null,M),[b==null?void 0:b.provider,M]);return r.jsxs("div",{className:"p-5",children:[!u&&f!=null&&r.jsxs("div",{role:"status","data-testid":"tests-readonly-banner",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"})]}),r.jsxs("span",{children:["Read-only — to author or modify tests, install this skill as source via"," ",r.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]})]}),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"}),k&&r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[w," running"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[k&&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"]}),u&&r.jsx("button",{onClick:()=>s("comparison"),disabled:!d||k,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:!d||k,className:u?"btn btn-secondary text-[12px]":"btn btn-primary text-[12px]",title:u?"Runs benchmark using your skill only":"Run all author-shipped eval cases",children:u?"Test Skill":"Run All"}),u&&r.jsx("button",{onClick:()=>s("baseline"),disabled:!d||k,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!k&&j.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: ",P]}),E&&r.jsxs("span",{children:["Est. cost: ",E]}),!E&&(b==null?void 0:b.provider)&&(b.provider==="claude-cli"||b.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!E&&(b==null?void 0:b.provider)&&(b.provider==="ollama"||b.provider==="lm-studio"||b.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),k&&j.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,"/",j.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(C/j.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/j.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: ",P]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:j.map(O=>{const z=y.get(O.id),_=h.get(O.id),H=(_==null?void 0:_.status)??"idle",F=v==null?void 0:v.cases.find(q=>q.eval_id===O.id);return r.jsxs(m.Fragment,{children:[r.jsx(vN,{name:O.name,evalId:O.id,result:z,caseCost:F==null?void 0:F.cost,caseBillingMode:F==null?void 0:F.billingMode,caseInputTokens:F==null?void 0:F.inputTokens,caseOutputTokens:F==null?void 0:F.outputTokens,caseStatus:H,runMode:(_==null?void 0:_.mode)??null,comparisonDetail:F==null?void 0:F.comparisonDetail,canEdit:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>i(q)}),r.jsx(oN,{evalId:O.id})]},O.id)})}),!k&&v&&v.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:cN(v.type)}),r.jsx("span",{className:"text-[20px] font-bold",style:{color:(v.overall_pass_rate??0)>=.8?"var(--green)":(v.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:v.overall_pass_rate!=null?`${Math.round(v.overall_pass_rate*100)}%`:"--"})]}),v.totalDurationMs!=null&&r.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(v.totalDurationMs/1e3).toFixed(1),"s",v.model&&` | Model: ${v.model}`,v.totalInputTokens!=null&&v.totalOutputTokens!=null&&` | Tokens: ${fb(v.totalInputTokens,v.totalOutputTokens)}`,v.totalCost!=null&&` | Cost: ${Hn(v.totalCost)}`]}),u&&v.overall_pass_rate>=.9999&&!v.comparison&&r.jsx("button",{onClick:()=>s("comparison"),disabled:!d,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:j.length===0?.5:1},children:"Run Final A/B Comparison"})]}),v.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 O=uN(v.model,v.timestamp);return O?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:O}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(iv,{label:"Skill",value:v.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(iv,{label:"Baseline",value:v.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),r.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:v.comparison.delta>0?"var(--green)":v.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",v.comparison.delta>0?"+":"",(v.comparison.delta*100).toFixed(1),"%",v.verdict&&` | ${ME(v.verdict)}`]}),(()=>{const O=v.cases.reduce((_,H)=>_+H.assertions.length,0),z=dN(v.comparison.delta,O,v.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:z})})()]})]})]})}const gN={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 vN({name:t,evalId:a,result:s,caseCost:i,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:f,runMode:h,comparisonDetail:x,canEdit:v=!1,onRun:y,onBaseline:b,onCompare:j,onCancel:k}){const[C,w]=m.useState(!1),N=f==="running"||f==="queued",T=f==="complete"||f==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[f==="running"&&r.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),f==="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]}),h&&(N||T)&&(()=>{const A=gN[h];return A?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:A.bg,color:A.color,padding:"1px 6px"},children:A.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[N?r.jsx("button",{onClick:()=>k(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:[v&&r.jsx("button",{onClick:()=>j(a),className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>y(a),className:v?"btn btn-secondary text-[10px] px-2 py-1":"btn btn-primary text-[10px] px-2 py-1",children:v?"Skill":"Run"}),v&&r.jsx("button",{onClick:()=>b(a),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:fb(u,d)}),i!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Hn(i,c)}),f==="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(A=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:A.pass?"var(--green)":"var(--red)"},children:A.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:A.text})]},A.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>w(!C),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:C?"Hide output":"Show output"}),C&&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})]}),x&&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 A=sv(x.skillContentScore,x.baselineContentScore),B=sv(x.skillStructureScore,x.baselineStructureScore),M=fN(x.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",A.skill,"% / Baseline ",A.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsx("span",{style:{color:M.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:M.text})]})})()})})}),s&&s.errorMessage&&r.jsx(yN,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const qd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function yN({errorMessage:t,classifiedError:a}){const[s,i]=m.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?qd[a.category]??qd.unknown:qd.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:()=>i(!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 iv({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 ov={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)"},SCOPE_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"},DRIFT_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"}},bN={scope_warning:"Description claims broader scope than name+tags suggest. Either narrow the description or add explicit '+' prefix to confirm intended scope.",drift_warning:"Description omits intent that classifier inferred from name+tags. Description may need to mention this case explicitly."};function jN(){const{state:t,dispatch:a,runActivationTest:s,cancelActivation:i,generateActivationPrompts:c,loadTestCasesFromSkillMd:u,saveTestCasesToSkillMd:d}=bn(),{plugin:f,skill:h,activationPrompts:x,activationResults:v,activationSummary:y,activationRunning:b,activationError:j,activationStartedAt:k,activationClassifyingStatus:C,generatingPrompts:w,generatingPromptsError:N,activationPromptsSource:T,savingTestCases:A,savingTestCasesError:B,savingTestCasesSuccess:M,activationHistory:P}=t,{state:E}=cr(),O=E.skills.find(J=>J.plugin===f&&J.skill===h),z=(O==null?void 0:O.resolvedVersion)??(O==null?void 0:O.version)??null,[_,H]=m.useState(x),[F,q]=m.useState(null),[ee,U]=m.useState(!1);m.useEffect(()=>{x&&x!==_&&H(x)},[x]),m.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:_})},[_,a]),m.useEffect(()=>{fetch(`/api/skills/${f}/${h}/description`).then(J=>J.json()).then(J=>q(J.rawContent||J.description||null)).catch(()=>q(null))},[f,h]),m.useEffect(()=>{(!x||x.trim().length===0)&&u()},[f,h]);function D(){s(_)}function $(){c(8)}function W(){d()}const Y=_.trim().split(`
|
|
102
|
+
`).filter(Boolean).length,oe=J=>J.verdict==="scope_warning"||J.verdict==="drift_warning",L=v.filter(J=>(J.classification==="TP"||J.classification==="TN")&&!oe(J)),I=v.filter(J=>(J.classification==="FP"||J.classification==="FN")&&!oe(J));v.filter(oe);const K=(F==null?void 0:F.replace(/^---[\s\S]*?---\s*/,"").trim())??null,Q=_.trim().length>0,ue=K?di(K):"";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.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),T==="skill-md"&&r.jsx("span",{className:"pill",style:{background:"var(--green-muted)",color:"var(--green)",fontSize:"9px",padding:"1px 5px"},title:"Loaded from the ## Test Cases block in SKILL.md. Save back any edits to persist them.",children:"from SKILL.md"}),T==="ai-generated"&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},title:"AI-generated. Save as test cases to persist into SKILL.md.",children:"AI-generated"})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:W,disabled:A||!Q||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:A?"var(--surface-3)":"var(--surface-2)",color:Q?"var(--green)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:Q?1:.5,cursor:Q?"pointer":"not-allowed"},title:Q?"Write the current prompts back to SKILL.md as a ## Test Cases block":"No prompts to save",onMouseEnter:J=>{Q&&!A&&(J.currentTarget.style.background="var(--surface-3)")},onMouseLeave:J=>{A||(J.currentTarget.style.background="var(--surface-2)")},children:A?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--green)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Saving..."]}):r.jsxs(r.Fragment,{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("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),r.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),r.jsx("polyline",{points:"7 3 7 8 15 8"})]}),"Save as test cases"]})}),r.jsx("button",{onClick:$,disabled:w||!K||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:w?"var(--surface-3)":"var(--surface-2)",color:K?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:K?1:.5,cursor:K?"pointer":"not-allowed"},title:K?void 0:"No skill description available",onMouseEnter:J=>{K&&!w&&(J.currentTarget.style.background="var(--surface-3)")},onMouseLeave:J=>{w||(J.currentTarget.style.background="var(--surface-2)")},children:w?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"})}),Q?"Regenerate":"Generate"," Test Prompts"]})})]})]}),M&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--green)",background:"var(--green-muted)"},"aria-live":"polite",children:M}),B&&r.jsxs("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},"aria-live":"polite",children:["Save failed: ",B]}),!K&&!b&&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."}),N&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:N}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:_,onChange:J=>H(J.target.value),placeholder:`How do I write a unit test?
|
|
103
|
+
What edge cases should I test?
|
|
104
|
+
+Deploy this to production
|
|
105
|
+
!What's the weather like today?
|
|
106
|
+
!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(zo,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(zo,{}),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(zo,{}),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(zo,{}),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:D,disabled:b||!_.trim(),className:"btn btn-primary",children:b?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"]})}),b&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:i,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[C||`${v.length} / ${Y} prompts tested`,k&&r.jsx(CN,{startedAt:k})]})]})]})]}),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:K?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:ue}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),j&&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:j}),b&&v.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..."})]}),v.length>0&&r.jsxs("div",{className:"space-y-5",children:[I.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 (",I.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:I.map((J,ie)=>r.jsx(cv,{result:J},`incorrect-${ie}`))})]}),L.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 (",L.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:L.map((J,ie)=>r.jsx(cv,{result:J},`correct-${ie}`))})]})]}),y&&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"}),y.autoClassifiedCount!=null&&y.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[y.autoClassifiedCount," of ",y.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(Yd,{label:"Precision",value:y.precision,description:"Of all activations, how many were correct?",detail:`${y.tp} true / ${y.tp+y.fp} total activations`}),r.jsx(Yd,{label:"Recall",value:y.recall,description:"Of expected activations, how many fired?",detail:`${y.tp} activated / ${y.tp+y.fn} expected`}),r.jsx(Yd,{label:"Reliability",value:y.reliability,description:"Overall correct classification rate",detail:`${y.tp+y.tn} correct / ${y.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(Do,{label:"True Positive",abbr:"TP",count:y.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(Do,{label:"False Positive",abbr:"FP",count:y.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(Do,{label:"False Negative",abbr:"FN",count:y.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(Do,{label:"True Negative",abbr:"TN",count:y.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]}),r.jsxs("div",{className:"mt-3 max-w-xs mx-auto text-center text-[11px]",style:{color:"var(--text-tertiary)"},title:"Auto-classified disagreements: not real failures, but worth reviewing. Hover a yellow row for details.",children:["Warnings:"," ",r.jsxs("span",{style:{color:(y.scopeWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[y.scopeWarnings??0," scope"]}),", ",r.jsxs("span",{style:{color:(y.driftWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[y.driftWarnings??0," drift"]})]})]})]}),r.jsx(SN,{history:P,expanded:ee,onToggle:()=>U(!ee),skillVersion:z})]})}function SN({history:t,expanded:a,onToggle:s,skillVersion:i}){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(kN,{run:c,skillVersion:i},c.id))})})]})}function kN({run:t,skillVersion:a}){const s=Math.round(t.summary.reliability*100),i=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=i;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:wN(t.timestamp)}),r.jsx(ui,{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:i,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 wN(t){const a=Date.now(),s=new Date(t).getTime(),i=Math.floor((a-s)/1e3);if(i<60)return"just now";const c=Math.floor(i/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 zo(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function cv({result:t}){const a=t.verdict==="scope_warning"||t.verdict==="drift_warning",s=a?t.verdict==="scope_warning"?"SCOPE_WARNING":"DRIFT_WARNING":t.classification,i=ov[s]||ov.FN,c=!a&&(t.classification==="TP"||t.classification==="TN"),u=t.verdict==="scope_warning"?"scope warn":t.verdict==="drift_warning"?"drift warn":null,d=t.verdict&&t.verdict!=="ok"?bN[t.verdict]:void 0;return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:i.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, ${i.text} 20%, transparent)`},children:c?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):a?r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.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:i.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},title:d,children:u??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 Yd({label:t,value:a,description:s,detail:i}){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:i})]})}function Do({abbr:t,count:a,bg:s,color:i,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:i},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:i},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function CN({startedAt:t}){const[a,s]=m.useState(0);return m.useEffect(()=>{const i=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(i)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}function EN(t){return t==="benchmark"||t==="activation"||t==="ab"}function NN({mode:t}){var f;const{state:a,runAll:s}=bn(),i=m.useRef(!1),u=(((f=a.evals)==null?void 0:f.evals)??[]).length,d=a.evals!=null;return m.useEffect(()=>{if(t!=="benchmark"||typeof window>"u"||i.current)return;const h=new URLSearchParams(window.location.search);if(h.get("autorun")!=="1"||!d||u===0)return;i.current=!0,s("benchmark"),h.delete("autorun");const x=h.toString(),v=`${window.location.pathname}${x?"?"+x:""}${window.location.hash}`;window.history.replaceState(null,"",v)},[t,d,u,s]),t==="activation"?r.jsx(jN,{}):r.jsx(xN,{})}const Kd={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},uv={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},Cf=600,Ef=180,gn=40,Xd=Cf-gn*2,ha=Ef-gn*2,TN=[25,50,75,100];function dv(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function RN(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function AN({entries:t,onPointClick:a}){const[s,i]=m.useState(null),c=m.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((x,v)=>{const y=gn+v/(u-1)*Xd,b=x.passRate*100,j=gn+ha-b/100*ha;return{x:y,y:j,pct:b,entry:x}}),f=d.map(x=>`${x.x},${x.y}`).join(" "),h=Array.from(new Set(c.map(x=>x.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:h.map(x=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Kd[x]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:uv[x]??x})]},x))}),r.jsxs("svg",{width:Cf,height:Ef,viewBox:`0 0 ${Cf} ${Ef}`,style:{display:"block",overflow:"visible"},children:[TN.map(x=>{const v=gn+ha-x/100*ha;return r.jsxs("g",{children:[r.jsx("line",{x1:gn,y1:v,x2:gn+Xd,y2:v,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:gn-8,y:v+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[x,"%"]})]},x)}),r.jsx("line",{x1:gn,y1:gn+ha,x2:gn+Xd,y2:gn+ha,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:gn-8,y:gn+ha+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),r.jsx("polyline",{points:f,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((x,v)=>r.jsx("circle",{cx:x.x,cy:x.y,r:5,fill:Kd[x.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"),i({x:x.x,y:x.y,entry:x.entry})},onMouseLeave:y=>{y.currentTarget.setAttribute("r","5"),i(null)},onClick:()=>a==null?void 0:a(x.entry)},v)),LN(u).map(x=>r.jsx("text",{x:d[x].x,y:gn+ha+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:dv(c[x].timestamp)},x))]}),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:dv(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:Kd[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:uv[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:RN(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function LN(t){if(t<=3)return Array.from({length:t},(i,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 i=a;i<t-1;i+=a)s.push(i);return s.push(t-1),s}const Fs=new Map;let vn=null,Go=null,_o=1e3,_l=0;function pb(){if(vn)return;vn=new EventSource("/api/events");const t=a=>s=>{let i={};try{i=s.data?JSON.parse(s.data):{}}catch{}const c=Fs.get(a);if(c)for(const u of c)u(i)};vn.addEventListener("benchmark:complete",t("benchmark:complete")),vn.addEventListener("history:written",t("history:written")),vn.addEventListener("leaderboard:updated",t("leaderboard:updated")),vn.onerror=()=>{vn==null||vn.close(),vn=null,_l>0&&(Go=setTimeout(()=>{_o=Math.min(_o*2,3e4),pb()},_o))},vn.onopen=()=>{_o=1e3}}function MN(){Go!=null&&(clearTimeout(Go),Go=null),vn==null||vn.close(),vn=null}function zN(t,a){return Fs.has(t)||Fs.set(t,new Set),Fs.get(t).add(a),_l++,pb(),()=>{var s;(s=Fs.get(t))==null||s.delete(a),_l--,_l<=0&&(_l=0,queueMicrotask(()=>{_l<=0&&MN()}))}}function Qo(t,a){const s=m.useRef(a);s.current=a,m.useEffect(()=>zN(t,c=>s.current(c)),[t])}function Zo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function DN(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function _N({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:Zo(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:Zo(t)}})})]})})}function ON({points:t}){if(t.length<2)return null;const a=200,s=48,i=4,c=t.length,u=t.map((h,x)=>{const v=i+x/(c-1)*(a-i*2),y=i+(s-i*2)-h.passRate*(s-i*2);return{x:v,y}}),d=`M ${u[0].x},${s-i} `+u.map(h=>`L ${h.x},${h.y}`).join(" ")+` L ${u[u.length-1].x},${s-i} Z`,f=u.map((h,x)=>`${x===0?"M":"L"} ${h.x},${h.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:f,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 BN({plugin:t,skill:a}){const s=`stats/${t}/${a}`,i=m.useCallback(()=>ke.getStats(t,a),[t,a]),{data:c,loading:u}=Ga(s,i),d=m.useCallback(()=>$n(s),[s]);if(Qo("benchmark:complete",d),Qo("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 f=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,h=c.trendPoints.length>0?c.trendPoints[0].passRate:0,x=f-h,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:Zo(f)},children:[Math.round(f*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:x>=0?"var(--green)":"var(--red)"},children:[x>=0?"+":"",Math.round(x*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:Hn(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:Hn(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(ON,{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:Zo(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:DN(y.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.avgCost!=null?Hn(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(_N,{rate:y.passRate,label:y.text})]},`${y.evalId}:${y.id}`))})]})]})}function IN({plugin:t,skill:a}){const[s,i]=m.useState(null),[c,u]=m.useState(null),[d,f]=m.useState({}),[h,x]=m.useState({});m.useEffect(()=>{ke.getEvals(t,a).then(i).catch(()=>i(null))},[t,a]);async function v(y){if(c===y){u(null);return}if(u(y),!d[y]){x(b=>({...b,[y]:!0}));try{const b=await ke.getCaseHistory(t,a,y);f(j=>({...j,[y]:b}))}catch{f(b=>({...b,[y]:[]}))}finally{x(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]||[],j=c===y.id,k=h[y.id],C=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:j?"var(--surface-2)":"transparent"},onMouseEnter:w=>{j||(w.currentTarget.style.background="var(--surface-2)")},onMouseLeave:w=>{j||(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:j?"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(ab,{entries:b}),C!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Hl(C)},children:[Math.round(C*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"]})]}),j&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?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,N)=>r.jsxs("div",{className:"p-4",style:{background:N===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:nb(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:Hl(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:rb(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(T=>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:T.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:T.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:T.text}),T.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:T.reasoning})]})]},T.id))})]},N))})})]},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 $N(){const{state:t,dispatch:a}=bn(),{plugin:s,skill:i}=t,{state:c}=cr(),u=c.skills.find(W=>W.plugin===s&&W.skill===i),d=(u==null?void 0:u.resolvedVersion)??(u==null?void 0:u.version)??null,[f,h]=m.useState("timeline"),[x,v]=m.useState(""),[y,b]=m.useState(""),[j,k]=m.useState(!1),[C,w]=m.useState([]),[N,T]=m.useState(null),[A,B]=m.useState(!1),[M,P]=m.useState(null),[E,O]=m.useState(!1),z=`history/${s}/${i}?model=${x}&type=${y}`,_=m.useCallback(()=>ke.getHistory(s,i,{model:x||void 0,type:y||void 0}),[s,i,x,y]),{data:H,loading:F}=Ga(z,_),q=H??[];m.useEffect(()=>{!H||H.length<2||ke.compareRuns(s,i,H[0].timestamp,H[1].timestamp).then(W=>{const Y=W.regressions.filter(oe=>oe.change==="regression");a({type:"SET_REGRESSIONS",regressions:Y})}).catch(()=>{})},[H,s,i,a]);const ee=m.useCallback(()=>$n(z),[z]);Qo("history:written",ee);const U=m.useCallback(async W=>{if(j){w(Y=>Y.includes(W)?Y.filter(oe=>oe!==W):Y.length>=2?[Y[1],W]:[...Y,W]);return}O(!0);try{const Y=await ke.getHistoryEntry(s,i,W);P(Y)}catch{}finally{O(!1)}},[s,i,j]),D=m.useCallback(async()=>{if(C.length===2){B(!0);try{const W=await ke.compareRuns(s,i,C[0],C[1]);T(W)}catch{}finally{B(!1)}}},[s,i,C]),$=[...new Set(q.map(W=>W.model))];return F?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(W=>r.jsx("button",{onClick:()=>h(W),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:f===W?"var(--accent-muted)":"transparent",color:f===W?"var(--accent)":"var(--text-tertiary)"},children:W==="timeline"?"Timeline":W==="per-eval"?"Per Eval":"Statistics"},W))}),f==="timeline"&&r.jsxs("div",{children:[q.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(AN,{entries:q,onPointClick:W=>U(W.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:x,onChange:W=>v(W.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),$.map(W=>r.jsx("option",{value:W,children:W},W))]}),r.jsxs("select",{value:y,onChange:W=>b(W.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:()=>{k(!j),w([]),T(null)},className:`btn text-[12px] ${j?"btn-primary":"btn-secondary"}`,children:j?"Exit Compare":"Compare Runs"}),j&&C.length===2&&r.jsx("button",{onClick:D,disabled:A,className:"btn btn-primary text-[12px]",children:A?"Comparing...":"Compare"})]}),r.jsx("div",{className:"space-y-2",children:q.length===0?r.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):q.map(W=>{const Y=C.includes(W.timestamp);return r.jsx("button",{onClick:()=>U(W.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:Y?"var(--accent-muted)":"var(--surface-1)",border:Y?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:oe=>{Y||(oe.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:oe=>{Y||(oe.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:[j&&r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:Y?"var(--accent)":"var(--border-default)",background:Y?"var(--accent)":"transparent"},children:Y&&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(W.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:W.type==="comparison"?"var(--purple-muted)":W.type==="baseline"?"var(--surface-3)":W.type==="model-compare"?"var(--accent-muted)":W.type==="improve"||W.type==="instruct"?"var(--purple-muted)":W.type==="ai-generate"?"var(--green-muted)":W.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:W.type==="comparison"?"var(--purple)":W.type==="baseline"?"var(--text-tertiary)":W.type==="model-compare"?"var(--accent)":W.type==="improve"||W.type==="instruct"?"var(--purple)":W.type==="ai-generate"?"var(--green)":W.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:W.type==="model-compare"?"model compare":W.type==="improve"?"ai improve":W.type==="instruct"?"ai edit":W.type==="ai-generate"?"ai generate":W.type==="eval-generate"?"eval generate":W.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ui,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:W.model}),W.totalCost!=null&&W.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Hn(W.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:W.passRate>=.8?"var(--green)":W.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(W.passRate*100),"%"]})]})]})},W.timestamp)})}),N&&r.jsx(UN,{result:N}),M&&!j&&r.jsx(HN,{run:M,onClose:()=>P(null)})]}),f==="per-eval"&&r.jsx(IN,{plugin:s,skill:i}),f==="statistics"&&r.jsx(BN,{plugin:s,skill:i})]})}function UN({result:t}){const a=t.regressions.filter(i=>i.change==="regression"),s=t.regressions.filter(i=>i.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: ",Hn(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Hn(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: ",Hn(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(i=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:i.assertionId})," (was passing, now failing)"]},`${i.evalId}-${i.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(i=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:i.assertionId})," (was failing, now passing)"]},`${i.evalId}-${i.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(i=>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:["#",i.eval_id," ",i.eval_name]}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:i.passRateA!=null?i.passRateA>=.8?"var(--green)":i.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:i.passRateA!=null?`${Math.round(i.passRateA*100)}%`:i.statusA}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:i.passRateB!=null?i.passRateB>=.8?"var(--green)":i.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:i.passRateB!=null?`${Math.round(i.passRateB*100)}%`:i.statusB})]},i.eval_id))})]})})]})}function HN({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(PN,{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: ${Hn(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:Hn(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 PN({run:t,onClose:a}){var u;const s=m.useMemo(()=>t.improve?dc(t.improve.original,t.improve.improved):[],[t.improve]),i=m.useMemo(()=>{const d=s.filter(h=>h.type==="added").length,f=s.filter(h=>h.type==="removed").length;return{added:d,removed:f}},[s]),c=m.useMemo(()=>{let d=0,f=0;return s.map(h=>h.type==="removed"?(d++,{...h,origNum:d,newNum:null}):h.type==="added"?(f++,{...h,origNum:null,newNum:f}):(d++,f++,{...h,origNum:d,newNum:f}))},[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:["+",i.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",i.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,f)=>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||""})]},f))})})})]})}function mb({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,i=24,c=2,u=s-c*2,d=i-c*2,f=a.length,h=Math.min(...a),v=Math.max(...a)-h||1,y=a.map((k,C)=>{const w=c+C/(f-1)*u,N=c+d-(k-h)/v*d;return`${w.toFixed(1)},${N.toFixed(1)}`}),b=a[a.length-1],j=Hl(b);return r.jsxs("svg",{width:s,height:i,viewBox:`0 0 ${s} ${i}`,style:{display:"block"},children:[r.jsx("polyline",{points:y.join(" "),fill:"none",stroke:j,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,C]=y[y.length-1].split(",");return r.jsx("circle",{cx:k,cy:C,r:2.5,fill:j})})()]})}function VN(){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 FN({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)",i=t>=0?"+":"";return r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[i,t.toFixed(1),"%"]})}function WN({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)"}},i=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:i.bg,color:i.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function GN({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 qN({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 YN(t){var i,c,u;if(t.length===0)return[];const a=new Map;for(const d of t)for(const f of d.models){if(f.status==="error")continue;const h=`${f.provider}/${f.model}`;a.has(h)||a.set(h,{provider:f.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const x=a.get(h);x.passRates.push(f.passRate.mean),x.lastRubric=((i=f.rubricScore)==null?void 0:i.mean)??null,x.lastDuration=f.duration.mean,x.lastCost=((c=f.cost)==null?void 0:c.total)??null,x.lastCompositeScore=f.compositeScore,f.baselinePassRate!=null&&(x.lastBaselinePassRate=f.baselinePassRate.mean,x.lastSkillDelta=(u=f.skillDelta)==null?void 0:u.mean,x.lastAmplificationPct=f.amplificationPct,x.hasBaseline=!0)}const s=[];for(const[d,f]of a){const[h,...x]=d.split("/");s.push({rank:0,model:x.join("/"),provider:h,passRate:f.passRates[f.passRates.length-1],rubricScore:f.lastRubric,duration:f.lastDuration,cost:f.lastCost,sparklineData:f.passRates,isBest:!1,baselinePassRate:f.lastBaselinePassRate,skillDelta:f.lastSkillDelta,amplificationPct:f.lastAmplificationPct,compositeScore:f.lastCompositeScore,hasBaseline:f.hasBaseline})}return s.sort((d,f)=>{const h=d.compositeScore??d.passRate;return(f.compositeScore??f.passRate)-h}),s.forEach((d,f)=>{d.rank=f+1}),s.length>0&&(s[0].isBest=!0),s}const hb=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function KN({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:hb(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(VN,{})]})}),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:Hl(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(mb,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function XN({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,i)=>(i.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:hb(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,i)=>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:i+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:Hl(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(FN,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(mb,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function QN(){const{state:t}=bn(),{plugin:a,skill:s}=t,[i,c]=m.useState("rankings"),u=`leaderboard/${a}/${s}`,d=m.useCallback(()=>ke.getLeaderboard(a,s),[a,s]),{data:f,loading:h,error:x}=Ga(u,d),v=(f==null?void 0:f.entries)??[],y=(x==null?void 0:x.message)??null;m.useEffect(()=>{c("rankings")},[a,s]);const b=m.useCallback(()=>$n(u),[u]);Qo("leaderboard:updated",b);const j=m.useMemo(()=>YN(v),[v]),k=j.some(N=>N.hasBaseline),C=v[0],w=C==null?void 0:C.judgeBiasWarning;return h?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})]})}):j.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(qN,{active:i,onChange:c,hasBaseline:k})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[v.length," sweep",v.length!==1?"s":""," · ",j.length," model",j.length!==1?"s":""]})]}),w&&r.jsx(GN,{warning:w}),i==="rankings"?r.jsx(KN,{entries:j}):r.jsx(XN,{entries:j}),i==="amplification"&&(C==null?void 0:C.skillQualityScore)!=null&&(C==null?void 0:C.skillQualityRating)&&r.jsx(WN,{score:C.skillQualityScore,rating:C.skillQualityRating})]})}function ZN(t){if(!t)return[];const a=t.split(`
|
|
107
|
+
`),s=[];for(const i of a)if(!(i.startsWith("--- ")||i.startsWith("+++ "))){if(i.startsWith("@@")){s.push({type:"header",content:i});continue}if(i.startsWith("+")){s.push({type:"add",content:i.slice(1)});continue}if(i.startsWith("-")){s.push({type:"remove",content:i.slice(1)});continue}(i.startsWith(" ")||i===""&&s.length>0)&&s.push({type:"context",content:i.startsWith(" ")?i.slice(1):""})}return s}function Kf({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:i,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:f}){const[h,x]=m.useState(u),[v,y]=m.useState("unified"),b=m.useRef(null),j=m.useRef(null),k=m.useMemo(()=>ZN(t),[t]),C=m.useMemo(()=>{const M=k.filter(E=>E.type==="add").length,P=k.filter(E=>E.type==="remove").length;return{added:M,removed:P}},[k]),w=m.useMemo(()=>{let M=0,P=0;return k.filter(E=>E.type!=="header").map(E=>E.type==="remove"?(M++,{...E,origNum:M,newNum:null}):E.type==="add"?(P++,{...E,origNum:null,newNum:P}):(M++,P++,{...E,origNum:M,newNum:P}))},[k]),N=m.useMemo(()=>{const M=[],P=[];for(const E of w)if(E.type==="remove")M.push(E);else if(E.type==="add")P.push(E);else{for(;M.length<P.length;)M.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<M.length;)P.push({type:"context",content:"",origNum:null,newNum:null});M.push(E),P.push(E)}for(;M.length<P.length;)M.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<M.length;)P.push({type:"context",content:"",origNum:null,newNum:null});return{left:M,right:P}},[w]),T=m.useCallback(M=>{const P=M==="left"?b.current:j.current,E=M==="left"?j.current:b.current;P&&E&&(E.scrollTop=P.scrollTop)},[]);if(!t||k.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."}),f&&r.jsx("button",{onClick:f,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const A=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=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:["+",C.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",C.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:()=>x(!h),className:"btn btn-ghost text-[11px]",children:h?"Expand":"Collapse"})]})]}),i&&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:i}),!h&&(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((M,P)=>r.jsxs("tr",{style:{background:M.type==="add"?"rgba(34,197,94,0.08)":M.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:M.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:M.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:M.origNum??""}),r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:M.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:M.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:M.newNum??""}),r.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:M.type==="add"?"var(--green)":M.type==="remove"?"var(--red)":"transparent",borderRight:M.type==="add"?"2px solid var(--green)":M.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:M.type==="add"?"+":M.type==="remove"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:M.type==="add"?"var(--green)":M.type==="remove"?"var(--red)":"var(--text-secondary)"},children:M.content||""})]},P))})})}):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:()=>T("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.left.map((M,P)=>r.jsxs("tr",{style:{background:M.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:M.origNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:M.type==="remove"?"var(--red)":"var(--text-secondary)"},children:M.content||""})]},P))})})}),r.jsx("div",{ref:j,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>T("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.right.map((M,P)=>r.jsxs("tr",{style:{background:M.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:M.newNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:M.type==="add"?"var(--green)":"var(--text-secondary)"},children:M.content||""})]},P))})})})]}))]});return d==="modal"?r.jsx("div",{className:A,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Qd="https://verified-skill.com/submit",JN=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function eT(t){if(!t)return Qd;const a=t.trim();return!a||!JN.test(a)?Qd:`${Qd}?repo=${encodeURIComponent(a)}`}const tT={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 nT({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 rT({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 fv={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)"}},aT={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function xb(t){return aT[t]??t}function lT({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 sT({tier:t,size:a}){return t==="TAINTED"?r.jsx(lT,{size:a}):t==="CERTIFIED"?r.jsx(rT,{size:a}):r.jsx(nT,{size:a})}function B4({tier:t,size:a="md",isTainted:s}){const i=tT[a],c=s?"TAINTED":t,u=fv[c]??fv.VERIFIED;return r.jsxs("span",{"data-testid":"tier-badge","data-tier":c,style:{display:"inline-flex",alignItems:"center",gap:i.gap,padding:`${i.py} ${i.px}`,height:i.height,borderRadius:i.radius,fontFamily:"var(--font-geist-mono)",fontSize:i.fontSize,fontWeight:600,letterSpacing:"0.03em",whiteSpace:"nowrap",color:u.color,backgroundColor:u.bg,border:`1px solid ${u.border}`,lineHeight:1},children:[r.jsx(sT,{tier:c,size:i.icon}),xb(c)]})}const pv={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 iT(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function oT(t){if(!t)return"";const a=t.trim();if(!a)return"";const s=a.toLowerCase();return s==="0 files"||s==="no files"||s==="no file changes"?"Metadata-only release — no file changes":a}function cT(){const{state:t}=bn(),{plugin:a,skill:s}=t,i=cr(),{onSkillUpdated:c,updateCount:u}=i,d=m.useMemo(()=>i.state.skills.find(Y=>Y.plugin===a&&Y.skill===s)??null,[i.state.skills,a,s]),f=`versions-envelope/${a}/${s}`,h=m.useCallback(()=>ke.getSkillVersionsEnvelope(a,s),[a,s]),{data:x,loading:v}=Ga(f,h),y=(x==null?void 0:x.versions)??[],b=(x==null?void 0:x.provider)??"local",j=(x==null?void 0:x.source)==="none",[k,C]=m.useState(null),[w,N]=m.useState(null),[T,A]=m.useState(null),[B,M]=m.useState(!1),[P,E]=m.useState("idle"),[O,z]=m.useState(null),_=m.useRef(null),H=m.useRef(null),F=m.useMemo(()=>(y==null?void 0:y.find(Y=>Y.isInstalled))??null,[y]),q=m.useMemo(()=>(y==null?void 0:y[0])??null,[y]),ee=F&&q&&F.version!==q.version,U=m.useCallback(Y=>{k?!w&&Y!==k?N(Y):(C(Y),N(null),A(null)):(C(Y),A(null))},[k,w]),D=m.useCallback(async(Y,oe)=>{M(!0);try{const L=await ke.getVersionDiff(a,s,Y,oe);A(L)}catch{A(null)}finally{M(!1)}},[a,s]);m.useEffect(()=>{if(k&&w){const Y=y||[],oe=Y.findIndex(Q=>Q.version===k),L=Y.findIndex(Q=>Q.version===w),[I,K]=oe>L?[k,w]:[w,k];D(I,K)}},[k,w,y,D]);const $=m.useCallback(()=>{!F||!q||(C(F.version),N(q.version))},[F,q]),W=m.useCallback(async()=>{E("updating"),z(null);const Y=new AbortController;_.current=Y;try{const oe=await ke.postSkillUpdate(a,s,Y.signal);if(oe.ok)E("done"),c(a,s);else{const L=`Update failed (HTTP ${oe.status}): ${oe.body||"no response body"}`;E("error"),z(L)}}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError")return;const L=oe instanceof Error?oe.message:"Network error";E("error"),z(L)}finally{_.current===Y&&(_.current=null)}},[a,s,c]);if(m.useEffect(()=>()=>{var Y;(Y=_.current)==null||Y.abort(),_.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(!y||y.length===0){if((d==null?void 0:d.origin)==="source"){const oe=eT((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:oe,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(wf,{provider:b}),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)"},"data-testid":"versions-no-upstream-message",children:j?"No upstream registry — this skill ships without origin metadata, so update tracking is unavailable.":"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:[ee&&r.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),ee&&P!=="done"&&(P==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:O||"Update failed"}),r.jsx("button",{onClick:W,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:W,disabled:P!=="idle",className:"btn btn-primary text-[11px]",children:P==="idle"?`Update to ${q==null?void 0:q.version}`:P==="updating"?"Starting update...":P==="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,")"]})]})]}),k&&!w&&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 ",k]}),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:y.map(Y=>{const oe=pv[Y.certTier]||pv.COMMUNITY,L=Y.version===k||Y.version===w,I=Y.isInstalled;return r.jsxs("button",{onClick:()=>U(Y.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:L?"var(--accent-muted)":"transparent",border:L?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:K=>{L||(K.currentTarget.style.background="var(--surface-1)")},onMouseLeave:K=>{L||(K.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:I?10:8,height:I?10:8,background:I?"var(--accent)":"var(--surface-3)",border:I?"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:Y.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:oe.bg,color:oe.text},children:xb(Y.certTier)}),r.jsx(wf,{provider:b}),I&&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(Y.createdAt).toLocaleDateString()})]}),(()=>{const K=oT(Y.diffSummary);return K?r.jsx("div",{"data-testid":"version-row-diff-summary",className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:iT(K,80)}):null})()]},Y.version)})}),r.jsx("div",{ref:H,style:{height:1}})]}),B&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),T&&!B&&r.jsx("div",{className:"mt-4",children:r.jsx(Kf,{contentDiff:T.contentDiff,fromLabel:T.from,toLabel:T.to,diffSummary:T.diffSummary,renderContext:"inline",onRetry:()=>k&&w&&D(T.from,T.to)})})]})}function uT(t){return t==="timeline"||t==="models"||t==="versions"}function dT({view:t}){return t==="models"?r.jsx(QN,{}):t==="versions"?r.jsx(cT,{}):r.jsx($N,{})}function fT(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 pT(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,i=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!i&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:i||s?null:t.aiSuggestedPlugin??null}}function Jo(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function mT(t,a,s,i){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){case 1:return`${u}/${s}/skills/${i}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${i}/SKILL.md`;case 3:return`${u}/skills/${i}/SKILL.md`}}function hT({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[i,c]=m.useState("ai"),[u,d]=m.useState(null),[f,h]=m.useState(!0),{config:x}=qa(),[v,y]=m.useState(""),[b,j]=m.useState(s??3),[k,C]=m.useState(""),[w,N]=m.useState(""),[T,A]=m.useState(""),[B,M]=m.useState(""),[P,E]=m.useState(""),[O,z]=m.useState(""),[_,H]=m.useState("write"),[F,q]=m.useState([]),[ee,U]=m.useState(!1),[D,$]=m.useState(null),[W,Y]=m.useState(null),[oe,L]=m.useState(null),[I,K]=m.useState("vskill"),[Q,ue]=m.useState("1.0.0"),[J,ie]=m.useState(!0),Z=m.useCallback(async()=>{try{const Be=await ke.detectEngines();L(Be),K(Je=>Je!=="vskill"?Je:Be.vskillSkillBuilder?"vskill":Be.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{L({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);m.useEffect(()=>{Z()},[Z]);const[me,je]=m.useState(""),[Te,Me]=m.useState(!1),[Fe,Ue]=m.useState(!1),[De,We]=m.useState(null),[ft,ce]=m.useState(null),[ve,ye]=m.useState([]),be=m.useRef(null),Ne=m.useRef(null),qe=m.useRef(null),He=m.useRef(null),jt=m.useRef(null),[Ot,St]=m.useState(!1),[Lt,xe]=m.useState(!1),Ze=m.useRef(v),Xe=m.useRef(k),kt=m.useRef(w);m.useEffect(()=>{Ze.current=v},[v]),m.useEffect(()=>{Xe.current=k},[k]),m.useEffect(()=>{kt.current=w},[w]),m.useEffect(()=>{ke.getProjectLayout().then(Be=>{if(d(Be),s)return;j(Be.suggestedLayout);const Je=Be.detectedLayouts.find(An=>An.layout===Be.suggestedLayout);Je!=null&&Je.existingPlugins.length&&C(Je.existingPlugins[0])}).catch(()=>{}).finally(()=>h(!1))},[s]),m.useEffect(()=>{var Be;i==="ai"&&((Be=be.current)==null||Be.focus())},[i]),m.useEffect(()=>()=>{var Be;(Be=Ne.current)==null||Be.abort()},[]);const Bt=m.useMemo(()=>{var Be;return u?((Be=u.detectedLayouts.find(Je=>Je.layout===b))==null?void 0:Be.existingPlugins)||[]:[]},[u,b]),lt=k==="__new__"?w:k,jn=u?mT(u.root,b,lt||"{plugin}",v||"{skill}"):"",Kt=m.useMemo(()=>u?u.detectedLayouts.filter(Be=>Be.layout!==4):[],[u]),mn=m.useMemo(()=>{if(!u)return null;const Be=u.detectedLayouts.find(kn=>kn.layout===2&&kn.existingPlugins.length>0),Je=u.detectedLayouts.find(kn=>kn.layout===1&&kn.existingPlugins.length>0),An=Be||Je;return An?{layout:An.layout,plugins:An.existingPlugins}:null},[u]),un=m.useCallback(()=>{if(a)return a();if(!x)return{provider:"claude-cli",model:"sonnet"};const Be=x.provider||"claude-cli",Je=x.model||"sonnet";return{provider:Be,model:Je}},[x,a]),ur=m.useCallback(()=>{var Be;(Be=Ne.current)==null||Be.abort(),Me(!1)},[]),wt=m.useCallback(()=>{We(null),ce(null)},[]),Pn=m.useCallback(async()=>{var kn,Vr;if(We(null),ce(null),ye([]),qe.current=null,He.current=null,!me.trim()){We("Describe what your skill should do");return}Me(!0);const Be=new AbortController;Ne.current=Be;const{provider:Je,model:An}=un();try{const rn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fT({prompt:me.trim(),provider:Je,model:An,targetAgents:F})),signal:Be.signal});if(!rn.ok||!rn.body){let Xt=`HTTP ${rn.status}`;try{const Ct=await rn.json();Ct.error&&(Xt=Ct.error)}catch{}throw new Error(Xt)}const Xa=rn.body.getReader(),re=new TextDecoder;let Se="",Ce="";for(;;){const{done:Xt,value:Ct}=await Xa.read();if(Xt)break;Se+=re.decode(Ct,{stream:!0});const hn=Se.split(`
|
|
108
|
+
`);Se=hn.pop()||"";for(const dr of hn)if(dr.startsWith("event: "))Ce=dr.slice(7).trim();else if(dr.startsWith("data: ")){try{const et=JSON.parse(dr.slice(6));if(Ce==="progress")ye(Mt=>[...Mt,{phase:et.phase,message:et.message,timestamp:Date.now()}]);else if(Ce==="provenance")He.current={resolvedModelId:typeof et.resolvedModelId=="string"?et.resolvedModelId:null,snapshotDate:typeof et.snapshotDate=="string"?et.snapshotDate:null};else if(Ce==="done"||Ce==="complete"){const Mt={prompt:me.trim(),provider:un().provider,model:un().model,resolvedModelId:((kn=He.current)==null?void 0:kn.resolvedModelId)??null,snapshotDate:((Vr=He.current)==null?void 0:Vr.snapshotDate)??null,reasoning:et.reasoning||""},Ut=pT({userName:Ze.current,userPlugin:Xe.current,userNewPlugin:kt.current,aiName:et.name,aiSuggestedPlugin:et.suggestedPlugin&&et.suggestedPlugin.plugin?{plugin:et.suggestedPlugin.plugin,layout:et.suggestedPlugin.layout}:null,forceLayout:s});if(Ut.applyName!==null&&y(Ut.applyName),A(et.description),M(et.model||""),E(et.allowedTools||""),z(et.body),Ue(!0),qe.current=Mt,c("manual"),s===3)j(3),C(""),N("");else if(Ut.applySuggestedPlugin&&Ut.suggestedPluginValue){const an=Ut.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(Wr=>Wr.existingPlugins))??[]).includes(an.plugin))if(C(an.plugin),an.layout&&(an.layout===1||an.layout===2))j(an.layout);else{const Wr=u==null?void 0:u.detectedLayouts.find(pi=>pi.existingPlugins.includes(an.plugin));Wr&&(Wr.layout===1||Wr.layout===2)&&j(Wr.layout)}else C("__new__"),N(an.plugin)}else!Ut.applySuggestedPlugin&&Xe.current.trim().length===0&&kt.current.trim().length===0&&b===3&&mn&&xe(!0);const Fr={name:et.name,plugin:lt||"",layout:b,description:et.description,model:et.model||void 0,allowedTools:et.allowedTools||void 0,body:et.body,aiMeta:Mt};ke.saveDraft(Fr).then(an=>{St(!0),an!=null&&an.dir&&(jt.current=an.dir)}).catch(()=>{})}else Ce==="error"&&(We(et.message||et.description||"Unknown error"),et.category&&ce(et))}catch{}Ce=""}}}catch(rn){rn.name!=="AbortError"&&We(rn.message)}finally{Me(!1),Ne.current=null}},[me,un,b,mn,lt,u,F,s]),Sn=m.useCallback(async()=>{var Be;if($(null),Y(null),!v.trim()){$("Skill name is required");return}if(!T.trim()){$("Description is required");return}if(b!==3&&!lt.trim()){$("Plugin name is required");return}if(!J){$("Version is not valid semver");return}U(!0);try{const Je=await ke.createSkill({name:Jo(v),plugin:lt||"",layout:b,description:T,model:B||void 0,allowedTools:P||void 0,body:O,aiMeta:qe.current||void 0,draftDir:jt.current||void 0,version:Q.trim()||void 0,engine:I});jt.current=null,t(Je.plugin,Je.skill)}catch(Je){if(Je instanceof va&&Je.status===409&&((Be=Je.details)==null?void 0:Be.code)==="skill-already-exists"){const An=typeof Je.details.plugin=="string"?Je.details.plugin:"",kn=typeof Je.details.skill=="string"?Je.details.skill:Jo(v);Y("Skill already existed — opened it."),jt.current=null,t(An,kn)}else $(Je.message)}finally{U(!1)}},[v,T,b,lt,B,P,O,Q,J,I,t]),Et=m.useCallback(()=>{mn&&(j(mn.layout),C(mn.plugins[0]),xe(!1))},[mn]);return{mode:i,setMode:c,layout:u,layoutLoading:f,selectedLayout:b,setSelectedLayout:j,creatableLayouts:Kt,availablePlugins:Bt,pathPreview:jn,plugin:k,setPlugin:C,newPlugin:w,setNewPlugin:N,effectivePlugin:lt,name:v,setName:y,description:T,setDescription:A,model:B,setModel:M,allowedTools:P,setAllowedTools:E,body:O,setBody:z,bodyViewMode:_,setBodyViewMode:H,aiPrompt:me,setAiPrompt:je,generating:Te,aiGenerated:Fe,aiError:De,aiClassifiedError:ft,aiProgress:ve,promptRef:be,handleGenerate:Pn,handleCancelGenerate:ur,clearAiError:wt,targetAgents:F,setTargetAgents:q,draftSaved:Ot,showPluginRecommendation:Lt,setShowPluginRecommendation:xe,pluginLayoutInfo:mn,applyPluginRecommendation:Et,creating:ee,error:D,info:W,handleCreate:Sn,engineDetection:oe,refreshEngineDetection:Z,engine:I,setEngine:K,version:Q,setVersion:ue,versionValid:J,setVersionValid:ie,standaloneLocked:s===3}}function gb(){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 xT(){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 vb({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(gb,{}):r.jsx(xT,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(i=>r.jsx(vb,{node:i,depth:a+1},i.name))]})}function gT(t,a,s){const i=[];a&&i.push({name:"evals.json",type:"file"}),i.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:i}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function vT({skillName:t,hasEvals:a,isDraft:s}){const i=gT(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(gb,{})}),"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(vb,{node:i})})]})}const xa={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Zd({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 yT({onCreated:t,onCancel:a}){const s=hT({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(Zd,{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(Zd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:i=>s.setAiPrompt(i.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
|
|
109
|
+
|
|
110
|
+
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:{...xa,minHeight:"120px"},onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.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(fi,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(fc,{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(Zd,{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(i=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(i.layout),s.setPlugin(i.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===i.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===i.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===i.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:i.label},i.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:i=>{s.setPlugin(i.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:xa,children:[s.availablePlugins.map(i=>r.jsx("option",{value:i,children:i},i)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:i=>s.setNewPlugin(Jo(i.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:xa})]}),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:i=>s.setName(Jo(i.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:xa})]}),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:i=>s.setDescription(i.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...xa,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:i=>s.setModel(i.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:xa,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:i=>s.setAllowedTools(i.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:xa})]})]})]}),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(i=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(i),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===i?"var(--surface-4)":"transparent",color:s.bodyViewMode===i?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===i?600:400,border:"none",cursor:"pointer"},children:[i==="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:i==="write"?"Write":"Preview"})]},i))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:i=>s.setBody(i.target.value),placeholder:`# /my-skill
|
|
111
|
+
|
|
112
|
+
You are an expert at...
|
|
113
|
+
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...xa,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:di(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(vT,{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 mv(){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 Ws({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=cr(),[u,d]=m.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(mv,{}):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:()=>i("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:f=>{f.currentTarget.style.opacity="0.9"},onMouseLeave:f=>{f.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==="no-project-skills"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in","data-testid":"empty-state-no-project-skills",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(mv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),r.jsx("p",{className:"text-[12px] mb-5",style:{color:"var(--text-tertiary)",maxWidth:360,textAlign:"center"},children:"Browse the marketplace to install one, or author a new skill from scratch."}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("button",{type:"button","data-testid":"empty-state-browse-marketplaces",onClick:()=>{window.dispatchEvent(new CustomEvent("studio:open-marketplace"))},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},"aria-label":"Browse marketplaces",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("circle",{cx:"9",cy:"21",r:"1"}),r.jsx("circle",{cx:"20",cy:"21",r:"1"}),r.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]}),"Browse marketplaces"]}),r.jsxs("button",{type:"button","data-testid":"empty-state-create-skill",onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-primary)",border:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer"},"aria-label":"Create new skill",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"})]}),"Create new 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 bT(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const jT={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 yb(){const[t,a]=m.useState([]),[s,i]=m.useState(!0),[c,u]=m.useState(new Set),[d,f]=m.useState(new Map),[h,x]=m.useState(!1),[v,y]=m.useState(new Set),[b,j]=m.useState(new Map),[k,C]=m.useState(null),[w,N]=m.useState(null),[T,A]=m.useState(!1),B=m.useCallback(async()=>{i(!0);try{const H=await ke.getSkillUpdates();a(H.filter(F=>F.updateAvailable))}catch{a([])}finally{i(!1)}},[]);m.useEffect(()=>{B()},[B]);const M=m.useMemo(()=>t.filter(H=>!H.pinned),[t]),P=m.useCallback(H=>{u(F=>{const q=new Set(F);return q.has(H)?q.delete(H):q.add(H),q})},[]),E=m.useCallback(()=>{c.size===M.length?u(new Set):u(new Set(M.map(H=>H.name)))},[c,M]),O=m.useCallback(()=>{const H=[...c];if(!H.length)return;x(!0),f(new Map(H.map(q=>[q,{skill:q,status:"pending"}])));const F=ke.startBatchUpdate(H);F.addEventListener("progress",q=>{try{const ee=JSON.parse(q.data);f(U=>new Map(U).set(ee.skill,ee))}catch{}}),F.addEventListener("done",q=>{F.close(),x(!1);try{const ee=JSON.parse(q.data);C(`Updated ${ee.updated??0} skills, ${ee.failed??0} failed`),setTimeout(()=>C(null),5e3)}catch{}B()}),F.addEventListener("error",()=>{F.close(),x(!1),C("Batch update failed"),setTimeout(()=>C(null),5e3)})},[c,B]),z=m.useCallback(async H=>{const F=H.name.split("/"),q=F.length>=3?F[F.length-2]:F[0],ee=F[F.length-1];y(U=>new Set(U).add(H.name)),j(U=>{const D=new Map(U);return D.delete(H.name),D});try{const U=await ke.postSkillUpdate(q,ee);if(U.ok)B();else{const D=`Update failed (HTTP ${U.status}): ${U.body}`;j($=>new Map($).set(H.name,D)),C(`Couldn't update ${ee} — HTTP ${U.status}`),setTimeout(()=>C(null),5e3)}}catch(U){const D=U instanceof Error?U.message:"Network error";j($=>new Map($).set(H.name,D)),C(`Couldn't update ${ee} — ${D}`),setTimeout(()=>C(null),5e3)}finally{y(U=>{const D=new Set(U);return D.delete(H.name),D})}},[B]),_=m.useCallback(async H=>{if(!H.latest)return;const F=H.name.split("/"),q=F.length>=3?F[F.length-2]:F[0],ee=F[F.length-1];A(!0);try{const U=await ke.getVersionDiff(q,ee,H.installed,H.latest);N({skill:H,diff:U})}catch{N(null)}finally{A(!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:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&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:k}),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 (",M.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:h,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||h,className:"btn btn-primary text-[12px]",children:h?"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===M.length&&M.length>0?"var(--accent)":"var(--border-default)",background:c.size===M.length&&M.length>0?"var(--accent)":"transparent"},children:c.size===M.length&&M.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(H=>{const F=H.name.split("/").pop()||H.name,q=H.latest?bT(H.installed,H.latest):"patch",ee=jT[q],U=!!H.pinned,D=v.has(H.name),$=d.get(H.name),W=c.has(H.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:U?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!U&&P(H.name),disabled:U,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:U?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:W?"var(--accent)":"var(--border-default)",background:W?"var(--accent)":"transparent",opacity:U?.4:1},children:W&&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:F}),U&&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:q})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",U&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),$&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:$.status==="done"?"var(--green-muted)":$.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:$.status==="done"?"var(--green)":$.status==="error"?"var(--red)":"var(--yellow)"},children:[$.status,$.error&&`: ${$.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>_(H),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>z(H),disabled:U||D||h,title:U?"Pinned — unpin from CLI to update":"",className:`btn ${U?"btn-ghost":"btn-primary"} text-[11px]`,children:D?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):($==null?void 0:$.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.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:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Kf,{contentDiff:w.diff.contentDiff,fromLabel:w.diff.from,toLabel:w.diff.to,diffSummary:w.diff.diffSummary,renderContext:"inline"})]})})]})}const ST=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:yb},Symbol.toStringTag,{value:"Module"}));function kT(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function wT(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function CT(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),i=s.hostname.toLowerCase();if(i!=="github.com"&&i!=="www.github.com"&&i!=="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 bb(t){const{author:a,repoUrl:s}=t,i=CT(s??null),c=a&&a.trim()!==""?a:i??"—",[u,d]=m.useState(!1),f=m.useCallback(async()=>{var h;try{await((h=navigator.clipboard)==null?void 0:h.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return i?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${i}`,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:f,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 jb(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function ET(t,a){const s=jb(t),i=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return i?`${s}/blob/HEAD/${i}`:`${s}/blob/HEAD/`}function hv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function Sb(t){const{repoUrl:a,skillPath:s,absolutePath:i}=t,[c,u]=m.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),f=s?hv(s):i?hv(i):"source",h=m.useCallback(async()=>{var y;const v=i??s??"";if(v)try{await((y=navigator.clipboard)==null?void 0:y.writeText(v)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[i,s]);if(d){const v=ET(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:f}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!i&&!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 x=i??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${x}`,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-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:f}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}const NT=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/,TT=/^[A-Za-z0-9._-]+$/;function RT(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;let s;try{s=jb(a)}catch{return null}let i;try{i=new URL(s)}catch{return null}const c=i.hostname.toLowerCase();if(c!=="github.com"&&c!=="www.github.com")return null;const u=i.pathname.split("/").filter(Boolean);if(u.length!==2)return null;const d=u[0],f=u[1].replace(/\.git$/i,"");return!NT.test(d)||!f||!TT.test(f)?null:{owner:d,repo:f}}function AT(t){const a=RT(t.repoUrl??null);if(!a)return null;const s=`https://github.com/${a.owner}/${a.repo}`;return r.jsxs("a",{"data-testid":t["data-testid"]??"repo-link",href:s,target:"_blank",rel:"noopener noreferrer",title:s,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:[a.owner,"/",a.repo]})}function xv(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function kb(t){return t.skill?MT({skill:t.skill}):DT({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function LT(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),i=t.slice(t.length-(a-12-1));return`${s}…${i}`}function MT({skill:t}){const[a,s]=m.useState(!1),i=(t.sourcePath??t.dir)||"—",c=m.useCallback(async()=>{var f;try{await((f=navigator.clipboard)==null?void 0:f.writeText(i)),s(!0),setTimeout(()=>s(!1),1500),xv(ae.toasts.pathCopied,"info")}catch{xv(ae.toasts.permissionDenied,"error")}},[i]),u=t.source==="project"?"Project":t.source==="personal"?"Personal":t.source==="plugin"?"Plugins":t.origin==="installed"?"Personal":"Skills",d=t.source==="project"?"var(--status-installed)":t.source==="plugin"?"var(--color-accent-ink)":"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: ${u}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:d}}),u]})]}),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.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ui,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})}),t.pluginName&&t.pluginVersion&&r.jsxs("span",{"data-testid":"detail-header-plugin-chip",title:`This skill ships in plugin ${t.pluginName} v${t.pluginVersion}. The plugin version is independent of this skill's own version track.`,style:{display:"inline-flex",alignItems:"baseline",gap:4,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)",padding:"2px 6px",borderRadius:4,background:"var(--surface-1, transparent)",border:"1px solid var(--border-subtle, transparent)",whiteSpace:"nowrap"},children:[r.jsx("span",{children:"from"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:t.pluginName}),r.jsx("span",{"aria-hidden":"true",children:"@"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:t.pluginVersion})]}),t.origin==="source"&&r.jsx("button",{type:"button","data-testid":"detail-header-delete","aria-label":"Delete skill",title:"Delete skill",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))},className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:4,borderRadius:4},onMouseEnter:f=>{f.currentTarget.style.color="var(--red)"},onMouseLeave:f=>{f.currentTarget.style.color="var(--text-tertiary)"},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("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"})]})})]})]}),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(bb,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(AT,{repoUrl:t.repoUrl??null}),r.jsx(Sb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(zT,{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:i,"aria-label":`Copy path ${i} to clipboard`,onClick:c,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:LT(i)}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:c,"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 zT({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let i="";switch(a){case"symlinked":i=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":i="Copied (independent)";break;case"authored":i="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:i})]})}function DT({state:t,isReadOnly:a,onDelete:s}){const{plugin:i,skill:c,evals:u,latestBenchmark:d,isDirty:f,caseRunStates:h,regressions:x,iterationCount:v}=t,y=Array.from(h.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,j=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,C=kT(b),w=wT(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:i}),r.jsx(_T,{}),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"]}),f&&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:i,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:N=>{y||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(OT,{})}),x.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"})]}),x.length," regression",x.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:C},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",j," assert",j!==1?"s":""]})]})]})}function _T(){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 OT(){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 ga(t){const{title:a,label:s,value:i,subtitle:c,description:u,linkLabel:d,children:f,onClick:h}=t,x=a??s??"",v=typeof h=="function",y=b=>{v&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),h==null||h())};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?()=>h==null?void 0:h():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:[x?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:x}):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(i)}),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,f?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:f}):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 BT="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 IT(t){const{onNavigate:a}=t,[s,i]=m.useState(t.open??!1),c=m.useCallback(()=>i(!1),[]);m.useEffect(()=>{if(!s)return;const d=f=>{f.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=m.useCallback(d=>{a==null||a(d),i(!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:()=>i(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:BT}),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:Jd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Jd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Jd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Jd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function $T(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const UT="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function HT({value:t}){const[a,s]=m.useState(!1),i=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[t]);return r.jsx("button",{type:"button","data-testid":"publish-status-copy","aria-label":"Copy GitHub setup command",onClick:i,style:{fontSize:11,padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",background:"var(--surface-2)",color:"var(--text-primary)",cursor:"pointer"},children:a?"Copied":"Copy"})}function gv({tone:t,label:a}){const s=t==="ok"?"color-mix(in srgb, var(--color-ok, #22c55e) 18%, transparent)":"color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",i=t==="ok"?"var(--color-ok, #22c55e)":"var(--color-own, #f59e0b)";return r.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:i,background:s},children:a})}function PT(t={}){const{status:a,loading:s}=Hy();if(s||!a)return null;if(a.status==="github")return r.jsxs("div",{"data-testid":"publish-status-row","data-status":"github",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsx(gv,{tone:"ok",label:"Publish-ready"}),r.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",a.githubOrigin]}),r.jsx("div",{style:{marginLeft:"auto"},children:r.jsx(Jy,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?$T(t.projectBasename??""):UT;return r.jsxs("div",{"data-testid":"publish-status-row","data-status":a.status,style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(gv,{tone:"warn",label:a.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[r.jsx("code",{"data-testid":"publish-status-command",style:{flex:1,minWidth:0,padding:"6px 10px",borderRadius:4,background:"var(--surface-2)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:i}),r.jsx(HT,{value:i})]})]})}function VT({plugin:t,skill:a}){const[s,i]=m.useState([]),[c,u]=m.useState([]),[d,f]=m.useState(!0),[h,x]=m.useState(null);m.useEffect(()=>{ke.getDependencies(t,a).then(y=>{i(y.mcpDependencies),u(y.skillDependencies)}).catch(()=>{}).finally(()=>f(!1))},[t,a]);async function v(y,b){try{await navigator.clipboard.writeText(b),x(y),setTimeout(()=>x(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:h===y.server?"var(--green)":"var(--accent)"},children:h===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))})]})]})]})}const FT="https://verified-skill.com/docs/parameters-and-secrets",WT="Stored as KEY=value in this skill's local .env.local (gitignored). Resolved from process.env first, then .env.local.";function vv({onToggleAdd:t,addFormOpen:a}){return r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wider flex items-center gap-1.5",style:{color:"var(--text-tertiary)"},children:["Parameters & Secrets",r.jsx("span",{"aria-label":"About Parameters & Secrets",title:WT,style:{cursor:"help",fontSize:11,color:"var(--text-tertiary)",opacity:.7,display:"inline-block",lineHeight:1},children:"ⓘ"})]}),r.jsx("button",{onClick:t,"aria-pressed":a,className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]})}function GT(){return r.jsxs("div",{className:"px-4 py-5 rounded-xl flex flex-col gap-2",style:{background:"var(--surface-2)"},children:[r.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-secondary)"},children:"No parameters yet"}),r.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:["Values are stored as ",r.jsx("code",{style:{fontSize:11},children:"KEY=value"})," in this skill's local"," ",r.jsx("code",{style:{fontSize:11},children:".env.local"})," (auto-added to"," ",r.jsx("code",{style:{fontSize:11},children:".gitignore"}),"). They appear here when declared as"," ",r.jsx("code",{style:{fontSize:11},children:"requiredCredentials"})," in"," ",r.jsx("code",{style:{fontSize:11},children:"evals.json"}),", or when you add custom ones below."]}),r.jsx("a",{href:FT,target:"_blank",rel:"noopener noreferrer",className:"text-[11px]",style:{color:"var(--accent)",textDecoration:"none"},children:"Learn more →"})]})}function qT({plugin:t,skill:a}){const[s,i]=m.useState([]),[c,u]=m.useState(!0),[d,f]=m.useState(null),[h,x]=m.useState(""),[v,y]=m.useState(!1),[b,j]=m.useState(null),[k,C]=m.useState(""),[w,N]=m.useState(""),[T,A]=m.useState(!1),[B,M]=m.useState(new Set),P=m.useCallback(async()=>{u(!0);try{const[_,H]=await Promise.all([ke.getCredentials(t,a).catch(()=>({credentials:[]})),ke.getParams(t,a).catch(()=>({params:[]}))]),F=new Map(H.params.map(U=>[U.name,U])),q=new Set,ee=[];for(const U of _.credentials){q.add(U.name);const D=F.get(U.name);ee.push({name:U.name,status:U.status==="ready"||U.status==="resolved"?"ready":"missing",source:U.source,maskedValue:D==null?void 0:D.maskedValue})}for(const U of H.params)q.has(U.name)||ee.push({name:U.name,status:U.status,maskedValue:U.maskedValue});i(ee)}finally{u(!1)}},[t,a]);m.useEffect(()=>{P()},[P]);const E=m.useCallback(async _=>{if(B.has(_)){M(H=>{const F=new Set(H);return F.delete(_),F}),i(H=>H.map(F=>F.name===_?{...F,revealedValue:void 0}:F));return}try{const F=(await ke.getParamsRevealed(t,a,_)).params.find(q=>q.name===_);F&&(i(q=>q.map(ee=>ee.name===_?{...ee,revealedValue:F.value}:ee)),M(q=>new Set(q).add(_)))}catch{}},[t,a,B]),O=async(_,H)=>{if(!(!_.trim()||!H.trim())){y(!0),j(null);try{await ke.setCredential(t,a,_,H),f(null),x(""),M(new Set),P()}catch(F){j(F.message)}finally{y(!1)}}},z=async()=>{if(!(!k.trim()||!w.trim())){y(!0),j(null);try{await ke.setCredential(t,a,k.trim().toUpperCase(),w),C(""),N(""),A(!1),P()}catch(_){j(_.message)}finally{y(!1)}}};return c?r.jsxs("div",{className:"mt-6",children:[r.jsx(vv,{onToggleAdd:()=>{},addFormOpen:!1}),r.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):r.jsxs("div",{className:"mt-6",children:[r.jsx(vv,{onToggleAdd:()=>A(!T),addFormOpen:T}),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&&!T?r.jsx(GT,{}):r.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(_=>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:_.name}),_.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(_.name)&&_.revealedValue!=null?_.revealedValue:_.maskedValue}),_.maskedValue&&r.jsx("button",{onClick:()=>E(_.name),className:"btn btn-ghost px-1",title:B.has(_.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(_.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:_.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:_.status==="ready"?"var(--green)":"var(--orange)"},children:_.status==="ready"?"ready":"missing"}),_.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:_.source}),d===_.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:h,onChange:H=>x(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(_.name,h)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(_.name,h),disabled:v||!h.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:v?"...":"Save"}),r.jsx("button",{onClick:()=>{f(null),x("")},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:()=>{f(_.name),x("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},_.name))}),T&&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:k,onChange:_=>C(_.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:w,onChange:_=>N(_.target.value),onKeyDown:_=>{_.key==="Enter"&&z()},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:()=>{A(!1),C(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:z,disabled:v||!k.trim()||!w.trim(),className:"btn btn-primary text-[10px]",children:v?"Saving...":"Save"})]})]})]})}function yv({children:t}){return r.jsx("h3",{style:{fontFamily:"var(--font-sans)",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:"var(--text-tertiary)",margin:"0 0 8px"},children:t})}function YT({plugin:t,skill:a}){return r.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[r.jsx(yv,{children:"Setup"}),r.jsx(VT,{plugin:t,skill:a})]}),r.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[r.jsx(yv,{children:"Credentials"}),r.jsx(qT,{plugin:t,skill:a})]})]})}function KT(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 Hs(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),i=Math.floor(s/1e3);if(i<60)return"just now";const c=Math.floor(i/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 f=Math.floor(d/30);if(f<12)return`${f} month${f===1?"":"s"} ago`;const h=Math.floor(f/12);return`${h} year${h===1?"":"s"} ago`}function XT(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function QT(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 ZT(t,a){const s=t.evalCount??0;return!t.hasEvals||s<=0?null:r.jsxs("button",{type:"button","data-testid":"overview-tests-chip",onClick:a?()=>a("run"):void 0,title:`Open Run tab — ${s} test case${s===1?"":"s"}`,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",border:"1px solid var(--border-default, var(--border))",borderRadius:9999,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)",background:"transparent",cursor:a?"pointer":"default"},children:[s," ",s===1?"test":"tests"]})}function JT(t){var y,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,f=u??(eR(a.homepage)?a.homepage??null:null),h=((y=a.mcpDeps)==null?void 0:y.length)??0,x=((b=a.deps)==null?void 0:b.length)??0,v=r.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},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(ui,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),QT(a),ZT(a,s)]}),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(bb,{author:a.author??null,repoUrl:f}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(Sb,{repoUrl:f,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Hs(a.lastModified)]}):null]})]}),a.origin!=="installed"&&!a.pluginMarketplace&&a.installMethod!=="copied"&&a.installMethod!=="symlinked"&&r.jsx(PT,{}),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(ga,{title:"Benchmark",value:XT(a),subtitle:a.lastBenchmark?Hs(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(IT,{onNavigate:s})})}),r.jsx(ga,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(ga,{title:"Activations",value:i,subtitle:c?`Last: ${Hs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(ga,{title:"Last run",value:Hs(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(ga,{title:"MCP deps",value:h,subtitle:h>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ga,{title:"Skill deps",value:x,subtitle:x>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ga,{title:"Size",value:KT(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(ga,{title:"Last modified",value:Hs(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:16,padding:16,alignItems:"start"},children:[v,r.jsx(YT,{plugin:a.plugin,skill:a.skill})]})}function eR(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function tR({skill:t}){const{onSkillUpdated:a}=cr(),{toast:s}=lc(),[i,c]=m.useState("idle"),[u,d]=m.useState(null),[f,h]=m.useState(!1),[x,v]=m.useState(null),[y,b]=m.useState(!1),j=m.useRef(null),k=m.useCallback(async()=>{if(!t||i==="updating")return;const T=new AbortController;j.current=T,c("updating"),d(null);try{const A=await ke.postSkillUpdate(t.plugin,t.skill,T.signal);if(A.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const B=`Update failed (HTTP ${A.status}): ${A.body}`;c("idle"),d(B),s({message:`Couldn't update ${t.skill} — HTTP ${A.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}}catch(A){if(A instanceof DOMException&&A.name==="AbortError")return;const B=A instanceof Error?A.message:"Network error";c("idle"),d(B),s({message:`Couldn't update ${t.skill} — ${B}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}finally{j.current===T&&(j.current=null)}},[t,i,a,s]);if(m.useEffect(()=>{if(!f||x!=null||!t||!t.latestVersion)return;let T=!1;return b(!0),ke.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(A=>{T||v(A)}).catch(()=>{T||v(null)}).finally(()=>{T||b(!1)}),()=>{T=!0}},[f,x,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),m.useEffect(()=>()=>{var T;(T=j.current)==null||T.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,w=i==="updating"?"Updating…":C?`Update to ${C}`:"Update",N=i==="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:()=>{k()},disabled:N,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:N?"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:()=>h(T=>!T),disabled:N||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:f?"Hide changelog":"Preview changelog"})]}),i==="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&&i!=="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}),f&&C&&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&&x&&r.jsx(Kf,{contentDiff:x.contentDiff,fromLabel:x.from,toLabel:x.to,diffSummary:x.diffSummary??void 0,renderContext:"inline"}),!y&&!x&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const nR=3e4;function rR({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=cr(),[u,d]=m.useState(!1),[f,h]=m.useState(!1),[,x]=m.useState(0),v=m.useRef(null),y=m.useRef(null),b=`${t}/${a}`,j=c.updatesById.get(b);if(m.useEffect(()=>{if(!u)return;const C=setInterval(()=>x(w=>(w+1)%1e6),250);return()=>clearInterval(C)},[u]),m.useEffect(()=>{if(!u||!j)return;const C=y.current??0;j.receivedAt<C||(v.current&&(clearTimeout(v.current),v.current=null),d(!1),h(!1),y.current=null)},[u,j]),m.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]),s===!1||i)return null;const k=async()=>{if(!u){h(!1),d(!0),y.current=Date.now(),v.current=setTimeout(()=>{d(!1),h(!0),v.current=null,y.current=null},nR);try{await ke.rescanSkill(t,a),v.current&&(clearTimeout(v.current),v.current=null);const C=c.updatesById.get(b),w=y.current??0,N=!!C&&C.receivedAt>=w;d(!1),N||h(!0),y.current=null}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:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&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"}}),f&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function aR(t,a){var s;typeof process<"u"&&((s=process==null?void 0:process.env)==null?void 0:s.NODE_ENV)==="production"||console.warn(`[SubTabBar] sub-tab "${a}" clicked under "${t}" but no onChange handler was wired. Pass an onChange prop or this click is a no-op.`)}function lR({tabs:t,active:a,onChange:s,parentTabId:i}){const[c,u]=m.useState(null),d=f=>{s?s(f):aR(i,f)};return r.jsx("div",{role:"tablist","aria-label":`${i} sub-sections`,"data-testid":`detail-subtab-bar-${i}`,style:{display:"flex",alignItems:"stretch",gap:2,borderBottom:"1px solid var(--border-subtle, var(--border-default))",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:t.map(f=>{const h=f.id===a,x=c===f.id&&!h;return r.jsx("button",{type:"button",role:"tab","aria-selected":h,tabIndex:h?0:-1,id:`detail-subtab-${i}-${f.id}`,"data-testid":`detail-subtab-${i}-${f.id}`,onClick:()=>d(f.id),onMouseEnter:()=>u(f.id),onMouseLeave:()=>u(v=>v===f.id?null:v),style:{background:x?"var(--surface-2, rgba(0,0,0,0.04))":"transparent",border:"none",borderBottom:h?"2px solid var(--text-primary)":"2px solid var(--border-subtle, transparent)",padding:"8px 10px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:h?500:400,color:h?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap",transition:"background 80ms ease"},children:f.label},f.id)})})}const sR=[{id:"overview",label:"Overview"},{id:"source",label:"Source"},{id:"edit",label:"Edit",visibleWhen:({isReadOnly:t})=>!t},{id:"tests",label:"Tests"},{id:"run",label:"Run"},{id:"history",label:"History"}];function wb(t){return sR.filter(a=>a.visibleWhen?a.visibleWhen({isReadOnly:t}):!0)}const iR={tests:{tab:"tests"},trigger:{tab:"run",mode:"activation"},activation:{tab:"run",mode:"activation"},versions:{tab:"history",view:"versions"},leaderboard:{tab:"history",view:"models"},editor:{tab:"edit"},overview:{tab:"overview"},source:{tab:"source"},edit:{tab:"edit"},run:{tab:"run"},history:{tab:"history"}};function ec(t){return t?iR[t]??null:null}function Nf(t){const a=new URLSearchParams(t),s=a.get("tab"),i=a.get("panel");return ec(s)??ec(i)??{tab:"overview"}}function Cb(t,a){return!a||new Set(wb(!0).map(i=>i.id)).has(t)?t:"source"}const $l={run:[{id:"benchmark",label:"Benchmark"},{id:"activation",label:"Activation"},{id:"ab",label:"A/B"}],history:[{id:"timeline",label:"Timeline"},{id:"models",label:"Models"},{id:"versions",label:"Versions"}]};function Xs(t){const a=$l[t];return a&&a.length>0?a[0].id:""}function Eb(t,a){const s=$l[t];if(!s)return"";const i=new URLSearchParams(a),c=t==="run"?"mode":t==="history"?"view":"sub",u=i.get(c)??i.get("sub");return u&&s.some(d=>d.id===u)?u:s[0].id}function oR(t){return t==="run"?"mode":t==="history"?"view":null}function cR(t){switch(t){case"editor":case"tests":case"deps":return{tab:"edit"};case"run":return{tab:"run",mode:"benchmark"};case"activation":return{tab:"run",mode:"activation"};case"history":return{tab:"history",view:"timeline"};case"leaderboard":return{tab:"history",view:"models"};case"versions":return{tab:"history",view:"versions"};default:return{tab:"overview"}}}function ef(){const{state:t,setMobileView:a}=cr();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 uR(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return dR(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=cr(),[u,d]=m.useState(typeof window<"u"?window.location.hash:"");if(m.useEffect(()=>{const x=()=>d(window.location.hash);return window.addEventListener("hashchange",x),()=>window.removeEventListener("hashchange",x)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(ef,{}),r.jsx(yb,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(ef,{}),r.jsx(yT,{onCreated:async(x,v)=>{i("browse"),await c(),s({plugin:x,skill:v,origin:"source",source:"project"})},onCancel:()=>i("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(Ws,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(Ws,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(x=>x.scopeV2==="available-project")?r.jsx(Ws,{variant:"no-project-skills"}):r.jsx(Ws,{variant:"no-selection"});const f=a.selectedSkill,h=a.skills.find(x=>x.plugin===f.plugin&&x.skill===f.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(ef,{}),r.jsx(fR,{skillInfo:h,allSkills:a.skills,onSelectSkill:x=>s(x)})]})}function dR(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return mR();if(t.loadError)return hR(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0,c=t.activeDetailSub??Xs(s);return Nb(a,s,t.onDetailTabChange,c,t.onDetailSubChange,i)}function fR({skillInfo:t,allSkills:a,onSelectSkill:s}){const i=m.useMemo(()=>typeof window>"u"?{tab:"overview"}:Nf(window.location.search),[]),[c,u]=m.useState(i.tab),[d,f]=m.useState(()=>i.mode?i.mode:i.view?i.view:Eb(i.tab,typeof window<"u"?window.location.search:""));m.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const v=Cb(c,!0);v!==c&&(u(v),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:"This skill is read-only — workbench tabs are hidden.",severity:"info"}})))},[t,c]),m.useEffect(()=>{f(Xs(c))},[c]),m.useEffect(()=>{if(typeof window>"u")return;const x=new URLSearchParams(window.location.search);x.delete("panel"),x.delete("sub"),c==="overview"?x.delete("tab"):x.set("tab",c);const v=oR(c),y=$l[c];x.delete("mode"),x.delete("view"),v&&y&&d&&d!==y[0].id&&x.set(v,d);const b=x.toString(),j=`${window.location.pathname}${b?"?"+b:""}${window.location.hash}`;window.history.replaceState(null,"",j)},[c,d]);const h=m.useMemo(()=>t?Nb(t,c,u,d,f,{}):r.jsx(Ws,{variant:"no-selection"}),[t,c,d,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:h})}function pR(t,a,s){const i=wb(s);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:i.map(({id:c,label:u})=>{const d=c===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":d,tabIndex:d?0:-1,id:`detail-tab-${c}`,"aria-controls":`detail-panel-${c}`,"data-testid":`detail-tab-${c}`,onClick:()=>a==null?void 0:a(c),style:{background:"transparent",border:"none",borderBottom:d?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:d?500:400,color:d?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:u},c)})})}function mR(){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 hR(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[kb({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 xR({active:t,sub:a}){if(t==="edit")return r.jsx(FE,{});if(t==="tests")return r.jsx(ob,{});if(t==="run"){const s=EN(a)?a:"benchmark";return r.jsx(NN,{mode:s})}if(t==="history"){const s=uT(a)?a:"timeline";return r.jsx(dT,{view:s})}return null}function gR({active:t,sub:a}){const{state:s,dispatch:i}=bn();return m.useEffect(()=>{if(t==="overview")return;const c=t==="edit"?"editor":t==="tests"?"tests":t==="run"?a==="activation"?"activation":"run":t==="history"?a==="models"?"leaderboard":a==="versions"?"versions":"history":"editor";s.activePanel!==c&&i({type:"SET_PANEL",panel:c})},[t,a,s.activePanel,i]),null}function Nb(t,a,s,i="",c,u){var b;const d=t.origin==="installed",f=Cb(a,d),h=j=>{const k=cR(j);s==null||s(k.tab),c&&(k.mode?c(k.mode):k.view&&c(k.view))},x=r.jsx(JT,{skill:t,onNavigate:h,repoUrl:t.homepage??null}),v=u!=null?r.jsxs(tE,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(gR,{active:f,sub:i}),r.jsx(xR,{active:f,sub:i})]},`${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 ",f," view."]}),y=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",{style:{flex:1,minWidth:0},children:"This is an installed copy of the skill. Editing and generating tests are disabled — running author-shipped evals is allowed. Open the source skill to make changes."}),t.trackedForUpdates&&r.jsx("button",{type:"button","data-testid":"uninstall-button","aria-label":`Uninstall ${t.skill}`,onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-uninstall",{detail:{skill:{plugin:t.plugin,skill:t.skill,dir:t.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"installed"}}}))},style:{flexShrink:0,marginLeft:8,padding:"3px 10px",fontSize:11,fontWeight:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,cursor:"pointer"},children:"Uninstall"})]});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:kb({skill:t})}),r.jsx(tR,{skill:t}),y,t.origin==="installed"&&t.scopeV2!=="available-plugin"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(rR,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),pR(f,s,d),$l[f]&&r.jsx(lR,{parentTabId:f,tabs:$l[f],active:i||(((b=$l[f][0])==null?void 0:b.id)??""),onChange:c}),r.jsx("div",{role:"tabpanel",id:`detail-panel-${f}`,"aria-labelledby":`detail-tab-${f}`,"data-testid":`detail-panel-${f}`,style:{flex:1,minHeight:0,overflow:"auto"},children:f==="overview"?x:f==="source"?r.jsx(iN,{plugin:t.plugin,skill:t.skill}):v})]})}function vR(){const{updateCount:t,state:a,dismissUpdateNotification:s}=cr(),i=t>0&&!a.updateNotificationDismissed;return m.useEffect(()=>{if(!i)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[i,s]),i?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 yR=[{name:ae.shortcuts.groupNavigation,items:[{keys:"/",label:ae.shortcuts.search},{keys:"j",label:ae.shortcuts.moveDown},{keys:"k",label:ae.shortcuts.moveUp},{keys:"Enter",label:ae.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ae.shortcuts.groupActions,items:[{keys:"⌘K",label:ae.shortcuts.openPalette},{keys:"?",label:ae.shortcuts.openShortcuts},{keys:"⌘B",label:ae.shortcuts.toggleSidebar},{keys:"E",label:ae.actions.edit}]},{name:ae.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ae.shortcuts.toggleTheme}]}];function bR({open:t,onClose:a,groups:s=yR,title:i=ae.shortcuts.title}){const c=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var f,h;(h=(f=c.current)==null?void 0:f.focus)==null||h.call(f),c.current=null}},[t]),m.useEffect(()=>{if(!t)return;function d(f){var h;if(f.key==="Escape"){f.preventDefault(),a();return}f.key==="Tab"&&(f.preventDefault(),(h=u.current)==null||h.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:i}),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(f=>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:f.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:f.keys})]},`${d.name}:${f.keys}`))})]},d.name))]})}):null}function jR(t){const a=ae.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 i=[...s];return t.updateAvailable&&i.push({action:"update",label:a.update}),i.push({action:"uninstall",label:a.uninstall}),i.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),i}function SR({state:t,onClose:a,onAction:s,itemsOverride:i}){const c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),h=m.useMemo(()=>t.skill?i??jR(t.skill):[],[t.skill,i]),x=m.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const y=8,b=220,j=44+h.length*28;let k=t.x,C=t.y;return k+b+y>window.innerWidth&&(k=Math.max(y,t.x-b)),C+j+y>window.innerHeight&&(C=Math.max(y,t.y-j)),{left:k,top:C}},[t.x,t.y,h.length]);m.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,f(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=m.useCallback(()=>{if(!t.skill)return;const y=h[d];!y||y.disabled||(s(y.action,t.skill),a())},[h,d,t.skill,s,a]);return m.useEffect(()=>{if(!t.open)return;function y(j){if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key==="ArrowDown"){j.preventDefault(),f(k=>Math.min(k+1,Math.max(h.length-1,0)));return}if(j.key==="ArrowUp"){j.preventDefault(),f(k=>Math.max(k-1,0));return}if(j.key==="Enter"||j.key===" "){j.preventDefault(),v();return}}function b(j){c.current&&j.target instanceof Node&&(c.current.contains(j.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,h.length,v]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:x.left,top:x.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:h.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:()=>f(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 bv=t=>`${t.plugin}/${t.skill}`;function jv(t){const a=(t==null?void 0:t.delayMs)??1e4,s=t==null?void 0:t.onCommit,i=t==null?void 0:t.onFailure,c=(t==null?void 0:t.apiCall)??ke.deleteSkill.bind(ke),u=m.useRef(s),d=m.useRef(i),f=m.useRef(c);u.current=s,d.current=i,f.current=c;const h=m.useRef(new Map),[,x]=m.useState(0),v=m.useCallback(()=>x(w=>w+1),[]),y=m.useCallback(async w=>{var N,T;try{await f.current(w.skill.plugin,w.skill.skill),(N=u.current)==null||N.call(u,w.skill)}catch(A){(T=d.current)==null||T.call(d,w.skill,A)}finally{h.current.delete(bv(w.skill)),v()}},[v]),b=m.useCallback(w=>{const N=bv(w),T=h.current.get(N);T!=null&&T.timeoutId&&clearTimeout(T.timeoutId);const A={skill:w,timeoutId:null};A.timeoutId=setTimeout(()=>{A.timeoutId=null,y(A)},a),h.current.set(N,A),v()},[a,y,v]),j=m.useCallback(w=>{const N=h.current.get(w);N&&(N.timeoutId&&clearTimeout(N.timeoutId),h.current.delete(w),v())},[v]),k=m.useCallback(async()=>{const w=Array.from(h.current.values());for(const N of w)N.timeoutId&&(clearTimeout(N.timeoutId),N.timeoutId=null);await Promise.all(w.map(N=>y(N)))},[y]),C=m.useCallback(w=>h.current.has(w),[]);return m.useEffect(()=>{const w=()=>{k()};return window.addEventListener("beforeunload",w),()=>{window.removeEventListener("beforeunload",w)}},[k]),m.useEffect(()=>{const w=h.current;return()=>{for(const N of w.values())N.timeoutId&&(clearTimeout(N.timeoutId),N.timeoutId=null,y(N));w.clear()}},[]),{enqueueDelete:b,cancelDelete:j,flushPending:k,isPending:C}}const kR={"anthropic-api":{name:ae.setupProviders.anthropic.name,description:ae.setupProviders.anthropic.description,envVars:ae.setupProviders.anthropic.envVars,keyUrl:ae.setupProviders.anthropic.keyUrl,learnMoreUrl:ae.setupProviders.anthropic.learnMoreUrl},openai:{name:ae.setupProviders.openai.name,description:ae.setupProviders.openai.description,envVars:ae.setupProviders.openai.envVars,keyUrl:ae.setupProviders.openai.keyUrl,learnMoreUrl:ae.setupProviders.openai.learnMoreUrl},openrouter:{name:ae.setupProviders.openrouter.name,description:ae.setupProviders.openrouter.description,envVars:ae.setupProviders.openrouter.envVars,keyUrl:ae.setupProviders.openrouter.keyUrl,learnMoreUrl:ae.setupProviders.openrouter.learnMoreUrl},gemini:{name:ae.setupProviders.gemini.name,description:ae.setupProviders.gemini.description,envVars:ae.setupProviders.gemini.envVars,keyUrl:ae.setupProviders.gemini.keyUrl,learnMoreUrl:ae.setupProviders.gemini.learnMoreUrl},ollama:{name:ae.setupProviders.ollama.name,description:ae.setupProviders.ollama.description,envVars:ae.setupProviders.ollama.envVars,install:[ae.setupProviders.ollama.installCmd],start:[ae.setupProviders.ollama.startCmd],pullExample:ae.setupProviders.ollama.pullExample,learnMoreUrl:ae.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ae.setupProviders.lmStudio.name,description:ae.setupProviders.lmStudio.description,envVars:ae.setupProviders.lmStudio.envVars,install:[ae.setupProviders.lmStudio.installCmd],start:[ae.setupProviders.lmStudio.startCmd],pullExample:ae.setupProviders.lmStudio.pullExample,learnMoreUrl:ae.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ae.setupProviders.claudeCode.name,description:ae.setupProviders.claudeCode.description,envVars:[],notes:[ae.setupProviders.claudeCode.loginHint,ae.claudeCodeLabel.compactLabel],learnMoreUrl:ae.setupProviders.claudeCode.learnMoreUrl}};function wR(t){return t?kR[t]??null:null}function CR({open:t,providerKey:a,onClose:s}){const i=m.useRef(null);if(m.useEffect(()=>{if(!t)return;const d=f=>{f.key==="Escape"&&(f.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),m.useEffect(()=>{if(!t)return;const d=i.current;if(!d)return;const f=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");f==null||f.focus()},[t]),!t||typeof document>"u")return null;const c=wR(a),u=(c==null?void 0:c.name)??ae.setupDrawer.fallbackTitle;return ac.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:i,role:"dialog","aria-modal":"true","aria-label":ae.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(ER,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(NR,{content:c}):r.jsx(TR,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
114
|
+
from { transform: translateX(100%); }
|
|
115
|
+
to { transform: translateX(0); }
|
|
116
|
+
}
|
|
117
|
+
@keyframes vskillDrawerBackdropIn {
|
|
118
|
+
from { opacity: 0; }
|
|
119
|
+
to { opacity: 1; }
|
|
120
|
+
}`})]})]}),document.body)}function ER({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:ae.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ae.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function NR({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(i=>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:i},i))}),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:ae.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(i=>r.jsx("li",{children:r.jsx(RR,{name:i})},i))})]}),t.keyUrl&&r.jsx(AR,{href:t.keyUrl,label:ae.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:ae.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((i,c)=>r.jsx(tf,{code:i},`install-${c}`)),(s=t.start)==null?void 0:s.map((i,c)=>r.jsx(tf,{code:i},`start-${c}`)),t.pullExample&&r.jsx(tf,{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:[ae.setupDrawer.learnMore," →"]})})]})}function TR(){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:ae.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ae.setupDrawer.fallbackBody})]})}function RR({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:ae.setupDrawer.copy})]})}function tf({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 AR({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 LR(){const[t,a]=m.useState(!1),[s,i]=m.useState(null),c=m.useRef(null),u=m.useCallback((f,h)=>{var x;c.current=typeof document<"u"?document.activeElement:null,(x=h==null?void 0:h.beforeOpen)==null||x.call(h),i(f),a(!0)},[]),d=m.useCallback(()=>{a(!1);const f=c.current;f&&"focus"in f&&typeof f.focus=="function"&&queueMicrotask(()=>f.focus())},[]);return m.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function MR(t){const a=[],s=[],i=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(i.has(u))continue;i.add(u);const d=t.filter(f=>c.sharedFolderGroup.includes(f.id));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((f,h)=>f+h.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function zR({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:i,onSwitch:c,onOpenSetup:u,onClose:d}){const f=m.useRef(null);m.useEffect(()=>{const v=y=>{y.key==="Escape"&&(y.preventDefault(),d())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[d]),m.useEffect(()=>{const v=b=>{f.current&&!f.current.contains(b.target)&&d()},y=setTimeout(()=>{document.addEventListener("mousedown",v)},0);return()=>{clearTimeout(y),document.removeEventListener("mousedown",v)}},[d]);const h=m.useMemo(()=>MR(t),[t]),x=t.find(v=>v.id===s)??t.find(v=>v.id===a)??t[0];return typeof document>"u"?null:ac.createPortal(r.jsxs("div",{ref:f,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ae.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:[h.detected.length===0&&h.notDetected.length===0&&r.jsx(Sv,{}),h.detected.map(v=>v.kind==="aggregate"?r.jsx(_R,{row:v,onFocus:()=>{var y;return i(((y=v.consumers[0])==null?void 0:y.id)??a??"")}},v.key):r.jsx(DR,{agent:v.agent,focused:v.agent.id===s,active:v.agent.id===a,onClick:()=>i(v.agent.id)},v.key)),h.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:ae.scopePicker.notDetectedSubheading}),h.notDetected.map(v=>r.jsx(OR,{agent:v.agent},v.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:x?r.jsx(BR,{agent:x,activeAgentId:a,onSwitch:()=>c(x.id)}):r.jsx(Sv,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
|
|
121
|
+
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
122
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
123
|
+
}`})]}),document.body)}function DR({agent:t,focused:a,active:s,onClick:i}){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:i,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",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function _R({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 OR({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 BR({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":ae.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":$R(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Oo,{label:ae.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Oo,{label:ae.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Oo,{label:ae.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(Oo,{label:ae.scopePicker.statsLastSync,value:t.lastSync?IR(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 Oo({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 IR(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function $R(t){switch(t){case"ok":return ae.scopePicker.statsHealthOk;case"stale":return ae.scopePicker.statsHealthStale;case"missing":return ae.scopePicker.statsHealthMissing}}function UR(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function HR({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=m.useState(!1),[d,f]=m.useState(null),h=m.useRef(null),x=m.useMemo(()=>t.find(j=>j.id===a)??t[0]??null,[t,a]),v=m.useMemo(()=>x?x.health==="ok"?"var(--color-ok, #22c55e)":x.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[x]),y=m.useCallback(()=>{var j;u(!1),(j=h.current)==null||j.focus()},[]),b=m.useCallback(j=>{s(j),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:h,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(j=>!j),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.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:(x==null?void 0:x.displayName)??"Select agent"}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(x==null?void 0:x.installedCount)??0," · ",(x==null?void 0:x.globalCount)??0," · ",(x==null?void 0:x.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(zR,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:f,onSwitch:b,onOpenSetup:j=>{i(j),y()},onClose:y})]})}const Tb="vskill-ccode-banner-dismissed",PR=new Set(["claude-cli","claude-code"]);function VR(){try{return sessionStorage.getItem(Tb)==="true"}catch{return!1}}function FR(){try{sessionStorage.setItem(Tb,"true")}catch{}}function WR({activeAgentId:t}){const[a,s]=m.useState(()=>VR()),i=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{FR(),s(!0)},[]);return!t||!PR.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:[ae.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ae.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 GR(){const[t,a]=m.useState(null),[s,i]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const f=await ke.getAgents();a(f),i("ready"),u(null)}catch(f){i("error"),u(f.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const f=()=>void d();return window.addEventListener("studio:agent-changed",f),()=>window.removeEventListener("studio:agent-changed",f)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Bo="workspace",qR=["skills","agents"];async function YR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function KR(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 XR(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 QR(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 nf(){for(const t of qR)$n(t)}function ZR(){const{data:t,loading:a,error:s,revalidate:i}=Ga(Bo,YR),c=t,u=c==null?void 0:c.projects.find(x=>x.id===c.activeProjectId),d=m.useCallback(async x=>{await KR(x),$n(Bo),nf()},[]),f=m.useCallback(async x=>{await XR(x),$n(Bo),nf()},[]),h=m.useCallback(async x=>{await QR(x),$n(Bo),nf()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:f,removeProject:h,revalidate:i}}function JR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=m.useState(!1),[f,h]=m.useState(!1),[x,v]=m.useState(""),[y,b]=m.useState(null),[j,k]=m.useState(null),[C,w]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],M=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(_){A.current&&!A.current.contains(_.target)&&(d(!1),h(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function P(){b(null);const z=x.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),v(""),h(!1)}catch(_){const H=_ instanceof Error?_.message:String(_);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function E(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();v(z.name),h(!0)}catch{}else h(!0)}function O(z){if(z.length<=50)return z;const _=z.split("/");return _.length<=4?z:`${_.slice(0,3).join("/")}/…/${_.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(M==null?void 0:M.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:(M==null?void 0:M.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M?M.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:[B.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."}),B.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const _=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),F=j===z.id;return r.jsxs("li",{role:"menuitem","data-stale":_?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(q=>q===z.id?null:q),onClick:()=>{if(!_){if(H){d(!1);return}w(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:F&&!_?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:_?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&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:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),_&&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 ${z.name}`,onClick:q=>{q.stopPropagation(),i(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:F?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:q=>{q.currentTarget.style.color="var(--color-error, #b91c1c)",q.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:q=>{q.currentTarget.style.color="var(--text-tertiary)",q.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"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:f?8:6},children:[!f&&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:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.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"]}),f&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:x,onChange:z=>v(z.target.value),onKeyDown:z=>{z.key==="Enter"&&P(),z.key==="Escape"&&(h(!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:()=>{h(!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 P(),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})]})]})]}),C&&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:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",C.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 "${C.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 "${C.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),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 e4(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function t4({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=m.useState(""),[d,f]=m.useState(0),h=m.useMemo(()=>e4(a,c),[a,c]);m.useEffect(()=>{t||(u(""),f(0))},[t]),m.useEffect(()=>{d>=h.length&&f(0)},[h.length,d]);const x=v=>{if(v.key==="Escape"){v.preventDefault(),i();return}if(v.key==="ArrowDown"){v.preventDefault(),f(y=>Math.min(y+1,Math.max(h.length-1,0)));return}if(v.key==="ArrowUp"){v.preventDefault(),f(y=>Math.max(y-1,0));return}if(v.key==="Enter"){v.preventDefault();const y=h[d];y&&(s(y.id),i())}};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:i}),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:x,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:[h.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),h.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:()=>f(y),onClick:()=>{s(v.id),i()},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 kv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function n4({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,f]=m.useState("destination"),[h,x]=m.useState(s),[v,y]=m.useState(""),[b,j]=m.useState(""),[k,C]=m.useState(""),[w,N]=m.useState([]),[T,A]=m.useState(!1),[B,M]=m.useState(null);if(m.useEffect(()=>{t&&(f("destination"),x(s),y(""),j(""),C(""),M(null))},[t,s]),m.useEffect(()=>{if(!t)return;let U=!0;return fetch("/api/authoring/plugins").then(D=>D.json()).then(D=>{U&&N(D.plugins??[])}).catch(()=>{}),()=>{U=!1}},[t]),m.useEffect(()=>{if(!t)return;function U(D){D.key==="Escape"&&(D.preventDefault(),a())}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[t,a]),!t)return null;const P=w.length>0,E=i&&P,O=i,z=kv.test(v),_=h==="existing-plugin"?b.length>0:kv.test(b),H=!T&&z&&(h==="standalone"||_),F=r4(c,h,b,v);async function q(){M(null),A(!0);try{const $=new URLSearchParams;$.set("mode",h),$.set("skillName",v),b&&$.set("pluginName",b);const W=await fetch(`/api/authoring/skill-exists?${$.toString()}`),Y=await W.json();if(!W.ok){M(Y.error??`Check failed: ${W.status}`);return}if(Y.exists){M(`Skill '${v}' already exists${Y.path?` at ${Y.path}`:""}`);return}}catch($){M($ instanceof Error?$.message:String($));return}finally{A(!1)}const U=new URLSearchParams;U.set("mode",h),U.set("skillName",v),k.trim()&&U.set("description",k.trim()),b&&U.set("pluginName",b);const D=`#/create?${U.toString()}`;typeof window<"u"&&(window.location.hash=D),a()}async function ee(){M(null),A(!0);try{const U=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:h,skillName:v,description:k.trim()||void 0,pluginName:h==="standalone"?void 0:b})}),D=await U.json();if(!U.ok||!D.ok){M(D.error??`Create failed: ${U.status}`);return}$n("skills"),u==null||u({mode:h,skillName:v,pluginName:D.pluginName??null,skillMdPath:D.skillMdPath}),a()}catch(U){M(U instanceof Error?U.message:String(U))}finally{A(!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(rf,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:h==="standalone",onClick:()=>x("standalone")}),r.jsx(rf,{title:"Add to existing plugin",subtitle:E?`${w.length} plugin source${w.length===1?"":"s"} in this project`:i?"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:h==="existing-plugin",onClick:()=>E&&x("existing-plugin")}),r.jsx(rf,{title:"Plugin (multi-skill)",subtitle:O?"Bundle related skills under one Claude Code plugin":"Claude Code only",description:"Creates <folder>/.claude-plugin/plugin.json and <folder>/skills/<first>/SKILL.md.",icon:"📦",disabled:!O,selected:h==="new-plugin",onClick:()=>O&&x("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[h==="new-plugin"&&r.jsx(Io,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:U=>j(U.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:$o(!b||_)})}),h==="existing-plugin"&&r.jsx(Io,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:U=>j(U.target.value),style:{...$o(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),w.map(U=>r.jsx("option",{value:U.name,children:U.name},U.path))]})}),r.jsx(Io,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:v,onChange:U=>y(U.target.value.trim()),placeholder:"my-new-skill",autoFocus:h!=="new-plugin",style:$o(!v||z)})}),r.jsx(Io,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:U=>C(U.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...$o(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),F&&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:"}),F.map((U,D)=>r.jsx("div",{children:U},D))]}),B&&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:B})]}),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:af,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>f("details"),style:wv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>f("destination"),style:af,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void q(),disabled:!H,style:{...af,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void ee(),disabled:!H,style:{...wv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function rf({title:t,subtitle:a,description:s,icon:i,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:i}),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 Io({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 $o(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 wv={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"},af={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 r4(t,a,s,i){const c=i||"<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 Rb(t){return t.trim().toLowerCase()}function a4(t,a){const s=Rb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function l4(t,a){const s=Rb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function s4({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=m.useState(null),[f,h]=m.useState([]),[x,v]=m.useState(null),[y,b]=m.useState(null),[j,k]=m.useState(!1),[C,w]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{x?T(""):B("")},[x]);const M=m.useMemo(()=>a4(f,N),[f,N]),P=m.useMemo(()=>l4((y==null?void 0:y.plugins)??[],A),[y,A]);return m.useEffect(()=>{t&&(k(!0),w(null),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>{if(E.error)throw new Error(E.error);h(E.marketplaces??[])}).catch(E=>w(E instanceof Error?E.message:String(E))).finally(()=>k(!1)))},[t]),m.useEffect(()=>{if(!x){b(null);return}k(!0),w(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(x)}`).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(()=>k(!1))},[x]),m.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:[x&&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:x?(y==null?void 0:y.name)??x:"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:[j&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),C&&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:C}),!x&&!j&&f.length===0&&!C&&r.jsx(i4,{}),!x&&f.length>0&&r.jsx(Cv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!x&&f.length>0&&M.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!x&&M.map(E=>r.jsxs("button",{type:"button",onClick:()=>v(E.name),style:c4,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)),x&&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:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),y.plugins.length>0&&P.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),P.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&&i?r.jsx("button",{type:"button",disabled:u===E.name,onClick:async()=>{d(E.name);try{await i(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,x),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)})]})]}),!x&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(o4,{onAdded:()=>{$n("marketplaces"),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>h(E.marketplaces??[]))}})})]})]}):null}function Cv({value:t,onChange:a,placeholder:s,ariaLabel:i,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":i,"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 i4(){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 o4({onAdded:t}){const[a,s]=m.useState(""),[i,c]=m.useState(!1),[u,d]=m.useState(null);async function f(){const h=a.trim();if(h){c(!0),d(null);try{const x=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:h})}),v=await x.json().catch(()=>({}));if(!x.ok||!v.ok){d(v.error??`Add failed (${x.status})`);return}s(""),t()}catch(x){d(x instanceof Error?x.message:String(x))}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:h=>s(h.target.value),onKeyDown:h=>{h.key==="Enter"&&f()},placeholder:"anthropics/claude-plugins-official",disabled:i,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 f(),disabled:i||!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:i||!a.trim()?"not-allowed":"pointer",opacity:i||!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:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const c4={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},lf=12;function u4({job:t,onDone:a}){const[s,i]=m.useState([]),[c,u]=m.useState("running"),[d,f]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;i([]),u("running"),f(!1);const y=new AbortController;let b=[],j="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:y.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const C=k.body.getReader(),w=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await C.read();if(A)break;N+=w.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const M of B){const P=M.match(/^data:\s*(.*)$/m);if(P)try{const E=JSON.parse(P[1]);E.type==="stdout"&&E.line?(b=[...b,E.line].slice(-lf),i(b)):E.type==="stderr"&&E.line?(b=[...b,`⚠ ${E.line}`].slice(-lf),i(b)):E.type==="done"?(j=E.ok?"ok":"failed",u(j),sy(),$n("skills"),a({ok:E.ok??!1,code:E.code??null,lines:b})):E.type==="error"&&E.error&&(b=[...b,`✘ ${E.error}`].slice(-lf),i(b))}catch{}}}j==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>y.abort()},[t==null?void 0:t.ref]),!t)return null;const h=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",x=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 ${h}`,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:()=>f(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:h,width:16,textAlign:"center"},children:c==="running"?r.jsx(d4,{}):x}),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-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",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-primary)"},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(`
|
|
124
|
+
`)})]})}function d4(){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 f4=3e3,p4={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Ev(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function m4(){const{toast:t}=lc(),a=m.useRef(new Map),s=m.useCallback(i=>{if(!Ev(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<f4)return;a.current.set(i.provider,c);const d=p4[i.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:i.provider}}))}}})},[t]);return m.useEffect(()=>{function i(c){const u=c.detail;!u||!Ev(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const Ab="vskill.studio.prefs";function Lb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Mb(){const t=Lb();if(!t)return{};try{const a=t.getItem(Ab);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function h4(t,a){const s=Lb();if(s)try{const c={...Mb(),[t]:a};s.setItem(Ab,JSON.stringify(c))}catch{}}function x4(t,a){const i=Mb()[t];return i===void 0?a:i}const Nv={open:!1,x:0,y:0,skill:null};function g4(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function gr(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function v4(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}async function Tv(t,a){var s;try{await ke.revealInEditor(t.plugin,t.skill,a),gr(ae.toasts.openingInEditor,"info")}catch(i){if(i instanceof va){const c=(s=i.details)==null?void 0:s.error;if(i.status===404){gr(ae.toasts.skillNotFound,"error");return}if(i.status===500&&c==="no_editor"){gr(ae.toasts.noEditor,"error");return}}gr(ae.toasts.openFailed,"error")}}async function y4(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{gr(ae.toasts.permissionDenied,"error");return}gr(ae.toasts.pathCopied,"info");return;case"reveal":case"edit":await Tv(a,"SKILL.md");return;case"open":await Tv(a);return;case"run-benchmark":gr(ae.toasts.benchmarkQueued,"info");return;case"duplicate":gr(ae.toasts.skillDuplicated,"info");return;case"update":gr(ae.toasts.skillUpdated,"info");return;case"uninstall":gr(ae.toasts.uninstallNotImplemented,"info");return;case"delete":v4(a);return;default:return}}function b4(t){return t.startsWith("#/create")}function j4(t){return t.startsWith("#/updates")}function zb(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function S4(){return zb(b4)}function k4(){return zb(j4)}function w4(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function C4(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function E4(){const[t,a]=m.useState("⌘⇧K");m.useEffect(()=>{a(w4())},[]);const s=C4();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"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 N4=m.lazy(()=>Fl(()=>import("./FindSkillsPalette-D0Zjhm31.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),T4=m.lazy(()=>Fl(()=>import("./SkillDetailPanel-B5J60ffv.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),R4=m.lazy(()=>Fl(()=>import("./CreateSkillPage-BmbvQEzE.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),A4=m.lazy(()=>Fl(()=>Promise.resolve().then(()=>ST),void 0).then(t=>({default:t.UpdatesPanel})));function L4(){return r.jsx(l2,{children:r.jsx(n2,{children:r.jsxs(ak,{children:[r.jsx(M4,{}),r.jsx(vR,{})]})})})}function M4(){var rn,Xa;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:f}=qa(),{resolvedTheme:h,setTheme:x}=ly(),{toast:v}=lc(),[y,b]=m.useState(()=>$C()),[j]=m.useState(!0),[k,C]=m.useState(!1),[w,N]=m.useState(!1),[T,A]=m.useState(()=>typeof window>"u"?"overview":Nf(window.location.search).tab),[B,M]=m.useState(()=>{if(typeof window>"u")return"";const re=Nf(window.location.search);return re.mode?re.mode:re.view?re.view:Eb(re.tab,window.location.search)}),P=m.useCallback(re=>{A(Se=>(Se!==re&&M(Xs(re)),re))},[]);m.useEffect(()=>{if(typeof window>"u")return;const re=()=>{const Se=new URLSearchParams(window.location.search),Ce=Se.get("tab"),Xt=Se.get("panel"),Ct=ec(Ce)??ec(Xt);if(!Ct)return;const hn=new URLSearchParams(window.location.search);hn.delete("panel"),hn.delete("sub"),Ct.tab==="overview"?hn.delete("tab"):hn.set("tab",Ct.tab),hn.delete("mode"),hn.delete("view"),Ct.mode&&hn.set("mode",Ct.mode),Ct.view&&hn.set("view",Ct.view);const dr=hn.toString(),et=`${window.location.pathname}${dr?"?"+dr:""}${window.location.hash}`,Mt=`${window.location.pathname}${window.location.search}${window.location.hash}`;et!==Mt&&window.history.replaceState(null,"",et),A(Ct.tab),Ct.mode?M(Ct.mode):Ct.view?M(Ct.view):M(Xs(Ct.tab))};return re(),window.addEventListener("popstate",re),()=>window.removeEventListener("popstate",re)},[]),m.useEffect(()=>{if(typeof window>"u")return;const re=new URLSearchParams(window.location.search);re.delete("panel"),re.delete("sub"),T==="overview"?re.delete("tab"):re.set("tab",T),re.delete("mode"),re.delete("view"),!(B===Xs(T))&&B&&(T==="run"?re.set("mode",B):T==="history"&&re.set("view",B));const Ce=re.toString(),Xt=`${window.location.pathname}${Ce?"?"+Ce:""}${window.location.hash}`,Ct=`${window.location.pathname}${window.location.search}${window.location.hash}`;Xt!==Ct&&window.history.replaceState(null,"",Xt)},[T,B]);const[E,O]=m.useState(Nv),z=m.useCallback((re,Se)=>{O(g4(re,Se))},[]),_=GR(),[H,F]=m.useState(()=>x4("activeAgent",null)),q=m.useCallback(re=>{F(re),h4("activeAgent",re),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:re}}))},[]);m.useEffect(()=>{var re;!H&&((re=_.response)!=null&&re.suggested)&&q(_.response.suggested)},[H,(rn=_.response)==null?void 0:rn.suggested,q]);const ee=m.useMemo(()=>_.response?UR(_.response):[],[_.response]),{workspace:U,switchProject:D,addProject:$,removeProject:W,activeProject:Y}=ZR(),[oe,L]=m.useState(!1),[I,K]=m.useState(!1),[Q,ue]=m.useState("standalone"),J=m.useCallback((re="standalone")=>{ue(re),K(!0)},[]);m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;J((Ce==null?void 0:Ce.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",re),()=>window.removeEventListener("studio:request-create-skill",re)},[J]);const[ie,Z]=m.useState(!1),[me,je]=m.useState(null),[Te,Me]=m.useState(null);m.useEffect(()=>{function re(){Z(!0)}return window.addEventListener("studio:open-marketplace",re),()=>window.removeEventListener("studio:open-marketplace",re)},[]);const Fe=m.useMemo(()=>{const re=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&re.add(Se.pluginName);return re},[t.skills]);vf([{key:"p",meta:!0,handler:re=>{var Ce;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Ce=re==null?void 0:re.preventDefault)==null||Ce.call(re),L(Xt=>!Xt))}}],{enabled:!0});const Ue=LR(),De=Ue.open;m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;Ce!=null&&Ce.provider&&De(Ce.provider)}return window.addEventListener("studio:open-setup-drawer",re),()=>window.removeEventListener("studio:open-setup-drawer",re)},[De]);const We=m.useCallback(()=>{O(Nv)},[]);m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;Ce!=null&&Ce.message&&v({message:Ce.message,severity:Ce.severity??"info"})}return window.addEventListener("studio:toast",re),()=>window.removeEventListener("studio:toast",re)},[v]),m4();const[ft,ce]=m.useState(!1),[ve,ye]=m.useState(void 0);m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;ye(Ce==null?void 0:Ce.provider),ce(!0)}return window.addEventListener("studio:open-settings",re),()=>window.removeEventListener("studio:open-settings",re)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${y}px`)},[y]),m.useEffect(()=>{function re(){i()}return window.addEventListener("studio:content-saved",re),()=>window.removeEventListener("studio:content-saved",re)},[i]);const[be,Ne]=m.useState(null),[qe,He]=m.useState(()=>new Set),jt=m.useRef(!1),Ot=m.useMemo(()=>pC(),[]),St=m.useCallback(re=>`${re.plugin}/${re.skill}`,[]),Lt=m.useCallback(re=>{He(Se=>{const Ce=new Set(Se);return Ce.add(St(re)),Ce})},[St]),xe=m.useCallback(re=>{He(Se=>{const Ce=new Set(Se);return Ce.delete(St(re)),Ce})},[St]),Ze=jv({delayMs:1e4,onCommit:re=>{i(),xe(re)},onFailure:(re,Se)=>{xe(re),v({message:`Couldn't delete ${re.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{Lt(re),Ze.enqueueDelete(re)}}})}});m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;Ce!=null&&Ce.skill&&Ne(Ce.skill)}return window.addEventListener("studio:request-delete",re),()=>window.removeEventListener("studio:request-delete",re)},[]);const[Xe,kt]=m.useState(null),Bt=jv({delayMs:250,apiCall:(re,Se)=>api.uninstallSkill(re,Se),onCommit:re=>{i(),xe(re)},onFailure:(re,Se)=>{xe(re),v({message:`Couldn't uninstall ${re.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{Lt(re),Bt.enqueueDelete(re)}}})}});m.useEffect(()=>{function re(Se){if(!(Se instanceof CustomEvent))return;const Ce=Se.detail;Ce!=null&&Ce.skill&&kt(Ce.skill)}return window.addEventListener("studio:request-uninstall",re),()=>window.removeEventListener("studio:request-uninstall",re)},[]);const lt=m.useCallback(()=>{const re=Xe;if(kt(null),!re)return;const Se={plugin:re.plugin,skill:re.skill};Lt(Se),Bt.enqueueDelete(Se),v({message:`Uninstalled ${re.skill}. Sent to your ${Ot}.`,severity:"info",durationMs:4e3})},[Xe,Lt,Bt,v,Ot]),jn=m.useCallback(()=>{kt(null)},[]),Kt=m.useCallback(()=>{const re=be;if(Ne(null),!re)return;const Se={plugin:re.plugin,skill:re.skill};Lt(Se),Ze.enqueueDelete(Se);const Ce=jt.current?"":`Sent to your ${Ot}. Open Trash to restore. `;jt.current=!0,v({message:`${Ce}Deleted ${re.skill}`,severity:"info",durationMs:1e4,action:{label:ae.actions.undo,onInvoke:()=>{Ze.cancelDelete(St(Se)),xe(Se)}}})},[be,Lt,xe,Ze,v,Ot,St]),mn=m.useCallback(()=>{Ne(null)},[]),un=m.useMemo(()=>t.skills.filter(re=>!qe.has(St(re))),[t.skills,qe,St]),ur=qC(un,(Y==null?void 0:Y.path)??null),wt=m.useMemo(()=>t.selectedSkill?t.skills.find(re=>re.plugin===t.selectedSkill.plugin&&re.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Pn=m.useRef(null);m.useEffect(()=>{if(!wt||typeof window>"u"||new URLSearchParams(window.location.search).get("tab")||!(wt.origin==="installed"))return;const Ce=`${wt.plugin}/${wt.skill}`;Pn.current!==Ce&&(Pn.current=Ce,T==="overview"&&A("source"))},[wt==null?void 0:wt.plugin,wt==null?void 0:wt.skill,wt==null?void 0:wt.origin]);const Sn=m.useCallback(re=>{a({plugin:re.plugin,skill:re.skill,origin:re.origin,source:re.source})},[a]),Et=m.useMemo(()=>{if(!t.selectedSkill)return"";const re=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${re})`},[t.selectedSkill]),[Be,Je]=m.useState(null);vf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>C(re=>!re)},{key:"cmd+shift+d",handler:()=>x(h==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>x(h==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(re=>!re)},{key:"ctrl+b",handler:()=>N(re=>!re)}]);const An=S4(),Vr=k4()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(A4,{})}):An?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(R4,{})}):r.jsx(uR,{selectedSkillInfo:wt,activeDetailTab:T,onDetailTabChange:P,activeDetailSub:B,onDetailSubChange:M,allSkills:t.skills,onSelectSkill:Sn});return r.jsxs(r.Fragment,{children:[r.jsx(s2,{sidebarWidth:y,sidebarHidden:w||t.isMobile&&t.mobileView==="detail",banner:r.jsx(YC,{connected:j}),liveMessage:Et,topRail:r.jsx(uk,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>J("standalone"),projectPickerSlot:U&&U.projects.length>0?r.jsx(JR,{workspace:U,onSwitch:D,onAdd:$,onRemove:W}):void 0,findSkillsSlot:r.jsx(E4,{})}),sidebar:r.jsx(RC,{skills:un,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Sn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:ur,onSkillsChanged:i,topSlot:_.status==="ready"&&ee.length>0?r.jsxs(r.Fragment,{children:[r.jsx(HR,{agents:ee,activeAgentId:H,onActiveAgentChange:q,onOpenSetup:re=>Ue.open(re)}),r.jsx(WR,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(HC,{initialWidth:y??Ks,onChange:b}),main:Vr,statusBar:r.jsx(jk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(Xa=f==null?void 0:f.providers)==null?void 0:Xa.map(re=>{const Se=re.id;return{id:Se,label:re.label,available:re.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(bR,{open:k,onClose:()=>C(!1)}),r.jsx(CR,{open:Ue.isOpen,providerKey:Ue.providerKey,onClose:Ue.close}),r.jsx(SR,{state:E,onClose:We,onAction:(re,Se)=>y4(re,Se)}),r.jsx(m.Suspense,{fallback:null,children:r.jsx(N4,{onSelect:re=>{const Se=re.name.split("/");Se.length===3&&Je({owner:Se[0],repo:Se[1],slug:Se[2],displayName:re.displayName??re.name})}})}),Be&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(T4,{selectedSkill:Be,onClose:()=>Je(null)})}),r.jsx(t4,{open:oe,projects:(U==null?void 0:U.projects)??[],onSwitch:re=>{D(re)},onClose:()=>L(!1)}),r.jsx(n4,{open:I,onClose:()=>K(!1),initialMode:Q,isClaudeCode:H==="claude-code",projectRoot:(Y==null?void 0:Y.path)??(f==null?void 0:f.projectName)??"",onCreated:re=>{i(),setTimeout(()=>{u(re.pluginName??"",re.skillName)},500)}}),r.jsx(s4,{open:ie,onClose:()=>Z(!1),installedNames:Fe,onInstall:(re,Se)=>{je({plugin:re,marketplace:Se,ref:`${re}@${Se}`}),Z(!1)},onUninstall:async re=>{if(await new Promise(Ce=>{Me({plugin:re,resolve:Ce})}))try{const Ce=await fetch(`/api/plugins/${encodeURIComponent(re)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Xt=await Ce.json().catch(()=>({}));if(!Ce.ok||!Xt.ok){v({message:Xt.error??`Uninstall failed (${Ce.status})`,severity:"error"});return}const Ct=Xt.fallback==="orphan-cache-removed"?`Removed orphaned ${re}.`:`Uninstalled ${re}.`;v({message:Ct,severity:"success"}),i()}catch(Ce){v({message:Ce instanceof Error?Ce.message:String(Ce),severity:"error"})}}}),r.jsx(ty,{open:ft,onClose:()=>ce(!1),initialProvider:ve,onToast:re=>v({message:re,severity:"info"})}),r.jsx(u4,{job:me,onDone:re=>{re.ok&&(i(),setTimeout(()=>je(null),3e3))}}),r.jsx(Wo,{open:be!==null,title:be?`Delete "${be.skill}"?`:"",body:`It will be sent to your ${Ot}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Kt,onCancel:mn}),r.jsx(Wo,{open:Xe!==null,title:Xe?`Uninstall "${Xe.skill}"?`:"",body:`It will be sent to your ${Ot} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:lt,onCancel:jn}),r.jsx(Wo,{open:Te!==null,title:Te?`Uninstall ${Te.plugin}?`:"",body:Te?`This removes the ${Te.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Te==null||Te.resolve(!0),Me(null)},onCancel:()=>{Te==null||Te.resolve(!1),Me(null)}})]})}const Rv="vskill.migrations.scope-rename.v1",z4={own:"authoring-project",installed:"available-project",global:"available-personal"},D4=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function _4(t){if(t.getItem(Rv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(D4);if(!c)continue;const[,u,d]=c,f=z4[d];if(!f)continue;const h=t.getItem(i);h!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${f}-collapsed`,value:h})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Rv,"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{_4(window.localStorage)}catch{}Q0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(vS,{children:r.jsx(xk,{children:r.jsx(L4,{})})})}));export{fc as E,Yv as L,fi as P,Ae as R,vT as S,B4 as T,Fl as _,cr as a,Mb as b,hT as c,di as d,lc as e,ke as f,x4 as g,xb as h,r as j,m as r,Jo as t,qa as u,h4 as w};
|