vskill 1.0.14 → 1.0.16
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 +61 -0
- package/agents.json +1 -1
- package/dist/agents/agents-registry.d.ts +8 -3
- package/dist/agents/agents-registry.js.map +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/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/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.js +527 -35
- 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/eval-server.js +8 -1
- package/dist/eval-server/eval-server.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/install-state-routes.d.ts +21 -0
- package/dist/eval-server/install-state-routes.js +111 -0
- package/dist/eval-server/install-state-routes.js.map +1 -0
- 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-resolver.js +40 -0
- package/dist/eval-server/skill-resolver.js.map +1 -1
- package/dist/eval-server/utils/resolve-editor.d.ts +6 -1
- package/dist/eval-server/utils/resolve-editor.js +11 -26
- package/dist/eval-server/utils/resolve-editor.js.map +1 -1
- 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-CKvqAya0.js → CreateSkillPage-CvdYq8Rr.js} +5 -5
- package/dist/eval-ui/assets/{FindSkillsPalette-B8pTa5NP.js → FindSkillsPalette-DsSgotS9.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-CkVRvaZk.js → SearchPaletteCore-Bf3PBC64.js} +2 -2
- package/dist/eval-ui/assets/SkillDetailPanel-DAD2yJO-.js +1 -0
- package/dist/eval-ui/assets/{UpdateDropdown-DA7OktXO.js → UpdateDropdown-h5Hg3h7Z.js} +1 -1
- package/dist/eval-ui/assets/{index-BKAvJDDF.css → index-CKLqBL52.css} +1 -1
- package/dist/eval-ui/assets/index-JaDg6FlU.js +124 -0
- package/dist/eval-ui/index.html +2 -2
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/installer/canonical.js +2 -11
- package/dist/installer/canonical.js.map +1 -1
- package/dist/installer/frontmatter.d.ts +26 -0
- package/dist/installer/frontmatter.js +91 -1
- 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/lib/provenance.js +3 -2
- package/dist/studio/lib/provenance.js.map +1 -1
- package/dist/studio/lib/query.d.ts +1 -0
- package/dist/studio/lib/query.js +7 -0
- package/dist/studio/lib/query.js.map +1 -0
- package/dist/studio/lib/scope-transfer.d.ts +6 -0
- package/dist/studio/lib/scope-transfer.js +5 -2
- package/dist/studio/lib/scope-transfer.js.map +1 -1
- package/dist/studio/routes/index.js +3 -0
- package/dist/studio/routes/index.js.map +1 -1
- package/dist/studio/routes/ops.js +1 -3
- package/dist/studio/routes/ops.js.map +1 -1
- package/dist/studio/routes/promote.js +1 -3
- package/dist/studio/routes/promote.js.map +1 -1
- package/dist/studio/routes/revert.js +2 -17
- package/dist/studio/routes/revert.js.map +1 -1
- package/dist/studio/routes/test-install.js +1 -3
- package/dist/studio/routes/test-install.js.map +1 -1
- 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/dist/utils/skill-builder-detection.d.ts +14 -1
- package/dist/utils/skill-builder-detection.js +20 -8
- package/dist/utils/skill-builder-detection.js.map +1 -1
- package/dist/utils/skill-creator-detection.d.ts +10 -2
- package/dist/utils/skill-creator-detection.js +12 -43
- package/dist/utils/skill-creator-detection.js.map +1 -1
- package/package.json +2 -1
- package/dist/eval-ui/assets/SkillDetailPanel-d4_LquVH.js +0 -1
- package/dist/eval-ui/assets/index-DCbohW6l.js +0 -122
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-h5Hg3h7Z.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-DsSgotS9.js","assets/SkillDetailPanel-DAD2yJO-.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-CvdYq8Rr.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 _v(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jd={exports:{}},Is={};/**
|
|
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 Vx;function K0(){if(Vx)return Is;Vx=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 Is.Fragment=a,Is.jsx=s,Is.jsxs=s,Is}var Fx;function X0(){return Fx||(Fx=1,jd.exports=K0()),jd.exports}var n=X0(),Sd={exports:{}},Ve={};/**
|
|
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 Wx;function Q0(){if(Wx)return Ve;Wx=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(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function T(M,I,K){this.props=M,this.context=I,this.refs=C,this.updater=K||k}T.prototype.isReactComponent={},T.prototype.setState=function(M,I){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,I,"setState")},T.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=T.prototype;function R(M,I,K){this.props=M,this.context=I,this.refs=C,this.updater=K||k}var O=R.prototype=new E;O.constructor=R,w(O,T.prototype),O.isPureReactComponent=!0;var L=Array.isArray;function P(){}var N={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function z(M,I,K){var Q=K.ref;return{$$typeof:t,type:M,key:I,ref:Q!==void 0?Q:null,props:K}}function _(M,I){return z(M.type,I,M.props)}function H(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function W(M){var I={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(K){return I[K]})}var q=/\/+/g;function ee(M,I){return typeof M=="object"&&M!==null&&M.key!=null?W(""+M.key):I.toString(36)}function $(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(P,P):(M.status="pending",M.then(function(I){M.status==="pending"&&(M.status="fulfilled",M.value=I)},function(I){M.status==="pending"&&(M.status="rejected",M.reason=I)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function D(M,I,K,Q,ue){var te=typeof M;(te==="undefined"||te==="boolean")&&(M=null);var ie=!1;if(M===null)ie=!0;else switch(te){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(M.$$typeof){case t:case a:ie=!0;break;case v:return ie=M._init,D(ie(M._payload),I,K,Q,ue)}}if(ie)return ue=ue(M),ie=Q===""?"."+ee(M,0):Q,L(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||M&&M.key===ue.key?"":(""+ue.key).replace(q,"$&/")+"/")+ie)),I.push(ue)),1;ie=0;var J=Q===""?".":Q+":";if(L(M))for(var he=0;he<M.length;he++)Q=M[he],te=J+ee(Q,he),ie+=D(Q,I,K,te,ue);else if(he=j(M),typeof he=="function")for(M=he.call(M),he=0;!(Q=M.next()).done;)Q=Q.value,te=J+ee(Q,he++),ie+=D(Q,I,K,te,ue);else if(te==="object"){if(typeof M.then=="function")return D($(M),I,K,Q,ue);throw I=String(M),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.")}return ie}function U(M,I,K){if(M==null)return M;var Q=[],ue=0;return D(M,Q,"","",function(te){return I.call(K,te,ue++)}),Q}function F(M){if(M._status===-1){var I=M._result;I=I(),I.then(function(K){(M._status===0||M._status===-1)&&(M._status=1,M._result=K)},function(K){(M._status===0||M._status===-1)&&(M._status=2,M._result=K)}),M._status===-1&&(M._status=0,M._result=I)}if(M._status===1)return M._result.default;throw M._result}var Y=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var I=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(I))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},oe={map:U,forEach:function(M,I,K){U(M,function(){I.apply(this,arguments)},K)},count:function(M){var I=0;return U(M,function(){I++}),I},toArray:function(M){return U(M,function(I){return I})||[]},only:function(M){if(!H(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ve.Activity=y,Ve.Children=oe,Ve.Component=T,Ve.Fragment=s,Ve.Profiler=c,Ve.PureComponent=R,Ve.StrictMode=i,Ve.Suspense=h,Ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Ve.__COMPILER_RUNTIME={__proto__:null,c:function(M){return N.H.useMemoCache(M)}},Ve.cache=function(M){return function(){return M.apply(null,arguments)}},Ve.cacheSignal=function(){return null},Ve.cloneElement=function(M,I,K){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var Q=w({},M.props),ue=M.key;if(I!=null)for(te in I.key!==void 0&&(ue=""+I.key),I)!B.call(I,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&I.ref===void 0||(Q[te]=I[te]);var te=arguments.length-2;if(te===1)Q.children=K;else if(1<te){for(var ie=Array(te),J=0;J<te;J++)ie[J]=arguments[J+2];Q.children=ie}return z(M.type,ue,Q)},Ve.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Ve.createElement=function(M,I,K){var Q,ue={},te=null;if(I!=null)for(Q in I.key!==void 0&&(te=""+I.key),I)B.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 J=Array(ie),he=0;he<ie;he++)J[he]=arguments[he+2];ue.children=J}if(M&&M.defaultProps)for(Q in ie=M.defaultProps,ie)ue[Q]===void 0&&(ue[Q]=ie[Q]);return z(M,te,ue)},Ve.createRef=function(){return{current:null}},Ve.forwardRef=function(M){return{$$typeof:f,render:M}},Ve.isValidElement=H,Ve.lazy=function(M){return{$$typeof:v,_payload:{_status:-1,_result:M},_init:F}},Ve.memo=function(M,I){return{$$typeof:x,type:M,compare:I===void 0?null:I}},Ve.startTransition=function(M){var I=N.T,K={};N.T=K;try{var Q=M(),ue=N.S;ue!==null&&ue(K,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(P,Y)}catch(te){Y(te)}finally{I!==null&&K.types!==null&&(I.types=K.types),N.T=I}},Ve.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Ve.use=function(M){return N.H.use(M)},Ve.useActionState=function(M,I,K){return N.H.useActionState(M,I,K)},Ve.useCallback=function(M,I){return N.H.useCallback(M,I)},Ve.useContext=function(M){return N.H.useContext(M)},Ve.useDebugValue=function(){},Ve.useDeferredValue=function(M,I){return N.H.useDeferredValue(M,I)},Ve.useEffect=function(M,I){return N.H.useEffect(M,I)},Ve.useEffectEvent=function(M){return N.H.useEffectEvent(M)},Ve.useId=function(){return N.H.useId()},Ve.useImperativeHandle=function(M,I,K){return N.H.useImperativeHandle(M,I,K)},Ve.useInsertionEffect=function(M,I){return N.H.useInsertionEffect(M,I)},Ve.useLayoutEffect=function(M,I){return N.H.useLayoutEffect(M,I)},Ve.useMemo=function(M,I){return N.H.useMemo(M,I)},Ve.useOptimistic=function(M,I){return N.H.useOptimistic(M,I)},Ve.useReducer=function(M,I,K){return N.H.useReducer(M,I,K)},Ve.useRef=function(M){return N.H.useRef(M)},Ve.useState=function(M){return N.H.useState(M)},Ve.useSyncExternalStore=function(M,I,K){return N.H.useSyncExternalStore(M,I,K)},Ve.useTransition=function(){return N.H.useTransition()},Ve.version="19.2.4",Ve}var Gx;function Lf(){return Gx||(Gx=1,Sd.exports=Q0()),Sd.exports}var p=Lf();const Le=_v(p);var kd={exports:{}},$s={},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 qx;function Z0(){return qx||(qx=1,(function(t){function a(D,U){var F=D.length;D.push(U);e:for(;0<F;){var Y=F-1>>>1,oe=D[Y];if(0<c(oe,U))D[Y]=U,D[F]=oe,F=Y;else break e}}function s(D){return D.length===0?null:D[0]}function i(D){if(D.length===0)return null;var U=D[0],F=D.pop();if(F!==U){D[0]=F;e:for(var Y=0,oe=D.length,M=oe>>>1;Y<M;){var I=2*(Y+1)-1,K=D[I],Q=I+1,ue=D[Q];if(0>c(K,F))Q<oe&&0>c(ue,K)?(D[Y]=ue,D[Q]=F,Y=Q):(D[Y]=K,D[I]=F,Y=I);else if(Q<oe&&0>c(ue,F))D[Y]=ue,D[Q]=F,Y=Q;else break e}}return U}function c(D,U){var F=D.sortIndex-U.sortIndex;return F!==0?F:D.id-U.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,w=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function O(D){for(var U=s(x);U!==null;){if(U.callback===null)i(x);else if(U.startTime<=D)i(x),U.sortIndex=U.expirationTime,a(h,U);else break;U=s(x)}}function L(D){if(w=!1,O(D),!k)if(s(h)!==null)k=!0,P||(P=!0,W());else{var U=s(x);U!==null&&$(L,U.startTime-D)}}var P=!1,N=-1,B=5,z=-1;function _(){return C?!0:!(t.unstable_now()-z<B)}function H(){if(C=!1,P){var D=t.unstable_now();z=D;var U=!0;try{e:{k=!1,w&&(w=!1,E(N),N=-1),j=!0;var F=b;try{t:{for(O(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,O(D),U=!0;break t}y===s(h)&&i(h),O(D)}else i(h);y=s(h)}if(y!==null)U=!0;else{var M=s(x);M!==null&&$(L,M.startTime-D),U=!1}}break e}finally{y=null,b=F,j=!1}U=void 0}}finally{U?W():P=!1}}}var W;if(typeof R=="function")W=function(){R(H)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,ee=q.port2;q.port1.onmessage=H,W=function(){ee.postMessage(null)}}else W=function(){T(H,0)};function $(D,U){N=T(function(){D(t.unstable_now())},U)}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"):B=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 U=3;break;default:U=b}var F=b;b=U;try{return D()}finally{b=F}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(D,U){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var F=b;b=D;try{return U()}finally{b=F}},t.unstable_scheduleCallback=function(D,U,F){var Y=t.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?Y+F:Y):F=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=F+oe,D={id:v++,callback:U,priorityLevel:D,startTime:F,expirationTime:oe,sortIndex:-1},F>Y?(D.sortIndex=F,a(x,D),s(h)===null&&D===s(x)&&(w?(E(N),N=-1):w=!0,$(L,F-Y))):(D.sortIndex=oe,a(h,D),k||j||(k=!0,P||(P=!0,W()))),D},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(D){var U=b;return function(){var F=b;b=U;try{return D.apply(this,arguments)}finally{b=F}}}})(Cd)),Cd}var Yx;function J0(){return Yx||(Yx=1,wd.exports=Z0()),wd.exports}var Ed={exports:{}},fn={};/**
|
|
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 Kx;function ej(){if(Kx)return fn;Kx=1;var t=Lf();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 fn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,fn.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)},fn.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()}},fn.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))},fn.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},fn.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})}},fn.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)},fn.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})}},fn.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)},fn.requestFormReset=function(h){i.d.r(h)},fn.unstable_batchedUpdates=function(h,x){return h(x)},fn.useFormState=function(h,x,v){return d.H.useFormState(h,x,v)},fn.useFormStatus=function(){return d.H.useHostTransitionStatus()},fn.version="19.2.4",fn}var Xx;function Ov(){if(Xx)return Ed.exports;Xx=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=ej(),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 Qx;function tj(){if(Qx)return $s;Qx=1;var t=J0(),a=Lf(),s=Ov();function i(e){var r="https://react.dev/errors/"+e;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+r+" 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 r=e,l=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(l=r.return),e=r.return;while(e)}return r.tag===3?l:null}function d(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function f(e){if(e.tag===31){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function h(e){if(u(e)!==e)throw Error(i(188))}function x(e){var r=e.alternate;if(!r){if(r=u(e),r===null)throw Error(i(188));return r!==e?null:e}for(var l=e,o=r;;){var m=l.return;if(m===null)break;var g=m.alternate;if(g===null){if(o=m.return,o!==null){l=o;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===l)return h(m),e;if(g===o)return h(m),r;g=g.sibling}throw Error(i(188))}if(l.return!==o.return)l=m,o=g;else{for(var S=!1,A=m.child;A;){if(A===l){S=!0,l=m,o=g;break}if(A===o){S=!0,o=m,l=g;break}A=A.sibling}if(!S){for(A=g.child;A;){if(A===l){S=!0,l=g,o=m;break}if(A===o){S=!0,o=g,l=m;break}A=A.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:r}function v(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e;for(e=e.child;e!==null;){if(r=v(e),r!==null)return r;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"),w=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),R=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),_=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function W(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 w:return"Fragment";case T:return"Profiler";case C:return"StrictMode";case L:return"Suspense";case P:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case R:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case O:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case N:return r=e.displayName||null,r!==null?r:ee(e.type)||"Memo";case B:r=e._payload,e=e._init;try{return ee(e(r))}catch{}}return null}var $=Array.isArray,D=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},Y=[],oe=-1;function M(e){return{current:e}}function I(e){0>oe||(e.current=Y[oe],Y[oe]=null,oe--)}function K(e,r){oe++,Y[oe]=e.current,e.current=r}var Q=M(null),ue=M(null),te=M(null),ie=M(null);function J(e,r){switch(K(te,r),K(ue,e),K(Q,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?fx(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=fx(r),e=px(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}I(Q),K(Q,e)}function he(){I(Q),I(ue),I(te)}function je(e){e.memoizedState!==null&&K(ie,e);var r=Q.current,l=px(r,e.type);r!==l&&(K(ue,e),K(Q,l))}function Ne(e){ue.current===e&&(I(Q),I(ue)),ie.current===e&&(I(ie),Ds._currentValue=F)}var De,He;function Ue(e){if(De===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);De=r&&r[1]||"",He=-1<l.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+De+e+He}var _e=!1;function Ze(e,r){if(!e||_e)return"";_e=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(r){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 m=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=o.DetermineComponentFrameRoot(),S=g[0],A=g[1];if(S&&A){var V=S.split(`
|
|
45
|
+
`),re=A.split(`
|
|
46
|
+
`);for(m=o=0;o<V.length&&!V[o].includes("DetermineComponentFrameRoot");)o++;for(;m<re.length&&!re[m].includes("DetermineComponentFrameRoot");)m++;if(o===V.length||m===re.length)for(o=V.length-1,m=re.length-1;1<=o&&0<=m&&V[o]!==re[m];)m--;for(;1<=o&&0<=m;o--,m--)if(V[o]!==re[m]){if(o!==1||m!==1)do if(o--,m--,0>m||V[o]!==re[m]){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<=m);break}}}finally{_e=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ue(l):""}function st(e,r){switch(e.tag){case 26:case 27:case 5:return Ue(e.type);case 16:return Ue("Lazy");case 13:return e.child!==r&&r!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return Ze(e.type,!1);case 11:return Ze(e.type.render,!1);case 1:return Ze(e.type,!0);case 31:return Ue("Activity");default:return""}}function ce(e){try{var r="",l=null;do r+=st(e,l),l=e,e=e.return;while(e);return r}catch(o){return`
|
|
48
|
+
Error generating stack: `+o.message+`
|
|
49
|
+
`+o.stack}}var ve=Object.prototype.hasOwnProperty,ye=t.unstable_scheduleCallback,Se=t.unstable_cancelCallback,Ae=t.unstable_shouldYield,Ge=t.unstable_requestPaint,We=t.unstable_now,wt=t.unstable_getCurrentPriorityLevel,Ct=t.unstable_ImmediatePriority,Et=t.unstable_UserBlockingPriority,zt=t.unstable_NormalPriority,xe=t.unstable_LowPriority,qe=t.unstable_IdlePriority,tt=t.log,Nt=t.unstable_setDisableYieldValue,St=null,dt=null;function Dt(e){if(typeof tt=="function"&&Nt(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(St,e)}catch{}}var Ft=Math.clz32?Math.clz32:Tn,jr=Math.log,en=Math.LN2;function Tn(e){return e>>>=0,e===0?32:31-(jr(e)/en|0)|0}var Rn=256,nr=262144,bn=4194304;function Tt(e){var r=e&42;if(r!==0)return r;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 pt(e,r,l){var o=e.pendingLanes;if(o===0)return 0;var m=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var A=o&134217727;return A!==0?(o=A&~g,o!==0?m=Tt(o):(S&=A,S!==0?m=Tt(S):l||(l=A&~e,l!==0&&(m=Tt(l))))):(A=o&~g,A!==0?m=Tt(A):S!==0?m=Tt(S):l||(l=o&~e,l!==0&&(m=Tt(l)))),m===0?0:r!==0&&r!==m&&(r&g)===0&&(g=m&-m,l=r&-r,g>=l||g===32&&(l&4194048)!==0)?r:m}function Pe(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function it(e,r){switch(e){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 un(){var e=bn;return bn<<=1,(bn&62914560)===0&&(bn=4194304),e}function rn(e){for(var r=[],l=0;31>l;l++)r.push(e);return r}function rr(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Hn(e,r,l,o,m,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 A=e.entanglements,V=e.expirationTimes,re=e.hiddenUpdates;for(l=S&~l;0<l;){var de=31-Ft(l),pe=1<<de;A[de]=0,V[de]=-1;var le=re[de];if(le!==null)for(re[de]=null,de=0;de<le.length;de++){var se=le[de];se!==null&&(se.lane&=-536870913)}l&=~pe}o!==0&&Kl(e,o,0),g!==0&&m===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~r))}function Kl(e,r,l){e.pendingLanes|=r,e.suspendedLanes&=~r;var o=31-Ft(r);e.entangledLanes|=r,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function Qa(e,r){var l=e.entangledLanes|=r;for(e=e.entanglements;l;){var o=31-Ft(l),m=1<<o;m&r|e[o]&r&&(e[o]|=r),l&=~m}}function Sr(e,r){var l=r&-r;return l=(l&42)!==0?1:jn(l),(l&(e.suspendedLanes|r))!==0?0:l}function jn(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 Z(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function be(){var e=U.p;return e!==0?e:(e=window.event,e===void 0?32:Ox(e.type))}function we(e,r){var l=U.p;try{return U.p=e,r()}finally{U.p=l}}var _t=Math.random().toString(36).slice(2),Te="__reactFiber$"+_t,ht="__reactProps$"+_t,dn="__reactContainer$"+_t,Gr="__reactEvents$"+_t,an="__reactListeners$"+_t,Jf="__reactHandles$"+_t,kr="__reactResources$"+_t,wa="__reactMarker$"+_t;function pc(e){delete e[Te],delete e[ht],delete e[Gr],delete e[an],delete e[Jf]}function Za(e){var r=e[Te];if(r)return r;for(var l=e.parentNode;l;){if(r=l[dn]||l[Te]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(e=bx(e);e!==null;){if(l=e[Te])return l;e=bx(e)}return r}e=l,l=e.parentNode}return null}function Ja(e){if(e=e[Te]||e[dn]){var r=e.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return e}return null}function Xl(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e.stateNode;throw Error(i(33))}function el(e){var r=e[kr];return r||(r=e[kr]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function tn(e){e[wa]=!0}var ep=new Set,tp={};function Ca(e,r){tl(e,r),tl(e+"Capture",r)}function tl(e,r){for(tp[e]=r,e=0;e<r.length;e++)ep.add(r[e])}var Ub=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]*$"),np={},rp={};function Hb(e){return ve.call(rp,e)?!0:ve.call(np,e)?!1:Ub.test(e)?rp[e]=!0:(np[e]=!0,!1)}function hi(e,r,l){if(Hb(r))if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(r);return;case"boolean":var o=r.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(r);return}}e.setAttribute(r,""+l)}}function xi(e,r,l){if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttribute(r,""+l)}}function wr(e,r,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(r,l,""+o)}}function Pn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ap(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Pb(e,r,l){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,r);if(!e.hasOwnProperty(r)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var m=o.get,g=o.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return m.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,r,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function mc(e){if(!e._valueTracker){var r=ap(e)?"checked":"value";e._valueTracker=Pb(e,r,""+e[r])}}function lp(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var l=r.getValue(),o="";return e&&(o=ap(e)?e.checked?"true":"false":e.value),e=o,e!==l?(r.setValue(e),!0):!1}function gi(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 Vb=/[\n"\\]/g;function Vn(e){return e.replace(Vb,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function hc(e,r,l,o,m,g,S,A){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),r!=null?S==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+Pn(r)):e.value!==""+Pn(r)&&(e.value=""+Pn(r)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),r!=null?xc(e,S,Pn(r)):l!=null?xc(e,S,Pn(l)):o!=null&&e.removeAttribute("value"),m==null&&g!=null&&(e.defaultChecked=!!g),m!=null&&(e.checked=m&&typeof m!="function"&&typeof m!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+Pn(A):e.removeAttribute("name")}function sp(e,r,l,o,m,g,S,A){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),r!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){mc(e);return}l=l!=null?""+Pn(l):"",r=r!=null?""+Pn(r):l,A||r===e.value||(e.value=r),e.defaultValue=r}o=o??m,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=A?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,r,l){r==="number"&&gi(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function nl(e,r,l,o){if(e=e.options,r){r={};for(var m=0;m<l.length;m++)r["$"+l[m]]=!0;for(l=0;l<e.length;l++)m=r.hasOwnProperty("$"+e[l].value),e[l].selected!==m&&(e[l].selected=m),m&&o&&(e[l].defaultSelected=!0)}else{for(l=""+Pn(l),r=null,m=0;m<e.length;m++){if(e[m].value===l){e[m].selected=!0,o&&(e[m].defaultSelected=!0);return}r!==null||e[m].disabled||(r=e[m])}r!==null&&(r.selected=!0)}}function ip(e,r,l){if(r!=null&&(r=""+Pn(r),r!==e.value&&(e.value=r),l==null)){e.defaultValue!==r&&(e.defaultValue=r);return}e.defaultValue=l!=null?""+Pn(l):""}function op(e,r,l,o){if(r==null){if(o!=null){if(l!=null)throw Error(i(92));if($(o)){if(1<o.length)throw Error(i(93));o=o[0]}l=o}l==null&&(l=""),r=l}l=Pn(r),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),mc(e)}function rl(e,r){if(r){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=r;return}}e.textContent=r}var Fb=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 cp(e,r,l){var o=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?o?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="":o?e.setProperty(r,l):typeof l!="number"||l===0||Fb.has(r)?r==="float"?e.cssFloat=l:e[r]=(""+l).trim():e[r]=l+"px"}function up(e,r,l){if(r!=null&&typeof r!="object")throw Error(i(62));if(e=e.style,l!=null){for(var o in l)!l.hasOwnProperty(o)||r!=null&&r.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var m in r)o=r[m],r.hasOwnProperty(m)&&l[m]!==o&&cp(e,m,o)}else for(var g in r)r.hasOwnProperty(g)&&cp(e,g,r[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 Wb=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"]]),Gb=/^[\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 vi(e){return Gb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Cr(){}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 al=null,ll=null;function dp(e){var r=Ja(e);if(r&&(e=r.stateNode)){var l=e[ht]||null;e:switch(e=r.stateNode,r.type){case"input":if(hc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Vn(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var o=l[r];if(o!==e&&o.form===e.form){var m=o[ht]||null;if(!m)throw Error(i(90));hc(o,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(r=0;r<l.length;r++)o=l[r],o.form===e.form&&lp(o)}break e;case"textarea":ip(e,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&nl(e,!!l.multiple,r,!1)}}}var bc=!1;function fp(e,r,l){if(bc)return e(r,l);bc=!0;try{var o=e(r);return o}finally{if(bc=!1,(al!==null||ll!==null)&&(lo(),al&&(r=al,e=ll,ll=al=null,dp(r),e)))for(r=0;r<e.length;r++)dp(e[r])}}function Ql(e,r){var l=e.stateNode;if(l===null)return null;var o=l[ht]||null;if(o===null)return null;l=o[r];e:switch(r){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,r,typeof l));return l}var Er=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jc=!1;if(Er)try{var Zl={};Object.defineProperty(Zl,"passive",{get:function(){jc=!0}}),window.addEventListener("test",Zl,Zl),window.removeEventListener("test",Zl,Zl)}catch{jc=!1}var qr=null,Sc=null,yi=null;function pp(){if(yi)return yi;var e,r=Sc,l=r.length,o,m="value"in qr?qr.value:qr.textContent,g=m.length;for(e=0;e<l&&r[e]===m[e];e++);var S=l-e;for(o=1;o<=S&&r[l-o]===m[g-o];o++);return yi=m.slice(e,1<o?1-o:void 0)}function bi(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function ji(){return!0}function mp(){return!1}function Sn(e){function r(l,o,m,g,S){this._reactName=l,this._targetInst=m,this.type=o,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(l=e[A],this[A]=l?l(g):g[A]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ji:mp,this.isPropagationStopped=mp,this}return y(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ji)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ji)},persist:function(){},isPersistent:ji}),r}var Ea={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Si=Sn(Ea),Jl=y({},Ea,{view:0,detail:0}),qb=Sn(Jl),kc,wc,es,ki=y({},Jl,{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!==es&&(es&&e.type==="mousemove"?(kc=e.screenX-es.screenX,wc=e.screenY-es.screenY):wc=kc=0,es=e),kc)},movementY:function(e){return"movementY"in e?e.movementY:wc}}),hp=Sn(ki),Yb=y({},ki,{dataTransfer:0}),Kb=Sn(Yb),Xb=y({},Jl,{relatedTarget:0}),Cc=Sn(Xb),Qb=y({},Ea,{animationName:0,elapsedTime:0,pseudoElement:0}),Zb=Sn(Qb),Jb=y({},Ea,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),e1=Sn(Jb),t1=y({},Ea,{data:0}),xp=Sn(t1),n1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},r1={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"},a1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l1(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=a1[e])?!!r[e]:!1}function Ec(){return l1}var s1=y({},Jl,{key:function(e){if(e.key){var r=n1[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=bi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?r1[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"?bi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?bi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),i1=Sn(s1),o1=y({},ki,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gp=Sn(o1),c1=y({},Jl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ec}),u1=Sn(c1),d1=y({},Ea,{propertyName:0,elapsedTime:0,pseudoElement:0}),f1=Sn(d1),p1=y({},ki,{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}),m1=Sn(p1),h1=y({},Ea,{newState:0,oldState:0}),x1=Sn(h1),g1=[9,13,27,32],Nc=Er&&"CompositionEvent"in window,ts=null;Er&&"documentMode"in document&&(ts=document.documentMode);var v1=Er&&"TextEvent"in window&&!ts,vp=Er&&(!Nc||ts&&8<ts&&11>=ts),yp=" ",bp=!1;function jp(e,r){switch(e){case"keyup":return g1.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var sl=!1;function y1(e,r){switch(e){case"compositionend":return Sp(r);case"keypress":return r.which!==32?null:(bp=!0,yp);case"textInput":return e=r.data,e===yp&&bp?null:e;default:return null}}function b1(e,r){if(sl)return e==="compositionend"||!Nc&&jp(e,r)?(e=pp(),yi=Sc=qr=null,sl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return vp&&r.locale!=="ko"?null:r.data;default:return null}}var j1={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 kp(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!j1[e.type]:r==="textarea"}function wp(e,r,l,o){al?ll?ll.push(o):ll=[o]:al=o,r=po(r,"onChange"),0<r.length&&(l=new Si("onChange","change",null,l,o),e.push({event:l,listeners:r}))}var ns=null,rs=null;function S1(e){sx(e,0)}function wi(e){var r=Xl(e);if(lp(r))return e}function Cp(e,r){if(e==="change")return r}var Ep=!1;if(Er){var Tc;if(Er){var Rc="oninput"in document;if(!Rc){var Np=document.createElement("div");Np.setAttribute("oninput","return;"),Rc=typeof Np.oninput=="function"}Tc=Rc}else Tc=!1;Ep=Tc&&(!document.documentMode||9<document.documentMode)}function Tp(){ns&&(ns.detachEvent("onpropertychange",Rp),rs=ns=null)}function Rp(e){if(e.propertyName==="value"&&wi(rs)){var r=[];wp(r,rs,e,yc(e)),fp(S1,r)}}function k1(e,r,l){e==="focusin"?(Tp(),ns=r,rs=l,ns.attachEvent("onpropertychange",Rp)):e==="focusout"&&Tp()}function w1(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return wi(rs)}function C1(e,r){if(e==="click")return wi(r)}function E1(e,r){if(e==="input"||e==="change")return wi(r)}function N1(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var An=typeof Object.is=="function"?Object.is:N1;function as(e,r){if(An(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var l=Object.keys(e),o=Object.keys(r);if(l.length!==o.length)return!1;for(o=0;o<l.length;o++){var m=l[o];if(!ve.call(r,m)||!An(e[m],r[m]))return!1}return!0}function Ap(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Lp(e,r){var l=Ap(e);e=0;for(var o;l;){if(l.nodeType===3){if(o=e+l.textContent.length,e<=r&&o>=r)return{node:l,offset:r-e};e=o}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Ap(l)}}function Mp(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?Mp(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function zp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=gi(e.document);r instanceof e.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)e=r.contentWindow;else break;r=gi(e.document)}return r}function Ac(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var T1=Er&&"documentMode"in document&&11>=document.documentMode,il=null,Lc=null,ls=null,Mc=!1;function Dp(e,r,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Mc||il==null||il!==gi(o)||(o=il,"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}),ls&&as(ls,o)||(ls=o,o=po(Lc,"onSelect"),0<o.length&&(r=new Si("onSelect","select",null,r,l),e.push({event:r,listeners:o}),r.target=il)))}function Na(e,r){var l={};return l[e.toLowerCase()]=r.toLowerCase(),l["Webkit"+e]="webkit"+r,l["Moz"+e]="moz"+r,l}var ol={animationend:Na("Animation","AnimationEnd"),animationiteration:Na("Animation","AnimationIteration"),animationstart:Na("Animation","AnimationStart"),transitionrun:Na("Transition","TransitionRun"),transitionstart:Na("Transition","TransitionStart"),transitioncancel:Na("Transition","TransitionCancel"),transitionend:Na("Transition","TransitionEnd")},zc={},_p={};Er&&(_p=document.createElement("div").style,"AnimationEvent"in window||(delete ol.animationend.animation,delete ol.animationiteration.animation,delete ol.animationstart.animation),"TransitionEvent"in window||delete ol.transitionend.transition);function Ta(e){if(zc[e])return zc[e];if(!ol[e])return e;var r=ol[e],l;for(l in r)if(r.hasOwnProperty(l)&&l in _p)return zc[e]=r[l];return e}var Op=Ta("animationend"),Bp=Ta("animationiteration"),Ip=Ta("animationstart"),R1=Ta("transitionrun"),A1=Ta("transitionstart"),L1=Ta("transitioncancel"),$p=Ta("transitionend"),Up=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 ar(e,r){Up.set(e,r),Ca(r,[e])}var Ci=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=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(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Fn=[],cl=0,_c=0;function Ei(){for(var e=cl,r=_c=cl=0;r<e;){var l=Fn[r];Fn[r++]=null;var o=Fn[r];Fn[r++]=null;var m=Fn[r];Fn[r++]=null;var g=Fn[r];if(Fn[r++]=null,o!==null&&m!==null){var S=o.pending;S===null?m.next=m:(m.next=S.next,S.next=m),o.pending=m}g!==0&&Hp(l,m,g)}}function Ni(e,r,l,o){Fn[cl++]=e,Fn[cl++]=r,Fn[cl++]=l,Fn[cl++]=o,_c|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Oc(e,r,l,o){return Ni(e,r,l,o),Ti(e)}function Ra(e,r){return Ni(e,null,null,r),Ti(e)}function Hp(e,r,l){e.lanes|=l;var o=e.alternate;o!==null&&(o.lanes|=l);for(var m=!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||(m=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,m&&r!==null&&(m=31-Ft(l),e=g.hiddenUpdates,o=e[m],o===null?e[m]=[r]:o.push(r),r.lane=l|536870912),g):null}function Ti(e){if(50<Ns)throw Ns=0,Wu=null,Error(i(185));for(var r=e.return;r!==null;)e=r,r=e.return;return e.tag===3?e.stateNode:null}var ul={};function M1(e,r,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=r,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 Ln(e,r,l,o){return new M1(e,r,l,o)}function Bc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Nr(e,r){var l=e.alternate;return l===null?(l=Ln(e.tag,r,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=r,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,r=e.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Pp(e,r){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=r,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,r=l.dependencies,e.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),e}function Ri(e,r,l,o,m,g){var S=0;if(o=e,typeof e=="function")Bc(e)&&(S=1);else if(typeof e=="string")S=B0(e,l,Q.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=Ln(31,l,r,m),e.elementType=z,e.lanes=g,e;case w:return Aa(l.children,m,g,r);case C:S=8,m|=24;break;case T:return e=Ln(12,l,r,m|2),e.elementType=T,e.lanes=g,e;case L:return e=Ln(13,l,r,m),e.elementType=L,e.lanes=g,e;case P:return e=Ln(19,l,r,m),e.elementType=P,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:S=10;break e;case E:S=9;break e;case O:S=11;break e;case N:S=14;break e;case B:S=16,o=null;break e}S=29,l=Error(i(130,e===null?"null":typeof e,"")),o=null}return r=Ln(S,l,r,m),r.elementType=e,r.type=o,r.lanes=g,r}function Aa(e,r,l,o){return e=Ln(7,e,o,r),e.lanes=l,e}function Ic(e,r,l){return e=Ln(6,e,null,r),e.lanes=l,e}function Vp(e){var r=Ln(18,null,null,0);return r.stateNode=e,r}function $c(e,r,l){return r=Ln(4,e.children!==null?e.children:[],e.key,r),r.lanes=l,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}var Fp=new WeakMap;function Wn(e,r){if(typeof e=="object"&&e!==null){var l=Fp.get(e);return l!==void 0?l:(r={value:e,source:r,stack:ce(r)},Fp.set(e,r),r)}return{value:e,source:r,stack:ce(r)}}var dl=[],fl=0,Ai=null,ss=0,Gn=[],qn=0,Yr=null,dr=1,fr="";function Tr(e,r){dl[fl++]=ss,dl[fl++]=Ai,Ai=e,ss=r}function Wp(e,r,l){Gn[qn++]=dr,Gn[qn++]=fr,Gn[qn++]=Yr,Yr=e;var o=dr;e=fr;var m=32-Ft(o)-1;o&=~(1<<m),l+=1;var g=32-Ft(r)+m;if(30<g){var S=m-m%5;g=(o&(1<<S)-1).toString(32),o>>=S,m-=S,dr=1<<32-Ft(r)+m|l<<m|o,fr=g+e}else dr=1<<g|l<<m|o,fr=e}function Uc(e){e.return!==null&&(Tr(e,1),Wp(e,1,0))}function Hc(e){for(;e===Ai;)Ai=dl[--fl],dl[fl]=null,ss=dl[--fl],dl[fl]=null;for(;e===Yr;)Yr=Gn[--qn],Gn[qn]=null,fr=Gn[--qn],Gn[qn]=null,dr=Gn[--qn],Gn[qn]=null}function Gp(e,r){Gn[qn++]=dr,Gn[qn++]=fr,Gn[qn++]=Yr,dr=r.id,fr=r.overflow,Yr=e}var ln=null,Rt=null,at=!1,Kr=null,Yn=!1,Pc=Error(i(519));function Xr(e){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw is(Wn(r,e)),Pc}function qp(e){var r=e.stateNode,l=e.type,o=e.memoizedProps;switch(r[Te]=e,r[ht]=o,l){case"dialog":et("cancel",r),et("close",r);break;case"iframe":case"object":case"embed":et("load",r);break;case"video":case"audio":for(l=0;l<Rs.length;l++)et(Rs[l],r);break;case"source":et("error",r);break;case"img":case"image":case"link":et("error",r),et("load",r);break;case"details":et("toggle",r);break;case"input":et("invalid",r),sp(r,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":et("invalid",r);break;case"textarea":et("invalid",r),op(r,o.value,o.defaultValue,o.children)}l=o.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||o.suppressHydrationWarning===!0||ux(r.textContent,l)?(o.popover!=null&&(et("beforetoggle",r),et("toggle",r)),o.onScroll!=null&&et("scroll",r),o.onScrollEnd!=null&&et("scrollend",r),o.onClick!=null&&(r.onclick=Cr),r=!0):r=!1,r||Xr(e,!0)}function Yp(e){for(ln=e.return;ln;)switch(ln.tag){case 5:case 31:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:ln=ln.return}}function pl(e){if(e!==ln)return!1;if(!at)return Yp(e),at=!0,!1;var r=e.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||sd(e.type,e.memoizedProps)),l=!l),l&&Rt&&Xr(e),Yp(e),r===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));Rt=yx(e)}else if(r===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));Rt=yx(e)}else r===27?(r=Rt,ua(e.type)?(e=dd,dd=null,Rt=e):Rt=r):Rt=ln?Xn(e.stateNode.nextSibling):null;return!0}function La(){Rt=ln=null,at=!1}function Vc(){var e=Kr;return e!==null&&(En===null?En=e:En.push.apply(En,e),Kr=null),e}function is(e){Kr===null?Kr=[e]:Kr.push(e)}var Fc=M(null),Ma=null,Rr=null;function Qr(e,r,l){K(Fc,r._currentValue),r._currentValue=l}function Ar(e){e._currentValue=Fc.current,I(Fc)}function Wc(e,r,l){for(;e!==null;){var o=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,o!==null&&(o.childLanes|=r)):o!==null&&(o.childLanes&r)!==r&&(o.childLanes|=r),e===l)break;e=e.return}}function Gc(e,r,l,o){var m=e.child;for(m!==null&&(m.return=e);m!==null;){var g=m.dependencies;if(g!==null){var S=m.child;g=g.firstContext;e:for(;g!==null;){var A=g;g=m;for(var V=0;V<r.length;V++)if(A.context===r[V]){g.lanes|=l,A=g.alternate,A!==null&&(A.lanes|=l),Wc(g.return,l,e),o||(S=null);break e}g=A.next}}else if(m.tag===18){if(S=m.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=m.child;if(S!==null)S.return=m;else for(S=m;S!==null;){if(S===e){S=null;break}if(m=S.sibling,m!==null){m.return=S.return,S=m;break}S=S.return}m=S}}function ml(e,r,l,o){e=null;for(var m=r,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var S=m.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var A=m.type;An(m.pendingProps.value,S.value)||(e!==null?e.push(A):e=[A])}}else if(m===ie.current){if(S=m.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(e!==null?e.push(Ds):e=[Ds])}m=m.return}e!==null&&Gc(r,e,l,o),r.flags|=262144}function Li(e){for(e=e.firstContext;e!==null;){if(!An(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function za(e){Ma=e,Rr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function sn(e){return Kp(Ma,e)}function Mi(e,r){return Ma===null&&za(e),Kp(e,r)}function Kp(e,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},Rr===null){if(e===null)throw Error(i(308));Rr=r,e.dependencies={lanes:0,firstContext:r},e.flags|=524288}else Rr=Rr.next=r;return l}var z1=typeof AbortController<"u"?AbortController:function(){var e=[],r=this.signal={aborted:!1,addEventListener:function(l,o){e.push(o)}};this.abort=function(){r.aborted=!0,e.forEach(function(l){return l()})}},D1=t.unstable_scheduleCallback,_1=t.unstable_NormalPriority,Wt={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qc(){return{controller:new z1,data:new Map,refCount:0}}function os(e){e.refCount--,e.refCount===0&&D1(_1,function(){e.controller.abort()})}var cs=null,Yc=0,hl=0,xl=null;function O1(e,r){if(cs===null){var l=cs=[];Yc=0,hl=Qu(),xl={status:"pending",value:void 0,then:function(o){l.push(o)}}}return Yc++,r.then(Xp,Xp),r}function Xp(){if(--Yc===0&&cs!==null){xl!==null&&(xl.status="fulfilled");var e=cs;cs=null,hl=0,xl=null;for(var r=0;r<e.length;r++)(0,e[r])()}}function B1(e,r){var l=[],o={status:"pending",value:null,reason:null,then:function(m){l.push(m)}};return e.then(function(){o.status="fulfilled",o.value=r;for(var m=0;m<l.length;m++)(0,l[m])(r)},function(m){for(o.status="rejected",o.reason=m,m=0;m<l.length;m++)(0,l[m])(void 0)}),o}var Qp=D.S;D.S=function(e,r){Dh=We(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&O1(e,r),Qp!==null&&Qp(e,r)};var Da=M(null);function Kc(){var e=Da.current;return e!==null?e:kt.pooledCache}function zi(e,r){r===null?K(Da,Da.current):K(Da,r.pool)}function Zp(){var e=Kc();return e===null?null:{parent:Wt._currentValue,pool:e}}var gl=Error(i(460)),Xc=Error(i(474)),Di=Error(i(542)),_i={then:function(){}};function Jp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function em(e,r,l){switch(l=e[l],l===void 0?e.push(r):l!==r&&(r.then(Cr,Cr),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,nm(e),e;default:if(typeof r.status=="string")r.then(Cr,Cr);else{if(e=kt,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=r,e.status="pending",e.then(function(o){if(r.status==="pending"){var m=r;m.status="fulfilled",m.value=o}},function(o){if(r.status==="pending"){var m=r;m.status="rejected",m.reason=o}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,nm(e),e}throw Oa=r,gl}}function _a(e){try{var r=e._init;return r(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Oa=l,gl):l}}var Oa=null;function tm(){if(Oa===null)throw Error(i(459));var e=Oa;return Oa=null,e}function nm(e){if(e===gl||e===Di)throw Error(i(483))}var vl=null,us=0;function Oi(e){var r=us;return us+=1,vl===null&&(vl=[]),em(vl,e,r)}function ds(e,r){r=r.props.ref,e.ref=r!==void 0?r:null}function Bi(e,r){throw r.$$typeof===b?Error(i(525)):(e=Object.prototype.toString.call(r),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)))}function rm(e){function r(X,G){if(e){var ne=X.deletions;ne===null?(X.deletions=[G],X.flags|=16):ne.push(G)}}function l(X,G){if(!e)return null;for(;G!==null;)r(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 m(X,G){return X=Nr(X,G),X.index=0,X.sibling=null,X}function g(X,G,ne){return X.index=ne,e?(ne=X.alternate,ne!==null?(ne=ne.index,ne<G?(X.flags|=67108866,G):ne):(X.flags|=67108866,G)):(X.flags|=1048576,G)}function S(X){return e&&X.alternate===null&&(X.flags|=67108866),X}function A(X,G,ne,fe){return G===null||G.tag!==6?(G=Ic(ne,X.mode,fe),G.return=X,G):(G=m(G,ne),G.return=X,G)}function V(X,G,ne,fe){var ze=ne.type;return ze===w?de(X,G,ne.props.children,fe,ne.key):G!==null&&(G.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===B&&_a(ze)===G.type)?(G=m(G,ne.props),ds(G,ne),G.return=X,G):(G=Ri(ne.type,ne.key,ne.props,null,X.mode,fe),ds(G,ne),G.return=X,G)}function re(X,G,ne,fe){return G===null||G.tag!==4||G.stateNode.containerInfo!==ne.containerInfo||G.stateNode.implementation!==ne.implementation?(G=$c(ne,X.mode,fe),G.return=X,G):(G=m(G,ne.children||[]),G.return=X,G)}function de(X,G,ne,fe,ze){return G===null||G.tag!==7?(G=Aa(ne,X.mode,fe,ze),G.return=X,G):(G=m(G,ne),G.return=X,G)}function pe(X,G,ne){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Ic(""+G,X.mode,ne),G.return=X,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return ne=Ri(G.type,G.key,G.props,null,X.mode,ne),ds(ne,G),ne.return=X,ne;case k:return G=$c(G,X.mode,ne),G.return=X,G;case B:return G=_a(G),pe(X,G,ne)}if($(G)||W(G))return G=Aa(G,X.mode,ne,null),G.return=X,G;if(typeof G.then=="function")return pe(X,Oi(G),ne);if(G.$$typeof===R)return pe(X,Mi(X,G),ne);Bi(X,G)}return null}function le(X,G,ne,fe){var ze=G!==null?G.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return ze!==null?null:A(X,G,""+ne,fe);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case j:return ne.key===ze?V(X,G,ne,fe):null;case k:return ne.key===ze?re(X,G,ne,fe):null;case B:return ne=_a(ne),le(X,G,ne,fe)}if($(ne)||W(ne))return ze!==null?null:de(X,G,ne,fe,null);if(typeof ne.then=="function")return le(X,G,Oi(ne),fe);if(ne.$$typeof===R)return le(X,G,Mi(X,ne),fe);Bi(X,ne)}return null}function se(X,G,ne,fe,ze){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return X=X.get(ne)||null,A(G,X,""+fe,ze);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case j:return X=X.get(fe.key===null?ne:fe.key)||null,V(G,X,fe,ze);case k:return X=X.get(fe.key===null?ne:fe.key)||null,re(G,X,fe,ze);case B:return fe=_a(fe),se(X,G,ne,fe,ze)}if($(fe)||W(fe))return X=X.get(ne)||null,de(G,X,fe,ze,null);if(typeof fe.then=="function")return se(X,G,ne,Oi(fe),ze);if(fe.$$typeof===R)return se(X,G,ne,Mi(G,fe),ze);Bi(G,fe)}return null}function Ee(X,G,ne,fe){for(var ze=null,ot=null,Re=G,Ke=G=0,rt=null;Re!==null&&Ke<ne.length;Ke++){Re.index>Ke?(rt=Re,Re=null):rt=Re.sibling;var ct=le(X,Re,ne[Ke],fe);if(ct===null){Re===null&&(Re=rt);break}e&&Re&&ct.alternate===null&&r(X,Re),G=g(ct,G,Ke),ot===null?ze=ct:ot.sibling=ct,ot=ct,Re=rt}if(Ke===ne.length)return l(X,Re),at&&Tr(X,Ke),ze;if(Re===null){for(;Ke<ne.length;Ke++)Re=pe(X,ne[Ke],fe),Re!==null&&(G=g(Re,G,Ke),ot===null?ze=Re:ot.sibling=Re,ot=Re);return at&&Tr(X,Ke),ze}for(Re=o(Re);Ke<ne.length;Ke++)rt=se(Re,X,Ke,ne[Ke],fe),rt!==null&&(e&&rt.alternate!==null&&Re.delete(rt.key===null?Ke:rt.key),G=g(rt,G,Ke),ot===null?ze=rt:ot.sibling=rt,ot=rt);return e&&Re.forEach(function(ha){return r(X,ha)}),at&&Tr(X,Ke),ze}function Be(X,G,ne,fe){if(ne==null)throw Error(i(151));for(var ze=null,ot=null,Re=G,Ke=G=0,rt=null,ct=ne.next();Re!==null&&!ct.done;Ke++,ct=ne.next()){Re.index>Ke?(rt=Re,Re=null):rt=Re.sibling;var ha=le(X,Re,ct.value,fe);if(ha===null){Re===null&&(Re=rt);break}e&&Re&&ha.alternate===null&&r(X,Re),G=g(ha,G,Ke),ot===null?ze=ha:ot.sibling=ha,ot=ha,Re=rt}if(ct.done)return l(X,Re),at&&Tr(X,Ke),ze;if(Re===null){for(;!ct.done;Ke++,ct=ne.next())ct=pe(X,ct.value,fe),ct!==null&&(G=g(ct,G,Ke),ot===null?ze=ct:ot.sibling=ct,ot=ct);return at&&Tr(X,Ke),ze}for(Re=o(Re);!ct.done;Ke++,ct=ne.next())ct=se(Re,X,Ke,ct.value,fe),ct!==null&&(e&&ct.alternate!==null&&Re.delete(ct.key===null?Ke:ct.key),G=g(ct,G,Ke),ot===null?ze=ct:ot.sibling=ct,ot=ct);return e&&Re.forEach(function(Y0){return r(X,Y0)}),at&&Tr(X,Ke),ze}function bt(X,G,ne,fe){if(typeof ne=="object"&&ne!==null&&ne.type===w&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case j:e:{for(var ze=ne.key;G!==null;){if(G.key===ze){if(ze=ne.type,ze===w){if(G.tag===7){l(X,G.sibling),fe=m(G,ne.props.children),fe.return=X,X=fe;break e}}else if(G.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===B&&_a(ze)===G.type){l(X,G.sibling),fe=m(G,ne.props),ds(fe,ne),fe.return=X,X=fe;break e}l(X,G);break}else r(X,G);G=G.sibling}ne.type===w?(fe=Aa(ne.props.children,X.mode,fe,ne.key),fe.return=X,X=fe):(fe=Ri(ne.type,ne.key,ne.props,null,X.mode,fe),ds(fe,ne),fe.return=X,X=fe)}return S(X);case k:e:{for(ze=ne.key;G!==null;){if(G.key===ze)if(G.tag===4&&G.stateNode.containerInfo===ne.containerInfo&&G.stateNode.implementation===ne.implementation){l(X,G.sibling),fe=m(G,ne.children||[]),fe.return=X,X=fe;break e}else{l(X,G);break}else r(X,G);G=G.sibling}fe=$c(ne,X.mode,fe),fe.return=X,X=fe}return S(X);case B:return ne=_a(ne),bt(X,G,ne,fe)}if($(ne))return Ee(X,G,ne,fe);if(W(ne)){if(ze=W(ne),typeof ze!="function")throw Error(i(150));return ne=ze.call(ne),Be(X,G,ne,fe)}if(typeof ne.then=="function")return bt(X,G,Oi(ne),fe);if(ne.$$typeof===R)return bt(X,G,Mi(X,ne),fe);Bi(X,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,G!==null&&G.tag===6?(l(X,G.sibling),fe=m(G,ne),fe.return=X,X=fe):(l(X,G),fe=Ic(ne,X.mode,fe),fe.return=X,X=fe),S(X)):l(X,G)}return function(X,G,ne,fe){try{us=0;var ze=bt(X,G,ne,fe);return vl=null,ze}catch(Re){if(Re===gl||Re===Di)throw Re;var ot=Ln(29,Re,null,X.mode);return ot.lanes=fe,ot.return=X,ot}finally{}}}var Ba=rm(!0),am=rm(!1),Zr=!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,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Jr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ea(e,r,l){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ft&2)!==0){var m=o.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),o.pending=r,r=Ti(e),Hp(e,null,l),r}return Ni(e,o,r,l),Ti(e)}function fs(e,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var o=r.lanes;o&=e.pendingLanes,l|=o,r.lanes=l,Qa(e,l)}}function Jc(e,r){var l=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,l===o)){var m=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?m=g=S:g=g.next=S,l=l.next}while(l!==null);g===null?m=g=r:g=g.next=r}else m=g=r;l={baseState:o.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:o.shared,callbacks:o.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=r:e.next=r,l.lastBaseUpdate=r}var eu=!1;function ps(){if(eu){var e=xl;if(e!==null)throw e}}function ms(e,r,l,o){eu=!1;var m=e.updateQueue;Zr=!1;var g=m.firstBaseUpdate,S=m.lastBaseUpdate,A=m.shared.pending;if(A!==null){m.shared.pending=null;var V=A,re=V.next;V.next=null,S===null?g=re:S.next=re,S=V;var de=e.alternate;de!==null&&(de=de.updateQueue,A=de.lastBaseUpdate,A!==S&&(A===null?de.firstBaseUpdate=re:A.next=re,de.lastBaseUpdate=V))}if(g!==null){var pe=m.baseState;S=0,de=re=V=null,A=g;do{var le=A.lane&-536870913,se=le!==A.lane;if(se?(nt&le)===le:(o&le)===le){le!==0&&le===hl&&(eu=!0),de!==null&&(de=de.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var Ee=e,Be=A;le=r;var bt=l;switch(Be.tag){case 1:if(Ee=Be.payload,typeof Ee=="function"){pe=Ee.call(bt,pe,le);break e}pe=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Be.payload,le=typeof Ee=="function"?Ee.call(bt,pe,le):Ee,le==null)break e;pe=y({},pe,le);break e;case 2:Zr=!0}}le=A.callback,le!==null&&(e.flags|=64,se&&(e.flags|=8192),se=m.callbacks,se===null?m.callbacks=[le]:se.push(le))}else se={lane:le,tag:A.tag,payload:A.payload,callback:A.callback,next:null},de===null?(re=de=se,V=pe):de=de.next=se,S|=le;if(A=A.next,A===null){if(A=m.shared.pending,A===null)break;se=A,A=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&(V=pe),m.baseState=V,m.firstBaseUpdate=re,m.lastBaseUpdate=de,g===null&&(m.shared.lanes=0),la|=S,e.lanes=S,e.memoizedState=pe}}function lm(e,r){if(typeof e!="function")throw Error(i(191,e));e.call(r)}function sm(e,r){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)lm(l[e],r)}var yl=M(null),Ii=M(0);function im(e,r){e=$r,K(Ii,e),K(yl,r),$r=e|r.baseLanes}function tu(){K(Ii,$r),K(yl,yl.current)}function nu(){$r=Ii.current,I(yl),I(Ii)}var Mn=M(null),Kn=null;function ta(e){var r=e.alternate;K(Ht,Ht.current&1),K(Mn,e),Kn===null&&(r===null||yl.current!==null||r.memoizedState!==null)&&(Kn=e)}function ru(e){K(Ht,Ht.current),K(Mn,e),Kn===null&&(Kn=e)}function om(e){e.tag===22?(K(Ht,Ht.current),K(Mn,e),Kn===null&&(Kn=e)):na()}function na(){K(Ht,Ht.current),K(Mn,Mn.current)}function zn(e){I(Mn),Kn===e&&(Kn=null),I(Ht)}var Ht=M(0);function $i(e){for(var r=e;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||cd(l)||ud(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Lr=0,Ye=null,vt=null,Gt=null,Ui=!1,bl=!1,Ia=!1,Hi=0,hs=0,jl=null,I1=0;function $t(){throw Error(i(321))}function au(e,r){if(r===null)return!1;for(var l=0;l<r.length&&l<e.length;l++)if(!An(e[l],r[l]))return!1;return!0}function lu(e,r,l,o,m,g){return Lr=g,Ye=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,D.H=e===null||e.memoizedState===null?Wm:bu,Ia=!1,g=l(o,m),Ia=!1,bl&&(g=um(r,l,o,m)),cm(e),g}function cm(e){D.H=vs;var r=vt!==null&&vt.next!==null;if(Lr=0,Gt=vt=Ye=null,Ui=!1,hs=0,jl=null,r)throw Error(i(300));e===null||qt||(e=e.dependencies,e!==null&&Li(e)&&(qt=!0))}function um(e,r,l,o){Ye=e;var m=0;do{if(bl&&(jl=null),hs=0,bl=!1,25<=m)throw Error(i(301));if(m+=1,Gt=vt=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=Gm,g=r(l,o)}while(bl);return g}function $1(){var e=D.H,r=e.useState()[0];return r=typeof r.then=="function"?xs(r):r,e=e.useState()[0],(vt!==null?vt.memoizedState:null)!==e&&(Ye.flags|=1024),r}function su(){var e=Hi!==0;return Hi=0,e}function iu(e,r,l){r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~l}function ou(e){if(Ui){for(e=e.memoizedState;e!==null;){var r=e.queue;r!==null&&(r.pending=null),e=e.next}Ui=!1}Lr=0,Gt=vt=Ye=null,bl=!1,hs=Hi=0,jl=null}function hn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gt===null?Ye.memoizedState=Gt=e:Gt=Gt.next=e,Gt}function Pt(){if(vt===null){var e=Ye.alternate;e=e!==null?e.memoizedState:null}else e=vt.next;var r=Gt===null?Ye.memoizedState:Gt.next;if(r!==null)Gt=r,vt=e;else{if(e===null)throw Ye.alternate===null?Error(i(467)):Error(i(310));vt=e,e={memoizedState:vt.memoizedState,baseState:vt.baseState,baseQueue:vt.baseQueue,queue:vt.queue,next:null},Gt===null?Ye.memoizedState=Gt=e:Gt=Gt.next=e}return Gt}function Pi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function xs(e){var r=hs;return hs+=1,jl===null&&(jl=[]),e=em(jl,e,r),r=Ye,(Gt===null?r.memoizedState:Gt.next)===null&&(r=r.alternate,D.H=r===null||r.memoizedState===null?Wm:bu),e}function Vi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return xs(e);if(e.$$typeof===R)return sn(e)}throw Error(i(438,String(e)))}function cu(e){var r=null,l=Ye.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var o=Ye.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(r={data:o.data.map(function(m){return m.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=Pi(),Ye.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(e),o=0;o<e;o++)l[o]=_;return r.index++,l}function Mr(e,r){return typeof r=="function"?r(e):r}function Fi(e){var r=Pt();return uu(r,vt,e)}function uu(e,r,l){var o=e.queue;if(o===null)throw Error(i(311));o.lastRenderedReducer=l;var m=e.baseQueue,g=o.pending;if(g!==null){if(m!==null){var S=m.next;m.next=g.next,g.next=S}r.baseQueue=m=g,o.pending=null}if(g=e.baseState,m===null)e.memoizedState=g;else{r=m.next;var A=S=null,V=null,re=r,de=!1;do{var pe=re.lane&-536870913;if(pe!==re.lane?(nt&pe)===pe:(Lr&pe)===pe){var le=re.revertLane;if(le===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),pe===hl&&(de=!0);else if((Lr&le)===le){re=re.next,le===hl&&(de=!0);continue}else pe={lane:0,revertLane:re.revertLane,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},V===null?(A=V=pe,S=g):V=V.next=pe,Ye.lanes|=le,la|=le;pe=re.action,Ia&&l(g,pe),g=re.hasEagerState?re.eagerState:l(g,pe)}else le={lane:pe,revertLane:re.revertLane,gesture:re.gesture,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},V===null?(A=V=le,S=g):V=V.next=le,Ye.lanes|=pe,la|=pe;re=re.next}while(re!==null&&re!==r);if(V===null?S=g:V.next=A,!An(g,e.memoizedState)&&(qt=!0,de&&(l=xl,l!==null)))throw l;e.memoizedState=g,e.baseState=S,e.baseQueue=V,o.lastRenderedState=g}return m===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function du(e){var r=Pt(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=e;var o=l.dispatch,m=l.pending,g=r.memoizedState;if(m!==null){l.pending=null;var S=m=m.next;do g=e(g,S.action),S=S.next;while(S!==m);An(g,r.memoizedState)||(qt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,o]}function dm(e,r,l){var o=Ye,m=Pt(),g=at;if(g){if(l===void 0)throw Error(i(407));l=l()}else l=r();var S=!An((vt||m).memoizedState,l);if(S&&(m.memoizedState=l,qt=!0),m=m.queue,mu(mm.bind(null,o,m,e),[e]),m.getSnapshot!==r||S||Gt!==null&&Gt.memoizedState.tag&1){if(o.flags|=2048,Sl(9,{destroy:void 0},pm.bind(null,o,m,l,r),null),kt===null)throw Error(i(349));g||(Lr&127)!==0||fm(o,r,l)}return l}function fm(e,r,l){e.flags|=16384,e={getSnapshot:r,value:l},r=Ye.updateQueue,r===null?(r=Pi(),Ye.updateQueue=r,r.stores=[e]):(l=r.stores,l===null?r.stores=[e]:l.push(e))}function pm(e,r,l,o){r.value=l,r.getSnapshot=o,hm(r)&&xm(e)}function mm(e,r,l){return l(function(){hm(r)&&xm(e)})}function hm(e){var r=e.getSnapshot;e=e.value;try{var l=r();return!An(e,l)}catch{return!0}}function xm(e){var r=Ra(e,2);r!==null&&Nn(r,e,2)}function fu(e){var r=hn();if(typeof e=="function"){var l=e;if(e=l(),Ia){Dt(!0);try{l()}finally{Dt(!1)}}}return r.memoizedState=r.baseState=e,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mr,lastRenderedState:e},r}function gm(e,r,l,o){return e.baseState=l,uu(e,vt,typeof o=="function"?o:Mr)}function U1(e,r,l,o,m){if(qi(e))throw Error(i(485));if(e=r.action,e!==null){var g={payload:m,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=r.pending,l===null?(g.next=r.pending=g,vm(r,g)):(g.next=l.next,r.pending=l.next=g)}}function vm(e,r){var l=r.action,o=r.payload,m=e.state;if(r.isTransition){var g=D.T,S={};D.T=S;try{var A=l(m,o),V=D.S;V!==null&&V(S,A),ym(e,r,A)}catch(re){pu(e,r,re)}finally{g!==null&&S.types!==null&&(g.types=S.types),D.T=g}}else try{g=l(m,o),ym(e,r,g)}catch(re){pu(e,r,re)}}function ym(e,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(o){bm(e,r,o)},function(o){return pu(e,r,o)}):bm(e,r,l)}function bm(e,r,l){r.status="fulfilled",r.value=l,jm(r),e.state=l,r=e.pending,r!==null&&(l=r.next,l===r?e.pending=null:(l=l.next,r.next=l,vm(e,l)))}function pu(e,r,l){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do r.status="rejected",r.reason=l,jm(r),r=r.next;while(r!==o)}e.action=null}function jm(e){e=e.listeners;for(var r=0;r<e.length;r++)(0,e[r])()}function Sm(e,r){return r}function km(e,r){if(at){var l=kt.formState;if(l!==null){e:{var o=Ye;if(at){if(Rt){t:{for(var m=Rt,g=Yn;m.nodeType!==8;){if(!g){m=null;break t}if(m=Xn(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){Rt=Xn(m.nextSibling),o=m.data==="F!";break e}}Xr(o)}o=!1}o&&(r=l[0])}}return l=hn(),l.memoizedState=l.baseState=r,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sm,lastRenderedState:r},l.queue=o,l=Pm.bind(null,Ye,o),o.dispatch=l,o=fu(!1),g=yu.bind(null,Ye,!1,o.queue),o=hn(),m={state:r,dispatch:null,action:e,pending:null},o.queue=m,l=U1.bind(null,Ye,m,g,l),m.dispatch=l,o.memoizedState=e,[r,l,!1]}function wm(e){var r=Pt();return Cm(r,vt,e)}function Cm(e,r,l){if(r=uu(e,r,Sm)[0],e=Fi(Mr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var o=xs(r)}catch(S){throw S===gl?Di:S}else o=r;r=Pt();var m=r.queue,g=m.dispatch;return l!==r.memoizedState&&(Ye.flags|=2048,Sl(9,{destroy:void 0},H1.bind(null,m,l),null)),[o,g,e]}function H1(e,r){e.action=r}function Em(e){var r=Pt(),l=vt;if(l!==null)return Cm(r,l,e);Pt(),r=r.memoizedState,l=Pt();var o=l.queue.dispatch;return l.memoizedState=e,[r,o,!1]}function Sl(e,r,l,o){return e={tag:e,create:l,deps:o,inst:r,next:null},r=Ye.updateQueue,r===null&&(r=Pi(),Ye.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=e.next=e:(o=l.next,l.next=e,e.next=o,r.lastEffect=e),e}function Nm(){return Pt().memoizedState}function Wi(e,r,l,o){var m=hn();Ye.flags|=e,m.memoizedState=Sl(1|r,{destroy:void 0},l,o===void 0?null:o)}function Gi(e,r,l,o){var m=Pt();o=o===void 0?null:o;var g=m.memoizedState.inst;vt!==null&&o!==null&&au(o,vt.memoizedState.deps)?m.memoizedState=Sl(r,g,l,o):(Ye.flags|=e,m.memoizedState=Sl(1|r,g,l,o))}function Tm(e,r){Wi(8390656,8,e,r)}function mu(e,r){Gi(2048,8,e,r)}function P1(e){Ye.flags|=4;var r=Ye.updateQueue;if(r===null)r=Pi(),Ye.updateQueue=r,r.events=[e];else{var l=r.events;l===null?r.events=[e]:l.push(e)}}function Rm(e){var r=Pt().memoizedState;return P1({ref:r,nextImpl:e}),function(){if((ft&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function Am(e,r){return Gi(4,2,e,r)}function Lm(e,r){return Gi(4,4,e,r)}function Mm(e,r){if(typeof r=="function"){e=e();var l=r(e);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function zm(e,r,l){l=l!=null?l.concat([e]):null,Gi(4,4,Mm.bind(null,r,e),l)}function hu(){}function Dm(e,r){var l=Pt();r=r===void 0?null:r;var o=l.memoizedState;return r!==null&&au(r,o[1])?o[0]:(l.memoizedState=[e,r],e)}function _m(e,r){var l=Pt();r=r===void 0?null:r;var o=l.memoizedState;if(r!==null&&au(r,o[1]))return o[0];if(o=e(),Ia){Dt(!0);try{e()}finally{Dt(!1)}}return l.memoizedState=[o,r],o}function xu(e,r,l){return l===void 0||(Lr&1073741824)!==0&&(nt&261930)===0?e.memoizedState=r:(e.memoizedState=l,e=Oh(),Ye.lanes|=e,la|=e,l)}function Om(e,r,l,o){return An(l,r)?l:yl.current!==null?(e=xu(e,l,o),An(e,r)||(qt=!0),e):(Lr&42)===0||(Lr&1073741824)!==0&&(nt&261930)===0?(qt=!0,e.memoizedState=l):(e=Oh(),Ye.lanes|=e,la|=e,r)}function Bm(e,r,l,o,m){var g=U.p;U.p=g!==0&&8>g?g:8;var S=D.T,A={};D.T=A,yu(e,!1,r,l);try{var V=m(),re=D.S;if(re!==null&&re(A,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var de=B1(V,o);gs(e,r,de,On(e))}else gs(e,r,o,On(e))}catch(pe){gs(e,r,{then:function(){},status:"rejected",reason:pe},On())}finally{U.p=g,S!==null&&A.types!==null&&(S.types=A.types),D.T=S}}function V1(){}function gu(e,r,l,o){if(e.tag!==5)throw Error(i(476));var m=Im(e).queue;Bm(e,m,r,F,l===null?V1:function(){return $m(e),l(o)})}function Im(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mr,lastRenderedState:F},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mr,lastRenderedState:l},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function $m(e){var r=Im(e);r.next===null&&(r=e.alternate.memoizedState),gs(e,r.next.queue,{},On())}function vu(){return sn(Ds)}function Um(){return Pt().memoizedState}function Hm(){return Pt().memoizedState}function F1(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var l=On();e=Jr(l);var o=ea(r,e,l);o!==null&&(Nn(o,r,l),fs(o,r,l)),r={cache:qc()},e.payload=r;return}r=r.return}}function W1(e,r,l){var o=On();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},qi(e)?Vm(r,l):(l=Oc(e,r,l,o),l!==null&&(Nn(l,e,o),Fm(l,r,o)))}function Pm(e,r,l){var o=On();gs(e,r,l,o)}function gs(e,r,l,o){var m={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(qi(e))Vm(r,m);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,A=g(S,l);if(m.hasEagerState=!0,m.eagerState=A,An(A,S))return Ni(e,r,m,0),kt===null&&Ei(),!1}catch{}finally{}if(l=Oc(e,r,m,o),l!==null)return Nn(l,e,o),Fm(l,r,o),!0}return!1}function yu(e,r,l,o){if(o={lane:2,revertLane:Qu(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},qi(e)){if(r)throw Error(i(479))}else r=Oc(e,l,o,2),r!==null&&Nn(r,e,2)}function qi(e){var r=e.alternate;return e===Ye||r!==null&&r===Ye}function Vm(e,r){bl=Ui=!0;var l=e.pending;l===null?r.next=r:(r.next=l.next,l.next=r),e.pending=r}function Fm(e,r,l){if((l&4194048)!==0){var o=r.lanes;o&=e.pendingLanes,l|=o,r.lanes=l,Qa(e,l)}}var vs={readContext:sn,use:Vi,useCallback:$t,useContext:$t,useEffect:$t,useImperativeHandle:$t,useLayoutEffect:$t,useInsertionEffect:$t,useMemo:$t,useReducer:$t,useRef:$t,useState:$t,useDebugValue:$t,useDeferredValue:$t,useTransition:$t,useSyncExternalStore:$t,useId:$t,useHostTransitionStatus:$t,useFormState:$t,useActionState:$t,useOptimistic:$t,useMemoCache:$t,useCacheRefresh:$t};vs.useEffectEvent=$t;var Wm={readContext:sn,use:Vi,useCallback:function(e,r){return hn().memoizedState=[e,r===void 0?null:r],e},useContext:sn,useEffect:Tm,useImperativeHandle:function(e,r,l){l=l!=null?l.concat([e]):null,Wi(4194308,4,Mm.bind(null,r,e),l)},useLayoutEffect:function(e,r){return Wi(4194308,4,e,r)},useInsertionEffect:function(e,r){Wi(4,2,e,r)},useMemo:function(e,r){var l=hn();r=r===void 0?null:r;var o=e();if(Ia){Dt(!0);try{e()}finally{Dt(!1)}}return l.memoizedState=[o,r],o},useReducer:function(e,r,l){var o=hn();if(l!==void 0){var m=l(r);if(Ia){Dt(!0);try{l(r)}finally{Dt(!1)}}}else m=r;return o.memoizedState=o.baseState=m,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:m},o.queue=e,e=e.dispatch=W1.bind(null,Ye,e),[o.memoizedState,e]},useRef:function(e){var r=hn();return e={current:e},r.memoizedState=e},useState:function(e){e=fu(e);var r=e.queue,l=Pm.bind(null,Ye,r);return r.dispatch=l,[e.memoizedState,l]},useDebugValue:hu,useDeferredValue:function(e,r){var l=hn();return xu(l,e,r)},useTransition:function(){var e=fu(!1);return e=Bm.bind(null,Ye,e.queue,!0,!1),hn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,l){var o=Ye,m=hn();if(at){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),kt===null)throw Error(i(349));(nt&127)!==0||fm(o,r,l)}m.memoizedState=l;var g={value:l,getSnapshot:r};return m.queue=g,Tm(mm.bind(null,o,g,e),[e]),o.flags|=2048,Sl(9,{destroy:void 0},pm.bind(null,o,g,l,r),null),l},useId:function(){var e=hn(),r=kt.identifierPrefix;if(at){var l=fr,o=dr;l=(o&~(1<<32-Ft(o)-1)).toString(32)+l,r="_"+r+"R_"+l,l=Hi++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=I1++,r="_"+r+"r_"+l.toString(32)+"_";return e.memoizedState=r},useHostTransitionStatus:vu,useFormState:km,useActionState:km,useOptimistic:function(e){var r=hn();r.memoizedState=r.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=yu.bind(null,Ye,!0,l),l.dispatch=r,[e,r]},useMemoCache:cu,useCacheRefresh:function(){return hn().memoizedState=F1.bind(null,Ye)},useEffectEvent:function(e){var r=hn(),l={impl:e};return r.memoizedState=l,function(){if((ft&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},bu={readContext:sn,use:Vi,useCallback:Dm,useContext:sn,useEffect:mu,useImperativeHandle:zm,useInsertionEffect:Am,useLayoutEffect:Lm,useMemo:_m,useReducer:Fi,useRef:Nm,useState:function(){return Fi(Mr)},useDebugValue:hu,useDeferredValue:function(e,r){var l=Pt();return Om(l,vt.memoizedState,e,r)},useTransition:function(){var e=Fi(Mr)[0],r=Pt().memoizedState;return[typeof e=="boolean"?e:xs(e),r]},useSyncExternalStore:dm,useId:Um,useHostTransitionStatus:vu,useFormState:wm,useActionState:wm,useOptimistic:function(e,r){var l=Pt();return gm(l,vt,e,r)},useMemoCache:cu,useCacheRefresh:Hm};bu.useEffectEvent=Rm;var Gm={readContext:sn,use:Vi,useCallback:Dm,useContext:sn,useEffect:mu,useImperativeHandle:zm,useInsertionEffect:Am,useLayoutEffect:Lm,useMemo:_m,useReducer:du,useRef:Nm,useState:function(){return du(Mr)},useDebugValue:hu,useDeferredValue:function(e,r){var l=Pt();return vt===null?xu(l,e,r):Om(l,vt.memoizedState,e,r)},useTransition:function(){var e=du(Mr)[0],r=Pt().memoizedState;return[typeof e=="boolean"?e:xs(e),r]},useSyncExternalStore:dm,useId:Um,useHostTransitionStatus:vu,useFormState:Em,useActionState:Em,useOptimistic:function(e,r){var l=Pt();return vt!==null?gm(l,vt,e,r):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:cu,useCacheRefresh:Hm};Gm.useEffectEvent=Rm;function ju(e,r,l,o){r=e.memoizedState,l=l(o,r),l=l==null?r:y({},r,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Su={enqueueSetState:function(e,r,l){e=e._reactInternals;var o=On(),m=Jr(o);m.payload=r,l!=null&&(m.callback=l),r=ea(e,m,o),r!==null&&(Nn(r,e,o),fs(r,e,o))},enqueueReplaceState:function(e,r,l){e=e._reactInternals;var o=On(),m=Jr(o);m.tag=1,m.payload=r,l!=null&&(m.callback=l),r=ea(e,m,o),r!==null&&(Nn(r,e,o),fs(r,e,o))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var l=On(),o=Jr(l);o.tag=2,r!=null&&(o.callback=r),r=ea(e,o,l),r!==null&&(Nn(r,e,l),fs(r,e,l))}};function qm(e,r,l,o,m,g,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,g,S):r.prototype&&r.prototype.isPureReactComponent?!as(l,o)||!as(m,g):!0}function Ym(e,r,l,o){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,o),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,o),r.state!==e&&Su.enqueueReplaceState(r,r.state,null)}function $a(e,r){var l=r;if("ref"in r){l={};for(var o in r)o!=="ref"&&(l[o]=r[o])}if(e=e.defaultProps){l===r&&(l=y({},l));for(var m in e)l[m]===void 0&&(l[m]=e[m])}return l}function Km(e){Ci(e)}function Xm(e){console.error(e)}function Qm(e){Ci(e)}function Yi(e,r){try{var l=e.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(o){setTimeout(function(){throw o})}}function Zm(e,r,l){try{var o=e.onCaughtError;o(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function ku(e,r,l){return l=Jr(l),l.tag=3,l.payload={element:null},l.callback=function(){Yi(e,r)},l}function Jm(e){return e=Jr(e),e.tag=3,e}function eh(e,r,l,o){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var g=o.value;e.payload=function(){return m(g)},e.callback=function(){Zm(r,l,o)}}var S=l.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){Zm(r,l,o),typeof m!="function"&&(sa===null?sa=new Set([this]):sa.add(this));var A=o.stack;this.componentDidCatch(o.value,{componentStack:A!==null?A:""})})}function G1(e,r,l,o,m){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(r=l.alternate,r!==null&&ml(r,l,m,!0),l=Mn.current,l!==null){switch(l.tag){case 31:case 13:return Kn===null?so():l.alternate===null&&Ut===0&&(Ut=3),l.flags&=-257,l.flags|=65536,l.lanes=m,o===_i?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([o]):r.add(o),Yu(e,o,m)),!1;case 22:return l.flags|=65536,o===_i?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([o])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([o]):l.add(o)),Yu(e,o,m)),!1}throw Error(i(435,l.tag))}return Yu(e,o,m),so(),!1}if(at)return r=Mn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=m,o!==Pc&&(e=Error(i(422),{cause:o}),is(Wn(e,l)))):(o!==Pc&&(r=Error(i(423),{cause:o}),is(Wn(r,l))),e=e.current.alternate,e.flags|=65536,m&=-m,e.lanes|=m,o=Wn(o,l),m=ku(e.stateNode,o,m),Jc(e,m),Ut!==4&&(Ut=2)),!1;var g=Error(i(520),{cause:o});if(g=Wn(g,l),Es===null?Es=[g]:Es.push(g),Ut!==4&&(Ut=2),r===null)return!0;o=Wn(o,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,e=m&-m,l.lanes|=e,e=ku(l.stateNode,o,e),Jc(l,e),!1;case 1:if(r=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(sa===null||!sa.has(g))))return l.flags|=65536,m&=-m,l.lanes|=m,m=Jm(m),eh(m,e,l,o),Jc(l,m),!1}l=l.return}while(l!==null);return!1}var wu=Error(i(461)),qt=!1;function on(e,r,l,o){r.child=e===null?am(r,null,l,o):Ba(r,e.child,l,o)}function th(e,r,l,o,m){l=l.render;var g=r.ref;if("ref"in o){var S={};for(var A in o)A!=="ref"&&(S[A]=o[A])}else S=o;return za(r),o=lu(e,r,l,S,g,m),A=su(),e!==null&&!qt?(iu(e,r,m),zr(e,r,m)):(at&&A&&Uc(r),r.flags|=1,on(e,r,o,m),r.child)}function nh(e,r,l,o,m){if(e===null){var g=l.type;return typeof g=="function"&&!Bc(g)&&g.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=g,rh(e,r,g,o,m)):(e=Ri(l.type,null,o,r,r.mode,m),e.ref=r.ref,e.return=r,r.child=e)}if(g=e.child,!Mu(e,m)){var S=g.memoizedProps;if(l=l.compare,l=l!==null?l:as,l(S,o)&&e.ref===r.ref)return zr(e,r,m)}return r.flags|=1,e=Nr(g,o),e.ref=r.ref,e.return=r,r.child=e}function rh(e,r,l,o,m){if(e!==null){var g=e.memoizedProps;if(as(g,o)&&e.ref===r.ref)if(qt=!1,r.pendingProps=o=g,Mu(e,m))(e.flags&131072)!==0&&(qt=!0);else return r.lanes=e.lanes,zr(e,r,m)}return Cu(e,r,l,o,m)}function ah(e,r,l,o){var m=o.children,g=e!==null?e.memoizedState:null;if(e===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,e!==null){for(o=r.child=e.child,m=0;o!==null;)m=m|o.lanes|o.childLanes,o=o.sibling;o=m&~g}else o=0,r.child=null;return lh(e,r,g,l,o)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},e!==null&&zi(r,g!==null?g.cachePool:null),g!==null?im(r,g):tu(),om(r);else return o=r.lanes=536870912,lh(e,r,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(zi(r,g.cachePool),im(r,g),na(),r.memoizedState=null):(e!==null&&zi(r,null),tu(),na());return on(e,r,m,l),r.child}function ys(e,r){return e!==null&&e.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function lh(e,r,l,o,m){var g=Kc();return g=g===null?null:{parent:Wt._currentValue,pool:g},r.memoizedState={baseLanes:l,cachePool:g},e!==null&&zi(r,null),tu(),om(r),e!==null&&ml(e,r,o,!0),r.childLanes=m,null}function Ki(e,r){return r=Qi({mode:r.mode,children:r.children},e.mode),r.ref=e.ref,e.child=r,r.return=e,r}function sh(e,r,l){return Ba(r,e.child,null,l),e=Ki(r,r.pendingProps),e.flags|=2,zn(r),r.memoizedState=null,e}function q1(e,r,l){var o=r.pendingProps,m=(r.flags&128)!==0;if(r.flags&=-129,e===null){if(at){if(o.mode==="hidden")return e=Ki(r,o),r.lanes=536870912,ys(null,e);if(ru(r),(e=Rt)?(e=vx(e,Yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Yr!==null?{id:dr,overflow:fr}:null,retryLane:536870912,hydrationErrors:null},l=Vp(e),l.return=r,r.child=l,ln=r,Rt=null)):e=null,e===null)throw Xr(r);return r.lanes=536870912,null}return Ki(r,o)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(ru(r),m)if(r.flags&256)r.flags&=-257,r=sh(e,r,l);else if(r.memoizedState!==null)r.child=e.child,r.flags|=128,r=null;else throw Error(i(558));else if(qt||ml(e,r,l,!1),m=(l&e.childLanes)!==0,qt||m){if(o=kt,o!==null&&(S=Sr(o,l),S!==0&&S!==g.retryLane))throw g.retryLane=S,Ra(e,S),Nn(o,e,S),wu;so(),r=sh(e,r,l)}else e=g.treeContext,Rt=Xn(S.nextSibling),ln=r,at=!0,Kr=null,Yn=!1,e!==null&&Gp(r,e),r=Ki(r,o),r.flags|=4096;return r}return e=Nr(e.child,{mode:o.mode,children:o.children}),e.ref=r.ref,r.child=e,e.return=r,e}function Xi(e,r){var l=r.ref;if(l===null)e!==null&&e.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(i(284));(e===null||e.ref!==l)&&(r.flags|=4194816)}}function Cu(e,r,l,o,m){return za(r),l=lu(e,r,l,o,void 0,m),o=su(),e!==null&&!qt?(iu(e,r,m),zr(e,r,m)):(at&&o&&Uc(r),r.flags|=1,on(e,r,l,m),r.child)}function ih(e,r,l,o,m,g){return za(r),r.updateQueue=null,l=um(r,o,l,m),cm(e),o=su(),e!==null&&!qt?(iu(e,r,g),zr(e,r,g)):(at&&o&&Uc(r),r.flags|=1,on(e,r,l,g),r.child)}function oh(e,r,l,o,m){if(za(r),r.stateNode===null){var g=ul,S=l.contextType;typeof S=="object"&&S!==null&&(g=sn(S)),g=new l(o,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Su,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=o,g.state=r.memoizedState,g.refs={},Qc(r),S=l.contextType,g.context=typeof S=="object"&&S!==null?sn(S):ul,g.state=r.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(ju(r,l,S,o),g.state=r.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),ms(r,o,g,m),ps(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),o=!0}else if(e===null){g=r.stateNode;var A=r.memoizedProps,V=$a(l,A);g.props=V;var re=g.context,de=l.contextType;S=ul,typeof de=="object"&&de!==null&&(S=sn(de));var pe=l.getDerivedStateFromProps;de=typeof pe=="function"||typeof g.getSnapshotBeforeUpdate=="function",A=r.pendingProps!==A,de||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(A||re!==S)&&Ym(r,g,o,S),Zr=!1;var le=r.memoizedState;g.state=le,ms(r,o,g,m),ps(),re=r.memoizedState,A||le!==re||Zr?(typeof pe=="function"&&(ju(r,l,pe,o),re=r.memoizedState),(V=Zr||qm(r,l,V,o,le,re,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"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=o,r.memoizedState=re),g.props=o,g.state=re,g.context=S,o=V):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),o=!1)}else{g=r.stateNode,Zc(e,r),S=r.memoizedProps,de=$a(l,S),g.props=de,pe=r.pendingProps,le=g.context,re=l.contextType,V=ul,typeof re=="object"&&re!==null&&(V=sn(re)),A=l.getDerivedStateFromProps,(re=typeof A=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==pe||le!==V)&&Ym(r,g,o,V),Zr=!1,le=r.memoizedState,g.state=le,ms(r,o,g,m),ps();var se=r.memoizedState;S!==pe||le!==se||Zr||e!==null&&e.dependencies!==null&&Li(e.dependencies)?(typeof A=="function"&&(ju(r,l,A,o),se=r.memoizedState),(de=Zr||qm(r,l,de,o,le,se,V)||e!==null&&e.dependencies!==null&&Li(e.dependencies))?(re||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"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(r.flags|=1024),r.memoizedProps=o,r.memoizedState=se),g.props=o,g.state=se,g.context=V,o=de):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(r.flags|=1024),o=!1)}return g=o,Xi(e,r),o=(r.flags&128)!==0,g||o?(g=r.stateNode,l=o&&typeof l.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,e!==null&&o?(r.child=Ba(r,e.child,null,m),r.child=Ba(r,null,l,m)):on(e,r,l,m),r.memoizedState=g.state,e=r.child):e=zr(e,r,m),e}function ch(e,r,l,o){return La(),r.flags|=256,on(e,r,l,o),r.child}var Eu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Nu(e){return{baseLanes:e,cachePool:Zp()}}function Tu(e,r,l){return e=e!==null?e.childLanes&~l:0,r&&(e|=_n),e}function uh(e,r,l){var o=r.pendingProps,m=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=e!==null&&e.memoizedState===null?!1:(Ht.current&2)!==0),S&&(m=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,e===null){if(at){if(m?ta(r):na(),(e=Rt)?(e=vx(e,Yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Yr!==null?{id:dr,overflow:fr}:null,retryLane:536870912,hydrationErrors:null},l=Vp(e),l.return=r,r.child=l,ln=r,Rt=null)):e=null,e===null)throw Xr(r);return ud(e)?r.lanes=32:r.lanes=536870912,null}var A=o.children;return o=o.fallback,m?(na(),m=r.mode,A=Qi({mode:"hidden",children:A},m),o=Aa(o,m,l,null),A.return=r,o.return=r,A.sibling=o,r.child=A,o=r.child,o.memoizedState=Nu(l),o.childLanes=Tu(e,S,l),r.memoizedState=Eu,ys(null,o)):(ta(r),Ru(r,A))}var V=e.memoizedState;if(V!==null&&(A=V.dehydrated,A!==null)){if(g)r.flags&256?(ta(r),r.flags&=-257,r=Au(e,r,l)):r.memoizedState!==null?(na(),r.child=e.child,r.flags|=128,r=null):(na(),A=o.fallback,m=r.mode,o=Qi({mode:"visible",children:o.children},m),A=Aa(A,m,l,null),A.flags|=2,o.return=r,A.return=r,o.sibling=A,r.child=o,Ba(r,e.child,null,l),o=r.child,o.memoizedState=Nu(l),o.childLanes=Tu(e,S,l),r.memoizedState=Eu,r=ys(null,o));else if(ta(r),ud(A)){if(S=A.nextSibling&&A.nextSibling.dataset,S)var re=S.dgst;S=re,o=Error(i(419)),o.stack="",o.digest=S,is({value:o,source:null,stack:null}),r=Au(e,r,l)}else if(qt||ml(e,r,l,!1),S=(l&e.childLanes)!==0,qt||S){if(S=kt,S!==null&&(o=Sr(S,l),o!==0&&o!==V.retryLane))throw V.retryLane=o,Ra(e,o),Nn(S,e,o),wu;cd(A)||so(),r=Au(e,r,l)}else cd(A)?(r.flags|=192,r.child=e.child,r=null):(e=V.treeContext,Rt=Xn(A.nextSibling),ln=r,at=!0,Kr=null,Yn=!1,e!==null&&Gp(r,e),r=Ru(r,o.children),r.flags|=4096);return r}return m?(na(),A=o.fallback,m=r.mode,V=e.child,re=V.sibling,o=Nr(V,{mode:"hidden",children:o.children}),o.subtreeFlags=V.subtreeFlags&65011712,re!==null?A=Nr(re,A):(A=Aa(A,m,l,null),A.flags|=2),A.return=r,o.return=r,o.sibling=A,r.child=o,ys(null,o),o=r.child,A=e.child.memoizedState,A===null?A=Nu(l):(m=A.cachePool,m!==null?(V=Wt._currentValue,m=m.parent!==V?{parent:V,pool:V}:m):m=Zp(),A={baseLanes:A.baseLanes|l,cachePool:m}),o.memoizedState=A,o.childLanes=Tu(e,S,l),r.memoizedState=Eu,ys(e.child,o)):(ta(r),l=e.child,e=l.sibling,l=Nr(l,{mode:"visible",children:o.children}),l.return=r,l.sibling=null,e!==null&&(S=r.deletions,S===null?(r.deletions=[e],r.flags|=16):S.push(e)),r.child=l,r.memoizedState=null,l)}function Ru(e,r){return r=Qi({mode:"visible",children:r},e.mode),r.return=e,e.child=r}function Qi(e,r){return e=Ln(22,e,null,r),e.lanes=0,e}function Au(e,r,l){return Ba(r,e.child,null,l),e=Ru(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function dh(e,r,l){e.lanes|=r;var o=e.alternate;o!==null&&(o.lanes|=r),Wc(e.return,r,l)}function Lu(e,r,l,o,m,g){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:o,tail:l,tailMode:m,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=l,S.tailMode=m,S.treeForkCount=g)}function fh(e,r,l){var o=r.pendingProps,m=o.revealOrder,g=o.tail;o=o.children;var S=Ht.current,A=(S&2)!==0;if(A?(S=S&1|2,r.flags|=128):S&=1,K(Ht,S),on(e,r,o,l),o=at?ss:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&dh(e,l,r);else if(e.tag===19)dh(e,l,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(m){case"forwards":for(l=r.child,m=null;l!==null;)e=l.alternate,e!==null&&$i(e)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),Lu(r,!1,m,l,g,o);break;case"backwards":case"unstable_legacy-backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(e=m.alternate,e!==null&&$i(e)===null){r.child=m;break}e=m.sibling,m.sibling=l,l=m,m=e}Lu(r,!0,l,null,g,o);break;case"together":Lu(r,!1,null,null,void 0,o);break;default:r.memoizedState=null}return r.child}function zr(e,r,l){if(e!==null&&(r.dependencies=e.dependencies),la|=r.lanes,(l&r.childLanes)===0)if(e!==null){if(ml(e,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(e!==null&&r.child!==e.child)throw Error(i(153));if(r.child!==null){for(e=r.child,l=Nr(e,e.pendingProps),r.child=l,l.return=r;e.sibling!==null;)e=e.sibling,l=l.sibling=Nr(e,e.pendingProps),l.return=r;l.sibling=null}return r.child}function Mu(e,r){return(e.lanes&r)!==0?!0:(e=e.dependencies,!!(e!==null&&Li(e)))}function Y1(e,r,l){switch(r.tag){case 3:J(r,r.stateNode.containerInfo),Qr(r,Wt,e.memoizedState.cache),La();break;case 27:case 5:je(r);break;case 4:J(r,r.stateNode.containerInfo);break;case 10:Qr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,ru(r),null;break;case 13:var o=r.memoizedState;if(o!==null)return o.dehydrated!==null?(ta(r),r.flags|=128,null):(l&r.child.childLanes)!==0?uh(e,r,l):(ta(r),e=zr(e,r,l),e!==null?e.sibling:null);ta(r);break;case 19:var m=(e.flags&128)!==0;if(o=(l&r.childLanes)!==0,o||(ml(e,r,l,!1),o=(l&r.childLanes)!==0),m){if(o)return fh(e,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),K(Ht,Ht.current),o)break;return null;case 22:return r.lanes=0,ah(e,r,l,r.pendingProps);case 24:Qr(r,Wt,e.memoizedState.cache)}return zr(e,r,l)}function ph(e,r,l){if(e!==null)if(e.memoizedProps!==r.pendingProps)qt=!0;else{if(!Mu(e,l)&&(r.flags&128)===0)return qt=!1,Y1(e,r,l);qt=(e.flags&131072)!==0}else qt=!1,at&&(r.flags&1048576)!==0&&Wp(r,ss,r.index);switch(r.lanes=0,r.tag){case 16:e:{var o=r.pendingProps;if(e=_a(r.elementType),r.type=e,typeof e=="function")Bc(e)?(o=$a(e,o),r.tag=1,r=oh(null,r,e,o,l)):(r.tag=0,r=Cu(null,r,e,o,l));else{if(e!=null){var m=e.$$typeof;if(m===O){r.tag=11,r=th(null,r,e,o,l);break e}else if(m===N){r.tag=14,r=nh(null,r,e,o,l);break e}}throw r=ee(e)||e,Error(i(306,r,""))}}return r;case 0:return Cu(e,r,r.type,r.pendingProps,l);case 1:return o=r.type,m=$a(o,r.pendingProps),oh(e,r,o,m,l);case 3:e:{if(J(r,r.stateNode.containerInfo),e===null)throw Error(i(387));o=r.pendingProps;var g=r.memoizedState;m=g.element,Zc(e,r),ms(r,o,null,l);var S=r.memoizedState;if(o=S.cache,Qr(r,Wt,o),o!==g.cache&&Gc(r,[Wt],l,!0),ps(),o=S.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=ch(e,r,o,l);break e}else if(o!==m){m=Wn(Error(i(424)),r),is(m),r=ch(e,r,o,l);break e}else{switch(e=r.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Rt=Xn(e.firstChild),ln=r,at=!0,Kr=null,Yn=!0,l=am(r,null,o,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(La(),o===m){r=zr(e,r,l);break e}on(e,r,o,l)}r=r.child}return r;case 26:return Xi(e,r),e===null?(l=wx(r.type,null,r.pendingProps,null))?r.memoizedState=l:at||(l=r.type,e=r.pendingProps,o=mo(te.current).createElement(l),o[Te]=r,o[ht]=e,cn(o,l,e),tn(o),r.stateNode=o):r.memoizedState=wx(r.type,e.memoizedProps,r.pendingProps,e.memoizedState),null;case 27:return je(r),e===null&&at&&(o=r.stateNode=jx(r.type,r.pendingProps,te.current),ln=r,Yn=!0,m=Rt,ua(r.type)?(dd=m,Rt=Xn(o.firstChild)):Rt=m),on(e,r,r.pendingProps.children,l),Xi(e,r),e===null&&(r.flags|=4194304),r.child;case 5:return e===null&&at&&((m=o=Rt)&&(o=w0(o,r.type,r.pendingProps,Yn),o!==null?(r.stateNode=o,ln=r,Rt=Xn(o.firstChild),Yn=!1,m=!0):m=!1),m||Xr(r)),je(r),m=r.type,g=r.pendingProps,S=e!==null?e.memoizedProps:null,o=g.children,sd(m,g)?o=null:S!==null&&sd(m,S)&&(r.flags|=32),r.memoizedState!==null&&(m=lu(e,r,$1,null,null,l),Ds._currentValue=m),Xi(e,r),on(e,r,o,l),r.child;case 6:return e===null&&at&&((e=l=Rt)&&(l=C0(l,r.pendingProps,Yn),l!==null?(r.stateNode=l,ln=r,Rt=null,e=!0):e=!1),e||Xr(r)),null;case 13:return uh(e,r,l);case 4:return J(r,r.stateNode.containerInfo),o=r.pendingProps,e===null?r.child=Ba(r,null,o,l):on(e,r,o,l),r.child;case 11:return th(e,r,r.type,r.pendingProps,l);case 7:return on(e,r,r.pendingProps,l),r.child;case 8:return on(e,r,r.pendingProps.children,l),r.child;case 12:return on(e,r,r.pendingProps.children,l),r.child;case 10:return o=r.pendingProps,Qr(r,r.type,o.value),on(e,r,o.children,l),r.child;case 9:return m=r.type._context,o=r.pendingProps.children,za(r),m=sn(m),o=o(m),r.flags|=1,on(e,r,o,l),r.child;case 14:return nh(e,r,r.type,r.pendingProps,l);case 15:return rh(e,r,r.type,r.pendingProps,l);case 19:return fh(e,r,l);case 31:return q1(e,r,l);case 22:return ah(e,r,l,r.pendingProps);case 24:return za(r),o=sn(Wt),e===null?(m=Kc(),m===null&&(m=kt,g=qc(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=l),m=g),r.memoizedState={parent:o,cache:m},Qc(r),Qr(r,Wt,m)):((e.lanes&l)!==0&&(Zc(e,r),ms(r,null,null,l),ps()),m=e.memoizedState,g=r.memoizedState,m.parent!==o?(m={parent:o,cache:o},r.memoizedState=m,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=m),Qr(r,Wt,o)):(o=g.cache,Qr(r,Wt,o),o!==m.cache&&Gc(r,[Wt],l,!0))),on(e,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Dr(e){e.flags|=4}function zu(e,r,l,o,m){if((r=(e.mode&32)!==0)&&(r=!1),r){if(e.flags|=16777216,(m&335544128)===m)if(e.stateNode.complete)e.flags|=8192;else if(Uh())e.flags|=8192;else throw Oa=_i,Xc}else e.flags&=-16777217}function mh(e,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Rx(r))if(Uh())e.flags|=8192;else throw Oa=_i,Xc}function Zi(e,r){r!==null&&(e.flags|=4),e.flags&16384&&(r=e.tag!==22?un():536870912,e.lanes|=r,El|=r)}function bs(e,r){if(!at)switch(e.tailMode){case"hidden":r=e.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.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?r||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function At(e){var r=e.alternate!==null&&e.alternate.child===e.child,l=0,o=0;if(r)for(var m=e.child;m!==null;)l|=m.lanes|m.childLanes,o|=m.subtreeFlags&65011712,o|=m.flags&65011712,m.return=e,m=m.sibling;else for(m=e.child;m!==null;)l|=m.lanes|m.childLanes,o|=m.subtreeFlags,o|=m.flags,m.return=e,m=m.sibling;return e.subtreeFlags|=o,e.childLanes=l,r}function K1(e,r,l){var o=r.pendingProps;switch(Hc(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return At(r),null;case 1:return At(r),null;case 3:return l=r.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),r.memoizedState.cache!==o&&(r.flags|=2048),Ar(Wt),he(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(pl(r)?Dr(r):e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Vc())),At(r),null;case 26:var m=r.type,g=r.memoizedState;return e===null?(Dr(r),g!==null?(At(r),mh(r,g)):(At(r),zu(r,m,null,o,l))):g?g!==e.memoizedState?(Dr(r),At(r),mh(r,g)):(At(r),r.flags&=-16777217):(e=e.memoizedProps,e!==o&&Dr(r),At(r),zu(r,m,e,o,l)),null;case 27:if(Ne(r),l=te.current,m=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==o&&Dr(r);else{if(!o){if(r.stateNode===null)throw Error(i(166));return At(r),null}e=Q.current,pl(r)?qp(r):(e=jx(m,o,l),r.stateNode=e,Dr(r))}return At(r),null;case 5:if(Ne(r),m=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==o&&Dr(r);else{if(!o){if(r.stateNode===null)throw Error(i(166));return At(r),null}if(g=Q.current,pl(r))qp(r);else{var S=mo(te.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);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(m,{is:o.is}):S.createElement(m)}}g[Te]=r,g[ht]=o;e:for(S=r.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===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(cn(g,m,o),m){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Dr(r)}}return At(r),zu(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,l),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==o&&Dr(r);else{if(typeof o!="string"&&r.stateNode===null)throw Error(i(166));if(e=te.current,pl(r)){if(e=r.stateNode,l=r.memoizedProps,o=null,m=ln,m!==null)switch(m.tag){case 27:case 5:o=m.memoizedProps}e[Te]=r,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||ux(e.nodeValue,l)),e||Xr(r,!0)}else e=mo(e).createTextNode(o),e[Te]=r,r.stateNode=e}return At(r),null;case 31:if(l=r.memoizedState,e===null||e.memoizedState!==null){if(o=pl(r),l!==null){if(e===null){if(!o)throw Error(i(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[Te]=r}else La(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),e=!1}else l=Vc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return r.flags&256?(zn(r),r):(zn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return At(r),null;case 13:if(o=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(m=pl(r),o!==null&&o.dehydrated!==null){if(e===null){if(!m)throw Error(i(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(i(317));m[Te]=r}else La(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),m=!1}else m=Vc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=m),m=!0;if(!m)return r.flags&256?(zn(r),r):(zn(r),null)}return zn(r),(r.flags&128)!==0?(r.lanes=l,r):(l=o!==null,e=e!==null&&e.memoizedState!==null,l&&(o=r.child,m=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(m=o.alternate.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==m&&(o.flags|=2048)),l!==e&&l&&(r.child.flags|=8192),Zi(r,r.updateQueue),At(r),null);case 4:return he(),e===null&&td(r.stateNode.containerInfo),At(r),null;case 10:return Ar(r.type),At(r),null;case 19:if(I(Ht),o=r.memoizedState,o===null)return At(r),null;if(m=(r.flags&128)!==0,g=o.rendering,g===null)if(m)bs(o,!1);else{if(Ut!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(g=$i(e),g!==null){for(r.flags|=128,bs(o,!1),e=g.updateQueue,r.updateQueue=e,Zi(r,e),r.subtreeFlags=0,e=l,l=r.child;l!==null;)Pp(l,e),l=l.sibling;return K(Ht,Ht.current&1|2),at&&Tr(r,o.treeForkCount),r.child}e=e.sibling}o.tail!==null&&We()>ro&&(r.flags|=128,m=!0,bs(o,!1),r.lanes=4194304)}else{if(!m)if(e=$i(g),e!==null){if(r.flags|=128,m=!0,e=e.updateQueue,r.updateQueue=e,Zi(r,e),bs(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!at)return At(r),null}else 2*We()-o.renderingStartTime>ro&&l!==536870912&&(r.flags|=128,m=!0,bs(o,!1),r.lanes=4194304);o.isBackwards?(g.sibling=r.child,r.child=g):(e=o.last,e!==null?e.sibling=g:r.child=g,o.last=g)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=We(),e.sibling=null,l=Ht.current,K(Ht,m?l&1|2:l&1),at&&Tr(r,o.treeForkCount),e):(At(r),null);case 22:case 23:return zn(r),nu(),o=r.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(r.flags|=8192):o&&(r.flags|=8192),o?(l&536870912)!==0&&(r.flags&128)===0&&(At(r),r.subtreeFlags&6&&(r.flags|=8192)):At(r),l=r.updateQueue,l!==null&&Zi(r,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==l&&(r.flags|=2048),e!==null&&I(Da),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Ar(Wt),At(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function X1(e,r){switch(Hc(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return Ar(Wt),he(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return Ne(r),null;case 31:if(r.memoizedState!==null){if(zn(r),r.alternate===null)throw Error(i(340));La()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(zn(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(i(340));La()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return I(Ht),null;case 4:return he(),null;case 10:return Ar(r.type),null;case 22:case 23:return zn(r),nu(),e!==null&&I(Da),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return Ar(Wt),null;case 25:return null;default:return null}}function hh(e,r){switch(Hc(r),r.tag){case 3:Ar(Wt),he();break;case 26:case 27:case 5:Ne(r);break;case 4:he();break;case 31:r.memoizedState!==null&&zn(r);break;case 13:zn(r);break;case 19:I(Ht);break;case 10:Ar(r.type);break;case 22:case 23:zn(r),nu(),e!==null&&I(Da);break;case 24:Ar(Wt)}}function js(e,r){try{var l=r.updateQueue,o=l!==null?l.lastEffect:null;if(o!==null){var m=o.next;l=m;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!==m)}}catch(A){gt(r,r.return,A)}}function ra(e,r,l){try{var o=r.updateQueue,m=o!==null?o.lastEffect:null;if(m!==null){var g=m.next;o=g;do{if((o.tag&e)===e){var S=o.inst,A=S.destroy;if(A!==void 0){S.destroy=void 0,m=r;var V=l,re=A;try{re()}catch(de){gt(m,V,de)}}}o=o.next}while(o!==g)}}catch(de){gt(r,r.return,de)}}function xh(e){var r=e.updateQueue;if(r!==null){var l=e.stateNode;try{sm(r,l)}catch(o){gt(e,e.return,o)}}}function gh(e,r,l){l.props=$a(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){gt(e,r,o)}}function Ss(e,r){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(m){gt(e,r,m)}}function pr(e,r){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(m){gt(e,r,m)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(m){gt(e,r,m)}else l.current=null}function vh(e){var r=e.type,l=e.memoizedProps,o=e.stateNode;try{e:switch(r){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(m){gt(e,e.return,m)}}function Du(e,r,l){try{var o=e.stateNode;v0(o,e.type,l,r),o[ht]=r}catch(m){gt(e,e.return,m)}}function yh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ua(e.type)||e.tag===4}function _u(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yh(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&&ua(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,r,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(e),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Cr));else if(o!==4&&(o===27&&ua(e.type)&&(l=e.stateNode,r=null),e=e.child,e!==null))for(Ou(e,r,l),e=e.sibling;e!==null;)Ou(e,r,l),e=e.sibling}function Ji(e,r,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,r?l.insertBefore(e,r):l.appendChild(e);else if(o!==4&&(o===27&&ua(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Ji(e,r,l),e=e.sibling;e!==null;)Ji(e,r,l),e=e.sibling}function bh(e){var r=e.stateNode,l=e.memoizedProps;try{for(var o=e.type,m=r.attributes;m.length;)r.removeAttributeNode(m[0]);cn(r,o,l),r[Te]=e,r[ht]=l}catch(g){gt(e,e.return,g)}}var _r=!1,Yt=!1,Bu=!1,jh=typeof WeakSet=="function"?WeakSet:Set,nn=null;function Q1(e,r){if(e=e.containerInfo,ad=jo,e=zp(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 m=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var S=0,A=-1,V=-1,re=0,de=0,pe=e,le=null;t:for(;;){for(var se;pe!==l||m!==0&&pe.nodeType!==3||(A=S+m),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&&++re===m&&(A=S),le===g&&++de===o&&(V=S),(se=pe.nextSibling)!==null)break;pe=le,le=pe.parentNode}pe=se}l=A===-1||V===-1?null:{start:A,end:V}}else l=null}l=l||{start:0,end:0}}else l=null;for(ld={focusedElem:e,selectionRange:l},jo=!1,nn=r;nn!==null;)if(r=nn,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,nn=e;else for(;nn!==null;){switch(r=nn,g=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)m=e[l],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,l=r,m=g.memoizedProps,g=g.memoizedState,o=l.stateNode;try{var Ee=$a(l.type,m);e=o.getSnapshotBeforeUpdate(Ee,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(Be){gt(l,l.return,Be)}}break;case 3:if((e&1024)!==0){if(e=r.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=r.sibling,e!==null){e.return=r.return,nn=e;break}nn=r.return}}function Sh(e,r,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:Br(e,l),o&4&&js(5,l);break;case 1:if(Br(e,l),o&4)if(e=l.stateNode,r===null)try{e.componentDidMount()}catch(S){gt(l,l.return,S)}else{var m=$a(l.type,r.memoizedProps);r=r.memoizedState;try{e.componentDidUpdate(m,r,e.__reactInternalSnapshotBeforeUpdate)}catch(S){gt(l,l.return,S)}}o&64&&xh(l),o&512&&Ss(l,l.return);break;case 3:if(Br(e,l),o&64&&(e=l.updateQueue,e!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{sm(e,r)}catch(S){gt(l,l.return,S)}}break;case 27:r===null&&o&4&&bh(l);case 26:case 5:Br(e,l),r===null&&o&4&&vh(l),o&512&&Ss(l,l.return);break;case 12:Br(e,l);break;case 31:Br(e,l),o&4&&Ch(e,l);break;case 13:Br(e,l),o&4&&Eh(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=s0.bind(null,l),E0(e,l))));break;case 22:if(o=l.memoizedState!==null||_r,!o){r=r!==null&&r.memoizedState!==null||Yt,m=_r;var g=Yt;_r=o,(Yt=r)&&!g?Ir(e,l,(l.subtreeFlags&8772)!==0):Br(e,l),_r=m,Yt=g}break;case 30:break;default:Br(e,l)}}function kh(e){var r=e.alternate;r!==null&&(e.alternate=null,kh(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&pc(r)),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 Ot=null,kn=!1;function Or(e,r,l){for(l=l.child;l!==null;)wh(e,r,l),l=l.sibling}function wh(e,r,l){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(St,l)}catch{}switch(l.tag){case 26:Yt||pr(l,r),Or(e,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Yt||pr(l,r);var o=Ot,m=kn;ua(l.type)&&(Ot=l.stateNode,kn=!1),Or(e,r,l),Ls(l.stateNode),Ot=o,kn=m;break;case 5:Yt||pr(l,r);case 6:if(o=Ot,m=kn,Ot=null,Or(e,r,l),Ot=o,kn=m,Ot!==null)if(kn)try{(Ot.nodeType===9?Ot.body:Ot.nodeName==="HTML"?Ot.ownerDocument.body:Ot).removeChild(l.stateNode)}catch(g){gt(l,r,g)}else try{Ot.removeChild(l.stateNode)}catch(g){gt(l,r,g)}break;case 18:Ot!==null&&(kn?(e=Ot,xx(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Dl(e)):xx(Ot,l.stateNode));break;case 4:o=Ot,m=kn,Ot=l.stateNode.containerInfo,kn=!0,Or(e,r,l),Ot=o,kn=m;break;case 0:case 11:case 14:case 15:ra(2,l,r),Yt||ra(4,l,r),Or(e,r,l);break;case 1:Yt||(pr(l,r),o=l.stateNode,typeof o.componentWillUnmount=="function"&&gh(l,r,o)),Or(e,r,l);break;case 21:Or(e,r,l);break;case 22:Yt=(o=Yt)||l.memoizedState!==null,Or(e,r,l),Yt=o;break;default:Or(e,r,l)}}function Ch(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Dl(e)}catch(l){gt(r,r.return,l)}}}function Eh(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Dl(e)}catch(l){gt(r,r.return,l)}}function Z1(e){switch(e.tag){case 31:case 13:case 19:var r=e.stateNode;return r===null&&(r=e.stateNode=new jh),r;case 22:return e=e.stateNode,r=e._retryCache,r===null&&(r=e._retryCache=new jh),r;default:throw Error(i(435,e.tag))}}function eo(e,r){var l=Z1(e);r.forEach(function(o){if(!l.has(o)){l.add(o);var m=i0.bind(null,e,o);o.then(m,m)}})}function wn(e,r){var l=r.deletions;if(l!==null)for(var o=0;o<l.length;o++){var m=l[o],g=e,S=r,A=S;e:for(;A!==null;){switch(A.tag){case 27:if(ua(A.type)){Ot=A.stateNode,kn=!1;break e}break;case 5:Ot=A.stateNode,kn=!1;break e;case 3:case 4:Ot=A.stateNode.containerInfo,kn=!0;break e}A=A.return}if(Ot===null)throw Error(i(160));wh(g,S,m),Ot=null,kn=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)Nh(r,e),r=r.sibling}var lr=null;function Nh(e,r){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:wn(r,e),Cn(e),o&4&&(ra(3,e,e.return),js(3,e),ra(5,e,e.return));break;case 1:wn(r,e),Cn(e),o&512&&(Yt||l===null||pr(l,l.return)),o&64&&_r&&(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 m=lr;if(wn(r,e),Cn(e),o&512&&(Yt||l===null||pr(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,m=m.ownerDocument||m;t:switch(o){case"title":g=m.getElementsByTagName("title")[0],(!g||g[wa]||g[Te]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(o),m.head.insertBefore(g,m.querySelector("head > title"))),cn(g,o,l),g[Te]=e,tn(g),o=g;break e;case"link":var S=Nx("link","href",m).get(o+(l.href||""));if(S){for(var A=0;A<S.length;A++)if(g=S[A],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(A,1);break t}}g=m.createElement(o),cn(g,o,l),m.head.appendChild(g);break;case"meta":if(S=Nx("meta","content",m).get(o+(l.content||""))){for(A=0;A<S.length;A++)if(g=S[A],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(A,1);break t}}g=m.createElement(o),cn(g,o,l),m.head.appendChild(g);break;default:throw Error(i(468,o))}g[Te]=e,tn(g),o=g}e.stateNode=o}else Tx(m,e.type,e.stateNode);else e.stateNode=Ex(m,o,e.memoizedProps);else g!==o?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,o===null?Tx(m,e.type,e.stateNode):Ex(m,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Du(e,e.memoizedProps,l.memoizedProps)}break;case 27:wn(r,e),Cn(e),o&512&&(Yt||l===null||pr(l,l.return)),l!==null&&o&4&&Du(e,e.memoizedProps,l.memoizedProps);break;case 5:if(wn(r,e),Cn(e),o&512&&(Yt||l===null||pr(l,l.return)),e.flags&32){m=e.stateNode;try{rl(m,"")}catch(Ee){gt(e,e.return,Ee)}}o&4&&e.stateNode!=null&&(m=e.memoizedProps,Du(e,m,l!==null?l.memoizedProps:m)),o&1024&&(Bu=!0);break;case 6:if(wn(r,e),Cn(e),o&4){if(e.stateNode===null)throw Error(i(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ee){gt(e,e.return,Ee)}}break;case 3:if(go=null,m=lr,lr=ho(r.containerInfo),wn(r,e),lr=m,Cn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{Dl(r.containerInfo)}catch(Ee){gt(e,e.return,Ee)}Bu&&(Bu=!1,Th(e));break;case 4:o=lr,lr=ho(e.stateNode.containerInfo),wn(r,e),Cn(e),lr=o;break;case 12:wn(r,e),Cn(e);break;case 31:wn(r,e),Cn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,eo(e,o)));break;case 13:wn(r,e),Cn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(no=We()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,eo(e,o)));break;case 22:m=e.memoizedState!==null;var V=l!==null&&l.memoizedState!==null,re=_r,de=Yt;if(_r=re||m,Yt=de||V,wn(r,e),Yt=de,_r=re,Cn(e),o&8192)e:for(r=e.stateNode,r._visibility=m?r._visibility&-2:r._visibility|1,m&&(l===null||V||_r||Yt||Ua(e)),l=null,r=e;;){if(r.tag===5||r.tag===26){if(l===null){V=l=r;try{if(g=V.stateNode,m)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{A=V.stateNode;var pe=V.memoizedProps.style,le=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;A.style.display=le==null||typeof le=="boolean"?"":(""+le).trim()}}catch(Ee){gt(V,V.return,Ee)}}}else if(r.tag===6){if(l===null){V=r;try{V.stateNode.nodeValue=m?"":V.memoizedProps}catch(Ee){gt(V,V.return,Ee)}}}else if(r.tag===18){if(l===null){V=r;try{var se=V.stateNode;m?gx(se,!0):gx(V.stateNode,!1)}catch(Ee){gt(V,V.return,Ee)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===e)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}o&4&&(o=e.updateQueue,o!==null&&(l=o.retryQueue,l!==null&&(o.retryQueue=null,eo(e,l))));break;case 19:wn(r,e),Cn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,eo(e,o)));break;case 30:break;case 21:break;default:wn(r,e),Cn(e)}}function Cn(e){var r=e.flags;if(r&2){try{for(var l,o=e.return;o!==null;){if(yh(o)){l=o;break}o=o.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var m=l.stateNode,g=_u(e);Ji(e,g,m);break;case 5:var S=l.stateNode;l.flags&32&&(rl(S,""),l.flags&=-33);var A=_u(e);Ji(e,A,S);break;case 3:case 4:var V=l.stateNode.containerInfo,re=_u(e);Ou(e,re,V);break;default:throw Error(i(161))}}catch(de){gt(e,e.return,de)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function Th(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var r=e;Th(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),e=e.sibling}}function Br(e,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Sh(e,r.alternate,r),r=r.sibling}function Ua(e){for(e=e.child;e!==null;){var r=e;switch(r.tag){case 0:case 11:case 14:case 15:ra(4,r,r.return),Ua(r);break;case 1:pr(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&gh(r,r.return,l),Ua(r);break;case 27:Ls(r.stateNode);case 26:case 5:pr(r,r.return),Ua(r);break;case 22:r.memoizedState===null&&Ua(r);break;case 30:Ua(r);break;default:Ua(r)}e=e.sibling}}function Ir(e,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var o=r.alternate,m=e,g=r,S=g.flags;switch(g.tag){case 0:case 11:case 15:Ir(m,g,l),js(4,g);break;case 1:if(Ir(m,g,l),o=g,m=o.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(re){gt(o,o.return,re)}if(o=g,m=o.updateQueue,m!==null){var A=o.stateNode;try{var V=m.shared.hiddenCallbacks;if(V!==null)for(m.shared.hiddenCallbacks=null,m=0;m<V.length;m++)lm(V[m],A)}catch(re){gt(o,o.return,re)}}l&&S&64&&xh(g),Ss(g,g.return);break;case 27:bh(g);case 26:case 5:Ir(m,g,l),l&&o===null&&S&4&&vh(g),Ss(g,g.return);break;case 12:Ir(m,g,l);break;case 31:Ir(m,g,l),l&&S&4&&Ch(m,g);break;case 13:Ir(m,g,l),l&&S&4&&Eh(m,g);break;case 22:g.memoizedState===null&&Ir(m,g,l),Ss(g,g.return);break;case 30:break;default:Ir(m,g,l)}r=r.sibling}}function Iu(e,r){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(e=r.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&os(l))}function $u(e,r){e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&os(e))}function sr(e,r,l,o){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Rh(e,r,l,o),r=r.sibling}function Rh(e,r,l,o){var m=r.flags;switch(r.tag){case 0:case 11:case 15:sr(e,r,l,o),m&2048&&js(9,r);break;case 1:sr(e,r,l,o);break;case 3:sr(e,r,l,o),m&2048&&(e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&os(e)));break;case 12:if(m&2048){sr(e,r,l,o),e=r.stateNode;try{var g=r.memoizedProps,S=g.id,A=g.onPostCommit;typeof A=="function"&&A(S,r.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(V){gt(r,r.return,V)}}else sr(e,r,l,o);break;case 31:sr(e,r,l,o);break;case 13:sr(e,r,l,o);break;case 23:break;case 22:g=r.stateNode,S=r.alternate,r.memoizedState!==null?g._visibility&2?sr(e,r,l,o):ks(e,r):g._visibility&2?sr(e,r,l,o):(g._visibility|=2,kl(e,r,l,o,(r.subtreeFlags&10256)!==0||!1)),m&2048&&Iu(S,r);break;case 24:sr(e,r,l,o),m&2048&&$u(r.alternate,r);break;default:sr(e,r,l,o)}}function kl(e,r,l,o,m){for(m=m&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=e,S=r,A=l,V=o,re=S.flags;switch(S.tag){case 0:case 11:case 15:kl(g,S,A,V,m),js(8,S);break;case 23:break;case 22:var de=S.stateNode;S.memoizedState!==null?de._visibility&2?kl(g,S,A,V,m):ks(g,S):(de._visibility|=2,kl(g,S,A,V,m)),m&&re&2048&&Iu(S.alternate,S);break;case 24:kl(g,S,A,V,m),m&&re&2048&&$u(S.alternate,S);break;default:kl(g,S,A,V,m)}r=r.sibling}}function ks(e,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=e,o=r,m=o.flags;switch(o.tag){case 22:ks(l,o),m&2048&&Iu(o.alternate,o);break;case 24:ks(l,o),m&2048&&$u(o.alternate,o);break;default:ks(l,o)}r=r.sibling}}var ws=8192;function wl(e,r,l){if(e.subtreeFlags&ws)for(e=e.child;e!==null;)Ah(e,r,l),e=e.sibling}function Ah(e,r,l){switch(e.tag){case 26:wl(e,r,l),e.flags&ws&&e.memoizedState!==null&&I0(l,lr,e.memoizedState,e.memoizedProps);break;case 5:wl(e,r,l);break;case 3:case 4:var o=lr;lr=ho(e.stateNode.containerInfo),wl(e,r,l),lr=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=ws,ws=16777216,wl(e,r,l),ws=o):wl(e,r,l));break;default:wl(e,r,l)}}function Lh(e){var r=e.alternate;if(r!==null&&(e=r.child,e!==null)){r.child=null;do r=e.sibling,e.sibling=null,e=r;while(e!==null)}}function Cs(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var o=r[l];nn=o,zh(o,e)}Lh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Mh(e),e=e.sibling}function Mh(e){switch(e.tag){case 0:case 11:case 15:Cs(e),e.flags&2048&&ra(9,e,e.return);break;case 3:Cs(e);break;case 12:Cs(e);break;case 22:var r=e.stateNode;e.memoizedState!==null&&r._visibility&2&&(e.return===null||e.return.tag!==13)?(r._visibility&=-3,to(e)):Cs(e);break;default:Cs(e)}}function to(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var o=r[l];nn=o,zh(o,e)}Lh(e)}for(e=e.child;e!==null;){switch(r=e,r.tag){case 0:case 11:case 15:ra(8,r,r.return),to(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,to(r));break;default:to(r)}e=e.sibling}}function zh(e,r){for(;nn!==null;){var l=nn;switch(l.tag){case 0:case 11:case 15:ra(8,l,r);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:os(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,nn=o;else e:for(l=e;nn!==null;){o=nn;var m=o.sibling,g=o.return;if(kh(o),o===l){nn=null;break e}if(m!==null){m.return=g,nn=m;break e}nn=g}}}var J1={getCacheForType:function(e){var r=sn(Wt),l=r.data.get(e);return l===void 0&&(l=e(),r.data.set(e,l)),l},cacheSignal:function(){return sn(Wt).controller.signal}},e0=typeof WeakMap=="function"?WeakMap:Map,ft=0,kt=null,Je=null,nt=0,xt=0,Dn=null,aa=!1,Cl=!1,Uu=!1,$r=0,Ut=0,la=0,Ha=0,Hu=0,_n=0,El=0,Es=null,En=null,Pu=!1,no=0,Dh=0,ro=1/0,ao=null,sa=null,Xt=0,ia=null,Nl=null,Ur=0,Vu=0,Fu=null,_h=null,Ns=0,Wu=null;function On(){return(ft&2)!==0&&nt!==0?nt&-nt:D.T!==null?Qu():be()}function Oh(){if(_n===0)if((nt&536870912)===0||at){var e=nr;nr<<=1,(nr&3932160)===0&&(nr=262144),_n=e}else _n=536870912;return e=Mn.current,e!==null&&(e.flags|=32),_n}function Nn(e,r,l){(e===kt&&(xt===2||xt===9)||e.cancelPendingCommit!==null)&&(Tl(e,0),oa(e,nt,_n,!1)),rr(e,l),((ft&2)===0||e!==kt)&&(e===kt&&((ft&2)===0&&(Ha|=l),Ut===4&&oa(e,nt,_n,!1)),mr(e))}function Bh(e,r,l){if((ft&6)!==0)throw Error(i(327));var o=!l&&(r&127)===0&&(r&e.expiredLanes)===0||Pe(e,r),m=o?r0(e,r):qu(e,r,!0),g=o;do{if(m===0){Cl&&!o&&oa(e,r,0,!1);break}else{if(l=e.current.alternate,g&&!t0(l)){m=qu(e,r,!1),g=!1;continue}if(m===2){if(g=r,e.errorRecoveryDisabledLanes&g)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var A=e;m=Es;var V=A.current.memoizedState.isDehydrated;if(V&&(Tl(A,S).flags|=256),S=qu(A,S,!1),S!==2){if(Uu&&!V){A.errorRecoveryDisabledLanes|=g,Ha|=g,m=4;break e}g=En,En=m,g!==null&&(En===null?En=g:En.push.apply(En,g))}m=S}if(g=!1,m!==2)continue}}if(m===1){Tl(e,0),oa(e,r,0,!0);break}e:{switch(o=e,g=m,g){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:oa(o,r,_n,!aa);break e;case 2:En=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(m=no+300-We(),10<m)){if(oa(o,r,_n,!aa),pt(o,0,!0)!==0)break e;Ur=r,o.timeoutHandle=mx(Ih.bind(null,o,l,En,ao,Pu,r,_n,Ha,El,aa,g,"Throttled",-0,0),m);break e}Ih(o,l,En,ao,Pu,r,_n,Ha,El,aa,g,null,-0,0)}}break}while(!0);mr(e)}function Ih(e,r,l,o,m,g,S,A,V,re,de,pe,le,se){if(e.timeoutHandle=-1,pe=r.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Cr},Ah(r,g,pe);var Ee=(g&62914560)===g?no-We():(g&4194048)===g?Dh-We():0;if(Ee=$0(pe,Ee),Ee!==null){Ur=g,e.cancelPendingCommit=Ee(Gh.bind(null,e,r,g,l,o,m,S,A,V,de,pe,null,le,se)),oa(e,g,S,!re);return}}Gh(e,r,g,l,o,m,S,A,V)}function t0(e){for(var r=e;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var o=0;o<l.length;o++){var m=l[o],g=m.getSnapshot;m=m.value;try{if(!An(g(),m))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function oa(e,r,l,o){r&=~Hu,r&=~Ha,e.suspendedLanes|=r,e.pingedLanes&=~r,o&&(e.warmLanes|=r),o=e.expirationTimes;for(var m=r;0<m;){var g=31-Ft(m),S=1<<g;o[g]=-1,m&=~S}l!==0&&Kl(e,l,r)}function lo(){return(ft&6)===0?(Ts(0),!1):!0}function Gu(){if(Je!==null){if(xt===0)var e=Je.return;else e=Je,Rr=Ma=null,ou(e),vl=null,us=0,e=Je;for(;e!==null;)hh(e.alternate,e),e=e.return;Je=null}}function Tl(e,r){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,j0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Ur=0,Gu(),kt=e,Je=l=Nr(e.current,null),nt=r,xt=0,Dn=null,aa=!1,Cl=Pe(e,r),Uu=!1,El=_n=Hu=Ha=la=Ut=0,En=Es=null,Pu=!1,(r&8)!==0&&(r|=r&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=r;0<o;){var m=31-Ft(o),g=1<<m;r|=e[m],o&=~g}return $r=r,Ei(),l}function $h(e,r){Ye=null,D.H=vs,r===gl||r===Di?(r=tm(),xt=3):r===Xc?(r=tm(),xt=4):xt=r===wu?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Dn=r,Je===null&&(Ut=1,Yi(e,Wn(r,e.current)))}function Uh(){var e=Mn.current;return e===null?!0:(nt&4194048)===nt?Kn===null:(nt&62914560)===nt||(nt&536870912)!==0?e===Kn:!1}function Hh(){var e=D.H;return D.H=vs,e===null?vs:e}function Ph(){var e=D.A;return D.A=J1,e}function so(){Ut=4,aa||(nt&4194048)!==nt&&Mn.current!==null||(Cl=!0),(la&134217727)===0&&(Ha&134217727)===0||kt===null||oa(kt,nt,_n,!1)}function qu(e,r,l){var o=ft;ft|=2;var m=Hh(),g=Ph();(kt!==e||nt!==r)&&(ao=null,Tl(e,r)),r=!1;var S=Ut;e:do try{if(xt!==0&&Je!==null){var A=Je,V=Dn;switch(xt){case 8:Gu(),S=6;break e;case 3:case 2:case 9:case 6:Mn.current===null&&(r=!0);var re=xt;if(xt=0,Dn=null,Rl(e,A,V,re),l&&Cl){S=0;break e}break;default:re=xt,xt=0,Dn=null,Rl(e,A,V,re)}}n0(),S=Ut;break}catch(de){$h(e,de)}while(!0);return r&&e.shellSuspendCounter++,Rr=Ma=null,ft=o,D.H=m,D.A=g,Je===null&&(kt=null,nt=0,Ei()),S}function n0(){for(;Je!==null;)Vh(Je)}function r0(e,r){var l=ft;ft|=2;var o=Hh(),m=Ph();kt!==e||nt!==r?(ao=null,ro=We()+500,Tl(e,r)):Cl=Pe(e,r);e:do try{if(xt!==0&&Je!==null){r=Je;var g=Dn;t:switch(xt){case 1:xt=0,Dn=null,Rl(e,r,g,1);break;case 2:case 9:if(Jp(g)){xt=0,Dn=null,Fh(r);break}r=function(){xt!==2&&xt!==9||kt!==e||(xt=7),mr(e)},g.then(r,r);break e;case 3:xt=7;break e;case 4:xt=5;break e;case 7:Jp(g)?(xt=0,Dn=null,Fh(r)):(xt=0,Dn=null,Rl(e,r,g,7));break;case 5:var S=null;switch(Je.tag){case 26:S=Je.memoizedState;case 5:case 27:var A=Je;if(S?Rx(S):A.stateNode.complete){xt=0,Dn=null;var V=A.sibling;if(V!==null)Je=V;else{var re=A.return;re!==null?(Je=re,io(re)):Je=null}break t}}xt=0,Dn=null,Rl(e,r,g,5);break;case 6:xt=0,Dn=null,Rl(e,r,g,6);break;case 8:Gu(),Ut=6;break e;default:throw Error(i(462))}}a0();break}catch(de){$h(e,de)}while(!0);return Rr=Ma=null,D.H=o,D.A=m,ft=l,Je!==null?0:(kt=null,nt=0,Ei(),Ut)}function a0(){for(;Je!==null&&!Ae();)Vh(Je)}function Vh(e){var r=ph(e.alternate,e,$r);e.memoizedProps=e.pendingProps,r===null?io(e):Je=r}function Fh(e){var r=e,l=r.alternate;switch(r.tag){case 15:case 0:r=ih(l,r,r.pendingProps,r.type,void 0,nt);break;case 11:r=ih(l,r,r.pendingProps,r.type.render,r.ref,nt);break;case 5:ou(r);default:hh(l,r),r=Je=Pp(r,$r),r=ph(l,r,$r)}e.memoizedProps=e.pendingProps,r===null?io(e):Je=r}function Rl(e,r,l,o){Rr=Ma=null,ou(r),vl=null,us=0;var m=r.return;try{if(G1(e,m,r,l,nt)){Ut=1,Yi(e,Wn(l,e.current)),Je=null;return}}catch(g){if(m!==null)throw Je=m,g;Ut=1,Yi(e,Wn(l,e.current)),Je=null;return}r.flags&32768?(at||o===1?e=!0:Cl||(nt&536870912)!==0?e=!1:(aa=e=!0,(o===2||o===9||o===3||o===6)&&(o=Mn.current,o!==null&&o.tag===13&&(o.flags|=16384))),Wh(r,e)):io(r)}function io(e){var r=e;do{if((r.flags&32768)!==0){Wh(r,aa);return}e=r.return;var l=K1(r.alternate,r,$r);if(l!==null){Je=l;return}if(r=r.sibling,r!==null){Je=r;return}Je=r=e}while(r!==null);Ut===0&&(Ut=5)}function Wh(e,r){do{var l=X1(e.alternate,e);if(l!==null){l.flags&=32767,Je=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(e=e.sibling,e!==null)){Je=e;return}Je=e=l}while(e!==null);Ut=6,Je=null}function Gh(e,r,l,o,m,g,S,A,V){e.cancelPendingCommit=null;do oo();while(Xt!==0);if((ft&6)!==0)throw Error(i(327));if(r!==null){if(r===e.current)throw Error(i(177));if(g=r.lanes|r.childLanes,g|=_c,Hn(e,l,g,S,A,V),e===kt&&(Je=kt=null,nt=0),Nl=r,ia=e,Ur=l,Vu=g,Fu=m,_h=o,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,o0(zt,function(){return Qh(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||o){o=D.T,D.T=null,m=U.p,U.p=2,S=ft,ft|=4;try{Q1(e,r,l)}finally{ft=S,U.p=m,D.T=o}}Xt=1,qh(),Yh(),Kh()}}function qh(){if(Xt===1){Xt=0;var e=ia,r=Nl,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=D.T,D.T=null;var o=U.p;U.p=2;var m=ft;ft|=4;try{Nh(r,e);var g=ld,S=zp(e.containerInfo),A=g.focusedElem,V=g.selectionRange;if(S!==A&&A&&A.ownerDocument&&Mp(A.ownerDocument.documentElement,A)){if(V!==null&&Ac(A)){var re=V.start,de=V.end;if(de===void 0&&(de=re),"selectionStart"in A)A.selectionStart=re,A.selectionEnd=Math.min(de,A.value.length);else{var pe=A.ownerDocument||document,le=pe&&pe.defaultView||window;if(le.getSelection){var se=le.getSelection(),Ee=A.textContent.length,Be=Math.min(V.start,Ee),bt=V.end===void 0?Be:Math.min(V.end,Ee);!se.extend&&Be>bt&&(S=bt,bt=Be,Be=S);var X=Lp(A,Be),G=Lp(A,bt);if(X&&G&&(se.rangeCount!==1||se.anchorNode!==X.node||se.anchorOffset!==X.offset||se.focusNode!==G.node||se.focusOffset!==G.offset)){var ne=pe.createRange();ne.setStart(X.node,X.offset),se.removeAllRanges(),Be>bt?(se.addRange(ne),se.extend(G.node,G.offset)):(ne.setEnd(G.node,G.offset),se.addRange(ne))}}}}for(pe=[],se=A;se=se.parentNode;)se.nodeType===1&&pe.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<pe.length;A++){var fe=pe[A];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}jo=!!ad,ld=ad=null}finally{ft=m,U.p=o,D.T=l}}e.current=r,Xt=2}}function Yh(){if(Xt===2){Xt=0;var e=ia,r=Nl,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=D.T,D.T=null;var o=U.p;U.p=2;var m=ft;ft|=4;try{Sh(e,r.alternate,r)}finally{ft=m,U.p=o,D.T=l}}Xt=3}}function Kh(){if(Xt===4||Xt===3){Xt=0,Ge();var e=ia,r=Nl,l=Ur,o=_h;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Xt=5:(Xt=0,Nl=ia=null,Xh(e,e.pendingLanes));var m=e.pendingLanes;if(m===0&&(sa=null),Z(l),r=r.stateNode,dt&&typeof dt.onCommitFiberRoot=="function")try{dt.onCommitFiberRoot(St,r,void 0,(r.current.flags&128)===128)}catch{}if(o!==null){r=D.T,m=U.p,U.p=2,D.T=null;try{for(var g=e.onRecoverableError,S=0;S<o.length;S++){var A=o[S];g(A.value,{componentStack:A.stack})}}finally{D.T=r,U.p=m}}(Ur&3)!==0&&oo(),mr(e),m=e.pendingLanes,(l&261930)!==0&&(m&42)!==0?e===Wu?Ns++:(Ns=0,Wu=e):Ns=0,Ts(0)}}function Xh(e,r){(e.pooledCacheLanes&=r)===0&&(r=e.pooledCache,r!=null&&(e.pooledCache=null,os(r)))}function oo(){return qh(),Yh(),Kh(),Qh()}function Qh(){if(Xt!==5)return!1;var e=ia,r=Vu;Vu=0;var l=Z(Ur),o=D.T,m=U.p;try{U.p=32>l?32:l,D.T=null,l=Fu,Fu=null;var g=ia,S=Ur;if(Xt=0,Nl=ia=null,Ur=0,(ft&6)!==0)throw Error(i(331));var A=ft;if(ft|=4,Mh(g.current),Rh(g,g.current,S,l),ft=A,Ts(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(St,g)}catch{}return!0}finally{U.p=m,D.T=o,Xh(e,r)}}function Zh(e,r,l){r=Wn(l,r),r=ku(e.stateNode,r,2),e=ea(e,r,2),e!==null&&(rr(e,2),mr(e))}function gt(e,r,l){if(e.tag===3)Zh(e,e,l);else for(;r!==null;){if(r.tag===3){Zh(r,e,l);break}else if(r.tag===1){var o=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(sa===null||!sa.has(o))){e=Wn(l,e),l=Jm(2),o=ea(r,l,2),o!==null&&(eh(l,o,r,e),rr(o,2),mr(o));break}}r=r.return}}function Yu(e,r,l){var o=e.pingCache;if(o===null){o=e.pingCache=new e0;var m=new Set;o.set(r,m)}else m=o.get(r),m===void 0&&(m=new Set,o.set(r,m));m.has(l)||(Uu=!0,m.add(l),e=l0.bind(null,e,r,l),r.then(e,e))}function l0(e,r,l){var o=e.pingCache;o!==null&&o.delete(r),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,kt===e&&(nt&l)===l&&(Ut===4||Ut===3&&(nt&62914560)===nt&&300>We()-no?(ft&2)===0&&Tl(e,0):Hu|=l,El===nt&&(El=0)),mr(e)}function Jh(e,r){r===0&&(r=un()),e=Ra(e,r),e!==null&&(rr(e,r),mr(e))}function s0(e){var r=e.memoizedState,l=0;r!==null&&(l=r.retryLane),Jh(e,l)}function i0(e,r){var l=0;switch(e.tag){case 31:case 13:var o=e.stateNode,m=e.memoizedState;m!==null&&(l=m.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(i(314))}o!==null&&o.delete(r),Jh(e,l)}function o0(e,r){return ye(e,r)}var co=null,Al=null,Ku=!1,uo=!1,Xu=!1,ca=0;function mr(e){e!==Al&&e.next===null&&(Al===null?co=Al=e:Al=Al.next=e),uo=!0,Ku||(Ku=!0,u0())}function Ts(e,r){if(!Xu&&uo){Xu=!0;do for(var l=!1,o=co;o!==null;){if(e!==0){var m=o.pendingLanes;if(m===0)var g=0;else{var S=o.suspendedLanes,A=o.pingedLanes;g=(1<<31-Ft(42|e)+1)-1,g&=m&~(S&~A),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,rx(o,g))}else g=nt,g=pt(o,o===kt?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||Pe(o,g)||(l=!0,rx(o,g));o=o.next}while(l);Xu=!1}}function c0(){ex()}function ex(){uo=Ku=!1;var e=0;ca!==0&&b0()&&(e=ca);for(var r=We(),l=null,o=co;o!==null;){var m=o.next,g=tx(o,r);g===0?(o.next=null,l===null?co=m:l.next=m,m===null&&(Al=l)):(l=o,(e!==0||(g&3)!==0)&&(uo=!0)),o=m}Xt!==0&&Xt!==5||Ts(e),ca!==0&&(ca=0)}function tx(e,r){for(var l=e.suspendedLanes,o=e.pingedLanes,m=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-Ft(g),A=1<<S,V=m[S];V===-1?((A&l)===0||(A&o)!==0)&&(m[S]=it(A,r)):V<=r&&(e.expiredLanes|=A),g&=~A}if(r=kt,l=nt,l=pt(e,e===r?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===r&&(xt===2||xt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Se(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Pe(e,l)){if(r=l&-l,r===e.callbackPriority)return r;switch(o!==null&&Se(o),Z(l)){case 2:case 8:l=Et;break;case 32:l=zt;break;case 268435456:l=qe;break;default:l=zt}return o=nx.bind(null,e),l=ye(l,o),e.callbackPriority=r,e.callbackNode=l,r}return o!==null&&o!==null&&Se(o),e.callbackPriority=2,e.callbackNode=null,2}function nx(e,r){if(Xt!==0&&Xt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(oo()&&e.callbackNode!==l)return null;var o=nt;return o=pt(e,e===kt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Bh(e,o,r),tx(e,We()),e.callbackNode!=null&&e.callbackNode===l?nx.bind(null,e):null)}function rx(e,r){if(oo())return null;Bh(e,r,!0)}function u0(){S0(function(){(ft&6)!==0?ye(Ct,c0):ex()})}function Qu(){if(ca===0){var e=hl;e===0&&(e=Rn,Rn<<=1,(Rn&261888)===0&&(Rn=256)),ca=e}return ca}function ax(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:vi(""+e)}function lx(e,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,e.id&&l.setAttribute("form",e.id),r.parentNode.insertBefore(l,r),e=new FormData(e),l.parentNode.removeChild(l),e}function d0(e,r,l,o,m){if(r==="submit"&&l&&l.stateNode===m){var g=ax((m[ht]||null).action),S=o.submitter;S&&(r=(r=S[ht]||null)?ax(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var A=new Si("action","action",null,o,m);e.push({event:A,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(ca!==0){var V=S?lx(m,S):new FormData(m);gu(l,{pending:!0,data:V,method:m.method,action:g},null,V)}}else typeof g=="function"&&(A.preventDefault(),V=S?lx(m,S):new FormData(m),gu(l,{pending:!0,data:V,method:m.method,action:g},g,V))},currentTarget:m}]})}}for(var Zu=0;Zu<Dc.length;Zu++){var Ju=Dc[Zu],f0=Ju.toLowerCase(),p0=Ju[0].toUpperCase()+Ju.slice(1);ar(f0,"on"+p0)}ar(Op,"onAnimationEnd"),ar(Bp,"onAnimationIteration"),ar(Ip,"onAnimationStart"),ar("dblclick","onDoubleClick"),ar("focusin","onFocus"),ar("focusout","onBlur"),ar(R1,"onTransitionRun"),ar(A1,"onTransitionStart"),ar(L1,"onTransitionCancel"),ar($p,"onTransitionEnd"),tl("onMouseEnter",["mouseout","mouseover"]),tl("onMouseLeave",["mouseout","mouseover"]),tl("onPointerEnter",["pointerout","pointerover"]),tl("onPointerLeave",["pointerout","pointerover"]),Ca("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ca("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ca("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ca("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ca("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ca("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rs="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(" "),m0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Rs));function sx(e,r){r=(r&4)!==0;for(var l=0;l<e.length;l++){var o=e[l],m=o.event;o=o.listeners;e:{var g=void 0;if(r)for(var S=o.length-1;0<=S;S--){var A=o[S],V=A.instance,re=A.currentTarget;if(A=A.listener,V!==g&&m.isPropagationStopped())break e;g=A,m.currentTarget=re;try{g(m)}catch(de){Ci(de)}m.currentTarget=null,g=V}else for(S=0;S<o.length;S++){if(A=o[S],V=A.instance,re=A.currentTarget,A=A.listener,V!==g&&m.isPropagationStopped())break e;g=A,m.currentTarget=re;try{g(m)}catch(de){Ci(de)}m.currentTarget=null,g=V}}}}function et(e,r){var l=r[Gr];l===void 0&&(l=r[Gr]=new Set);var o=e+"__bubble";l.has(o)||(ix(r,e,2,!1),l.add(o))}function ed(e,r,l){var o=0;r&&(o|=4),ix(l,e,o,r)}var fo="_reactListening"+Math.random().toString(36).slice(2);function td(e){if(!e[fo]){e[fo]=!0,ep.forEach(function(l){l!=="selectionchange"&&(m0.has(l)||ed(l,!1,e),ed(l,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[fo]||(r[fo]=!0,ed("selectionchange",!1,r))}}function ix(e,r,l,o){switch(Ox(r)){case 2:var m=P0;break;case 8:m=V0;break;default:m=xd}l=m.bind(null,r,l,e),m=void 0,!jc||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),o?m!==void 0?e.addEventListener(r,l,{capture:!0,passive:m}):e.addEventListener(r,l,!0):m!==void 0?e.addEventListener(r,l,{passive:m}):e.addEventListener(r,l,!1)}function nd(e,r,l,o,m){var g=o;if((r&1)===0&&(r&2)===0&&o!==null)e:for(;;){if(o===null)return;var S=o.tag;if(S===3||S===4){var A=o.stateNode.containerInfo;if(A===m)break;if(S===4)for(S=o.return;S!==null;){var V=S.tag;if((V===3||V===4)&&S.stateNode.containerInfo===m)return;S=S.return}for(;A!==null;){if(S=Za(A),S===null)return;if(V=S.tag,V===5||V===6||V===26||V===27){o=g=S;continue e}A=A.parentNode}}o=o.return}fp(function(){var re=g,de=yc(l),pe=[];e:{var le=Up.get(e);if(le!==void 0){var se=Si,Ee=e;switch(e){case"keypress":if(bi(l)===0)break e;case"keydown":case"keyup":se=i1;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=hp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":se=Kb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":se=u1;break;case Op:case Bp:case Ip:se=Zb;break;case $p:se=f1;break;case"scroll":case"scrollend":se=qb;break;case"wheel":se=m1;break;case"copy":case"cut":case"paste":se=e1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":se=gp;break;case"toggle":case"beforetoggle":se=x1}var Be=(r&4)!==0,bt=!Be&&(e==="scroll"||e==="scrollend"),X=Be?le!==null?le+"Capture":null:le;Be=[];for(var G=re,ne;G!==null;){var fe=G;if(ne=fe.stateNode,fe=fe.tag,fe!==5&&fe!==26&&fe!==27||ne===null||X===null||(fe=Ql(G,X),fe!=null&&Be.push(As(G,fe,ne))),bt)break;G=G.return}0<Be.length&&(le=new se(le,Ee,null,l,de),pe.push({event:le,listeners:Be}))}}if((r&7)===0){e:{if(le=e==="mouseover"||e==="pointerover",se=e==="mouseout"||e==="pointerout",le&&l!==vc&&(Ee=l.relatedTarget||l.fromElement)&&(Za(Ee)||Ee[dn]))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=re,Ee=Ee?Za(Ee):null,Ee!==null&&(bt=u(Ee),Be=Ee.tag,Ee!==bt||Be!==5&&Be!==27&&Be!==6)&&(Ee=null)):(se=null,Ee=re),se!==Ee)){if(Be=hp,fe="onMouseLeave",X="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Be=gp,fe="onPointerLeave",X="onPointerEnter",G="pointer"),bt=se==null?le:Xl(se),ne=Ee==null?le:Xl(Ee),le=new Be(fe,G+"leave",se,l,de),le.target=bt,le.relatedTarget=ne,fe=null,Za(de)===re&&(Be=new Be(X,G+"enter",Ee,l,de),Be.target=ne,Be.relatedTarget=bt,fe=Be),bt=fe,se&&Ee)t:{for(Be=h0,X=se,G=Ee,ne=0,fe=X;fe;fe=Be(fe))ne++;fe=0;for(var ze=G;ze;ze=Be(ze))fe++;for(;0<ne-fe;)X=Be(X),ne--;for(;0<fe-ne;)G=Be(G),fe--;for(;ne--;){if(X===G||G!==null&&X===G.alternate){Be=X;break t}X=Be(X),G=Be(G)}Be=null}else Be=null;se!==null&&ox(pe,le,se,Be,!1),Ee!==null&&bt!==null&&ox(pe,bt,Ee,Be,!0)}}e:{if(le=re?Xl(re):window,se=le.nodeName&&le.nodeName.toLowerCase(),se==="select"||se==="input"&&le.type==="file")var ot=Cp;else if(kp(le))if(Ep)ot=E1;else{ot=w1;var Re=k1}else se=le.nodeName,!se||se.toLowerCase()!=="input"||le.type!=="checkbox"&&le.type!=="radio"?re&&gc(re.elementType)&&(ot=Cp):ot=C1;if(ot&&(ot=ot(e,re))){wp(pe,ot,l,de);break e}Re&&Re(e,le,re),e==="focusout"&&re&&le.type==="number"&&re.memoizedProps.value!=null&&xc(le,"number",le.value)}switch(Re=re?Xl(re):window,e){case"focusin":(kp(Re)||Re.contentEditable==="true")&&(il=Re,Lc=re,ls=null);break;case"focusout":ls=Lc=il=null;break;case"mousedown":Mc=!0;break;case"contextmenu":case"mouseup":case"dragend":Mc=!1,Dp(pe,l,de);break;case"selectionchange":if(T1)break;case"keydown":case"keyup":Dp(pe,l,de)}var Ke;if(Nc)e:{switch(e){case"compositionstart":var rt="onCompositionStart";break e;case"compositionend":rt="onCompositionEnd";break e;case"compositionupdate":rt="onCompositionUpdate";break e}rt=void 0}else sl?jp(e,l)&&(rt="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(rt="onCompositionStart");rt&&(vp&&l.locale!=="ko"&&(sl||rt!=="onCompositionStart"?rt==="onCompositionEnd"&&sl&&(Ke=pp()):(qr=de,Sc="value"in qr?qr.value:qr.textContent,sl=!0)),Re=po(re,rt),0<Re.length&&(rt=new xp(rt,e,null,l,de),pe.push({event:rt,listeners:Re}),Ke?rt.data=Ke:(Ke=Sp(l),Ke!==null&&(rt.data=Ke)))),(Ke=v1?y1(e,l):b1(e,l))&&(rt=po(re,"onBeforeInput"),0<rt.length&&(Re=new xp("onBeforeInput","beforeinput",null,l,de),pe.push({event:Re,listeners:rt}),Re.data=Ke)),d0(pe,e,re,l,de)}sx(pe,r)})}function As(e,r,l){return{instance:e,listener:r,currentTarget:l}}function po(e,r){for(var l=r+"Capture",o=[];e!==null;){var m=e,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=Ql(e,l),m!=null&&o.unshift(As(e,m,g)),m=Ql(e,r),m!=null&&o.push(As(e,m,g))),e.tag===3)return o;e=e.return}return[]}function h0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function ox(e,r,l,o,m){for(var g=r._reactName,S=[];l!==null&&l!==o;){var A=l,V=A.alternate,re=A.stateNode;if(A=A.tag,V!==null&&V===o)break;A!==5&&A!==26&&A!==27||re===null||(V=re,m?(re=Ql(l,g),re!=null&&S.unshift(As(l,re,V))):m||(re=Ql(l,g),re!=null&&S.push(As(l,re,V)))),l=l.return}S.length!==0&&e.push({event:r,listeners:S})}var x0=/\r\n?/g,g0=/\u0000|\uFFFD/g;function cx(e){return(typeof e=="string"?e:""+e).replace(x0,`
|
|
50
|
+
`).replace(g0,"")}function ux(e,r){return r=cx(r),cx(e)===r}function yt(e,r,l,o,m,g){switch(l){case"children":typeof o=="string"?r==="body"||r==="textarea"&&o===""||rl(e,o):(typeof o=="number"||typeof o=="bigint")&&r!=="body"&&rl(e,""+o);break;case"className":xi(e,"class",o);break;case"tabIndex":xi(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":xi(e,l,o);break;case"style":up(e,o,g);break;case"data":if(r!=="object"){xi(e,"data",o);break}case"src":case"href":if(o===""&&(r!=="a"||l!=="href")){e.removeAttribute(l);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=vi(""+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"?(r!=="input"&&yt(e,r,"name",m.name,m,null),yt(e,r,"formEncType",m.formEncType,m,null),yt(e,r,"formMethod",m.formMethod,m,null),yt(e,r,"formTarget",m.formTarget,m,null)):(yt(e,r,"encType",m.encType,m,null),yt(e,r,"method",m.method,m,null),yt(e,r,"target",m.target,m,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=vi(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=Cr);break;case"onScroll":o!=null&&et("scroll",e);break;case"onScrollEnd":o!=null&&et("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(m.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=vi(""+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":et("beforetoggle",e),et("toggle",e),hi(e,"popover",o);break;case"xlinkActuate":wr(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":wr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":wr(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":wr(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":wr(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":wr(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":wr(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":wr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":wr(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":hi(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=Wb.get(l)||l,hi(e,l,o))}}function rd(e,r,l,o,m,g){switch(l){case"style":up(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(m.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"children":typeof o=="string"?rl(e,o):(typeof o=="number"||typeof o=="bigint")&&rl(e,""+o);break;case"onScroll":o!=null&&et("scroll",e);break;case"onScrollEnd":o!=null&&et("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Cr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!tp.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),r=l.slice(2,m?l.length-7:void 0),g=e[ht]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(r,g,m),typeof o=="function")){typeof g!="function"&&g!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(r,o,m);break e}l in e?e[l]=o:o===!0?e.setAttribute(l,""):hi(e,l,o)}}}function cn(e,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":et("error",e),et("load",e);var o=!1,m=!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":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:yt(e,r,g,S,l,null)}}m&&yt(e,r,"srcSet",l.srcSet,l,null),o&&yt(e,r,"src",l.src,l,null);return;case"input":et("invalid",e);var A=g=S=m=null,V=null,re=null;for(o in l)if(l.hasOwnProperty(o)){var de=l[o];if(de!=null)switch(o){case"name":m=de;break;case"type":S=de;break;case"checked":V=de;break;case"defaultChecked":re=de;break;case"value":g=de;break;case"defaultValue":A=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(i(137,r));break;default:yt(e,r,o,de,l,null)}}sp(e,g,A,V,re,S,m,!1);return;case"select":et("invalid",e),o=S=g=null;for(m in l)if(l.hasOwnProperty(m)&&(A=l[m],A!=null))switch(m){case"value":g=A;break;case"defaultValue":S=A;break;case"multiple":o=A;default:yt(e,r,m,A,l,null)}r=g,l=S,e.multiple=!!o,r!=null?nl(e,!!o,r,!1):l!=null&&nl(e,!!o,l,!0);return;case"textarea":et("invalid",e),g=m=o=null;for(S in l)if(l.hasOwnProperty(S)&&(A=l[S],A!=null))switch(S){case"value":o=A;break;case"defaultValue":m=A;break;case"children":g=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(i(91));break;default:yt(e,r,S,A,l,null)}op(e,o,m,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:yt(e,r,V,o,l,null)}return;case"dialog":et("beforetoggle",e),et("toggle",e),et("cancel",e),et("close",e);break;case"iframe":case"object":et("load",e);break;case"video":case"audio":for(o=0;o<Rs.length;o++)et(Rs[o],e);break;case"image":et("error",e),et("load",e);break;case"details":et("toggle",e);break;case"embed":case"source":case"link":et("error",e),et("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(re in l)if(l.hasOwnProperty(re)&&(o=l[re],o!=null))switch(re){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:yt(e,r,re,o,l,null)}return;default:if(gc(r)){for(de in l)l.hasOwnProperty(de)&&(o=l[de],o!==void 0&&rd(e,r,de,o,l,void 0));return}}for(A in l)l.hasOwnProperty(A)&&(o=l[A],o!=null&&yt(e,r,A,o,l,null))}function v0(e,r,l,o){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,S=null,A=null,V=null,re=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)||yt(e,r,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":m=se;break;case"checked":re=se;break;case"defaultChecked":de=se;break;case"value":S=se;break;case"defaultValue":A=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(i(137,r));break;default:se!==pe&&yt(e,r,le,se,o,pe)}}hc(e,S,A,V,re,de,g,m);return;case"select":se=S=A=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)||yt(e,r,g,null,o,V)}for(m in o)if(g=o[m],V=l[m],o.hasOwnProperty(m)&&(g!=null||V!=null))switch(m){case"value":le=g;break;case"defaultValue":A=g;break;case"multiple":S=g;default:g!==V&&yt(e,r,m,g,o,V)}r=A,l=S,o=se,le!=null?nl(e,!!l,le,!1):!!o!=!!l&&(r!=null?nl(e,!!l,r,!0):nl(e,!!l,l?[]:"",!1));return;case"textarea":se=le=null;for(A in l)if(m=l[A],l.hasOwnProperty(A)&&m!=null&&!o.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:yt(e,r,A,null,o,m)}for(S in o)if(m=o[S],g=l[S],o.hasOwnProperty(S)&&(m!=null||g!=null))switch(S){case"value":le=m;break;case"defaultValue":se=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(i(91));break;default:m!==g&&yt(e,r,S,m,o,g)}ip(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:yt(e,r,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:yt(e,r,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 Be in l)le=l[Be],l.hasOwnProperty(Be)&&le!=null&&!o.hasOwnProperty(Be)&&yt(e,r,Be,null,o,le);for(re in o)if(le=o[re],se=l[re],o.hasOwnProperty(re)&&le!==se&&(le!=null||se!=null))switch(re){case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(i(137,r));break;default:yt(e,r,re,le,o,se)}return;default:if(gc(r)){for(var bt in l)le=l[bt],l.hasOwnProperty(bt)&&le!==void 0&&!o.hasOwnProperty(bt)&&rd(e,r,bt,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,r,de,le,o,se);return}}for(var X in l)le=l[X],l.hasOwnProperty(X)&&le!=null&&!o.hasOwnProperty(X)&&yt(e,r,X,null,o,le);for(pe in o)le=o[pe],se=l[pe],!o.hasOwnProperty(pe)||le===se||le==null&&se==null||yt(e,r,pe,le,o,se)}function dx(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function y0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,r=0,l=performance.getEntriesByType("resource"),o=0;o<l.length;o++){var m=l[o],g=m.transferSize,S=m.initiatorType,A=m.duration;if(g&&A&&dx(S)){for(S=0,A=m.responseEnd,o+=1;o<l.length;o++){var V=l[o],re=V.startTime;if(re>A)break;var de=V.transferSize,pe=V.initiatorType;de&&dx(pe)&&(V=V.responseEnd,S+=de*(V<A?1:(A-re)/(V-re)))}if(--o,r+=8*(g+S)/(m.duration/1e3),e++,10<e)break}}if(0<e)return r/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var ad=null,ld=null;function mo(e){return e.nodeType===9?e:e.ownerDocument}function fx(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 px(e,r){if(e===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&r==="foreignObject"?0:e}function sd(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var id=null;function b0(){var e=window.event;return e&&e.type==="popstate"?e===id?!1:(id=e,!0):(id=null,!1)}var mx=typeof setTimeout=="function"?setTimeout:void 0,j0=typeof clearTimeout=="function"?clearTimeout:void 0,hx=typeof Promise=="function"?Promise:void 0,S0=typeof queueMicrotask=="function"?queueMicrotask:typeof hx<"u"?function(e){return hx.resolve(null).then(e).catch(k0)}:mx;function k0(e){setTimeout(function(){throw e})}function ua(e){return e==="head"}function xx(e,r){var l=r,o=0;do{var m=l.nextSibling;if(e.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"||l==="/&"){if(o===0){e.removeChild(m),Dl(r);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")Ls(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,Ls(l);for(var g=l.firstChild;g;){var S=g.nextSibling,A=g.nodeName;g[wa]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=S}}else l==="body"&&Ls(e.ownerDocument.body);l=m}while(l);Dl(r)}function gx(e,r){var l=e;e=0;do{var o=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(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 r=e.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.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 w0(e,r,l,o){for(;e.nodeType===1;){var m=l;if(e.nodeName.toLowerCase()!==r.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[wa])switch(r){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!==m.rel||e.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||e.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||e.getAttribute("title")!==(m.title==null?null:m.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(m.src==null?null:m.src)||e.getAttribute("type")!==(m.type==null?null:m.type)||e.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(r==="input"&&e.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Xn(e.nextSibling),e===null)break}return null}function C0(e,r,l){if(r==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Xn(e.nextSibling),e===null))return null;return e}function vx(e,r){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Xn(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 E0(e,r){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=r;else if(e.data!=="$?"||l.readyState!=="loading")r();else{var o=function(){r(),l.removeEventListener("DOMContentLoaded",o)};l.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Xn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return e}var dd=null;function yx(e){e=e.nextSibling;for(var r=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(r===0)return Xn(e.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}e=e.nextSibling}return null}function bx(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return e;r--}else l!=="/$"&&l!=="/&"||r++}e=e.previousSibling}return null}function jx(e,r,l){switch(r=mo(l),e){case"html":if(e=r.documentElement,!e)throw Error(i(452));return e;case"head":if(e=r.head,!e)throw Error(i(453));return e;case"body":if(e=r.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Ls(e){for(var r=e.attributes;r.length;)e.removeAttributeNode(r[0]);pc(e)}var Qn=new Map,Sx=new Set;function ho(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Hr=U.d;U.d={f:N0,r:T0,D:R0,C:A0,L:L0,m:M0,X:D0,S:z0,M:_0};function N0(){var e=Hr.f(),r=lo();return e||r}function T0(e){var r=Ja(e);r!==null&&r.tag===5&&r.type==="form"?$m(r):Hr.r(e)}var Ll=typeof document>"u"?null:document;function kx(e,r,l){var o=Ll;if(o&&typeof r=="string"&&r){var m=Vn(r);m='link[rel="'+e+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),Sx.has(m)||(Sx.add(m),e={rel:e,crossOrigin:l,href:r},o.querySelector(m)===null&&(r=o.createElement("link"),cn(r,"link",e),tn(r),o.head.appendChild(r)))}}function R0(e){Hr.D(e),kx("dns-prefetch",e,null)}function A0(e,r){Hr.C(e,r),kx("preconnect",e,r)}function L0(e,r,l){Hr.L(e,r,l);var o=Ll;if(o&&e&&r){var m='link[rel="preload"][as="'+Vn(r)+'"]';r==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+Vn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+Vn(l.imageSizes)+'"]')):m+='[href="'+Vn(e)+'"]';var g=m;switch(r){case"style":g=Ml(e);break;case"script":g=zl(e)}Qn.has(g)||(e=y({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:e,as:r},l),Qn.set(g,e),o.querySelector(m)!==null||r==="style"&&o.querySelector(Ms(g))||r==="script"&&o.querySelector(zs(g))||(r=o.createElement("link"),cn(r,"link",e),tn(r),o.head.appendChild(r)))}}function M0(e,r){Hr.m(e,r);var l=Ll;if(l&&e){var o=r&&typeof r.as=="string"?r.as:"script",m='link[rel="modulepreload"][as="'+Vn(o)+'"][href="'+Vn(e)+'"]',g=m;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=zl(e)}if(!Qn.has(g)&&(e=y({rel:"modulepreload",href:e},r),Qn.set(g,e),l.querySelector(m)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(zs(g)))return}o=l.createElement("link"),cn(o,"link",e),tn(o),l.head.appendChild(o)}}}function z0(e,r,l){Hr.S(e,r,l);var o=Ll;if(o&&e){var m=el(o).hoistableStyles,g=Ml(e);r=r||"default";var S=m.get(g);if(!S){var A={loading:0,preload:null};if(S=o.querySelector(Ms(g)))A.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":r},l),(l=Qn.get(g))&&fd(e,l);var V=S=o.createElement("link");tn(V),cn(V,"link",e),V._p=new Promise(function(re,de){V.onload=re,V.onerror=de}),V.addEventListener("load",function(){A.loading|=1}),V.addEventListener("error",function(){A.loading|=2}),A.loading|=4,xo(S,r,o)}S={type:"stylesheet",instance:S,count:1,state:A},m.set(g,S)}}}function D0(e,r){Hr.X(e,r);var l=Ll;if(l&&e){var o=el(l).hoistableScripts,m=zl(e),g=o.get(m);g||(g=l.querySelector(zs(m)),g||(e=y({src:e,async:!0},r),(r=Qn.get(m))&&pd(e,r),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(m,g))}}function _0(e,r){Hr.M(e,r);var l=Ll;if(l&&e){var o=el(l).hoistableScripts,m=zl(e),g=o.get(m);g||(g=l.querySelector(zs(m)),g||(e=y({src:e,async:!0,type:"module"},r),(r=Qn.get(m))&&pd(e,r),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(m,g))}}function wx(e,r,l,o){var m=(m=te.current)?ho(m):null;if(!m)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Ml(l.href),l=el(m).hoistableStyles,o=l.get(r),o||(o={type:"style",instance:null,count:0,state:null},l.set(r,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=Ml(l.href);var g=el(m).hoistableStyles,S=g.get(e);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,S),(g=m.querySelector(Ms(e)))&&!g._p&&(S.instance=g,S.state.loading=5),Qn.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},Qn.set(e,l),g||O0(m,e,l,S.state))),r&&o===null)throw Error(i(528,""));return S}if(r&&o!==null)throw Error(i(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=zl(l),l=el(m).hoistableScripts,o=l.get(r),o||(o={type:"script",instance:null,count:0,state:null},l.set(r,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ml(e){return'href="'+Vn(e)+'"'}function Ms(e){return'link[rel="stylesheet"]['+e+"]"}function Cx(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function O0(e,r,l,o){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?o.loading=1:(r=e.createElement("link"),o.preload=r,r.addEventListener("load",function(){return o.loading|=1}),r.addEventListener("error",function(){return o.loading|=2}),cn(r,"link",l),tn(r),e.head.appendChild(r))}function zl(e){return'[src="'+Vn(e)+'"]'}function zs(e){return"script[async]"+e}function Ex(e,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var o=e.querySelector('style[data-href~="'+Vn(l.href)+'"]');if(o)return r.instance=o,tn(o),o;var m=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",m),xo(o,l.precedence,e),r.instance=o;case"stylesheet":m=Ml(l.href);var g=e.querySelector(Ms(m));if(g)return r.state.loading|=4,r.instance=g,tn(g),g;o=Cx(l),(m=Qn.get(m))&&fd(o,m),g=(e.ownerDocument||e).createElement("link"),tn(g);var S=g;return S._p=new Promise(function(A,V){S.onload=A,S.onerror=V}),cn(g,"link",o),r.state.loading|=4,xo(g,l.precedence,e),r.instance=g;case"script":return g=zl(l.src),(m=e.querySelector(zs(g)))?(r.instance=m,tn(m),m):(o=l,(m=Qn.get(g))&&(o=y({},l),pd(o,m)),e=e.ownerDocument||e,m=e.createElement("script"),tn(m),cn(m,"link",o),e.head.appendChild(m),r.instance=m);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(o=r.instance,r.state.loading|=4,xo(o,l.precedence,e));return r.instance}function xo(e,r,l){for(var o=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=o.length?o[o.length-1]:null,g=m,S=0;S<o.length;S++){var A=o[S];if(A.dataset.precedence===r)g=A;else if(g!==m)break}g?g.parentNode.insertBefore(e,g.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(e,r.firstChild))}function fd(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.title==null&&(e.title=r.title)}function pd(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.integrity==null&&(e.integrity=r.integrity)}var go=null;function Nx(e,r,l){if(go===null){var o=new Map,m=go=new Map;m.set(l,o)}else m=go,o=m.get(l),o||(o=new Map,m.set(l,o));if(o.has(e))return o;for(o.set(e,null),l=l.getElementsByTagName(e),m=0;m<l.length;m++){var g=l[m];if(!(g[wa]||g[Te]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=e+S;var A=o.get(S);A?A.push(g):o.set(S,[g])}}return o}function Tx(e,r,l){e=e.ownerDocument||e,e.head.insertBefore(l,r==="title"?e.querySelector("head > title"):null)}function B0(e,r,l){if(l===1||r.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return e=r.disabled,typeof r.precedence=="string"&&e==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Rx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function I0(e,r,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 m=Ml(o.href),g=r.querySelector(Ms(m));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=vo.bind(e),r.then(e,e)),l.state.loading|=4,l.instance=g,tn(g);return}g=r.ownerDocument||r,o=Cx(o),(m=Qn.get(m))&&fd(o,m),g=g.createElement("link"),tn(g);var S=g;S._p=new Promise(function(A,V){S.onload=A,S.onerror=V}),cn(g,"link",o),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=vo.bind(e),r.addEventListener("load",l),r.addEventListener("error",l))}}var md=0;function $0(e,r){return e.stylesheets&&e.count===0&&bo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&bo(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+r);0<e.imgBytes&&md===0&&(md=62500*y0());var m=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&bo(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>md?50:800)+r);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(m)}}:null}function vo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)bo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var yo=null;function bo(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,yo=new Map,r.forEach(U0,e),yo=null,vo.call(e))}function U0(e,r){if(!(r.state.loading&4)){var l=yo.get(e);if(l)var o=l.get(null);else{l=new Map,yo.set(e,l);for(var m=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var S=m[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(l.set(S.dataset.precedence,S),o=S)}o&&l.set(null,o)}m=r.instance,S=m.getAttribute("data-precedence"),g=l.get(S)||o,g===o&&l.set(null,m),l.set(S,m),this.count++,o=vo.bind(this),m.addEventListener("load",o),m.addEventListener("error",o),g?g.parentNode.insertBefore(m,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(m,e.firstChild)),r.state.loading|=4}}var Ds={$$typeof:R,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function H0(e,r,l,o,m,g,S,A,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=rn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rn(0),this.hiddenUpdates=rn(null),this.identifierPrefix=o,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function Ax(e,r,l,o,m,g,S,A,V,re,de,pe){return e=new H0(e,r,l,S,V,re,de,pe,A),r=1,g===!0&&(r|=24),g=Ln(3,null,null,r),e.current=g,g.stateNode=e,r=qc(),r.refCount++,e.pooledCache=r,r.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:r},Qc(g),e}function Lx(e){return e?(e=ul,e):ul}function Mx(e,r,l,o,m,g){m=Lx(m),o.context===null?o.context=m:o.pendingContext=m,o=Jr(r),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=ea(e,o,r),l!==null&&(Nn(l,e,r),fs(l,e,r))}function zx(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<r?l:r}}function hd(e,r){zx(e,r),(e=e.alternate)&&zx(e,r)}function Dx(e){if(e.tag===13||e.tag===31){var r=Ra(e,67108864);r!==null&&Nn(r,e,67108864),hd(e,67108864)}}function _x(e){if(e.tag===13||e.tag===31){var r=On();r=jn(r);var l=Ra(e,r);l!==null&&Nn(l,e,r),hd(e,r)}}var jo=!0;function P0(e,r,l,o){var m=D.T;D.T=null;var g=U.p;try{U.p=2,xd(e,r,l,o)}finally{U.p=g,D.T=m}}function V0(e,r,l,o){var m=D.T;D.T=null;var g=U.p;try{U.p=8,xd(e,r,l,o)}finally{U.p=g,D.T=m}}function xd(e,r,l,o){if(jo){var m=gd(o);if(m===null)nd(e,r,o,So,l),Bx(e,o);else if(W0(m,e,r,l,o))o.stopPropagation();else if(Bx(e,o),r&4&&-1<F0.indexOf(e)){for(;m!==null;){var g=Ja(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=Tt(g.pendingLanes);if(S!==0){var A=g;for(A.pendingLanes|=2,A.entangledLanes|=2;S;){var V=1<<31-Ft(S);A.entanglements[1]|=V,S&=~V}mr(g),(ft&6)===0&&(ro=We()+500,Ts(0))}}break;case 31:case 13:A=Ra(g,2),A!==null&&Nn(A,g,2),lo(),hd(g,2)}if(g=gd(o),g===null&&nd(e,r,o,So,l),g===m)break;m=g}m!==null&&o.stopPropagation()}else nd(e,r,o,null,l)}}function gd(e){return e=yc(e),vd(e)}var So=null;function vd(e){if(So=null,e=Za(e),e!==null){var r=u(e);if(r===null)e=null;else{var l=r.tag;if(l===13){if(e=d(r),e!==null)return e;e=null}else if(l===31){if(e=f(r),e!==null)return e;e=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null)}}return So=e,null}function Ox(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(wt()){case Ct:return 2;case Et:return 8;case zt:case xe:return 32;case qe:return 268435456;default:return 32}default:return 32}}var yd=!1,da=null,fa=null,pa=null,_s=new Map,Os=new Map,ma=[],F0="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 Bx(e,r){switch(e){case"focusin":case"focusout":da=null;break;case"dragenter":case"dragleave":fa=null;break;case"mouseover":case"mouseout":pa=null;break;case"pointerover":case"pointerout":_s.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Os.delete(r.pointerId)}}function Bs(e,r,l,o,m,g){return e===null||e.nativeEvent!==g?(e={blockedOn:r,domEventName:l,eventSystemFlags:o,nativeEvent:g,targetContainers:[m]},r!==null&&(r=Ja(r),r!==null&&Dx(r)),e):(e.eventSystemFlags|=o,r=e.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),e)}function W0(e,r,l,o,m){switch(r){case"focusin":return da=Bs(da,e,r,l,o,m),!0;case"dragenter":return fa=Bs(fa,e,r,l,o,m),!0;case"mouseover":return pa=Bs(pa,e,r,l,o,m),!0;case"pointerover":var g=m.pointerId;return _s.set(g,Bs(_s.get(g)||null,e,r,l,o,m)),!0;case"gotpointercapture":return g=m.pointerId,Os.set(g,Bs(Os.get(g)||null,e,r,l,o,m)),!0}return!1}function Ix(e){var r=Za(e.target);if(r!==null){var l=u(r);if(l!==null){if(r=l.tag,r===13){if(r=d(l),r!==null){e.blockedOn=r,we(e.priority,function(){_x(l)});return}}else if(r===31){if(r=f(l),r!==null){e.blockedOn=r,we(e.priority,function(){_x(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ko(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.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 r=Ja(l),r!==null&&Dx(r),e.blockedOn=l,!1;r.shift()}return!0}function $x(e,r,l){ko(e)&&l.delete(r)}function G0(){yd=!1,da!==null&&ko(da)&&(da=null),fa!==null&&ko(fa)&&(fa=null),pa!==null&&ko(pa)&&(pa=null),_s.forEach($x),Os.forEach($x)}function wo(e,r){e.blockedOn===r&&(e.blockedOn=null,yd||(yd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,G0)))}var Co=null;function Ux(e){Co!==e&&(Co=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Co===e&&(Co=null);for(var r=0;r<e.length;r+=3){var l=e[r],o=e[r+1],m=e[r+2];if(typeof o!="function"){if(vd(o||l)===null)continue;break}var g=Ja(l);g!==null&&(e.splice(r,3),r-=3,gu(g,{pending:!0,data:m,method:l.method,action:o},o,m))}}))}function Dl(e){function r(V){return wo(V,e)}da!==null&&wo(da,e),fa!==null&&wo(fa,e),pa!==null&&wo(pa,e),_s.forEach(r),Os.forEach(r);for(var l=0;l<ma.length;l++){var o=ma[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<ma.length&&(l=ma[0],l.blockedOn===null);)Ix(l),l.blockedOn===null&&ma.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(o=0;o<l.length;o+=3){var m=l[o],g=l[o+1],S=m[ht]||null;if(typeof g=="function")S||Ux(l);else if(S){var A=null;if(g&&g.hasAttribute("formAction")){if(m=g,S=g[ht]||null)A=S.formAction;else if(vd(m)!==null)continue}else A=S.action;typeof A=="function"?l[o+1]=A:(l.splice(o,3),o-=3),Ux(l)}}}function Hx(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return m=S})},focusReset:"manual",scroll:"manual"})}function r(){m!==null&&(m(),m=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,m=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),m!==null&&(m(),m=null)}}}function bd(e){this._internalRoot=e}Eo.prototype.render=bd.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(i(409));var l=r.current,o=On();Mx(l,o,e,r,null,null)},Eo.prototype.unmount=bd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;Mx(e.current,2,null,e,null,null),lo(),r[dn]=null}};function Eo(e){this._internalRoot=e}Eo.prototype.unstable_scheduleHydration=function(e){if(e){var r=be();e={blockedOn:null,target:e,priority:r};for(var l=0;l<ma.length&&r!==0&&r<ma[l].priority;l++);ma.splice(l,0,e),l===0&&Ix(e)}};var Px=a.version;if(Px!=="19.2.4")throw Error(i(527,Px,"19.2.4"));U.findDOMNode=function(e){var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=x(r),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var q0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var No=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!No.isDisabled&&No.supportsFiber)try{St=No.inject(q0),dt=No}catch{}}return $s.createRoot=function(e,r){if(!c(e))throw Error(i(299));var l=!1,o="",m=Km,g=Xm,S=Qm;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(o=r.identifierPrefix),r.onUncaughtError!==void 0&&(m=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=Ax(e,1,!1,null,null,l,o,null,m,g,S,Hx),e[dn]=r.current,td(e),new bd(r)},$s.hydrateRoot=function(e,r,l){if(!c(e))throw Error(i(299));var o=!1,m="",g=Km,S=Xm,A=Qm,V=null;return l!=null&&(l.unstable_strictMode===!0&&(o=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(S=l.onCaughtError),l.onRecoverableError!==void 0&&(A=l.onRecoverableError),l.formState!==void 0&&(V=l.formState)),r=Ax(e,1,!0,r,l??null,o,m,V,g,S,A,Hx),r.context=Lx(null),l=r.current,o=On(),o=jn(o),m=Jr(o),m.callback=null,ea(l,m,o),l=o,r.current.lanes=l,rr(r,l),mr(r),e[dn]=r.current,td(e),new Eo(r)},$s.version="19.2.4",$s}var Zx;function nj(){if(Zx)return kd.exports;Zx=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=tj(),kd.exports}var rj=nj();/**
|
|
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 Jx="popstate";function eg(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function aj(t={}){function a(c,u){let{pathname:d="/",search:f="",hash:h=""}=Fl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),uf("",{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:Js(u))}function i(c,u){or(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return sj(a,s,i,t)}function Jt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function or(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function lj(){return Math.random().toString(36).substring(2,10)}function tg(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 uf(t,a,s=null,i,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Fl(a):a,state:s,key:a&&a.key||i||lj(),unstable_mask:c}}function Js({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 Fl(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 sj(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 C=v(),T=C==null?null:C-x;x=C,h&&h({action:f,location:w.location,delta:T})}function b(C,T){f="PUSH";let E=eg(C)?C:uf(w.location,C,T);s&&s(E,C),x=v()+1;let R=tg(E,x),O=w.createHref(E.unstable_mask||E);try{d.pushState(R,"",O)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;c.location.assign(O)}u&&h&&h({action:f,location:w.location,delta:1})}function j(C,T){f="REPLACE";let E=eg(C)?C:uf(w.location,C,T);s&&s(E,C),x=v();let R=tg(E,x),O=w.createHref(E.unstable_mask||E);d.replaceState(R,"",O),u&&h&&h({action:f,location:w.location,delta:0})}function k(C){return ij(C)}let w={get action(){return f},get location(){return t(c,d)},listen(C){if(h)throw new Error("A history only accepts one active listener");return c.addEventListener(Jx,y),h=C,()=>{c.removeEventListener(Jx,y),h=null}},createHref(C){return a(c,C)},createURL:k,encodeLocation(C){let T=k(C);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:b,replace:j,go(C){return d.go(C)}};return w}function ij(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Jt(s,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:Js(t);return i=i.replace(/ $/,"%20"),!a&&i.startsWith("//")&&(i=s+i),new URL(i,s)}function Bv(t,a,s="/"){return oj(t,a,s,!1)}function oj(t,a,s,i){let c=typeof a=="string"?Fl(a):a,u=Fr(c.pathname||"/",s);if(u==null)return null;let d=Iv(t);cj(d);let f=null;for(let h=0;f==null&&h<d.length;++h){let x=bj(u);f=vj(d[h],x,i)}return f}function Iv(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;Jt(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=vr([i,v.relativePath]),b=s.concat(v);d.children&&d.children.length>0&&(Jt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Iv(d.children,a,b,y,h)),!(d.path==null&&!d.index)&&a.push({path:y,score:xj(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 $v(d.path))u(d,f,!0,x)}),a}function $v(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=$v(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 cj(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:gj(a.routesMeta.map(i=>i.childrenIndex),s.routesMeta.map(i=>i.childrenIndex)))}var uj=/^:[\w-]+$/,dj=3,fj=2,pj=1,mj=10,hj=-2,ng=t=>t==="*";function xj(t,a){let s=t.split("/"),i=s.length;return s.some(ng)&&(i+=hj),a&&(i+=fj),s.filter(c=>!ng(c)).reduce((c,u)=>c+(uj.test(u)?dj:u===""?pj:mj),i)}function gj(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 vj(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=Yo({path:h.relativePath,caseSensitive:h.caseSensitive,end:x},v),b=h.route;if(!y&&x&&s&&!i[i.length-1].route.index&&(y=Yo({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},v)),!y)return null;Object.assign(c,y.params),d.push({params:c,pathname:vr([u,y.pathname]),pathnameBase:wj(vr([u,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(u=vr([u,y.pathnameBase]))}return d}function Yo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,i]=yj(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 yj(t,a=!1,s=!0){or(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 bj(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return or(!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 Fr(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 jj=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Sj(t,a="/"){let{pathname:s,search:i="",hash:c=""}=typeof t=="string"?Fl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=rg(s.substring(1),"/"):u=rg(s,a)):u=a,{pathname:u,search:Cj(i),hash:Ej(c)}}function rg(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 kj(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function Uv(t){let a=kj(t);return a.map((s,i)=>i===a.length-1?s.pathname:s.pathnameBase)}function Mf(t,a,s,i=!1){let c;typeof t=="string"?c=Fl(t):(c={...t},Jt(!c.pathname||!c.pathname.includes("?"),Nd("?","pathname","search",c)),Jt(!c.pathname||!c.pathname.includes("#"),Nd("#","pathname","hash",c)),Jt(!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=Sj(c,f),x=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&s.endsWith("/");return!h.pathname.endsWith("/")&&(x||v)&&(h.pathname+="/"),h}var vr=t=>t.join("/").replace(/\/\/+/g,"/"),wj=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Cj=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Ej=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Nj=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 Tj(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Rj(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Hv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pv(t,a){let s=t;if(typeof s!="string"||!jj.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let i=s,c=!1;if(Hv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),f=Fr(d.pathname,a);d.origin===u.origin&&f!=null?s=f+d.search+d.hash:c=!0}catch{or(!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 Vv=["POST","PUT","PATCH","DELETE"];new Set(Vv);var Aj=["GET",...Vv];new Set(Aj);var Wl=p.createContext(null);Wl.displayName="DataRouter";var tc=p.createContext(null);tc.displayName="DataRouterState";var Lj=p.createContext(!1),Fv=p.createContext({isTransitioning:!1});Fv.displayName="ViewTransition";var Mj=p.createContext(new Map);Mj.displayName="Fetchers";var zj=p.createContext(null);zj.displayName="Await";var tr=p.createContext(null);tr.displayName="Navigation";var nc=p.createContext(null);nc.displayName="Location";var Wr=p.createContext({outlet:null,matches:[],isDataRoute:!1});Wr.displayName="Route";var zf=p.createContext(null);zf.displayName="RouteError";var Wv="REACT_ROUTER_ERROR",Dj="REDIRECT",_j="ROUTE_ERROR_RESPONSE";function Oj(t){if(t.startsWith(`${Wv}:${Dj}:{`))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 Bj(t){if(t.startsWith(`${Wv}:${_j}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new Nj(a.status,a.statusText,a.data)}catch{}}function Ij(t,{relative:a}={}){Jt(ii(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:i}=p.useContext(tr),{hash:c,pathname:u,search:d}=oi(t,{relative:a}),f=u;return s!=="/"&&(f=u==="/"?s:vr([s,u])),i.createHref({pathname:f,search:d,hash:c})}function ii(){return p.useContext(nc)!=null}function ba(){return Jt(ii(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(nc).location}var Gv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function qv(t){p.useContext(tr).static||p.useLayoutEffect(t)}function $j(){let{isDataRoute:t}=p.useContext(Wr);return t?Zj():Uj()}function Uj(){Jt(ii(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Wl),{basename:a,navigator:s}=p.useContext(tr),{matches:i}=p.useContext(Wr),{pathname:c}=ba(),u=JSON.stringify(Uv(i)),d=p.useRef(!1);return qv(()=>{d.current=!0}),p.useCallback((h,x={})=>{if(or(d.current,Gv),!d.current)return;if(typeof h=="number"){s.go(h);return}let v=Mf(h,JSON.parse(u),c,x.relative==="path");t==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:vr([a,v.pathname])),(x.replace?s.replace:s.push)(v,x.state,x)},[a,s,u,c,t])}p.createContext(null);function oi(t,{relative:a}={}){let{matches:s}=p.useContext(Wr),{pathname:i}=ba(),c=JSON.stringify(Uv(s));return p.useMemo(()=>Mf(t,JSON.parse(c),i,a==="path"),[t,c,i,a])}function Hj(t,a,s){Jt(ii(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=p.useContext(tr),{matches:c}=p.useContext(Wr),u=c[c.length-1],d=u?u.params:{},f=u?u.pathname:"/",h=u?u.pathnameBase:"/",x=u&&u.route;{let C=x&&x.path||"";Kv(f,!x||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
60
|
+
|
|
61
|
+
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let v=ba(),y;y=v;let b=y.pathname||"/",j=b;if(h!=="/"){let C=h.replace(/^\//,"").split("/");j="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=Bv(t,{pathname:j});return or(x||k!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),or(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.`),Gj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:vr([h,i.encodeLocation?i.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?h:vr([h,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function Pj(){let t=Qj(),a=Tj(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=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:u},"ErrorBoundary")," or"," ",p.createElement("code",{style:u},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},a),s?p.createElement("pre",{style:c},s):null,d)}var Vj=p.createElement(Pj,null),Yv=class extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,a){return a.location!==t.location||a.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:a.error,location:a.location,revalidation:t.revalidation||a.revalidation}}componentDidCatch(t,a){this.props.onError?this.props.onError(t,a):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=Bj(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(Wr.Provider,{value:this.props.routeContext},p.createElement(zf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(Fj,{error:t},a):a}};Yv.contextType=Lj;var Td=new WeakMap;function Fj({children:t,error:a}){let{basename:s}=p.useContext(tr);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=Oj(a.digest);if(i){let c=Td.get(a);if(c)throw c;let u=Pv(i.location,s);if(Hv&&!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 p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Wj({routeContext:t,match:a,children:s}){let i=p.useContext(Wl);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(Wr.Provider,{value:t},s)}function Gj(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);Jt(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:Rj(i.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let j,k=!1,w=null,C=null;i&&(j=u&&y.route.id?u[y.route.id]:void 0,w=y.route.errorElement||Vj,d&&(f<0&&b===0?(Kv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):f===b&&(k=!0,C=y.route.hydrateFallbackElement||null)));let T=a.concat(c.slice(0,b+1)),E=()=>{let R;return j?R=w:k?R=C:y.route.Component?R=p.createElement(y.route.Component,null):y.route.element?R=y.route.element:R=v,p.createElement(Wj,{match:y,routeContext:{outlet:v,matches:T,isDataRoute:i!=null},children:R})};return i&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?p.createElement(Yv,{location:i.location,revalidation:i.revalidation,component:w,error:j,children:E(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:x}):E()},null)}function Df(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qj(t){let a=p.useContext(Wl);return Jt(a,Df(t)),a}function Yj(t){let a=p.useContext(tc);return Jt(a,Df(t)),a}function Kj(t){let a=p.useContext(Wr);return Jt(a,Df(t)),a}function _f(t){let a=Kj(t),s=a.matches[a.matches.length-1];return Jt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Xj(){return _f("useRouteId")}function Qj(){var i;let t=p.useContext(zf),a=Yj("useRouteError"),s=_f("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function Zj(){let{router:t}=qj("useNavigate"),a=_f("useNavigate"),s=p.useRef(!1);return qv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{or(s.current,Gv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var ag={};function Kv(t,a,s){!a&&!ag[t]&&(ag[t]=!0,or(!1,s))}p.memo(Jj);function Jj({routes:t,future:a,state:s,isStatic:i,onError:c}){return Hj(t,void 0,{state:s,isStatic:i,onError:c})}function eS({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Jt(!ii(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=t.replace(/^\/*/,"/"),h=p.useMemo(()=>({basename:f,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[f,c,u,d]);typeof s=="string"&&(s=Fl(s));let{pathname:x="/",search:v="",hash:y="",state:b=null,key:j="default",unstable_mask:k}=s,w=p.useMemo(()=>{let C=Fr(x,f);return C==null?null:{location:{pathname:C,search:v,hash:y,state:b,key:j,unstable_mask:k},navigationType:i}},[f,x,v,y,b,j,i,k]);return or(w!=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.`),w==null?null:p.createElement(tr.Provider,{value:h},p.createElement(nc.Provider,{children:a,value:w}))}var Ho="get",Po="application/x-www-form-urlencoded";function rc(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function tS(t){return rc(t)&&t.tagName.toLowerCase()==="button"}function nS(t){return rc(t)&&t.tagName.toLowerCase()==="form"}function rS(t){return rc(t)&&t.tagName.toLowerCase()==="input"}function aS(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function lS(t,a){return t.button===0&&(!a||a==="_self")&&!aS(t)}var To=null;function sS(){if(To===null)try{new FormData(document.createElement("form"),0),To=!1}catch{To=!0}return To}var iS=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Rd(t){return t!=null&&!iS.has(t)?(or(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Po}"`),null):t}function oS(t,a){let s,i,c,u,d;if(nS(t)){let f=t.getAttribute("action");i=f?Fr(f,a):null,s=t.getAttribute("method")||Ho,c=Rd(t.getAttribute("enctype"))||Po,u=new FormData(t)}else if(tS(t)||rS(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?Fr(h,a):null,s=t.getAttribute("formmethod")||f.getAttribute("method")||Ho,c=Rd(t.getAttribute("formenctype"))||Rd(f.getAttribute("enctype"))||Po,u=new FormData(f,t),!sS()){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=Ho,i=null,c=Po,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 Of(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function cS(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&&Fr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${i}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${i}`,c}async function uS(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 dS(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 fS(t,a,s){let i=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await uS(u,s);return d.links?d.links():[]}return[]}));return xS(i.flat(1).filter(dS).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function lg(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 pS(t,a,{includeHydrateFallback:s}={}){return mS(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 mS(t){return[...new Set(t)]}function hS(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function xS(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(hS(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Xv(){let t=p.useContext(Wl);return Of(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function gS(){let t=p.useContext(tc);return Of(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Bf=p.createContext(void 0);Bf.displayName="FrameworkContext";function Qv(){let t=p.useContext(Bf);return Of(t,"You must render this element inside a <HydratedRouter> element"),t}function vS(t,a){let s=p.useContext(Bf),[i,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:f,onBlur:h,onMouseEnter:x,onMouseLeave:v,onTouchStart:y}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let w=T=>{T.forEach(E=>{d(E.isIntersecting)})},C=new IntersectionObserver(w,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),p.useEffect(()=>{if(i){let w=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(w)}}},[i]);let j=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Us(f,j),onBlur:Us(h,k),onMouseEnter:Us(x,j),onMouseLeave:Us(v,k),onTouchStart:Us(y,j)}]:[!1,b,{}]}function Us(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function yS({page:t,...a}){let{router:s}=Xv(),i=p.useMemo(()=>Bv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?p.createElement(jS,{page:t,matches:i,...a}):null}function bS(t){let{manifest:a,routeModules:s}=Qv(),[i,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return fS(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function jS({page:t,matches:a,...s}){let i=ba(),{future:c,manifest:u,routeModules:d}=Qv(),{basename:f}=Xv(),{loaderData:h,matches:x}=gS(),v=p.useMemo(()=>lg(t,a,x,u,i,"data"),[t,a,x,u,i]),y=p.useMemo(()=>lg(t,a,x,u,i,"assets"),[t,a,x,u,i]),b=p.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let w=new Set,C=!1;if(a.forEach(E=>{var O;let R=u.routes[E.route.id];!R||!R.hasLoader||(!v.some(L=>L.route.id===E.route.id)&&E.route.id in h&&((O=d[E.route.id])!=null&&O.shouldRevalidate)||R.hasClientLoader?C=!0:w.add(E.route.id))}),w.size===0)return[];let T=cS(t,f,c.unstable_trailingSlashAwareDataRequests,"data");return C&&w.size>0&&T.searchParams.set("_routes",a.filter(E=>w.has(E.route.id)).map(E=>E.route.id).join(",")),[T.pathname+T.search]},[f,c.unstable_trailingSlashAwareDataRequests,h,i,u,v,a,t,d]),j=p.useMemo(()=>pS(y,u),[y,u]),k=bS(y);return p.createElement(p.Fragment,null,b.map(w=>p.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...s})),j.map(w=>p.createElement("link",{key:w,rel:"modulepreload",href:w,...s})),k.map(({key:w,link:C})=>p.createElement("link",{key:w,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function SS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var kS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{kS&&(window.__reactRouterVersion="7.13.1")}catch{}function wS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=p.useRef();c.current==null&&(c.current=aj({window:i,v5Compat:!0}));let u=c.current,[d,f]=p.useState({action:u.action,location:u.location}),h=p.useCallback(x=>{s===!1?f(x):p.startTransition(()=>f(x))},[s]);return p.useLayoutEffect(()=>u.listen(h),[u,h]),p.createElement(eS,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Zv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Jv=p.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},w){let{basename:C,navigator:T,unstable_useTransitions:E}=p.useContext(tr),R=typeof v=="string"&&Zv.test(v),O=Pv(v,C);v=O.to;let L=Ij(v,{relative:c}),P=ba(),N=null;if(f){let $=Mf(f,[],P.unstable_mask?P.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:vr([C,$.pathname])),N=T.createHref($)}let[B,z,_]=vS(i,k),H=TS(v,{replace:d,unstable_mask:f,state:h,target:x,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:j,unstable_useTransitions:E});function W($){a&&a($),$.defaultPrevented||H($)}let q=!(O.isExternal||u),ee=p.createElement("a",{...k,..._,href:(q?N:void 0)||O.absoluteURL||L,onClick:q?W:a,ref:SS(w,z),target:x,"data-discover":!R&&s==="render"?"true":void 0});return B&&!R?p.createElement(p.Fragment,null,ee,p.createElement(yS,{page:L})):ee});Jv.displayName="Link";var CS=p.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=oi(d,{relative:x.relative}),b=ba(),j=p.useContext(tc),{navigator:k,basename:w}=p.useContext(tr),C=j!=null&&zS(y)&&f===!0,T=k.encodeLocation?k.encodeLocation(y).pathname:y.pathname,E=b.pathname,R=j&&j.navigation&&j.navigation.location?j.navigation.location.pathname:null;s||(E=E.toLowerCase(),R=R?R.toLowerCase():null,T=T.toLowerCase()),R&&w&&(R=Fr(R,w)||R);const O=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let L=E===T||!c&&E.startsWith(T)&&E.charAt(O)==="/",P=R!=null&&(R===T||!c&&R.startsWith(T)&&R.charAt(T.length)==="/"),N={isActive:L,isPending:P,isTransitioning:C},B=L?a:void 0,z;typeof i=="function"?z=i(N):z=[i,L?"active":null,P?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(N):u;return p.createElement(Jv,{...x,"aria-current":B,className:z,ref:v,style:_,to:d,viewTransition:f},typeof h=="function"?h(N):h)});CS.displayName="NavLink";var ES=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Ho,action:f,onSubmit:h,relative:x,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...j},k)=>{let{unstable_useTransitions:w}=p.useContext(tr),C=LS(),T=MS(f,{relative:x}),E=d.toLowerCase()==="get"?"get":"post",R=typeof f=="string"&&Zv.test(f),O=L=>{if(h&&h(L),L.defaultPrevented)return;L.preventDefault();let P=L.nativeEvent.submitter,N=(P==null?void 0:P.getAttribute("formmethod"))||d,B=()=>C(P||L.currentTarget,{fetcherKey:a,method:N,navigate:s,replace:c,state:u,relative:x,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});w&&s!==!1?p.startTransition(()=>B()):B()};return p.createElement("form",{ref:k,method:E,action:T,onSubmit:i?h:O,...j,"data-discover":!R&&t==="render"?"true":void 0})});ES.displayName="Form";function NS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ey(t){let a=p.useContext(Wl);return Jt(a,NS(t)),a}function TS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:h,unstable_useTransitions:x}={}){let v=$j(),y=ba(),b=oi(t,{relative:d});return p.useCallback(j=>{if(lS(j,a)){j.preventDefault();let k=s!==void 0?s:Js(y)===Js(b),w=()=>v(t,{replace:k,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:h});x?p.startTransition(()=>w()):w()}},[y,v,b,s,i,c,a,t,u,d,f,h,x])}var RS=0,AS=()=>`__${String(++RS)}__`;function LS(){let{router:t}=ey("useSubmit"),{basename:a}=p.useContext(tr),s=Xj(),i=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:f,method:h,encType:x,formData:v,body:y}=oS(u,a);if(d.navigate===!1){let b=d.fetcherKey||AS();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 MS(t,{relative:a}={}){let{basename:s}=p.useContext(tr),i=p.useContext(Wr);Jt(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...oi(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:vr([s,u.pathname])),Js(u)}function zS(t,{relative:a}={}){let s=p.useContext(Fv);Jt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=ey("useViewTransitionState"),c=oi(t,{relative:a});if(!s.isTransitioning)return!1;let u=Fr(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Fr(s.nextLocation.pathname,i)||s.nextLocation.pathname;return Yo(c.pathname,d)!=null||Yo(c.pathname,u)!=null}var ac=Ov();const DS=_v(ac),_S="modulepreload",OS=function(t){return"/"+t},sg={},Gl=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=OS(x),x in sg)return;sg[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":_S,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)})},BS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Ro(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!BS.test(a)||a==="0.0.0"?null:a}function ty(t){if(t.preferInstalled){const c=Ro(t.installedCurrentVersion);if(c)return{version:c,versionSource:"registry"}}const a=Ro(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=Ro(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=Ro(t.pluginVersion);return i?{version:i,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const ig={own:"authoring-project",installed:"available-project",global:"available-personal"},df=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function IS(t){if(typeof t=="string"){if(df.has(t))return t;if(Object.prototype.hasOwnProperty.call(ig,t))return ig[t]}return"authoring-project"}function $S(t){return t.startsWith("available-")?"available":"authoring"}function US(t){const a=t.indexOf("-");return t.slice(a+1)}const Zn="";class Vr 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(`${Zn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new Vr((i==null?void 0:i.error)||`HTTP ${s.status}`,s.status,c)}return s.json()}async function og(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 cg=100;function ug(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 HS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Bl(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 PS(t){if(!t||typeof t!="object")return null;const a=t,s=Vt(a.python)??void 0,i=Bl(a.pip)??void 0,c=Vt(a.node)??void 0;return!s&&!i&&!c?null:{python:s,pip:i,node:c}}function VS(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:Bl(a.requires)??void 0}}function FS(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"&&df.has(a.scopeV2)?a.scopeV2:IS(a.scope),d=$S(u),f=US(u),h=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let x;a.shadowedBy===null?x=null:typeof a.shadowedBy=="string"&&df.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:Bl(a.tags),deps:Bl(a.deps),mcpDeps:Bl(a.mcpDeps),entryPoint:Vt(a.entryPoint),lastModified:Vt(a.lastModified),sizeBytes:HS(a.sizeBytes),sourceAgent:Vt(a.sourceAgent),secrets:Bl(a.secrets),runtime:PS(a.runtime),integrationTests:VS(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=ty({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(FS):[]},getSkillInstallState(t){return Oe(`/api/studio/install-state?skill=${encodeURIComponent(t)}`)},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(`${Zn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new Vr(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=`${Zn}/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=`${Zn}/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=`${Zn}/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=`${Zn}/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 w=await v.read();if(b=w.done,w.value){const C=y.decode(w.value,{stream:!b});j+=C,x.length<200&&(x+=C)}}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(`${Zn}/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(`${Zn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];const a=[...t].sort(),s=ug(a,cg),i=async u=>{try{const d=await og(`${Zn}/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=ug(t,cg),s=async u=>{try{const d=await og(`${Zn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:u.map(x=>({name:x.name,currentVersion:x.currentVersion??"0.0.0"}))})});if(!d.ok)return{ok:!1,map:new Map};const f=await d.json().catch(()=>null),h=Array.isArray(f)?f:Array.isArray(f==null?void 0:f.results)?f.results:[];return{ok:!0,map:new Map(h.filter(x=>typeof x.name=="string"&&x.name.length>0).map(x=>[x.name,x]))}}catch{return{ok:!1,map:new Map}}},i=await Promise.all(a.map(s));if(i.length>0&&i.every(u=>!u.ok))throw new Error("resolveInstalledSkillIds: all chunks failed");const c=new Map;for(const u of i)for(const[d,f]of u.map)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}})},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(`${Zn}/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(`${Zn}${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 Vr(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 w={type:f,...k};a==null||a(w),w.type==="done"&&(h=w),w.type==="error"&&(x=w)}f=""}}if(x){const v=new Vr(x.message,500);throw v.code=x.code,v}if(!h)throw new Vr("Transfer stream ended without 'done' event",500);return h}function WS(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 GS(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&&!WS(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=ty({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 Vo=new Map,Va=new Map,Fs=new Map;function In(t){Vo.delete(t),Va.delete(t);const a=Fs.get(t);if(a)for(const s of a)s()}function qa(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=p.useState(0),[d,f]=p.useState(void 0),[h,x]=p.useState(0),v=p.useRef(!0),y=p.useRef(t);y.current=t;const b=()=>{f(void 0),In(t),x(w=>w+1)};p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),p.useEffect(()=>{if(!c)return;const w=()=>{v.current&&x(C=>C+1)};return Fs.has(t)||Fs.set(t,new Set),Fs.get(t).add(w),()=>{var C;(C=Fs.get(t))==null||C.delete(w)}},[t,c]),p.useEffect(()=>{if(!c)return;const w=Vo.get(t);if(!(!w||Date.now()-w.fetchedAt>i))return;if(Va.has(t)){const R=Va.get(t),O=()=>{v.current&&y.current===t&&u(L=>L+1)};R.subscribers.push(O);return}const T={promise:Promise.resolve(),subscribers:[]},E=a().then(R=>{Vo.set(t,{data:R,fetchedAt:Date.now()}),Va.delete(t),v.current&&y.current===t&&(f(void 0),u(O=>O+1));for(const O of T.subscribers)O()},R=>{Va.delete(t);const O=R instanceof Error?R:new Error(String(R));v.current&&y.current===t&&(f(O),u(L=>L+1));for(const L of T.subscribers)L()});T.promise=E,Va.set(t,T)},[t,a,i,c,h]);const j=Vo.get(t),k=c&&!j&&!d&&Va.has(t);return{data:j==null?void 0:j.data,loading:k,error:d,revalidate:b}}function qS(t){const[a,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.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 YS=500,ff="vskill.updates.seenLastId";function KS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(ff)}catch{return null}}function Ld(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(ff):window.localStorage.setItem(ff,t)}catch{}}function XS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=KS();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>YS){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 Pa=XS(),QS=3e5,ZS=500,JS=15e3,e2=6e4,t2=6e4,n2="/api/v1/skills/stream";function dg(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 fg(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function r2(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 a2(t){const a=(t==null?void 0:t.intervalMs)??QS,s=(t==null?void 0:t.debounceMs)??ZS,i=(t==null?void 0:t.timeoutMs)??JS,c=(t==null?void 0:t.staleAfterMs)??e2,u=(t==null?void 0:t.disconnectFallbackMs)??t2,d=(t==null?void 0:t.streamUrlBase)??n2,f=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),h=p.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[x,v]=p.useState([]),[y,b]=p.useState(()=>new Map),[j,k]=p.useState(0),[w,C]=p.useState(!1),[T,E]=p.useState(null),[R,O]=p.useState(null),L=p.useRef(null),P=p.useRef(null),N=p.useRef(null),B=p.useRef(null),z=p.useRef(!0),[_,H]=p.useState(()=>f?"connecting":"fallback"),W=p.useRef(_);W.current=_;const q=p.useSyncExternalStore(M=>Pa.subscribe(M),()=>Pa.getSnapshot(),()=>Pa.getSnapshot()),ee=q.size,$=p.useCallback(async()=>{C(!0);const M=new AbortController,I=setTimeout(()=>M.abort(),i);try{const K=await Promise.race([ke.getSkillUpdates(),new Promise((Q,ue)=>{M.signal.addEventListener("abort",()=>{ue(new Error("TIMEOUT"))})})]);if(K==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;v(K),b(dg(K)),k(fg(K)),P.current=Date.now(),E(P.current),O(null)}catch(K){if(!z.current)return;O(K instanceof Error?K:new Error(String(K)))}finally{clearTimeout(I),z.current&&C(!1)}},[i]),D=p.useCallback(()=>{if(L.current)return L.current;const M=$().finally(()=>{L.current=null});return L.current=M,M},[$]),U=p.useCallback(()=>{N.current==null&&(N.current=setInterval(()=>{D()},a))},[a,D]),F=p.useCallback(()=>{N.current!=null&&(clearInterval(N.current),N.current=null)},[]);p.useEffect(()=>{z.current=!0,(P.current==null||Date.now()-P.current>c)&&D(),(typeof document>"u"||document.visibilityState!=="hidden")&&U();const K=()=>{if(B.current&&(clearTimeout(B.current),B.current=null),document.visibilityState==="hidden"){F();return}B.current=setTimeout(()=>{B.current=null,(P.current==null||Date.now()-P.current>c)&&D(),U()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",K),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",K),B.current&&clearTimeout(B.current),F()}},[]);const Y=p.useCallback(async M=>{if(M.length!==0)try{const I=await ke.checkSkillUpdates(M);if(!z.current||I.length===0)return;const K=Date.now(),Q=I.filter(te=>te.skillId&&te.eventId&&te.version).map(te=>({skillId:te.skillId,version:te.version,eventId:te.eventId,publishedAt:te.publishedAt,diffSummary:te.diffSummary,receivedAt:K}));Q.length>0&&Pa.mergeBulk(Q);const ue=I.filter(te=>typeof te.trackedForUpdates=="boolean"||typeof te.updateAvailable=="boolean").map(te=>({name:te.name??te.skillId,installed:te.installed??"",latest:te.latest??null,updateAvailable:te.updateAvailable??!1,trackedForUpdates:typeof te.trackedForUpdates=="boolean"?te.trackedForUpdates:void 0}));ue.length>0&&v(te=>{const ie=new Map;for(const je of te)ie.set(je.name,je);let J=0;for(const je of ue){const Ne=je.name,De=ie.get(Ne);if(De){const He={...De};De.trackedForUpdates===void 0&&je.trackedForUpdates!==void 0&&(He.trackedForUpdates=je.trackedForUpdates),ie.set(Ne,He)}else ie.set(Ne,{name:je.name,installed:je.installed??"",latest:je.latest??null,updateAvailable:je.updateAvailable??!1,trackedForUpdates:je.trackedForUpdates}),J+=1}if(J===0&&ie.size===te.length)return te;const he=[...ie.values()];return b(dg(he)),k(fg(he)),he})}catch{}},[]);p.useEffect(()=>{const M=f||h;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const I=M.split(","),K=`${d}?skills=${encodeURIComponent(M)}`;let Q=null,ue=null,te=null;const ie=()=>{ue==null&&(ue=setTimeout(()=>{ue=null,z.current&&W.current!=="connected"&&H("fallback")},u))},J=()=>{ue!=null&&(clearTimeout(ue),ue=null)};ie();const he=1e3,je=()=>{z.current&&te==null&&(te=setTimeout(()=>{if(te=null,!!z.current&&!(Q&&Q.readyState!==EventSource.CLOSED)){if(Q)try{Q.close()}catch{}He()}},he))},Ne=Ue=>{if(!z.current)return;let _e;try{_e=JSON.parse(Ue.data)}catch{return}if(!r2(_e)||Pa.ingest(_e)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const ce=`${_e.skillId} updated to ${_e.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:ce,severity:"info",skillId:_e.skillId,version:_e.version,eventId:_e.eventId}}))}},De=()=>{z.current&&(Pa.clearSeen(),Y(I))},He=()=>{z.current&&(Q=new EventSource(K),Q.onopen=()=>{z.current&&(J(),H("connected"))},Q.onerror=()=>{z.current&&(ie(),Q&&Q.readyState===EventSource.CLOSED&&je())},Q.onmessage=Ne,Q.addEventListener("gone",De))};return He(),()=>{if(J(),te!=null&&(clearTimeout(te),te=null),Q){try{Q.removeEventListener("gone",De)}catch{}try{Q.close()}catch{}}}},[f,h,d,u,Y]),p.useEffect(()=>{if(!h)return;const M=h.split(",");Y(M)},[h,Y]);const oe=p.useCallback(M=>{Pa.dismiss(M)},[]);return{updates:x,updatesMap:y,updateCount:j,isRefreshing:w,lastFetchAt:T,error:R,refresh:D,updatesById:q,pushUpdateCount:ee,status:_,dismiss:oe}}function l2(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 s2={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function i2(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 ny=p.createContext(null),ry=ny;function ur(){const t=p.useContext(ry);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function o2({children:t}){const[a,s]=p.useReducer(i2,s2),i=qS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=p.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]=p.useState(c!==null);p.useEffect(()=>{function Y(oe){if(!(oe instanceof CustomEvent))return;const M=oe.detail;M!=null&&M.agentId&&(u(M.agentId),f(!0))}return window.addEventListener("studio:agent-changed",Y),()=>window.removeEventListener("studio:agent-changed",Y)},[]),p.useEffect(()=>{if(d)return;let Y=!1;return ke.getAgents().then(oe=>{if(Y)return;const M=(oe==null?void 0:oe.suggested)??"claude-code";u(I=>I??M),f(!0)}).catch(()=>{Y||(u(oe=>oe??"claude-code"),f(!0))}),()=>{Y=!0}},[d]);const h=p.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 M=window.location.hash,I=M.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(I){const[,Q,ue,te]=I,ie=Q,J=oe.find(je=>je.plugin===ue&&je.skill===te&&je.source===ie);if(J){s({type:"SELECT_SKILL",skill:{plugin:ue,skill:te,origin:J.origin,source:J.source}});return}const he=oe.find(je=>je.plugin===ue&&je.skill===te);he&&s({type:"SELECT_SKILL",skill:{plugin:ue,skill:te,origin:he.origin,source:he.source}});return}const K=M.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,Q,ue]=K,te=oe.find(ie=>ie.plugin===Q&&ie.skill===ue);te&&s({type:"SELECT_SKILL",skill:{plugin:Q,skill:ue,origin:te.origin,source:te.source}})}}).catch(oe=>s({type:"SET_SKILLS_ERROR",error:oe.message}))},[c,d]);p.useEffect(()=>{h()},[h]);const x=p.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=p.useRef(a.skills);p.useEffect(()=>{v.current=a.skills},[a.skills]);const y=p.useCallback((Y,oe)=>{const M=v.current,I=Y?M.find(te=>te.plugin===Y&&te.skill===oe):M.find(te=>te.skill===oe&&te.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=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),j=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=p.useCallback(Y=>{s({type:"SET_MODE",mode:Y})},[]),w=p.useCallback(Y=>{s({type:"SET_SEARCH",query:Y})},[]),C=p.useCallback(Y=>{s({type:"SET_MOBILE_VIEW",view:Y})},[]),T=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),E=p.useRef(new Map),R=p.useRef(""),O=p.useRef(!1),[L,P]=p.useState(""),N=p.useMemo(()=>a.skills.map(Y=>`${Y.plugin}/${Y.skill}`),[a.skills]),B=p.useMemo(()=>L?L.split(",").filter(Boolean):[],[L]),z=a2({skillIds:B,trackingSkillIds:N}),_=p.useRef("");p.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 M=Y.map(Q=>{const ue=oe.get(Q.skill),te=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:te}}),I=M.map(Q=>`${Q.plugin}/${Q.skill}@${Q.currentVersion}#${Q.name}`).sort().join("|");if(I===_.current)return;_.current=I;let K=!1;return ke.resolveInstalledSkillIds(M).then(Q=>{if(K)return;const ie=[...l2(Q).flatMap(J=>[J.uuid,J.slug].filter(Boolean))].sort().join(",");ie!==R.current&&(R.current=ie,E.current=new Map(Q.map(J=>[`${J.plugin}/${J.skill}`,{uuid:J.uuid,slug:J.slug}])),P(ie))}).catch(Q=>{if(K||(_.current=""),!O.current){O.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=p.useMemo(()=>{const Y=a.skills.map(oe=>{if(!oe.updateAvailable&&oe.latestVersion===void 0&&oe.trackedForUpdates===void 0)return oe;const M={...oe};return delete M.updateAvailable,delete M.currentVersion,delete M.latestVersion,delete M.trackedForUpdates,M});return GS(Y,z.updates)},[a.skills,z.updates]),W=p.useMemo(()=>{const Y={source:0,installed:0};for(const oe of H)oe.updateAvailable&&(Y[oe.origin]+=1);return Y},[H]),q=p.useMemo(()=>({...a,skills:H}),[a,H]),ee=z.updateCount,$=z.refresh,D=z.isRefreshing,U=p.useCallback((Y,oe)=>{$(),h(),In(`versions/${Y}/${oe}`),z.dismiss(`${Y}/${oe}`)},[$,h,z]),F=p.useMemo(()=>({state:q,selectSkill:x,clearSelection:j,setMode:k,setSearch:w,setMobileView:C,refreshSkills:h,updateCount:ee,dismissUpdateNotification:T,updates:z.updates,outdatedByOrigin:W,isRefreshingUpdates:D,refreshUpdates:$,revealSkill:y,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss,activeAgent:c,onSkillUpdated:U}),[q,x,j,k,w,C,h,ee,T,z.updates,W,D,$,y,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss,c,U]);return n.jsx(ry.Provider,{value:F,children:t})}const c2={config:null,loading:!0};function u2(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 ay=p.createContext(null);function Ya(){const t=p.useContext(ay);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function d2({children:t}){const[a,s]=p.useReducer(u2,c2),i=p.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{i()},[i]);const c=p.useCallback(async(d,f)=>{const h=await ke.setConfig(d,f);return s({type:"SET_CONFIG",config:h}),h},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return n.jsx(ay.Provider,{value:u,children:t})}function f2({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 n.jsxs("div",{className:"studio-shell",style:x,children:[u,n.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),n.jsxs("div",{style:v,children:[!h&&n.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,n.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),n.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:i}),n.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 p2={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}`},m2={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"},h2={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"},x2={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",cloneToAuthoring:"Clone to authoring…",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"},g2={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"},v2={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"},y2={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",cloneStarted:"Cloning to authoring…",cloneSucceeded:"Cloned to authoring.",cloneFailed:"Clone failed. Check eval-server logs.",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."},b2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},j2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},S2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},k2={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"},w2={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)."}},C2={subscriptionBilling:"· subscription",free:"· free"},E2={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`},N2={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.`},T2={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}`},R2={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.`},A2={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"},L2={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."},M2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},z2={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:p2,shell:m2,detail:h2,actions:x2,palette:g2,shortcuts:v2,toasts:y2,connection:b2,forms:j2,errors:S2,picker:k2,providers:w2,models:C2,settings:E2,statusBar:N2,scopePicker:T2,scopeSection:R2,claudeCodeLabel:A2,setupDrawer:L2,setupProviders:z2,scopeLabels:M2},pg=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],D2={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},_2={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},O2={"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"},B2={"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 I2(t,a){var f,h;const s=D2[t.id]??null,i=_2[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:B2[t.id]??"per-token",...x.pricing?{pricing:x.pricing}:{},...x.resolvedId?{resolvedId:x.resolvedId}:{}}));return{id:t.id,displayName:$2(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:O2[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function $2(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 U2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of pg){const c=a.get(i);c&&s.push(c)}for(const i of t)pg.includes(i.id)||s.push(i);return s}function H2(t){const[a,s]=p.useState(null),[i,c]=p.useState("loading"),[u,d]=p.useState(null),[f,h]=p.useState(null),x=p.useRef(null),v=p.useRef(0),y=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{y.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const j=p.useCallback(async()=>{try{const E=await fetch("/api/config");if(!E.ok)throw new Error(`/api/config returned ${E.status}`);const R=await E.json(),O=U2((R.providers||[]).map(L=>I2(L,R.detection)));s({agents:O,activeAgent:R.provider??null,activeModel:R.model??null}),c("ready"),d(null)}catch(E){c("error"),d(E.message)}},[]);p.useEffect(()=>{j()},[j]);const k=p.useCallback(async()=>{var R;const E=Date.now();if(!(E-v.current<5*6e4))try{const O=await fetch("/api/openrouter/models");if(!O.ok){O.status!==400&&h(`OpenRouter catalog fetch failed (${O.status})`);return}const L=await O.json();v.current=E,h(null),s(B=>{if(!B)return B;const z=B.agents.map(_=>{if(_.id!=="openrouter")return _;const H=L.models.map(q=>({id:q.id,displayName:q.name,contextWindow:q.contextWindow,pricing:q.pricing,billingMode:"per-token"}));return{..._,models:H,catalogAgeMs:L.ageSec?L.ageSec*1e3:0,cacheStale:!!L.stale}});return{...B,agents:z}});const P=L.ageSec??0;(L.stale===!0||P>600)&&((R=y.current)==null||R.call(y,"openrouter",P*1e3))}catch(O){h(`OpenRouter catalog unreachable: ${O.message}`)}},[]),w=p.useCallback(E=>{x.current=E,E==="openrouter"&&k()},[k]),C=p.useCallback(()=>{v.current=0,j()},[j]),T=p.useCallback(async(E,R)=>{var P,N;let O;try{O=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:E,model:R})})}catch(B){(P=b.current)==null||P.call(b,`Network error while setting ${E}: ${B.message}`);return}if(O.ok){s(B=>B&&{...B,activeAgent:E,activeModel:R});return}let L=`Failed to set ${E} (${O.status})`;try{const B=await O.json();B&&typeof B.error=="string"&&(L=B.error)}catch{}(N=b.current)==null||N.call(b,L)},[]);return{status:i,catalog:a,error:u,openRouterError:f,focusAgent:w,refresh:C,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:T}}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 n.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 pf({unlocked:t=!1,size:a=10}){return t?n.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:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),n.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):n.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:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),n.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const P2=new Set(["claude-cli","claude-code"]);function mg(t){return P2.has(t)}const hg=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function V2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(h=>hg.has(h.id)),f=t.filter(h=>!hg.has(h.id));return n.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=>n.jsx(xg,{agent:h,isActive:h.id===a,isFocused:h.id===s,onFocus:i,onSelect:c,onOpenSettings:u},h.id)),f.length>0&&n.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),f.map(h=>n.jsx(xg,{agent:h,isActive:h.id===a,isFocused:h.id===s,onFocus:i,onSelect:c,onOpenSettings:u},h.id))]})}function xg({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=mg(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)"),n.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&&n.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&&n.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),n.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[n.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),mg(t.id)&&n.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})]}),n.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?n.jsx(pf,{unlocked:!0,size:10}):n.jsx(pf,{size:10})}),a&&n.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"&&n.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]&&n.jsx(Md,{variant:"cli-install",label:h[t.id].label,installUrl:h[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&n.jsx(Md,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),f[t.id]&&n.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:f[t.id]})]})}function F2(t,a,s,i){const d=t>=80,f=p.useRef(null),[h,x]=p.useState(0),v=p.useCallback(j=>{x(j.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const j=Math.max(0,Math.floor(h/a)-4),k=Math.ceil(s/a)+8,w=Math.min(t,j+k);return{visibleStart:j,visibleEnd:w}},[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 ly=44,W2=352,G2=60,gg=480;function q2(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 Y2(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 K2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=p.useState(""),[f,h]=p.useState(""),x=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>h(u),G2);return()=>clearTimeout(b)},[u]),p.useEffect(()=>{t.id==="openrouter"&&t.available&&x.current&&x.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return n.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:gg,padding:20,display:"flex",flexDirection:"column",gap:12},children:[n.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ae.providers.openrouter.emptyCardBody}),n.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=p.useMemo(()=>Y2(t.models,f),[t.models,f]),y=F2(v.length,ly,W2);return n.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:gg,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&n.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:n.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?n.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[n.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ae.picker.noMatches(f)}),n.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?n.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ae.picker.noModelsYet}):n.jsx("div",{...y.containerProps,children:n.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:n.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 n.jsx(Q2,{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 X2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function Q2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=q2(t),d=X2(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 n.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:ly,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:[n.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),n.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&&n.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 vg={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function Z2(){const[t,a]=p.useState(null),[s,i]=p.useState(!0),[c,u]=p.useState(null),d=p.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({...vg,...v}),u(null)}catch(x){u(x.message),a(vg)}finally{i(!1)}},[]);p.useEffect(()=>{d()},[d]);const f=p.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=p.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 J2({onMigrated:t,fetchImpl:a}){const[s,i]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.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]);p.useEffect(()=>{u()},[u]);const d=p.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=p.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 n.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:[n.jsx("span",{style:{flex:1},children:s.message}),n.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:zd,children:"Retry"})]});const h=s.kind==="working";return n.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:[n.jsxs("div",{style:{flex:1},children:[n.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),n.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."})]}),n.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"}),n.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"},ek=[{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 tk(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 sy({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:f}=Z2(),h=p.useRef(null),x=p.useRef(null),[v,y]=p.useState(null);p.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 w=await k.json();j||y(w.path??null)}catch{j||y(null)}})(),()=>{j=!0}},[t]),p.useEffect(()=>{if(!t)return;const j=document.activeElement,k=setTimeout(()=>{var T;const w=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(T=h.current)==null?void 0:T.querySelector(w);C==null||C.focus()},0);return()=>{var w;clearTimeout(k),(w=j==null?void 0:j.focus)==null||w.call(j)}},[t,s]),p.useEffect(()=>{if(!t)return;const j=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&h.current){const w=h.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(w.length===0)return;const C=w[0],T=w[w.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),T.focus()):!k.shiftKey&&document.activeElement===T&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,a]);const b=p.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?n.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:n.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:[n.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ae.settings.title}),n.jsx(J2,{onMigrated:()=>{f()}}),n.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}),n.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[n.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ae.settings.sectionApiKeys}),ek.map(j=>n.jsx(nk,{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 w=await u(j.id,k);return i==null||i(ae.settings.keySaved(j.name)),w},onRemove:async()=>{await d(j.id),i==null||i(ae.settings.keyRemoved(j.name))},inputRef:j.id===(s??"anthropic")?x:void 0},j.id))]}),n.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:[n.jsx("span",{style:{flex:1},children:v?ae.settings.storagePath(v):ae.settings.storagePathFallback}),n.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Fa,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:ae.settings.copyPath})]}),n.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:n.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 nk({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:f,inputRef:h}){const[x,v]=p.useState(""),[y,b]=p.useState(!1),[j,k]=p.useState(!1),[w,C]=p.useState(!1),[T,E]=p.useState(null),R=x.trim(),O=R.length===0,L=R.length>0&&!R.startsWith(i),P=p.useCallback(async()=>{if(O)return;k(!0);const z=R;v("");try{const _=await d(z);_.warning?E(_.warning):E(null)}finally{k(!1)}},[O,d,R]),N=p.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const _=await navigator.clipboard.readText();v(_)}catch{}},[]),B=p.useCallback(async()=>{C(!1),await f()},[f]);return n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("strong",{style:{fontSize:13},children:a}),n.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("input",{ref:h,type:y?"text":"password",value:x,onChange:z=>{v(z.target.value),E(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"}}),n.jsx("button",{type:"button",onClick:()=>b(!y),style:Fa,children:y?ae.settings.hide:ae.settings.show}),n.jsx("button",{type:"button",onClick:N,style:Fa,children:ae.settings.paste})]}),L&&n.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:yg,children:ae.settings.prefixWarn(a)}),T&&n.jsx("div",{role:"status",style:yg,children:T}),n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{type:"button",onClick:P,disabled:O||j,"data-testid":`save-${t}`,style:{...Fa,background:O?"var(--surface-2)":"var(--accent, var(--color-accent))",color:O?"var(--text-muted)":"white",cursor:O?"not-allowed":"pointer"},children:ae.settings.save}),(u==null?void 0:u.stored)&&n.jsx(n.Fragment,{children:w?n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{fontSize:12},children:ae.settings.removeConfirm(a)}),n.jsx("button",{type:"button",onClick:B,"data-testid":`remove-confirm-${t}`,style:{...Fa,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),n.jsx("button",{type:"button",onClick:()=>C(!1),style:Fa,children:"Cancel"})]}):n.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Fa,color:"var(--text-muted)"},children:ae.settings.remove})}),n.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(tk(u.updatedAt)):ae.settings.noKey})]})]})}const Fa={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},yg={fontSize:11,color:"var(--warning, var(--text-muted))"};function rk(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ak({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=H2({onStaleCatalog:(_,H)=>{const W=Math.round(H/6e4);t==null||t(`Using cached ${_} catalog (${W} min old)`)},onSetActiveError:_=>t==null?void 0:t(_)}),[u,d]=p.useState(!1),[f,h]=p.useState(!1),[x,v]=p.useState(),[y,b]=p.useState(null),[j,k]=p.useState("agents"),[w,C]=p.useState(0),T=p.useRef(null);p.useRef(null),p.useEffect(()=>{var _;s&&!y&&b(s.activeAgent??((_=s.agents[0])==null?void 0:_.id)??null)},[s,y]);const E=(s==null?void 0:s.agents)??[],R=p.useMemo(()=>E.find(_=>_.id===y)??E[0],[E,y]);p.useEffect(()=>{C(0)},[y]);const O=p.useCallback(()=>{var _;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((_=E[0])==null?void 0:_.id)??null),C(0)},[s,E]),L=p.useCallback(()=>{var _;d(!1),(_=T.current)==null||_.focus()},[]);p.useEffect(()=>{const _=H=>{var q;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const W=(q=document.activeElement)==null?void 0:q.tagName;W==="INPUT"||W==="TEXTAREA"||(H.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),p.useEffect(()=>{if(!u)return;const _=W=>{if(W.key==="Escape"){W.preventDefault(),L();return}if(W.key==="ArrowDown"){W.preventDefault(),H(1);return}if(W.key==="ArrowUp"){W.preventDefault(),H(-1);return}if(W.key==="ArrowRight"&&j==="agents"){W.preventDefault(),k("models"),C(q=>{const ee=((R==null?void 0:R.models.length)??1)-1;return Math.max(0,Math.min(q,Math.max(0,ee)))});return}if(W.key==="ArrowLeft"&&j==="models"){W.preventDefault(),k("agents");return}if(W.key==="Enter"){if(W.preventDefault(),j==="agents"&&R)k("models"),C(0);else if(j==="models"&&R){const q=Math.max(0,Math.min(R.models.length-1,w)),ee=R.models[q];ee&&(c(R.id,ee.id),L())}return}};function H(W){if(j==="agents"){const q=E.findIndex($=>$.id===y),ee=E[Math.max(0,Math.min(E.length-1,q+W))];ee&&(b(ee.id),i(ee.id));return}if(j==="models"&&R){const q=R.models.length;if(q===0)return;C(ee=>{const $=ee+W;return Math.max(0,Math.min(q-1,$))})}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u,j,E,y,R,w,L,i,c]);const P=p.useCallback(_=>{v(_==="anthropic"||_==="openrouter"?_:void 0),h(!0),d(!1)},[]),N=E.find(_=>_.id===(s==null?void 0:s.activeAgent)),B=N==null?void 0:N.models.find(_=>_.id===(s==null?void 0:s.activeModel)),z=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const _=(N==null?void 0:N.displayName)??"Agent",H=(B==null?void 0:B.displayName)??s.activeModel??"Model";return`${_} · ${H}`},[a,s,N,B]);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{ref:T,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?L():O(),"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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:N!=null&&N.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),n.jsx("span",{children:z})]}),u&&typeof document<"u"&&ac.createPortal(n.jsxs(lk,{reducedMotion:rk(),onClickOutside:L,children:[n.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[n.jsx(V2,{agents:E,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:_=>{b(_),i(_)},onSelect:_=>{b(_),i(_),k("models")},onOpenSettings:P}),R&&n.jsx(K2,{agent:R,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:j==="models"?w:-1,onSelect:_=>{c(R.id,_),L()},onOpenSettings:P})]}),n.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:[n.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}),n.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ae.picker.footerHint})]})]}),document.body),n.jsx(sy,{open:f,onClose:()=>h(!1),initialProvider:x,onToast:t})]})}function lk({children:t,reducedMotion:a,onClickOutside:s}){const i=p.useRef(null);return p.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),n.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,n.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 sk="/assets/skill-studio-logo-CRyKgIrg.png";function bg(){typeof window>"u"||(window.location.hash="#/")}function ik({onHome:t}){const[a,s]=p.useState(!1),[i,c]=p.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),bg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),bg(),t==null||t())};return n.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:[n.jsx("img",{src:sk,alt:"","aria-hidden":"true",width:28,height:28,style:{display:"block",objectFit:"contain",flexShrink:0}}),n.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const jg=p.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return n.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 ok({toast:t,onDismiss:a}){const[s,i]=p.useState(!0),c=p.useRef(null);p.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 n.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:[n.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&n.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}),n.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 ck({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return n.jsxs(n.Fragment,{children:[n.jsx(jg,{politeness:"polite",message:s}),n.jsx(jg,{politeness:"assertive",message:i}),t.length>0&&n.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=>n.jsx("div",{style:{pointerEvents:"auto"},children:n.jsx(ok,{toast:c,onDismiss:a})},c.id))})]})}const iy=p.createContext(null);function lc(){const t=p.useContext(iy);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function uk({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=p.useState([]),[u,d]=p.useState(""),[f,h]=p.useState(""),x=p.useRef(new Map),v=p.useCallback(C=>{const T=x.current.get(C);T&&(clearTimeout(T),x.current.delete(C)),c(E=>E.filter(R=>R.id!==C))},[]),y=p.useCallback((C,T)=>{if(T<=0)return;const E=setTimeout(()=>{v(C)},T);x.current.set(C,E)},[v]),b=p.useCallback(C=>{const T=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,E={id:T,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(R=>[...R,E]),E.severity==="error"?h(E.message):d(E.message),y(T,E.durationMs),T},[s,y]),j=p.useCallback(()=>{for(const C of x.current.values())clearTimeout(C);x.current.clear(),c([])},[]);p.useEffect(()=>{function C(T){T.key==="Escape"&&c(E=>{if(E.length===0)return E;const R=E.slice(0,a),O=R[R.length-1],L=x.current.get(O.id);return L&&(clearTimeout(L),x.current.delete(O.id)),E.filter(P=>P.id!==O.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[a]),p.useEffect(()=>()=>{for(const C of x.current.values())clearTimeout(C);x.current.clear()},[]);const k=i.slice(0,a),w=p.useMemo(()=>({toast:b,dismiss:v,clear:j}),[b,v,j]);return n.jsxs(iy.Provider,{value:w,children:[t,n.jsx(ck,{toasts:k,onDismiss:v,liveMessage:u,liveAssertiveMessage:f})]})}function dk(){const{data:t,loading:a}=qa("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 fk=p.lazy(()=>Gl(()=>import("./UpdateDropdown-h5Hg3h7Z.js"),__vite__mapDeps([0,1])));function pk(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:h}=ur(),{toast:x}=lc(),{data:v}=dk(),y=(v==null?void 0:v.degraded)===!0,b=p.useMemo(()=>{if(!f||f.size===0)return;const P=new Map;for(const[N,B]of f)B.diffSummary&&P.set(N,B.diffSummary);return P.size>0?P:void 0},[f]),[j,k]=p.useState(!1),w=p.useRef(null),C=p.useCallback(()=>k(!1),[]),T=y?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",E=t>9?"9+":String(t),R=t===0?"No updates available":`${t} updates available, open summary`,O=y?`${R} — platform crawler degraded`:R,L=y?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return n.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[n.jsxs("button",{ref:w,type:"button","data-testid":"update-bell","aria-label":O,"aria-haspopup":"dialog","aria-expanded":j,title:L,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:T,cursor:"pointer"},children:[n.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:T},children:[n.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"}),n.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),n.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&n.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:E})]}),j&&n.jsx(p.Suspense,{fallback:n.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:n.jsx(fk,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:P=>{const N=P.localSkill??P.name.split("/").pop()??"",B=P.localPlugin??"";if(u)u(B,N);else{const _=P.name.split("/"),H=_.length>=2?_[_.length-2]:_[0];c({plugin:H,skill:N,origin:"installed"})}if(!(d??[]).some(_=>_.skill===N&&(B===""||_.plugin===B))){const _=P.installLocations??[];if(_.length>0){const H=h?_.filter(q=>q.agent===h):[],W=h?_.filter(q=>q.agent!==h):_;if(H.length>0&&W.length>0){const q=W.length>=2?`Also installed under ${W.length} other locations.`:`Also installed under ${W[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.`})}}}C()},onViewAll:()=>{window.location.hash="#/updates",C()},onClose:C,anchorRef:w})})]})}function Sg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function mk(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 hk(t){return t.source==="project"?"var(--status-installed)":t.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function xk({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?mk(a):null,f=a?hk(a):"var(--text-secondary)";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[n.jsx(ik,{onHome:s}),i?n.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):t&&n.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})]}),n.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&&n.jsxs(n.Fragment,{children:[n.jsx(kg,{segment:"origin",onClick:()=>Sg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:f},children:d}),n.jsx(wg,{}),n.jsx(kg,{segment:"plugin",onClick:()=>Sg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),n.jsx(wg,{}),n.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})]})}),n.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&n.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:[n.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:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),n.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:n.jsx(ak,{})}),n.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:n.jsx(pk,{})})]})]})]})}function kg({segment:t,onClick:a,style:s,children:i}){return n.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 wg(){return n.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const sc="vskill-theme";function oy(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function gk(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function vk(t){try{const a=t.getItem(sc);return oy(a)}catch{return"auto"}}function yk(t,a){try{t.setItem(sc,a)}catch{}}function bk(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function jk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const cy=p.createContext(null);function Sk({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]=p.useState(()=>c?vk(c):"auto"),[x,v]=p.useState(()=>jk(u)),y=p.useMemo(()=>gk(f,x),[f,x]);p.useEffect(()=>{d&&bk(d,f,y)},[d,f,y]),p.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),w=T=>v(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",w),()=>k.removeEventListener("change",w);const C=k;return C.addListener(w),()=>C.removeListener(w)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const k=w=>{w.key===sc&&h(oy(w.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),p.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const w=E=>{E?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};w(k.matches);const C=E=>w(E.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const T=k;return T.addListener(C),()=>T.removeListener(C)},[u,d]);const b=p.useCallback(k=>{h(k),c&&yk(c,k)},[c]),j=p.useMemo(()=>({mode:f,resolvedTheme:y,setTheme:b}),[f,y,b]);return n.jsx(cy.Provider,{value:j,children:i})}function uy(){const t=p.useContext(cy);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const Cg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function kk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of Cg){const c=a.get(i);c&&s.push(c)}for(const i of t)Cg.includes(i.id)||s.push(i);return s}function wk(t){const[a,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const 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 Ck({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=kk(t),c=wk(640),[u,d]=p.useState(!1),f=p.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 n.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[n.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&&n.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=>n.jsx(Eg,{p:x,onClick:f},x.id))})]})}return n.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(h=>n.jsx(Eg,{p:h,onClick:f,compact:!0},h.id))})}function Eg({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 n.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:[n.jsx(pf,{unlocked:t.available,size:10}),!s&&n.jsx("span",{children:t.label})]})}function Ek(){try{return typeof localStorage>"u"?null:localStorage.getItem(sc)}catch{return null}}function Nk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:h,setTheme:x}=uy(),y=Ek()==="auto",b=Tk(f,h,y),j=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return n.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:[n.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),n.jsx(Ng,{}),n.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx(Rk,{color:j}),n.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Ng,{}),n.jsx(Ck,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),n.jsx("div",{style:{flex:1}}),n.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:[n.jsx(Ak,{mode:f}),n.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function Tk(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function Rk({color:t}){return n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function Ng(){return n.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function Ak({mode:t}){return t==="dark"?n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"4"}),n.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"})]}):n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const mf=new Set;function dy(){for(const t of mf)t()}const Lk=5,Mk=1e3,zk=6e4;function Dk(){const[t,a]=p.useState(void 0),[s,i]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),f=p.useRef(null),h=p.useRef(null),x=p.useRef(!0),v=p.useRef(0),[y,b]=p.useState(0),j=()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},k=p.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),w=p.useCallback(async()=>{if(!x.current||document.visibilityState==="hidden")return;k();const T=new AbortController;f.current=T;try{const E=await fetch("/api/plugins",{signal:T.signal});if(!x.current)return;const R=await E.json();if(!x.current)return;d.current=0,a(R.plugins??[]),u(!1),i(!1),h.current=setTimeout(()=>{x.current&&b(O=>O+1)},zk)}catch(E){if(!x.current||E instanceof DOMException&&E.name==="AbortError")return;if(d.current+=1,u(!1),d.current>Lk){i(!0);return}const R=Mk*Math.pow(2,d.current-1);h.current=setTimeout(()=>{x.current&&b(O=>O+1)},R)}},[k]);p.useEffect(()=>(x.current=!0,()=>{x.current=!1,j(),k()}),[k]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(j(),w())},[y,w]),p.useEffect(()=>{const T=()=>{document.visibilityState==="hidden"?(j(),k()):(d.current=0,i(!1),b(E=>E+1))};return document.addEventListener("visibilitychange",T),()=>{document.removeEventListener("visibilitychange",T)}},[k]);const C=p.useCallback(()=>{d.current=0,i(!1),j(),v.current+=1,b(T=>T+1)},[]);return p.useEffect(()=>(mf.add(C),()=>{mf.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const ic=0,ja=1,ql=2,fy=4;function Tg(t){return()=>t}function _k(t){t()}function py(t,a){return s=>t(a(s))}function Rg(t,a){return()=>t(a)}function Ok(t,a){return s=>t(a,s)}function If(t){return t!==void 0}function Bk(...t){return()=>{t.map(_k)}}function Yl(){}function oc(t,a){return a(t),t}function Ik(t,a){return a(t)}function Mt(...t){return t}function mt(t,a){return t(ja,a)}function Xe(t,a){t(ic,a)}function $f(t){t(ql)}function It(t){return t(fy)}function Me(t,a){return mt(t,Ok(a,ic))}function ir(t,a){const s=t(ja,i=>{s(),a(i)});return s}function Ag(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function my(t,a){return t===a}function Lt(t=my){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function $e(t){return a=>s=>{t(s)&&a(s)}}function Ce(t){return a=>py(a,t)}function hr(t){return a=>()=>{a(t)}}function me(t,...a){const s=$k(...a);return((i,c)=>{switch(i){case ql:$f(t);return;case ja:return mt(t,s(c))}})}function gr(t,a){return s=>i=>{s(a=t(a,i))}}function Ga(t){return a=>s=>{t>0?t--:a(s)}}function Pr(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;mt(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 $k(...t){return a=>t.reduceRight(Ik,a)}function Uk(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=mt(t,u),a):(i(),Yl);case ql:i(),s=null;return}}}function ge(t){let a=t;const s=lt();return((i,c)=>{switch(i){case ic:a=c;break;case ja:{c(a);break}case fy:return a}return s(i,c)})}function mn(t,a){return oc(ge(a),s=>Me(t,s))}function lt(){const t=[];return((a,s)=>{switch(a){case ic:t.slice().forEach(i=>{i(s)});return;case ql:t.splice(0,t.length);return;case ja:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function $n(t){return oc(lt(),a=>Me(t,a))}function ut(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:Hk(),singleton:s}}const Hk=()=>Symbol();function Pk(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 Kt(...t){const a=lt(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;mt(u,h=>{s[d]=h,i|=f,i===c&&Xe(a,s)})}),function(u,d){switch(u){case ql:{$f(a);return}case ja:return i===c&&d(s),mt(a,d)}}}function Ie(t,a=my){return me(t,Lt(a))}function hf(...t){return function(a,s){switch(a){case ql:return;case ja:return Bk(...t.map(i=>mt(i,s)))}}}const Zt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Vk={[Zt.DEBUG]:"debug",[Zt.ERROR]:"error",[Zt.INFO]:"log",[Zt.WARN]:"warn"},Fk=()=>typeof globalThis>"u"?window:globalThis,Sa=ut(()=>{const t=ge(Zt.ERROR);return{log:ge((a,s,i=Zt.INFO)=>{const c=Fk().VIRTUOSO_LOG_LEVEL??It(t);i>=c&&console[Vk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Uf(t,a,s).callbackRef}function Uf(t,a,s){const i=Le.useRef(null);let c=d=>{};const u=Le.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 Wk(t,a,s,i,c,u,d,f,h){const x=Le.useCallback(v=>{const y=Gk(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 w=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,C=d?f?d.scrollWidth:d.scrollHeight:j?f?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,T=d?f?d.offsetWidth:d.offsetHeight:j?f?k.innerWidth:k.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:C,scrollTop:Math.max(w,0),viewportHeight:T}),u==null||u(f?Lg("column-gap",getComputedStyle(v).columnGap,c):Lg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,i,f]);return Uf(x,s,h)}function Gk(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},Zt.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 Lg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Zt.WARN),a==="normal"?0:parseInt(a??"0",10)}function hy(t,a,s){const i=Le.useRef(null),c=Le.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}=Uf(c,!0,s),f=Le.useCallback(()=>{c(d.current)},[c,d]);return Le.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 vn=ut(()=>{const t=lt(),a=lt(),s=ge(0),i=lt(),c=ge(0),u=lt(),d=lt(),f=ge(0),h=ge(0),x=ge(0),v=ge(0),y=lt(),b=lt(),j=ge(!1),k=ge(!1),w=ge(!1);return Me(me(t,Ce(({scrollTop:C})=>C)),a),Me(me(t,Ce(({scrollHeight:C})=>C)),d),Me(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:w,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),ei={lvl:0};function xy(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 jt(t){return t===ei}function ti(t,a){if(!jt(t))return a===t.k?t.v:a<t.k?ti(t.l,a):ti(t.r,a)}function cr(t,a,s="k"){if(jt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=cr(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return cr(t.l,a,s)}function Bn(t,a,s){return jt(t)?yy(a,s,1):a===t.k?Qt(t,{k:a,v:s}):a<t.k?Mg(Qt(t,{l:Bn(t.l,a,s)})):Mg(Qt(t,{r:Bn(t.r,a,s)}))}function $l(){return ei}function Ul(t,a,s){if(jt(t))return[];const i=cr(t,a)[0];return qk(gf(t,i,s))}function xf(t,a){if(jt(t))return ei;const{k:s,l:i,r:c}=t;if(a===s){if(jt(i))return c;if(jt(c))return i;const[u,d]=vy(i);return Fo(Qt(t,{k:u,l:gy(i),v:d}))}return a<s?Fo(Qt(t,{l:xf(i,a)})):Fo(Qt(t,{r:xf(c,a)}))}function Wa(t){return jt(t)?[]:[...Wa(t.l),{k:t.k,v:t.v},...Wa(t.r)]}function gf(t,a,s){if(jt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(gf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(gf(u,a,s))),f}function Fo(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 by(Qt(t,{lvl:s-1}));if(!jt(a)&&!jt(a.r))return Qt(a.r,{l:Qt(a,{r:a.r.l}),lvl:s,r:Qt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Dd(t))return vf(Qt(t,{lvl:s-1}));if(!jt(i)&&!jt(i.l)){const c=i.l,u=Dd(c)?i.lvl-1:i.lvl;return Qt(c,{l:Qt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:vf(Qt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Qt(t,a){return yy(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 gy(t){return jt(t.r)?t.l:Fo(Qt(t,{r:gy(t.r)}))}function Dd(t){return jt(t)||t.lvl>t.r.lvl}function vy(t){return jt(t.r)?[t.k,t.v]:vy(t.r)}function yy(t,a,s,i=ei,c=ei){return{k:t,l:i,lvl:s,r:c,v:a}}function Mg(t){return vf(by(t))}function by(t){const{l:a}=t;return!jt(a)&&a.lvl===t.lvl?Qt(a,{r:Qt(t,{l:a.r})}):t}function vf(t){const{lvl:a,r:s}=t;return!jt(s)&&!jt(s.r)&&s.lvl===a&&s.r.lvl===a?Qt(s,{l:Qt(t,{r:s.l}),lvl:a+1}):t}function qk(t){return xy(t,({k:a,v:s})=>({index:a,value:s}))}function jy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function ni(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Hf=ut(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Sy(t,a,s){return t[Ko(t,a,s)]}function Ko(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 Yk(t,a,s,i){const c=Ko(t,a,i),u=Ko(t,s,i,c);return t.slice(c,u+1)}function ya(t,a){return Math.round(t.getBoundingClientRect()[a])}function cc(t){return!jt(t.groupOffsetTree)}function Pf({index:t},a){return a===t?0:a<t?-1:1}function Kk(){return{groupIndices:[],groupOffsetTree:$l(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:$l()}}function Xk(t,a){let s=jt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),jt(t)){t=Bn(t,0,u);continue}const f=Ul(t,d-1,c+1);if(f.some(rw(i)))continue;let h=!1,x=!1;for(const{end:v,start:y,value:b}of f)h?(c>=y||u===b)&&(t=xf(t,y)):(x=b!==u,h=!0),v>c&&c>=y&&b!==u&&(t=Bn(t,c+1,b));x&&(t=Bn(t,d,u))}return[t,s]}function Qk(t){return typeof t.groupIndex<"u"}function Zk({offset:t},a){return a===t?0:a<t?-1:1}function ri(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=Sy(a,t,Pf),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function ky(t,a){if(!cc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function wy(t,a,s){if(Qk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=ky(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Jk(t,a,s,i=0){return i>0&&(a=Math.max(a,Sy(t,i,Pf).offset)),xy(Yk(t,a,s,Zk),nw)}function ew(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Zt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&jt(u)&&a.length===2){const b=a[0].size,j=a[1].size;d=s.reduce((k,w)=>Bn(Bn(k,w,b),w+1,j),d)}else[d,f]=Xk(d,a);if(d===u)return t;const{lastIndex:h,lastOffset:x,lastSize:v,offsetTree:y}=yf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,j)=>Bn(b,j,ri(j,y,c)),$l()),lastIndex:h,lastOffset:x,lastSize:v,offsetTree:y,sizeTree:d}}function tw(t){return Wa(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 zg(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 yf(t,a,s,i){let c=t,u=0,d=0,f=0,h=0;if(a!==0){h=Ko(c,a-1,Pf),f=c[h].offset;const x=cr(s,a-1);u=x[0],d=x[1],c.length&&c[h].size===cr(s,a)[1]&&(h-=1),c=c.slice(0,h+1)}else c=[];for(const{start:x,value:v}of Ul(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 nw(t){return{index:t.index,value:t}}function rw(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 aw={offsetHeight:"height",offsetWidth:"width"},br=ut(([{log:t},{recalcInProgress:a}])=>{const s=lt(),i=lt(),c=mn(i,0),u=lt(),d=lt(),f=ge(0),h=ge([]),x=ge(void 0),v=ge(void 0),y=ge(void 0),b=ge(void 0),j=ge((N,B)=>ya(N,aw[B])),k=ge(void 0),w=ge(0),C=Kk(),T=mn(me(s,Qe(h,t,w),gr(ew,C),Lt()),C),E=mn(me(h,Lt(),gr((N,B)=>({current:B,prev:N.current}),{current:[],prev:[]}),Ce(({prev:N})=>N)),[]);Me(me(h,$e(N=>N.length>0),Qe(T,w),Ce(([N,B,z])=>{const _=N.reduce((H,W,q)=>Bn(H,W,ri(W,B.offsetTree,z)||q),$l());return{...B,groupIndices:N,groupOffsetTree:_}})),T),Me(me(i,Qe(T),$e(([N,{lastIndex:B}])=>N<B),Ce(([N,{lastIndex:B,lastSize:z}])=>[{endIndex:B,size:z,startIndex:N}])),s),Me(x,v);const R=mn(me(x,Ce(N=>N===void 0)),!0);Me(me(v,$e(N=>N!==void 0&&jt(It(T).sizeTree)),Ce(N=>{const B=It(y),z=It(h).length>0;return B!==void 0&&B!==0?z?[{endIndex:0,size:B,startIndex:0},{endIndex:1,size:N,startIndex:1}]:[]:[{endIndex:0,size:N,startIndex:0}]})),s),Me(me(b,$e(N=>N!==void 0&&N.length>0&&jt(It(T).sizeTree)),Ce(N=>{const B=[];let z=N[0],_=0;for(let H=1;H<N.length;H++){const W=N[H];W!==z&&(B.push({endIndex:H-1,size:z,startIndex:_}),z=W,_=H)}return B.push({endIndex:N.length-1,size:z,startIndex:_}),B})),s),Me(me(h,Qe(y,v),$e(([,N,B])=>N!==void 0&&B!==void 0),Ce(([N,B,z])=>{const _=[];for(let H=0;H<N.length;H++){const W=N[H],q=N[H+1];_.push({startIndex:W,endIndex:W,size:B}),q!==void 0&&_.push({startIndex:W+1,endIndex:q-1,size:z})}return _})),s);const O=$n(me(s,Qe(T),gr(({sizes:N},[B,z])=>({changed:z!==N,sizes:z}),{changed:!1,sizes:C}),Ce(N=>N.changed)));mt(me(f,gr((N,B)=>({diff:N.prev-B,prev:B}),{diff:0,prev:0}),Ce(N=>N.diff)),N=>{const{groupIndices:B}=It(T);if(N>0)Xe(a,!0),Xe(u,N+zg(N,B));else if(N<0){const z=It(E);z.length>0&&(N-=zg(-N,z)),Xe(d,N)}}),mt(me(f,Qe(t)),([N,B])=>{N<0&&B("`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},Zt.ERROR)});const L=$n(u);Me(me(u,Qe(T),Ce(([N,B])=>{const z=B.groupIndices.length>0,_=[],H=B.lastSize;if(z){const W=ti(B.sizeTree,0);let q=0,ee=0;for(;q<N;){const D=B.groupIndices[ee],U=B.groupIndices.length===ee+1?1/0:B.groupIndices[ee+1]-D-1;_.push({endIndex:D,size:W,startIndex:D}),_.push({endIndex:D+1+U-1,size:H,startIndex:D+1}),ee++,q+=U+1}const $=Wa(B.sizeTree);return q!==N&&$.shift(),$.reduce((D,{k:U,v:F})=>{let Y=D.ranges;return D.prevSize!==0&&(Y=[...D.ranges,{endIndex:U+N-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:U+N,prevSize:F,ranges:Y}},{prevIndex:N,prevSize:0,ranges:_}).ranges}return Wa(B.sizeTree).reduce((W,{k:q,v:ee})=>({prevIndex:q+N,prevSize:ee,ranges:[...W.ranges,{endIndex:q+N-1,size:W.prevSize,startIndex:W.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const P=$n(me(d,Qe(T,w),Ce(([N,{offsetTree:B},z])=>{const _=-N;return ri(_,B,z)})));return Me(me(d,Qe(T,w),Ce(([N,B,z])=>{if(B.groupIndices.length>0){if(jt(B.sizeTree))return B;let H=$l();const W=It(E);let q=0,ee=0,$=0;for(;q<-N;){$=W[ee];const D=W[ee+1]-$-1;ee++,q+=D+1}if(H=Wa(B.sizeTree).reduce((D,{k:U,v:F})=>Bn(D,Math.max(0,U+N),F),H),q!==-N){const D=ti(B.sizeTree,$);H=Bn(H,0,D);const U=cr(B.sizeTree,-N+1)[1];H=Bn(H,1,U)}return{...B,sizeTree:H,...yf(B.offsetTree,0,H,z)}}const _=Wa(B.sizeTree).reduce((H,{k:W,v:q})=>Bn(H,Math.max(0,W+N),q),$l());return{...B,sizeTree:_,...yf(B.offsetTree,0,_,z)}})),T),{beforeUnshiftWith:L,data:k,defaultItemSize:v,firstItemIndex:f,fixedItemSize:x,fixedGroupSize:y,gap:w,groupIndices:h,heightEstimates:b,itemSize:j,listRefresh:O,shiftWith:d,shiftWithOffset:P,sizeRanges:s,sizes:T,statefulTotalCount:c,totalCount:i,trackItemSizes:R,unshiftWith:u}},Mt(Sa,Hf),{singleton:!0});function lw(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Cy=ut(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=lt(),d=lt(),f=$n(me(u,Ce(lw)));return Me(me(f,Ce(h=>h.totalCount)),s),Me(me(f,Ce(h=>h.groupIndices)),t),Me(me(Kt(c,a,i),$e(([h,x])=>cc(x)),Ce(([h,x,v])=>cr(x.groupOffsetTree,Math.max(h-v,0),"v")[0]),Lt(),Ce(h=>[h])),d),{groupCounts:u,topItemsIndexes:d}},Mt(br,vn)),ka=ut(([{log:t}])=>{const a=ge(!1),s=$n(me(a,$e(i=>i),Lt()));return mt(a,i=>{i&&It(t)("props updated",{},Zt.DEBUG)}),{didMount:s,propsReady:a}},Mt(Sa),{singleton:!0}),sw=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ey(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!sw)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ci=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=lt(),k=lt(),w=ge(0);let C=null,T=null,E=null;function R(){C!==null&&(C(),C=null),E!==null&&(E(),E=null),T&&(clearTimeout(T),T=null),Xe(h,!1)}return Me(me(j,Qe(s,y,i,w,f,d,b),Qe(t,u,c),Ce(([[O,L,P,N,B,z,_,H],W,q,ee])=>{const $=Ey(O),{align:D,behavior:U,offset:F}=$,Y=N-1,oe=wy($,L,Y);let M=ri(oe,L.offsetTree,W)+z;D==="end"?(M+=q+cr(L.sizeTree,oe)[1]-P+ee,oe===Y&&(M+=_)):D==="center"?M+=(q+cr(L.sizeTree,oe)[1]-P+ee)/2:M-=B,F!==void 0&&F!==0&&(M+=F);const I=K=>{R(),K?(H("retrying to scroll to",{location:O},Zt.DEBUG),Xe(j,O)):(Xe(k,!0),H("list did not change, scroll successful",{},Zt.DEBUG))};if(R(),U==="smooth"){let K=!1;E=mt(a,Q=>{K=K||Q}),C=ir(v,()=>{I(K)})}else C=ir(me(a,iw(150)),I);return T=setTimeout(()=>{R()},1200),Xe(h,!0),H("scrolling from index to",{behavior:U,index:oe,top:M},Zt.DEBUG),{behavior:U,top:M}})),x),{scrollTargetReached:k,scrollToIndex:j,topListHeight:w}},Mt(br,vn,Sa),{singleton:!0});function iw(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Vf(t,a){t===0?a():requestAnimationFrame(()=>{Vf(t-1,a)})}function Ff(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ui=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 Me(me(d,Qe(h),$e(([v,y])=>y!==0),hr(!1)),f),Me(me(d,Qe(h),$e(([v,y])=>y!==0),hr(!1)),x),mt(me(Kt(a,d),Qe(f,s,t,x),$e(([[,v],y,{sizeTree:b},j,k])=>v&&(!jt(b)||If(j))&&!y&&!k),Qe(h)),([,v])=>{ir(c,()=>{Xe(x,!0)}),Vf(4,()=>{ir(i,()=>{Xe(f,!0)}),Xe(u,v)})}),{initialItemFinalLocationReached:x,initialTopMostItemIndex:h,scrolledToInitialItem:f}},Mt(br,vn,ci,ka),{singleton:!0});function Ny(t,a){return Math.abs(t-a)<1.01}const ai="up",Ys="down",ow="none",cw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},uw=0,di=ut(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),f=ge(!0),h=lt(),x=lt(),v=ge(4),y=ge(uw),b=mn(me(hf(me(Ie(c),Ga(1),hr(!0)),me(Ie(c),Ga(1),hr(!1),Ag(100))),Lt()),!1),j=mn(me(hf(me(s,hr(!0)),me(s,hr(!1),Ag(200))),Lt()),!1);Me(me(Kt(Ie(c),Ie(y)),Ce(([E,R])=>E<=R),Lt()),f),Me(me(f,Pr(50)),x);const k=$n(me(Kt(i,Ie(u),Ie(a),Ie(t),Ie(v)),gr((E,[{scrollHeight:R,scrollTop:O},L,P,N,B])=>{const z=O+L-R>-B,_={scrollHeight:R,scrollTop:O,viewportHeight:L};if(z){let W,q;return O>E.state.scrollTop?(W="SCROLLED_DOWN",q=E.state.scrollTop-O):(W="SIZE_DECREASED",q=E.state.scrollTop-O||E.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:q,state:_}}let H;return _.scrollHeight>E.state.scrollHeight?H="SIZE_INCREASED":L<E.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":O<E.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:_}},cw),Lt((E,R)=>E!==void 0&&E.atBottom===R.atBottom))),w=mn(me(i,gr((E,{scrollHeight:R,scrollTop:O,viewportHeight:L})=>{if(!Ny(E.scrollHeight,R)){const P=R-(O+L)<1;return E.scrollTop!==O&&P?{changed:!0,jump:E.scrollTop-O,scrollHeight:R,scrollTop:O}:{changed:!0,jump:0,scrollHeight:R,scrollTop:O}}return{changed:!1,jump:0,scrollHeight:R,scrollTop:O}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),$e(E=>E.changed),Ce(E=>E.jump)),0);Me(me(k,Ce(E=>E.atBottom)),d),Me(me(d,Pr(50)),h);const C=ge(Ys);Me(me(i,Ce(({scrollTop:E})=>E),Lt(),gr((E,R)=>It(j)?{direction:E.direction,prevScrollTop:R}:{direction:R<E.prevScrollTop?ai:Ys,prevScrollTop:R},{direction:Ys,prevScrollTop:0}),Ce(E=>E.direction)),C),Me(me(i,Pr(50),hr(ow)),C);const T=ge(0);return Me(me(b,$e(E=>!E),hr(0)),T),Me(me(c,Pr(100),Qe(b),$e(([E,R])=>R),gr(([E,R],[O])=>[R,O],[0,0]),Ce(([E,R])=>R-E)),T),{atBottomState:k,atBottomStateChange:h,atBottomThreshold:v,atTopStateChange:x,atTopThreshold:y,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:w,scrollDirection:C,scrollVelocity:T}},Mt(vn)),li="top",si="bottom",Dg="none";function _g(t,a,s){return typeof t=="number"?s===ai&&a===li||s===Ys&&a===si?t:0:s===ai?a===li?t.main:t.reverse:a===si?t.main:t.reverse}function Og(t,a){return typeof t=="number"?t:t[a]??0}const Wf=ut(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=lt(),d=ge(0),f=ge(0),h=ge(0),x=mn(me(Kt(Ie(i),Ie(c),Ie(s),Ie(u,ni),Ie(h),Ie(d),Ie(a),Ie(t),Ie(f)),Ce(([v,y,b,[j,k],w,C,T,E,R])=>{const O=v-E,L=C+T,P=Math.max(b-O,0);let N=Dg;const B=Og(R,li),z=Og(R,si);return j-=E,j+=b+T,k+=b+T,k-=E,j>v+L-B&&(N=ai),k<v-P+y+z&&(N=Ys),N!==Dg?[Math.max(O-b-_g(w,li,N)-B,0),O-P-T+y+_g(w,si,N)+z]:null}),$e(v=>v!==null),Lt(ni)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:h,topListHeight:d,visibleRange:x}},Mt(vn),{singleton:!0});function dw(t,a,s){if(cc(a)){const i=ky(t,a);return[{index:cr(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 Wo(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 w=t[t.length-1];v=w.offset+w.size}const y=s-d,b=f+y*h+(y-1)*i,j=x,k=b-v;return{bottom:v,firstItemIndex:u,items:Bg(t,c,u),offsetBottom:k,offsetTop:x,top:j,topItems:Bg(a,c,u),topListHeight:a.reduce((w,C)=>C.size+w,0),totalCount:s}}function Ty(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=Ff(a,f),x=Array.from({length:f}).map((v,y)=>({data:u[y+h],index:y+h,offset:0,size:0}));return Wo(x,[],f,c,s,i)}function Bg(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=Ul(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 Ig(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=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 w=ge([]),C=ge(0),T=lt(),E=ge(0);Me(u.topItemsIndexes,w);const R=mn(me(Kt(j,k,Ie(h,ni),Ie(c),Ie(i),Ie(x),v,Ie(w),Ie(a),Ie(s),Ie(E),t),$e(([N,B,,z,,,,,,,,_])=>{const H=_!==void 0&&_.length!==z;return N&&!B&&!H}),Ce(([,,[N,B],z,_,H,W,q,ee,$,D,U])=>{var he,je;const F=_,{offsetTree:Y,sizeTree:oe}=F,M=It(C);if(z===0)return{..._d,totalCount:z};if(N===0&&B===0)return M===0?{..._d,totalCount:z}:Ty(M,H,_,ee,$,U||[]);if(jt(oe))return M>0?null:Wo(dw(Ff(H,z),F,U),[],z,$,F,ee);const I=[];if(q.length>0){const Ne=q[0],De=q[q.length-1];let He=0;for(const Ue of Ul(oe,Ne,De)){const _e=Ue.value,Ze=Math.max(Ue.start,Ne),st=Math.min(Ue.end,De);for(let ce=Ze;ce<=st;ce++)I.push({data:U==null?void 0:U[ce],index:ce,offset:He,size:_e}),He+=_e}}if(!W)return Wo([],I,z,$,F,ee);const K=q.length>0?q[q.length-1]+1:0,Q=Jk(Y,N,B,K);if(Q.length===0)return null;const ue=z-1,te=oc([],Ne=>{for(const De of Q){const He=De.value;let Ue=He.offset,_e=De.start;const Ze=He.size;if(He.offset<N){_e+=Math.floor((N-He.offset+$)/(Ze+$));const ce=_e-De.start;Ue+=ce*Ze+ce*$}_e<K&&(Ue+=(K-_e)*Ze,_e=K);const st=Math.min(De.end,ue);for(let ce=_e;ce<=st&&!(Ue>=B);ce++)Ne.push({data:U==null?void 0:U[ce],index:ce,offset:Ue,size:Ze}),Ue+=Ze+$}}),ie=Ig(D,li),J=Ig(D,si);if(te.length>0&&(ie>0||J>0)){const Ne=te[0],De=te[te.length-1];if(ie>0&&Ne.index>K){const He=Math.min(ie,Ne.index-K),Ue=[];let _e=Ne.offset;for(let Ze=Ne.index-1;Ze>=Ne.index-He;Ze--){const st=((he=Ul(oe,Ze,Ze)[0])==null?void 0:he.value)??Ne.size;_e-=st+$,Ue.unshift({data:U==null?void 0:U[Ze],index:Ze,offset:_e,size:st})}te.unshift(...Ue)}if(J>0&&De.index<ue){const He=Math.min(J,ue-De.index);let Ue=De.offset+De.size+$;for(let _e=De.index+1;_e<=De.index+He;_e++){const Ze=((je=Ul(oe,_e,_e)[0])==null?void 0:je.value)??De.size;te.push({data:U==null?void 0:U[_e],index:_e,offset:Ue,size:Ze}),Ue+=Ze+$}}}return Wo(te,I,z,$,F,ee)}),$e(N=>N!==null),Lt()),_d);Me(me(t,$e(If),Ce(N=>N==null?void 0:N.length)),c),Me(me(R,Ce(N=>N.topListHeight)),y),Me(y,f),Me(me(R,Ce(N=>[N.top,N.bottom])),d),Me(me(R,Ce(N=>N.items)),T);const O=$n(me(R,$e(({items:N})=>N.length>0),Qe(c,t),$e(([{items:N},B])=>N[N.length-1].originalIndex===B-1),Ce(([,N,B])=>[N-1,B]),Lt(ni),Ce(([N])=>N))),L=$n(me(R,Pr(200),$e(({items:N,topItems:B})=>N.length>0&&N[0].originalIndex===B.length),Ce(({items:N})=>N[0].index),Lt())),P=$n(me(R,$e(({items:N})=>N.length>0),Ce(({items:N})=>{let B=0,z=N.length-1;for(;N[B].type==="group"&&B<z;)B++;for(;N[z].type==="group"&&z>B;)z--;return{endIndex:N[z].index,startIndex:N[B].index}}),Lt(jy)));return{endReached:O,initialItemCount:C,itemsRendered:T,listState:R,minOverscanItemCount:E,rangeChanged:P,startReached:L,topItemsIndexes:w,...b}},Mt(br,Cy,Wf,ui,ci,di,ka,Hf),{singleton:!0}),Ry=ut(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=lt(),d=mn(me(Kt(s,t,i,a,c),Ce(([f,h,x,v,y])=>f+h+x+v+y.offsetBottom+y.bottom)),0);return Me(Ie(d),u),{totalListHeight:d,totalListHeightChanged:u}},Mt(vn,Xa),{singleton:!0}),fw=ut(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=mn(me(Kt(s,t,a),$e(([c])=>c),Ce(([,c,u])=>Math.max(0,c-u)),Pr(0),Lt()),0);return{alignToBottom:s,paddingTopAddition:i}},Mt(vn,Ry),{singleton:!0}),Ay=ut(()=>({context:ge(null)})),pw=({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,Ly=ut(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:h},{scrollToIndex:x}])=>{const v=lt();return Me(me(v,Qe(a,h,s,u,c,i,f),Qe(t),Ce(([[y,b,j,k,w,C,T,E],R])=>{const{calculateViewLocation:O=pw,done:L,...P}=y,N=wy(y,b,k-1),B=ri(N,b.offsetTree,R)+w+C,z=B+cr(b.sizeTree,N)[1],_=E+C,H=E+j-T,W=O({itemBottom:z,itemTop:B,locationParams:P,viewportBottom:H,viewportTop:_});return W!==null?L&&ir(me(d,$e(q=>!q),Ga(It(d)?1:2)),L):L==null||L(),W}),$e(y=>y!==null)),x),{scrollIntoView:v}},Mt(br,vn,ci,Xa,Sa),{singleton:!0});function $g(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const mw=(t,a)=>typeof t=="function"?$g(t(a)):a&&$g(t),hw=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),w=lt();let C=null;function T(L){Xe(d,{align:"end",behavior:L,index:"LAST"})}mt(me(Kt(me(Ie(a),Ga(1)),h),Qe(Ie(k),u,f,y),Ce(([[L,P],N,B,z,_])=>{let H=P&&z,W="auto";return H&&(W=mw(N,B||_),H=H&&W!==!1),{followOutputBehavior:W,shouldFollow:H,totalCount:L}}),$e(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:P})=>{C!==null&&(C(),C=null),It(s)!==void 0?requestAnimationFrame(()=>{It(v)("following output to ",{totalCount:P},Zt.DEBUG),T(L)}):C=ir(t,()=>{It(v)("following output to ",{totalCount:P},Zt.DEBUG),T(L),C=null})});function E(L){const P=ir(c,N=>{L&&!N.atBottom&&N.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(It(v)("scrolling to bottom due to increased size",{},Zt.DEBUG),T("auto"))});setTimeout(P,100)}mt(me(Kt(Ie(k),a,x),$e(([L,,P])=>L!==!1&&P),gr(({value:L},[,P])=>({refreshed:L===P,value:P}),{refreshed:!1,value:0}),$e(({refreshed:L})=>L),Qe(k,a)),([,L])=>{It(f)&&E(L!==!1)}),mt(w,()=>{E(It(k)!==!1)}),mt(Kt(Ie(k),c),([L,P])=>{L!==!1&&!P.atBottom&&P.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&T("auto")});const R=ge(null),O=lt();return Me(hf(me(Ie(i),Ce(L=>(L==null?void 0:L.length)??0)),me(Ie(a))),O),mt(me(Kt(me(O,Ga(1)),h),Qe(Ie(R),f,y,b),Ce(([[L,P],N,B,z,_])=>P&&B&&(N==null?void 0:N({context:_,totalCount:L,scrollingInProgress:z}))),$e(L=>!!L),Pr(0)),L=>{C!==null&&(C(),C=null),It(s)!==void 0?requestAnimationFrame(()=>{It(v)("scrolling into view",{}),Xe(j,L)}):C=ir(t,()=>{It(v)("scrolling into view",{}),Xe(j,L),C=null})}),{autoscrollToBottom:w,followOutput:k,scrollIntoViewOnChange:R}},Mt(br,di,ci,ui,ka,Sa,vn,Ay,Ly)),xw=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Me(me(f,Qe(u),$e(([,h])=>h!==0),Qe(c,i,a,s,t),Ce(([[,h],x,v,y,b,j=[]])=>Ty(h,x,v,y,b,j))),d),{}),Mt(br,ui,Xa,ka),{singleton:!0}),gw=ut(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return mt(me(t,Qe(i),$e(([,c])=>c!==0),Ce(([,c])=>({top:c}))),c=>{ir(me(s,Ga(1),$e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Xe(a,c)})})}),{initialScrollTop:i}},Mt(ka,vn,Xa),{singleton:!0}),My=ut(([{scrollVelocity:t}])=>{const a=ge(!1),s=lt(),i=ge(!1);return Me(me(t,Qe(i,a,s),$e(([c,u])=>u!==!1&&u!==void 0),Ce(([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}),Lt()),a),mt(me(Kt(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}},Mt(di),{singleton:!0}),Gf=ut(([{scrollContainerState:t,scrollTo:a}])=>{const s=lt(),i=lt(),c=lt(),u=ge(!1),d=ge(void 0);return Me(me(Kt(s,i),Ce(([{scrollTop:f,viewportHeight:h},{offsetTop:x,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,f-x),viewportHeight:h}))),t),Me(me(a,Qe(i),Ce(([f,{offsetTop:h}])=>({...f,top:f.top+h}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Mt(vn)),vw=ut(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:h}])=>{const x=lt(),v=ge(void 0),y=ge(null),b=ge(null);return Me(f,y),Me(h,b),mt(me(x,Qe(a,i,d,y,b,s)),([j,k,w,C,T,E,R])=>{const O=tw(k.sizeTree);C&&T!==null&&E!==null&&(w=T.scrollTop-E.offsetTop),w-=R,j({ranges:O,scrollTop:w})}),Me(me(v,$e(If),Ce(yw)),c),Me(me(u,Qe(v),$e(([,j])=>j!==void 0),Lt(),Ce(([,j])=>j.ranges)),t),{getState:x,restoreStateFrom:v}},Mt(br,vn,ui,ka,Gf));function yw(t){return{align:"start",index:0,offset:t.scrollTop}}const bw=ut(([{topItemsIndexes:t}])=>{const a=ge(0);return Me(me(a,$e(s=>s>=0),Ce(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Mt(Xa));function zy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const jw=zy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sw=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 w=$n(me(h,Qe(d),gr(([,T,E,R],[{bottom:O,items:L,offsetBottom:P,totalCount:N},B])=>{const z=O+P;let _=0;return E===N&&T.length>0&&L.length>0&&(L[0].originalIndex===0&&T[0].originalIndex===0||(_=z-R,_!==0&&(_+=B))),[_,L,N,z]},[0,[],0,0]),$e(([T])=>T!==0),Qe(i,f,s,c,j,k),$e(([,T,E,R,,,O])=>!O&&!R&&T!==0&&E===ai),Ce(([[T],,,,,E])=>(E("Upward scrolling compensation",{amount:T},Zt.DEBUG),T))));function C(T){T>0?(Xe(a,{behavior:"auto",top:-T}),Xe(t,0)):(Xe(t,0),Xe(a,{behavior:"auto",top:-T}))}return mt(me(w,Qe(t,u)),([T,E,R])=>{R&&jw()?Xe(t,E-T):C(-T)}),mt(me(Kt(mn(u,!1),t,k),$e(([T,E,R])=>!T&&!R&&E!==0),Ce(([T,E])=>E),Pr(1)),C),Me(me(y,Ce(T=>({top:-T}))),a),mt(me(x,Qe(b,v),Ce(([T,{groupIndices:E,lastSize:R,sizeTree:O},L])=>{function P(H){return H*(R+L)}if(E.length===0)return P(T);let N=0;const B=ti(O,0);let z=0,_=0;for(;z<T;){z++,N+=B;let H=E.length===_+1?1/0:E[_+1]-E[_]-1;z+H>T&&(N-=B,H=T-z+1),z+=H,N+=P(H),_++}return N})),T=>{Xe(t,T),requestAnimationFrame(()=>{Xe(a,{top:T}),requestAnimationFrame(()=>{Xe(t,0),Xe(k,!1)})})}),{deviation:t}},Mt(vn,di,Xa,br,Sa,Hf)),kw=ut(([t,a,s,i,c,u,d,f,h,x,v])=>({...t,...a,...s,...i,...c,...u,...d,...f,...h,...x,...v}),Mt(Wf,xw,ka,My,Ry,gw,fw,Gf,Ly,Sa,Ay)),Dy=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:w,scrolledToInitialItem:C},T,E,R,O,{scrollToIndex:L},P,{topItemCount:N},{groupCounts:B},z])=>{const{listState:_,minOverscanItemCount:H,topItemsIndexes:W,rangeChanged:q,...ee}=O;return Me(q,z.scrollSeekRangeChanged),Me(me(z.windowViewportRect,Ce($=>$.visibleHeight)),T.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:B,heightEstimates:f,initialItemFinalLocationReached:k,initialTopMostItemIndex:w,scrolledToInitialItem:C,sizeRanges:x,topItemCount:N,topItemsIndexes:W,totalCount:b,...R,groupIndices:d,itemSize:h,listState:_,minOverscanItemCount:H,scrollToIndex:L,statefulTotalCount:y,trackItemSizes:j,rangeChanged:q,...ee,...z,...T,sizes:v,...E}},Mt(br,ui,vn,vw,hw,Xa,ci,Sw,bw,Cy,kw));function ww(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 Ao=typeof document<"u"?Le.useLayoutEffect:Le.useEffect;function _y(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=Le.createContext({});function h(C,T){C.propsReady!==void 0&&Xe(C.propsReady,!1);for(const E of i){const R=C[a.required[E]];Xe(R,T[E])}for(const E of c)if(E in T){const R=C[a.optional[E]];Xe(R,T[E])}C.propsReady!==void 0&&Xe(C.propsReady,!0)}function x(C){return u.reduce((T,E)=>(T[E]=R=>{const O=C[a.methods[E]];Xe(O,R)},T),{})}function v(C){return d.reduce((T,E)=>(T[E]=Uk(C[a.events[E]]),T),{})}const y=Le.forwardRef(function(C,T){const{children:E,...R}=C,[O]=Le.useState(()=>oc(Pk(t),N=>{h(N,R)})),[L]=Le.useState(Rg(v,O));Ao(()=>{for(const N of d)N in R&&mt(L[N],R[N]);return()=>{Object.values(L).map($f)}},[R,L,O]),Ao(()=>{h(O,R)}),Le.useImperativeHandle(T,Tg(x(O)));const P=s;return n.jsx(f.Provider,{value:O,children:s!==void 0?n.jsx(P,{...ww([...i,...c,...d],R),children:E}):E})}),b=C=>{const T=Le.useContext(f);return Le.useCallback(E=>{Xe(T[C],E)},[T,C])},j=C=>{const T=Le.useContext(f)[C],E=Le.useCallback(R=>mt(T,R),[T]);return Le.useSyncExternalStore(E,()=>It(T),()=>It(T))},k=C=>{const T=Le.useContext(f)[C],[E,R]=Le.useState(Rg(It,T));return Ao(()=>mt(T,O=>{O!==E&&R(Tg(O))}),[T,E]),E},w=parseInt(Le.version)>=18?j:k;return{Component:y,useEmitter:(C,T)=>{const E=Le.useContext(f)[C];Ao(()=>mt(E,T),[T,E])},useEmitterValue:w,usePublisher:b}}const Oy=Le.createContext(void 0),By=Le.createContext(void 0),Od="-webkit-sticky",Ug="sticky",qf=zy(()=>{if(typeof document>"u")return Ug;const t=document.createElement("div");return t.style.position=Od,t.style.position===Od?Od:Ug}),Iy=typeof document<"u"?Le.useLayoutEffect:Le.useEffect;function Bd(t){return"self"in t}function Cw(t){return"body"in t}function $y(t,a,s,i=Yl,c,u){const d=Le.useRef(null),f=Le.useRef(null),h=Le.useRef(null),x=Le.useCallback(b=>{let j,k,w;const C=b.target;if(Cw(C)||Bd(C)){const E=Bd(C)?C:C.defaultView;w=u===!0?E.scrollX:E.scrollY,j=u===!0?E.document.documentElement.scrollWidth:E.document.documentElement.scrollHeight,k=u===!0?E.innerWidth:E.innerHeight}else w=u===!0?C.scrollLeft:C.scrollTop,j=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const T=()=>{t({scrollHeight:j,scrollTop:Math.max(w,0),viewportHeight:k})};b.suppressFlushSync===!0?T():DS.flushSync(T),f.current!==null&&(w===f.current||w<=0||w===j-k)&&(f.current=null,a(!0),h.current&&(clearTimeout(h.current),h.current=null))},[t,a,u]);Le.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 w,C,T;Bd(j)?(C=Math.max(ya(j.document.documentElement,u===!0?"width":"height"),u===!0?j.document.documentElement.scrollWidth:j.document.documentElement.scrollHeight),w=u===!0?j.innerWidth:j.innerHeight,T=u===!0?window.scrollX:window.scrollY):(C=j[u===!0?"scrollWidth":"scrollHeight"],w=ya(j,u===!0?"width":"height"),T=j[u===!0?"scrollLeft":"scrollTop"]);const E=C-w;if(b.top=Math.ceil(Math.max(Math.min(E,b.top),0)),Ny(w,C)||b.top===T){t({scrollHeight:C,scrollTop:T,viewportHeight:w}),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 Yf(t){return t}const Ew=ut(()=>{const t=ge(f=>`Item ${f}`),a=ge(f=>`Group ${f}`),s=ge({}),i=ge(Yf),c=ge("div"),u=ge(Yl),d=(f,h=null)=>mn(me(s,Ce(x=>x[f]),Lt()),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")}}),Nw=ut(([t,a])=>({...t,...a}),Mt(Dy,Ew)),Tw=({height:t})=>n.jsx("div",{style:{height:t}}),Rw={overflowAnchor:"none",position:qf(),zIndex:1},Uy={overflowAnchor:"none"},Aw={...Uy,display:"inline-block",height:"100%"},Hg=Le.memo(function({showTopList:t=!1}){const a=Fe("listState"),s=Jn("sizeRanges"),i=Fe("useWindowScroll"),c=Fe("customScrollParent"),u=Jn("windowScrollContainerState"),d=Jn("scrollContainerState"),f=c||i?u:d,h=Fe("itemContent"),x=Fe("context"),v=Fe("groupContent"),y=Fe("trackItemSizes"),b=Fe("itemSize"),j=Fe("log"),k=Jn("gap"),w=Fe("horizontalDirection"),{callbackRef:C}=Wk(s,b,y,t?Yl:f,j,k,c,w,Fe("skipAnimationFrameInResizeObserver")),[T,E]=Le.useState(0);Kf("deviation",ee=>{T!==ee&&E(ee)});const R=Fe("EmptyPlaceholder"),O=Fe("ScrollSeekPlaceholder")??Tw,L=Fe("ListComponent"),P=Fe("ItemComponent"),N=Fe("GroupComponent"),B=Fe("computeItemKey"),z=Fe("isSeeking"),_=Fe("groupIndices").length>0,H=Fe("alignToBottom"),W=Fe("initialItemFinalLocationReached"),q=t?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:T!==0?T:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:T!==0?T:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...W?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&R!==null&&R!==void 0?n.jsx(R,{...pn(R,x)}):n.jsx(L,{...pn(L,x),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:q,children:(t?a.topItems:a.items).map(ee=>{const $=ee.originalIndex,D=B($+a.firstItemIndex,ee.data,x);return z?p.createElement(O,{...pn(O,x),height:ee.size,index:ee.index,key:D,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?p.createElement(N,{...pn(N,x),"data-index":$,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:Rw},v(ee.index,x)):p.createElement(P,{...pn(P,x),...Dw(P,ee.data),"data-index":$,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:w?Aw:Uy},_?h(ee.index,ee.groupIndex,ee.data,x):h(ee.index,ee.data,x))})})}),Lw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Mw={outline:"none",overflowX:"auto",position:"relative"},uc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),zw={position:qf(),top:0,width:"100%",zIndex:1};function pn(t,a){if(typeof t!="string")return{context:a}}function Dw(t,a){return{item:typeof t=="string"?void 0:a}}const _w=Le.memo(function(){const t=Fe("HeaderComponent"),a=Jn("headerHeight"),s=Fe("HeaderFooterTag"),i=Ka(Le.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,Fe("skipAnimationFrameInResizeObserver")),c=Fe("context");return t!=null?n.jsx(s,{ref:i,children:n.jsx(t,{...pn(t,c)})}):null}),Ow=Le.memo(function(){const t=Fe("FooterComponent"),a=Jn("footerHeight"),s=Fe("HeaderFooterTag"),i=Ka(Le.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,Fe("skipAnimationFrameInResizeObserver")),c=Fe("context");return t!=null?n.jsx(s,{ref:i,children:n.jsx(t,{...pn(t,c)})}):null});function Hy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Le.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}=$y(f,x,h,v,void 0,y);return t("scrollTo",k),t("scrollBy",b),n.jsx(h,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:j,style:{...y?Mw:Lw,...c},tabIndex:0,...d,...pn(h,u),children:i})})}function Py({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Le.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=Le.useRef(null),k=a("scrollerRef"),{scrollByCallback:w,scrollerRef:C,scrollToCallback:T}=$y(f,x,h,k,b);return Iy(()=>{var E;return C.current=b||((E=j.current)==null?void 0:E.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",T),t("scrollBy",w),n.jsx(h,{ref:j,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...pn(h,u),children:i})})}const Bw=({children:t})=>{const a=Le.useContext(Oy),s=Jn("viewportHeight"),i=Jn("fixedItemHeight"),c=Fe("alignToBottom"),u=Fe("horizontalDirection"),d=Le.useMemo(()=>py(s,h=>ya(h,u?"width":"height")),[s,u]),f=Ka(d,!0,Fe("skipAnimationFrameInResizeObserver"));return Le.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),n.jsx("div",{"data-viewport-type":"element",ref:f,style:uc(c),children:t})},Iw=({children:t})=>{const a=Le.useContext(Oy),s=Jn("windowViewportRect"),i=Jn("fixedItemHeight"),c=Fe("customScrollParent"),u=hy(s,c,Fe("skipAnimationFrameInResizeObserver")),d=Fe("alignToBottom");return Le.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),n.jsx("div",{"data-viewport-type":"window",ref:u,style:uc(d),children:t})},$w=({children:t})=>{const a=Fe("TopItemListComponent")??"div",s=Fe("headerHeight"),i={...zw,marginTop:`${s}px`},c=Fe("context");return n.jsx(a,{style:i,...pn(a,c),children:t})},Uw=Le.memo(function(t){const a=Fe("useWindowScroll"),s=Fe("topItemsIndexes").length>0,i=Fe("customScrollParent"),c=Fe("context");return n.jsxs(i||a?Vw:Pw,{...t,context:c,children:[s&&n.jsx($w,{children:n.jsx(Hg,{showTopList:!0})}),n.jsxs(i||a?Iw:Bw,{children:[n.jsx(_w,{}),n.jsx(Hg,{}),n.jsx(Ow,{})]})]})}),{Component:Hw,useEmitter:Kf,useEmitterValue:Fe,usePublisher:Jn}=_y(Nw,{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"}},Uw),Pw=Hy({useEmitter:Kf,useEmitterValue:Fe,usePublisher:Jn}),Vw=Py({useEmitter:Kf,useEmitterValue:Fe,usePublisher:Jn}),Fw=Hw,Ww=ut(()=>{const t=ge(x=>n.jsxs("td",{children:["Item $",x]})),a=ge(null),s=ge(x=>n.jsxs("td",{colSpan:1e3,children:["Group ",x]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Yf),f=ge(Yl),h=(x,v=null)=>mn(me(u,Ce(y=>y[x]),Lt()),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")}});Mt(Dy,Ww);qf();const Pg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Gw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Vg,floor:Xo,max:Ks,min:Id,round:Fg}=Math;function Wg(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function qw(t){return{...Gw,items:t}}function Lo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Yw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Kw=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:w},{customScrollParent:C,useWindowScroll:T,windowScrollContainerState:E,windowScrollTo:R,windowViewportRect:O},L])=>{const P=ge(0),N=ge(0),B=ge(Pg),z=ge({height:0,width:0}),_=ge({height:0,width:0}),H=lt(),W=lt(),q=ge(0),ee=ge(null),$=ge({column:0,row:0}),D=lt(),U=lt(),F=ge(!1),Y=ge(0),oe=ge(!0),M=ge(!1),I=ge(!1);mt(me(k,Qe(Y),$e(([J,he])=>he!==0)),()=>{Xe(oe,!1)}),mt(me(Kt(k,oe,_,z,Y,M),$e(([J,he,je,Ne,,De])=>J&&!he&&je.height!==0&&Ne.height!==0&&!De)),([,,,,J])=>{Xe(M,!0),Vf(1,()=>{Xe(H,J)}),ir(me(x),()=>{Xe(a,[0,0]),Xe(oe,!0)})}),Me(me(U,$e(J=>J!=null&&J.scrollTop>0),hr(0)),N),mt(me(k,Qe(U),$e(([,J])=>J!=null)),([,J])=>{J&&(Xe(z,J.viewport),Xe(_,J.item),Xe($,J.gap),J.scrollTop>0&&(Xe(F,!0),ir(me(x,Ga(1)),he=>{Xe(F,!1)}),Xe(h,{top:J.scrollTop})))}),Me(me(z,Ce(({height:J})=>J)),y),Me(me(Kt(Ie(z,Lo),Ie(_,Lo),Ie($,(J,he)=>J!==void 0&&J.column===he.column&&J.row===he.row),Ie(x)),Ce(([J,he,je,Ne])=>({gap:je,item:he,scrollTop:Ne,viewport:J}))),D),Me(me(Kt(Ie(P),i,Ie($,Yw),Ie(_,Lo),Ie(z,Lo),Ie(ee),Ie(N),Ie(F),Ie(oe),Ie(Y)),$e(([,,,,,,,J])=>!J),Ce(([J,[he,je],Ne,De,He,Ue,_e,,Ze,st])=>{const{column:ce,row:ve}=Ne,{height:ye,width:Se}=De,{width:Ae}=He;if(_e===0&&(J===0||Ae===0))return Pg;if(Se===0){const tt=Ff(st,J),Nt=tt+Math.max(_e-1,0);return qw(Wg(tt,Nt,Ue))}const Ge=Vy(Ae,Se,ce);let We,wt;Ze?he===0&&je===0&&_e>0?(We=0,wt=_e-1):(We=Ge*Xo((he+ve)/(ye+ve)),wt=Ge*Vg((je+ve)/(ye+ve))-1,wt=Id(J-1,Ks(wt,Ge-1)),We=Id(wt,Ks(0,We))):(We=0,wt=-1);const Ct=Wg(We,wt,Ue),{bottom:Et,top:zt}=Gg(He,Ne,De,Ct),xe=Vg(J/Ge),qe=xe*ye+(xe-1)*ve-Et;return{bottom:Et,itemHeight:ye,items:Ct,itemWidth:Se,offsetBottom:qe,offsetTop:zt,top:zt}})),B),Me(me(ee,$e(J=>J!==null),Ce(J=>J.length)),P),Me(me(Kt(z,_,B,$),$e(([J,he,{items:je}])=>je.length>0&&he.height!==0&&J.height!==0),Ce(([J,he,{items:je},Ne])=>{const{bottom:De,top:He}=Gg(J,Ne,he,je);return[He,De]}),Lt(ni)),a);const K=ge(!1);Me(me(x,Qe(K),Ce(([J,he])=>he||J!==0)),K);const Q=$n(me(Kt(B,P),$e(([{items:J}])=>J.length>0),Qe(K),$e(([[J,he],je])=>{const Ne=J.items[J.items.length-1].index===he-1;return(je||J.bottom>0&&J.itemHeight>0&&J.offsetBottom===0&&J.items.length===he)&&Ne}),Ce(([[,J]])=>J-1),Lt())),ue=$n(me(Ie(B),$e(({items:J})=>J.length>0&&J[0].index===0),hr(0),Lt())),te=$n(me(Ie(B),Qe(F),$e(([{items:J},he])=>J.length>0&&!he),Ce(([{items:J}])=>({endIndex:J[J.length-1].index,startIndex:J[0].index})),Lt(jy),Pr(0)));Me(te,j.scrollSeekRangeChanged),Me(me(H,Qe(z,_,P,$),Ce(([J,he,je,Ne,De])=>{const He=Ey(J),{align:Ue,behavior:_e,offset:Ze}=He;let st=He.index;st==="LAST"&&(st=Ne-1),st=Ks(0,st,Id(Ne-1,st));let ce=bf(he,De,je,st);return Ue==="end"?ce=Fg(ce-he.height+je.height):Ue==="center"&&(ce=Fg(ce-he.height/2+je.height/2)),Ze!==void 0&&Ze!==0&&(ce+=Ze),{behavior:_e,top:ce}})),h);const ie=mn(me(B,Ce(J=>J.offsetBottom+J.bottom)),0);return Me(me(O,Ce(J=>({height:J.visibleHeight,width:J.visibleWidth}))),z),{customScrollParent:C,data:ee,deviation:q,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:N,itemDimensions:_,overscan:s,restoreStateFrom:U,scrollBy:d,scrollContainerState:f,scrollHeight:W,scrollTo:h,scrollToIndex:H,scrollTop:x,smoothScrollTargetReached:v,totalCount:P,useWindowScroll:T,viewportDimensions:z,windowScrollContainerState:E,windowScrollTo:R,windowViewportRect:O,...j,gridState:B,horizontalDirection:I,initialTopMostItemIndex:Y,totalListHeight:ie,...b,endReached:Q,propsReady:w,rangeChanged:te,startReached:ue,stateChanged:D,stateRestoreInProgress:F,...L}},Mt(Wf,vn,di,My,ka,Gf,Sa));function Vy(t,a,s){return Ks(1,Xo((t+s)/(Xo(a)+s)))}function Gg(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=bf(t,a,s,i[0].index);return{bottom:bf(t,a,s,i[i.length-1].index)+c,top:u}}function bf(t,a,s,i){const c=Vy(t.width,s.width,a.column),u=Xo(i/c),d=u*s.height+Ks(0,u-1)*a.row;return d>0?d+a.row:d}const Xw=ut(()=>{const t=ge(y=>`Item ${y}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Yf),d=ge("div"),f=ge(Yl),h=(y,b=null)=>mn(me(a,Ce(j=>j[y]),Lt()),b),x=ge(!1),v=ge(!1);return Me(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")}}),Qw=ut(([t,a])=>({...t,...a}),Mt(Kw,Xw)),Zw=Le.memo(function(){const t=Bt("gridState"),a=Bt("listClassName"),s=Bt("itemClassName"),i=Bt("itemContent"),c=Bt("computeItemKey"),u=Bt("isSeeking"),d=er("scrollHeight"),f=Bt("ItemComponent"),h=Bt("ListComponent"),x=Bt("ScrollSeekPlaceholder"),v=Bt("context"),y=er("itemDimensions"),b=er("gap"),j=Bt("log"),k=Bt("stateRestoreInProgress"),w=er("reportReadyState"),C=Ka(Le.useMemo(()=>T=>{const E=T.parentElement.parentElement.scrollHeight;d(E);const R=T.firstChild;if(R!==null){const{height:O,width:L}=R.getBoundingClientRect();y({height:O,width:L})}b({column:qg("column-gap",getComputedStyle(T).columnGap,j),row:qg("row-gap",getComputedStyle(T).rowGap,j)})},[d,y,b,j]),!0,!1);return Iy(()=>{t.itemHeight>0&&t.itemWidth>0&&w(!0)},[t]),k?null:n.jsx(h,{className:a,ref:C,...pn(h,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(T=>{const E=c(T.index,T.data,v);return u?n.jsx(x,{...pn(x,v),height:t.itemHeight,index:T.index,width:t.itemWidth},E):p.createElement(f,{...pn(f,v),className:s,"data-index":T.index,key:E},i(T.index,T.data,v))})})}),Jw=Le.memo(function(){const t=Bt("HeaderComponent"),a=er("headerHeight"),s=Bt("headerFooterTag"),i=Ka(Le.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,!1),c=Bt("context");return t!=null?n.jsx(s,{ref:i,children:n.jsx(t,{...pn(t,c)})}):null}),eC=Le.memo(function(){const t=Bt("FooterComponent"),a=er("footerHeight"),s=Bt("headerFooterTag"),i=Ka(Le.useMemo(()=>u=>{a(ya(u,"height"))},[a]),!0,!1),c=Bt("context");return t!=null?n.jsx(s,{ref:i,children:n.jsx(t,{...pn(t,c)})}):null}),tC=({children:t})=>{const a=Le.useContext(By),s=er("itemDimensions"),i=er("viewportDimensions"),c=Ka(Le.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Le.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),n.jsx("div",{ref:c,style:uc(!1),children:t})},nC=({children:t})=>{const a=Le.useContext(By),s=er("windowViewportRect"),i=er("itemDimensions"),c=Bt("customScrollParent"),u=hy(s,c,!1);return Le.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),n.jsx("div",{ref:u,style:uc(!1),children:t})},rC=Le.memo(function({...t}){const a=Bt("useWindowScroll"),s=Bt("customScrollParent"),i=s||a?lC:aC,c=s||a?nC:tC,u=Bt("context");return n.jsx(i,{...t,...pn(i,u),children:n.jsxs(c,{children:[n.jsx(Jw,{}),n.jsx(Zw,{}),n.jsx(eC,{})]})})}),{useEmitter:Fy,useEmitterValue:Bt,usePublisher:er}=_y(Qw,{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"}},rC),aC=Hy({useEmitter:Fy,useEmitterValue:Bt,usePublisher:er}),lC=Py({useEmitter:Fy,useEmitterValue:Bt,usePublisher:er});function qg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Zt.WARN),a==="normal"?0:parseInt(a??"0",10)}const sC={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Wy={source:"Own",installed:"Installed"};function iC(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 oC(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Yg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=sC[t],[d,f]=p.useState(()=>iC(u)),h=p.useCallback(()=>{f(b=>{const j=!b;return oC(u,j),j})},[u]),x=Wy[t],v=`sidebar-section-${t}-header`,y=`sidebar-section-${t}-group`;return n.jsxs("section",{"aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:[n.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:[n.jsx(uC,{collapsed:d}),n.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:x}),n.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&&n.jsx(cC,{origin:t,updateCount:i})]}),!d&&n.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function cC({origin:t,updateCount:a}){const[s,i]=p.useState(!1),c=Wy[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return n.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",n.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function uC({collapsed:t}){return n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Xf(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 dC({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return p.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)},[]),n.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[n.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:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("path",{d:"M21 21l-4.35-4.35"})]}),n.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&&n.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}),n.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 fC({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 n.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:n.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:[n.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"}),n.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 pC({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return n.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:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 19V5"}),n.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function mC({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(ny)}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 n.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:n.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 hC(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 fi(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=hC(c,f,u),k=t.title??j,w={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&&(w.fontStyle="italic"),n.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:k,style:w,children:h})}function xC({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return n.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:[n.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"}}),n.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&n.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)"}}),n.jsx(fi,{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&&n.jsx(fC,{target:t.symlinkTarget??null}),n.jsx(pC,{skill:t}),n.jsx(mC,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Xs=p.memo(xC);function gC({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){var x;const d=[...a].sort((v,y)=>v.skill.localeCompare(y.skill)),f=(x=a[0])==null?void 0:x.pluginDisplay,h=!!f&&f.toLowerCase()!==t.toLowerCase();return n.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 12px 4px 14px"},children:[n.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}),n.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]}),h&&n.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})]}),n.jsx("div",{role:"list",children:d.map(v=>{const y=!!s&&s.plugin===v.plugin&&s.skill===v.skill;return n.jsx("div",{role:"listitem",children:n.jsx(Xs,{skill:v,isSelected:y,onSelect:()=>i(v),onContextMenu:c,dirty:u==null?void 0:u.has(`${v.plugin}/${v.skill}`)})},`${v.plugin}/${v.skill}`)})})]})}function vC(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]=p.useState(()=>vC(i,s)),v=d?!1:h,y=p.useCallback(()=>{x(k=>{const w=!k;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(w))}catch{}return w})},[i]),b=v?"▸":"▾";return n.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${t.length})`,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[n.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:[n.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}),n.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:f}),n.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&&n.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!v&&n.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=>n.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}function Go({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const h=p.useRef(null),x=p.useRef(null),v=p.useRef(null);if(p.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=x.current)==null||k.focus()}),()=>{var k,w;(w=(k=v.current)==null?void 0:k.focus)==null||w.call(k),v.current=null}},[t]),p.useEffect(()=>{if(!t)return;function k(w){if(w.key==="Escape"){w.preventDefault(),f();return}if(w.key==="Tab"&&h.current){const C=h.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const T=C[0],E=C[C.length-1];w.shiftKey&&document.activeElement===T?(w.preventDefault(),E.focus()):!w.shiftKey&&document.activeElement===E&&(w.preventDefault(),T.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 n.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:n.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:[n.jsx("h2",{id:y,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),n.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[n.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}),n.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 yC(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 bC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[f,h]=p.useState(null),[x,v]=p.useState(!1),y=p.useRef(null);p.useEffect(()=>{if(!i)return;function k(w){y.current&&!y.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[i]);async function b(k){d(k),h(null);try{const w=await fetch(`/api/plugins/${encodeURIComponent(t)}/${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),C=await w.json().catch(()=>({}));if(!w.ok||!C.ok){const T=C.error??`${k} failed (${w.status})`;h(T),k==="uninstall"&&Ud(`Failed to uninstall ${t}: ${T}`,"error");return}if(k==="uninstall"){const T=C.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Ud(T,"success")}In("skills"),dy(),s==null||s(),c(!1)}catch(w){const C=w instanceof Error?w.message:String(w);h(C),k==="uninstall"&&Ud(`Failed to uninstall ${t}: ${C}`,"error")}finally{d(null)}}function j(){v(!0)}return n.jsxs("div",{ref:y,style:{position:"relative",display:"inline-flex"},children:[n.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:k=>{k.stopPropagation(),c(w=>!w)},"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&&n.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?n.jsx(Hd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):n.jsx(Hd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),n.jsx(Hd,{onClick:j,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&n.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})]}),n.jsx(Go,{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 n.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:[n.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),n.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const jC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function SC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=p.useState(s),[h,x]=p.useState(i??""),[v,y]=p.useState(!1),[b,j]=p.useState(null),[k,w]=p.useState(null),C=jC.test(d),T=v||!C,E=p.useCallback(async R=>{if(R.preventDefault(),!T){y(!0),j(null),w(null);try{const O=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:h.trim()});c({pluginDir:O.pluginDir,manifestPath:O.manifestPath,validation:O.validation})}catch(O){if(O instanceof Vr){j(O.message);const L=O.details;L&&typeof L.stderr=="string"&&w(L.stderr)}else j(O instanceof Error?O.message:String(O));y(!1)}}},[T,t,d,h,c]);return n.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:R=>{R.target===R.currentTarget&&!v&&u()},children:n.jsxs("form",{onSubmit:E,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:[n.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",n.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),n.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",n.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",n.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),n.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),n.jsx("input",{type:"text",value:d,onChange:R=>f(R.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}}),!C&&n.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),n.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),n.jsx("input",{type:"text",value:h,onChange:R=>x(R.target.value),disabled:v,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&n.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:[n.jsx("div",{style:{fontWeight:500},children:b}),k&&n.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})]}),n.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[n.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"}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",opacity:T?.5:1},children:v?"Converting…":"Convert"})]})]})})}function Kg({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=n.jsxs(n.Fragment,{children:[x&&n.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}),n.jsx("span",{className:"vskill-group-header-name",children:t}),n.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&&n.jsx("span",{style:{marginLeft:"auto"},children:n.jsx(kC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return x?n.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}):n.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 kC({label:t,title:a,icon:s,onClick:i,accent:c}){return n.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 wC(){return n.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[n.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),n.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function CC(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 EC(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 NC(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 jf(t,a={}){const{enabled:s=!0,target:i}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(CC),p.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(h){const x=h,v=EC(x.target);for(const y of c.current){if(!NC(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 Gy(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function TC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function RC({projectRoot:t}){const{status:a,loading:s}=Gy();if(s||!a||a.status==="github"||TC(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 n.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:n.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:[n.jsx("path",{d:"m2 2 20 20"}),n.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),n.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 AC=200;function LC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function MC(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=>Xf(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 zC(t,a){const s=[],i=[],c=[];for(const d of t){const f=LC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var v;const f=d.filter(y=>Xf(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 DC(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=>Xf(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 _C({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[w,C]=p.useState(null),T=!!h||t.some(ie=>ie.scope!==void 0&&ie.scope!==null),E=h??"claude-cli",[R,O]=p.useState(""),L=p.useDeferredValue(R),P=p.useMemo(()=>zC(t,L),[t,L]),N=p.useMemo(()=>MC(t,L),[t,L]),B=E==="claude-code",{plugins:z}=Dk(),_=B?{plugins:z??[]}:void 0,H=p.useMemo(()=>{const ie=new Map;for(const J of(_==null?void 0:_.plugins)??[]){const he=ie.get(J.name);ie.set(J.name,!!he||!!J.enabled)}return ie},[_==null?void 0:_.plugins]),[W,q]=p.useState(()=>Sf(`vskill-sidebar-${E}-group-available-collapsed`)),[ee,$]=p.useState(()=>Sf(`vskill-sidebar-${E}-group-authoring-collapsed`)),D=p.useCallback(ie=>{q(ie);try{window.localStorage.setItem(`vskill-sidebar-${E}-group-available-collapsed`,String(ie))}catch{}},[E]),U=p.useCallback(ie=>{$(ie);try{window.localStorage.setItem(`vskill-sidebar-${E}-group-authoring-collapsed`,String(ie))}catch{}},[E]),{own:F,installed:Y}=p.useMemo(()=>DC(t,L),[t,L]),M=P.own.filtered+P.installed.filtered+P.global.filtered>=AC,I=p.useMemo(()=>{const ie=J=>{const he=[];for(const[,je]of J){const Ne=[...je].sort((De,He)=>De.skill.localeCompare(He.skill));he.push(...Ne)}return he};return T?[...ie(P.own.byPlugin),...ie(P.installed.byPlugin),...ie(P.global.byPlugin)]:[...ie(F.byPlugin),...ie(Y.byPlugin)]},[T,P.own.byPlugin,P.installed.byPlugin,P.global.byPlugin,F.byPlugin,Y.byPlugin]),K=p.useMemo(()=>a?I.findIndex(ie=>ie.plugin===a.plugin&&ie.skill===a.skill):-1,[I,a]),Q=p.useCallback(ie=>{if(I.length===0)return;const J=K<0?ie>0?0:I.length-1:Math.min(Math.max(K+ie,0),I.length-1);s(I[J])},[I,K,s]),ue=p.useMemo(()=>{if(!y)return null;const[ie,J]=y.split("/");if(!ie||!J)return null;const he=t.find(De=>De.plugin===ie&&De.skill===J);if(!he)return{plugin:ie,skill:J,bucket:null,pluginName:null};const je=he.source==="plugin"?"plugin":"project",Ne=je==="plugin"?he.pluginName??ie:null;return{plugin:ie,skill:J,bucket:je,pluginName:Ne}},[y,t]),te=p.useRef(null);return p.useEffect(()=>{if(!y){te.current=null;return}if(te.current===y)return;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),J=document.querySelector(`[data-skill-id="${ie}"]`);J&&(te.current=y,J.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),jf([{key:"j",handler:()=>Q(1)},{key:"k",handler:()=>Q(-1)},{key:"Enter",handler:()=>{K>=0&&s(I[K])}}],{enabled:!i&&!c}),n.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,n.jsx(dC,{value:R,onChange:O}),i&&n.jsx(PC,{}),!i&&c&&n.jsx(VC,{error:c,onRetry:u}),!i&&!c&&T&&n.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[n.jsx(Kg,{name:ae.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:W,onToggle:D,count:N.availableProject.total+N.availablePersonal.total+N.availablePlugin.total}),!W&&n.jsxs(n.Fragment,{children:[n.jsx(Hs,{label:ae.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${E}-available-project-collapsed`,count:N.availableProject.total,filteredCount:R?N.availableProject.filtered:null,updateCount:(x==null?void 0:x.installed)??(f==null?void 0:f.installed),headerRightSlot:B?n.jsx(RC,{projectRoot:E}):null,children:N.availableProject.filtered===0?n.jsx(Qg,{queryActive:!!R,agentId:E}):n.jsx(Ps,{items:N.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:j})}),n.jsx(Hs,{label:ae.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${E}-available-personal-collapsed`,count:N.availablePersonal.total,filteredCount:R?N.availablePersonal.filtered:null,updateCount:x==null?void 0:x.global,children:N.availablePersonal.filtered===0?n.jsx(BC,{queryActive:!!R,agentId:E}):n.jsx(Ps,{items:N.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:j})}),B&&n.jsxs(Hs,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${E}-available-plugin-collapsed`,count:N.availablePlugin.total,filteredCount:R?N.availablePlugin.filtered:null,children:[n.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:[n.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),N.availablePlugin.filtered===0?n.jsx(IC,{queryActive:!!R,hasInstalled:N.availablePlugin.total>0}):N.availablePlugin.byPlugin.map(([ie,J])=>n.jsx($d,{pluginName:ie,skills:J,persistKey:`vskill-plugin-available-${ie}-collapsed`,headerActionSlot:B?n.jsx(bC,{pluginName:ie,enabled:H.get(ie)??!0}):void 0,renderSkill:he=>n.jsx(Xs,{skill:he,isSelected:(a==null?void 0:a.plugin)===he.plugin&&(a==null?void 0:a.skill)===he.skill,onSelect:()=>s(he),onContextMenu:d,dirty:j==null?void 0:j.has(`${he.plugin}/${he.skill}`)})},`available-${ie}`))]})]}),n.jsx(HC,{}),n.jsx(Kg,{name:ae.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:ue?!1:ee,onToggle:U,count:N.authoringProject.total+N.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:n.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:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.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)&&n.jsxs(n.Fragment,{children:[n.jsx(Hs,{label:ae.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${E}-authoring-project-collapsed`,count:N.authoringProject.total,filteredCount:R?N.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:N.authoringProject.filtered===0?n.jsx(Xg,{queryActive:!!R}):n.jsxs(n.Fragment,{children:[N.authoringCandidatePlugins.map(ie=>n.jsx($d,{pluginName:ie.groupKey,skills:ie.skills,persistKey:`vskill-candidate-plugin-${ie.groupKey}-collapsed`,headerActionSlot:n.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),C({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:J=>n.jsx(Xs,{skill:J,isSelected:(a==null?void 0:a.plugin)===J.plugin&&(a==null?void 0:a.skill)===J.skill,onSelect:()=>s(J),onContextMenu:d,dirty:j==null?void 0:j.has(`${J.plugin}/${J.skill}`)})},`candidate-${ie.groupKey}`)),n.jsx(Ps,{items:N.authoringProject.byPlugin.filter(([ie])=>!N.authoringCandidatePlugins.some(J=>J.groupKey===ie)),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:j})]})}),B&&n.jsx(Hs,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${E}-authoring-plugin-collapsed`,count:N.authoringPlugin.total,filteredCount:R?N.authoringPlugin.filtered:null,forceOpen:(ue==null?void 0:ue.bucket)==="plugin",children:N.authoringPlugin.filtered===0?n.jsx($C,{queryActive:!!R,hasSources:N.authoringPlugin.total>0,candidates:N.authoringCandidatePlugins,onPromote:ie=>C({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})}):N.authoringPlugin.byPlugin.map(([ie,J])=>n.jsx($d,{pluginName:ie,skills:J,persistKey:`vskill-plugin-authoring-${ie}-collapsed`,forceOpen:(ue==null?void 0:ue.bucket)==="plugin"&&ue.pluginName===ie,renderSkill:he=>n.jsx(Xs,{skill:he,isSelected:(a==null?void 0:a.plugin)===he.plugin&&(a==null?void 0:a.skill)===he.skill,onSelect:()=>s(he),onContextMenu:d,dirty:j==null?void 0:j.has(`${he.plugin}/${he.skill}`)})},`authoring-${ie}`))})]})]}),!i&&!c&&!T&&n.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[n.jsx(Yg,{origin:"source",count:F.total,filteredCount:R?F.filtered:null,updateCount:f==null?void 0:f.source,children:F.filtered===0?n.jsx(Xg,{queryActive:!!R}):n.jsx(Ps,{items:F.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:j})}),n.jsx(UC,{}),n.jsx(Yg,{origin:"installed",count:Y.total,filteredCount:R?Y.filtered:null,updateCount:f==null?void 0:f.installed,children:Y.filtered===0?n.jsx(Qg,{queryActive:!!R}):n.jsx(Ps,{items:Y.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:j})})]}),w&&n.jsx(SC,{anchorSkillDir:w.anchorSkillDir,candidateLabel:w.candidateLabel,initialName:w.initialName,onCancel:()=>C(null),onConverted:ie=>{C(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 Sf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Hs({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[h,x]=p.useState(()=>Sf(a)),v=d?!1:h,y=p.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 n.jsxs("section",{"data-vskill-named-scope":t,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[n.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:[n.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?"▸":"▾"}),n.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),n.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&n.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!v&&n.jsx("div",{style:{paddingLeft:18},children:u})]})}function OC(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 Ps({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=OC(t);return n.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:n.jsx(Fw,{overscan:4,totalCount:d.length,itemContent:f=>{const h=d[f];if(!h)return null;if(h.kind==="header")return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[n.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),n.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 n.jsx(Xs,{skill:x,isSelected:v,onSelect:()=>s(x),onContextMenu:i,dirty:u==null?void 0:u.has(`${x.plugin}/${x.skill}`)})}})})}return n.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>n.jsx(gC,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Xg({queryActive:t}){return t?n.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):n.jsx(yr,{headline:"No skills yet.",body:n.jsxs(n.Fragment,{children:["Create one with ",n.jsx(Pl,{children:"vskill new"})," or the"," ",n.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Qg({queryActive:t,agentId:a}){return t?n.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):n.jsx(yr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:n.jsxs(n.Fragment,{children:["Run ",n.jsx(Pl,{children:"vskill install <skill>"})," to add one."]})})}function BC({queryActive:t,agentId:a}){return t?n.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):n.jsx(yr,{headline:`No global skills for ${a}.`,body:n.jsxs(n.Fragment,{children:["Run ",n.jsx(Pl,{children:"vskill install --global <skill>"})," to add one."]})})}function IC({queryActive:t,hasInstalled:a}){return t&&a?n.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):n.jsx(yr,{headline:"No plugin skills installed yet.",body:n.jsxs(n.Fragment,{children:["Click ",n.jsx(Pl,{children:"Browse marketplaces…"})," above to add one."]})})}function $C({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?n.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):n.jsxs(n.Fragment,{children:[n.jsx(yr,{headline:"No plugin sources in this project.",body:n.jsxs(n.Fragment,{children:["Add ",n.jsx(Pl,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",n.jsx(Pl,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&n.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[n.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>n.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:[n.jsxs("span",{children:[c.groupKey,"/ ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),n.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function yr({headline:t,body:a}){return n.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[n.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),n.jsx("div",{children:a})]})}function Pl({children:t}){return n.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 UC(){return n.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function HC(){return n.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 PC(){return n.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>n.jsx(wC,{},t))})}function VC({error:t,onRetry:a}){return n.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:[n.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),n.jsxs("details",{children:[n.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:FC(t)}),n.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&&n.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 FC(t){const a=t.split(`
|
|
66
|
+
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const qy=240,Yy=480,Ky="vskill-sidebar-width",Qs=320;function Qf(t){return Number.isFinite(t)?Math.round(Math.max(qy,Math.min(Yy,t))):Qs}function WC(){try{const t=localStorage.getItem(Ky);if(!t)return Qs;const a=Number(t);return Number.isFinite(a)?Qf(a):Qs}catch{return Qs}}function GC(t){try{localStorage.setItem(Ky,String(Qf(t)))}catch{}}function qC({initialWidth:t,onChange:a}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),i=p.useRef(t);return p.useEffect(()=>{i.current=t},[t]),p.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const f=d.clientX-s.current.startX,h=Qf(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,GC(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]),n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":qy,"aria-valuemax":Yy,"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 YC=/^[ MADRCU?!]{1,2} +/;function KC(t){return t.replace(YC,"")}function XC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function QC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>KC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const f=XC(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 ZC=5e3;function JC(t,a,s=ZC){const[i,c]=p.useState([]),u=p.useRef(t);return u.current=t,p.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?QC(u.current,i,a):new Set}function eE({connected:t,hint:a,onRetry:s}){return t?null:n.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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),n.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&n.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),n.jsx("div",{style:{flex:1}}),s&&n.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function Xy(t,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 Qy(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]=p.useState([]),[s,i]=p.useState(!1),[c,u]=p.useState(!1),[d,f]=p.useState(null),h=p.useRef(null),x=p.useCallback(async(y,b)=>{a([]),i(!0),u(!1),f(null);const j=new AbortController;h.current=j;try{const k=Qy(b),w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:j.signal});if(!w.ok||!w.body){let O=`HTTP ${w.status}`,L;try{L=await w.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(O=L.error)}catch{}throw Xy(w.status,L),new Error(O)}const C=w.body.getReader(),T=new TextDecoder;let E="",R="";for(;;){const{done:O,value:L}=await C.read();if(O)break;E+=T.decode(L,{stream:!0});const P=E.split(`
|
|
67
|
+
`);E=P.pop()||"";for(const N of P)if(N.startsWith("event: "))R=N.slice(7).trim();else if(N.startsWith("data: ")){try{const B=JSON.parse(N.slice(6)),z={event:R,data:B};R==="done"?(u(!0),a(_=>[..._,z])):a(_=>[..._,z])}catch{}R=""}}}catch(k){k.name!=="AbortError"&&f(k.message)}finally{i(!1),h.current=null}},[]),v=p.useCallback(()=>{var y;(y=h.current)==null||y.abort()},[]);return{events:t,running:s,done:c,error:d,start:x,stop:v}}function tE(t){const a=p.useRef(t);a.current=t;const[s,i]=p.useState(new Set),c=p.useRef(new Map),u=p.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 w=new Set(k);return w.add(x),w});try{const k=Qy(y),w=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!w.ok||!w.body){let O=`HTTP ${w.status}`,L;try{L=await w.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(O=L.error)}catch{}throw Xy(w.status,L),new Error(O)}const C=w.body.getReader(),T=new TextDecoder;let E="",R="";for(;;){const{done:O,value:L}=await C.read();if(O)break;E+=T.decode(L,{stream:!0});const P=E.split(`
|
|
68
|
+
`);E=P.pop()||"";for(const N of P)if(N.startsWith("event: "))R=N.slice(7).trim();else if(N.startsWith("data: ")){try{const B=JSON.parse(N.slice(6)),z={event:R,data:B};a.current.onEvent(x,z)}catch{}R=""}}a.current.onDone(x)}catch(k){k.name!=="AbortError"&&a.current.onError(x,k.message)}finally{i(k=>{const w=new Set(k);return w.delete(x),w}),c.current.delete(x)}},[]),d=p.useCallback(x=>{var v;(v=c.current.get(x))==null||v.abort()},[]),f=p.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 nE={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 rE(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 aE(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 lE(t){if(t==="unit"||t==="integration")return t}function sE(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 Zy=p.createContext(null);function yn(){const t=p.useContext(Zy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function iE({plugin:t,skill:a,origin:s,children:i}){var st;const c=s==="installed",{config:u}=Ya(),[d,f]=p.useReducer(rE,{...nE,plugin:t,skill:a}),h=aE({origin:s},{exists:d.evals!=null,cases:((st=d.evals)==null?void 0:st.evals)??[]}),x=h.canEdit,v=h.canRun,y=p.useRef(new Set),b=p.useRef(new Set),j=p.useRef(new Map),k=p.useCallback((ce,ve)=>{let ye=j.current.get(ce);ye||(ye={assertions:[]},j.current.set(ce,ye)),sE(ye,ve),f({type:"UPDATE_INLINE_RESULT",evalId:ce,result:{...ye,assertions:[...ye.assertions]}})},[]),w=p.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]),C=p.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:T,stopCase:E,stopAll:R}=tE({onEvent:k,onDone:w,onError:C});p.useEffect(()=>()=>{R()},[R]);const O=p.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]);p.useEffect(()=>{let ce=!1;async function ve(){try{const[ye,Se,Ae]=await Promise.allSettled([ke.getSkillDetail(t,a),ke.getEvals(t,a),ke.getLatestBenchmark(t,a)]);if(ce)return;let Ge=null,We=null;if(Se.status==="fulfilled")Ge=Se.value;else{const wt=Se.reason;We=(wt==null?void 0:wt.message)??"Failed to load test cases"}f({type:"INIT_DATA",skillContent:ye.status==="fulfilled"?ye.value.skillContent:"",evals:Ge,evalsError:We,benchmark:Ae.status==="fulfilled"?Ae.value:null})}catch(ye){ce||f({type:"SET_ERROR",error:ye.message})}}return ve(),O(),()=>{ce=!0}},[t,a,O]);const L=p.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=p.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]),N=p.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 Se=ve==="comparison"?{eval_ids:[ce]}:ve==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(Se.provider=u.provider),u!=null&&u.model&&(Se.model=u.model),ve==="comparison"){const Ae=`/api/skills/${t}/${a}/compare`;T(ce,Ae,Se)}else{const Ae=`/api/skills/${t}/${a}/benchmark/case/${ce}`;T(ce,Ae,Object.keys(Se).length>0?Se:void 0)}},[t,a,d.caseRunStates,T,u]),B=p.useCallback((ce="benchmark")=>{var Se;const ve=((Se=d.evals)==null?void 0:Se.evals)??[];if(ve.length===0)return;const ye=ve.map(Ae=>Ae.id);for(const Ae of ye)j.current.delete(Ae),b.current.delete(Ae);f({type:"BULK_RUN_START",caseIds:ye,mode:ce}),y.current=new Set(ye);for(const Ae of ye){const Ge=ce==="comparison"?{eval_ids:[Ae]}:ce==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(Ge.provider=u.provider),u!=null&&u.model&&(Ge.model=u.model),ce==="comparison")T(Ae,`/api/skills/${t}/${a}/compare`,Ge);else{const We=`/api/skills/${t}/${a}/benchmark/case/${Ae}`;T(Ae,We,Object.keys(Ge).length>0?Ge:void 0)}}},[t,a,d.evals,T,u]),z=p.useCallback(ce=>{E(ce),f({type:"CASE_RUN_CANCEL",caseId:ce}),y.current.delete(ce),b.current.add(ce)},[E]),_=p.useCallback(()=>{R(),f({type:"CANCEL_ALL"}),y.current.clear()},[R]),H=p.useCallback(async(ce,ve)=>{f({type:"OPEN_IMPROVE",evalId:ce})},[]),W=p.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"}),N(ce,"benchmark")}catch(ye){f({type:"SET_ERROR",error:ye.message})}},[t,a,N]),q=Pd(),ee=p.useRef(null),$=p.useRef(0);p.useEffect(()=>{const ce=q.events;for(let ve=$.current;ve<ce.length;ve++){const ye=ce[ve],Se=ye.data;if(ye.event==="progress"&&f({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:Se.phase,message:Se.message}}),ye.event==="done"){const Ae=Se.improved,Ge=Se.reasoning,We=Se.evalChanges??[];f({type:"AI_EDIT_RESULT",improved:Ae,reasoning:Ge,evalChanges:We})}if(ye.event==="error"){const Ae=Se;f({type:"AI_EDIT_ERROR",message:Ae.description||"Unknown error",classified:Ae})}}$.current=ce.length},[q.events]),p.useEffect(()=>{q.error&&f({type:"AI_EDIT_ERROR",message:q.error})},[q.error]),p.useEffect(()=>()=>{q.stop()},[q.stop]);const D=p.useCallback(async(ce,ve,ye)=>{c||($.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]),U=p.useCallback(()=>{q.stop(),f({type:"AI_EDIT_ERROR",message:"Cancelled"})},[q]),F=p.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 Gl(async()=>{const{mergeEvalChanges:Ge}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Ge}},[]),Se=d.evals??{skill_name:a,evals:[]},Ae=ye(Se,d.aiEditEvalChanges,d.aiEditEvalSelections);try{const Ge=await ke.saveEvals(t,a,Ae);f({type:"SET_EVALS",evals:Ge})}catch(Ge){f({type:"SET_EVALS_RETRY",evalsFile:Ae}),f({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Ge.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=p.useCallback(()=>{f({type:"CLOSE_AI_EDIT"})},[]),oe=p.useCallback(ce=>{f({type:"TOGGLE_EVAL_CHANGE",index:ce})},[]),M=p.useCallback(()=>{f({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=p.useCallback(()=>{f({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),K=p.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=p.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(),te=p.useRef(0);p.useEffect(()=>{const ce=ue.events;for(let ve=te.current;ve<ce.length;ve++){const ye=ce[ve],Se=ye.data;if(ye.event==="progress"&&f({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:Se.phase,message:Se.message}}),ye.event==="done"){const Ae=Se;ke.saveEvals(t,a,Ae).then(Ge=>f({type:"GENERATE_EVALS_DONE",evals:Ge})).catch(Ge=>f({type:"SET_ERROR",error:Ge.message}))}ye.event==="error"&&f({type:"GENERATE_EVALS_ERROR",classified:Se})}te.current=ce.length},[ue.events,t,a]),p.useEffect(()=>{ue.error&&f({type:"SET_ERROR",error:ue.error})},[ue.error]),p.useEffect(()=>()=>{ue.stop()},[ue.stop]);const ie=p.useCallback(async ce=>{if(c)return;te.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=lE(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]),J=Pd(),he=p.useRef(0);p.useEffect(()=>()=>{J.stop()},[J.stop]),p.useEffect(()=>{const ce=J.events;for(let ve=he.current;ve<ce.length;ve++){const ye=ce[ve];if(ye.event==="classifying"){const Se=ye.data;f({type:"ACTIVATION_CLASSIFYING",index:Se.index,total:Se.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 Se=ye.data;if(Se.error)f({type:"ACTIVATION_ERROR",error:Se.error});else{f({type:"ACTIVATION_DONE",summary:Se});const Ae={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:Se.total,summary:{precision:Se.precision,recall:Se.recall,reliability:Se.reliability,tp:Se.tp,tn:Se.tn,fp:Se.fp,fn:Se.fn}};f({type:"ACTIVATION_HISTORY_LOADED",runs:[Ae,...d.activationHistory??[]]})}}}he.current=ce.length},[J.events,u,d.activationHistory]),p.useEffect(()=>{J.error&&(je.current&&(clearTimeout(je.current),je.current=null),f({type:"ACTIVATION_ERROR",error:J.error}))},[J.error]);const je=p.useRef(null),Ne=p.useCallback(()=>{je.current&&(clearTimeout(je.current),je.current=null),J.stop(),f({type:"ACTIVATION_CANCEL",totalPrompts:0})},[J]),De=p.useCallback(ce=>{const ye=ce.trim().split(`
|
|
69
|
+
`).filter(Boolean).map(Ae=>Ae.startsWith("!")?{prompt:Ae.slice(1).trim(),expected:"should_not_activate"}:Ae.startsWith("+")?{prompt:Ae.slice(1).trim(),expected:"should_activate"}:{prompt:Ae.trim(),expected:"auto"});he.current=0,f({type:"ACTIVATION_START"}),f({type:"SET_ACTIVATION_PROMPTS",prompts:ce});const Se={prompts:ye};u!=null&&u.provider&&(Se.provider=u.provider),u!=null&&u.model&&(Se.model=u.model),J.start(`/api/skills/${t}/${a}/activation-test`,Se),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{J.stop(),f({type:"ACTIVATION_TIMEOUT"}),je.current=null},12e4)},[t,a,J,u]),He=p.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 Et=`HTTP ${ye.status}`;try{const zt=await ye.json();zt.error&&(Et=zt.error)}catch{}throw new Error(Et)}const Se=ye.body.getReader(),Ae=new TextDecoder;let Ge="",We="",wt=[];for(;;){const{done:Et,value:zt}=await Se.read();if(Et)break;Ge+=Ae.decode(zt,{stream:!0});const xe=Ge.split(`
|
|
70
|
+
`);Ge=xe.pop()||"";for(const qe of xe)if(qe.startsWith("event: "))We=qe.slice(7).trim();else if(qe.startsWith("data: ")){try{const tt=JSON.parse(qe.slice(6));if(We==="done"){if(tt.error)throw new Error(tt.error);wt=tt.prompts||[]}if(We==="error")throw new Error(tt.message||tt.description||"Generation failed")}catch(tt){if(!(tt instanceof SyntaxError))throw tt}We=""}}const Ct=wt.map(Et=>`${Et.expected==="should_activate"?"+":"!"}${Et.prompt}`).join(`
|
|
71
|
+
`);f({type:"SET_PROMPTS_SOURCE",source:"ai-generated",canonical:Ct}),f({type:"SET_ACTIVATION_PROMPTS",prompts:Ct}),f({type:"GENERATE_PROMPTS_DONE"})}catch(ve){f({type:"GENERATE_PROMPTS_ERROR",error:ve.message})}},[t,a,u]),Ue=p.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(Se=>Se.expected==="should_activate"?`+${Se.prompt}`:Se.expected==="should_not_activate"?`!${Se.prompt}`:Se.prompt).join(`
|
|
72
|
+
`);f({type:"SET_PROMPTS_SOURCE",source:"skill-md",canonical:ye}),f({type:"SET_ACTIVATION_PROMPTS",prompts:ye})}catch{}},[t,a]),_e=p.useCallback(async()=>{f({type:"SAVE_TEST_CASES_START"});try{const ve=d.activationPrompts.split(`
|
|
73
|
+
`).map(Ae=>Ae.trim()).filter(Boolean).map(Ae=>Ae.startsWith("!")?{prompt:Ae.slice(1).trim(),expected:"should_not_activate"}:Ae.startsWith("+")?{prompt:Ae.slice(1).trim(),expected:"should_activate"}:{prompt:Ae,expected:"auto"}),ye=await fetch(`/api/skills/${t}/${a}/test-cases`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompts:ve})}),Se=await ye.json().catch(()=>({}));if(!ye.ok||!Se.ok)throw new Error(Se.error||`HTTP ${ye.status}`);f({type:"SAVE_TEST_CASES_SUCCESS",count:Se.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]),Ze=p.useMemo(()=>({state:d,dispatch:f,isReadOnly:c,canEdit:x,canRun:v,saveContent:L,saveEvals:P,runCase:N,runAll:B,cancelCase:z,cancelAll:_,improveForCase:H,applyImproveAndRerun:W,refreshSkillContent:Q,generateEvals:ie,runActivationTest:De,cancelActivation:Ne,generateActivationPrompts:He,fetchActivationHistory:O,loadTestCasesFromSkillMd:Ue,saveTestCasesToSkillMd:_e,submitAiEdit:D,cancelAiEdit:U,applyAiEdit:F,discardAiEdit:Y,toggleEvalChange:oe,selectAllEvalChanges:M,deselectAllEvalChanges:I,retryEvalsSave:K}),[d,c,x,v,L,P,N,B,z,_,H,W,Q,ie,De,Ne,He,O,Ue,_e,D,U,F,Y,oe,M,I,K]);return n.jsx(Zy.Provider,{value:Ze,children:i})}function Jy(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 w=j.match(/^\[(.+)\]$/);w?k[b]=w[1].split(",").map(C=>C.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 pi(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=oE(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 oE(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=Zg(a[i]);i+=2;const u=[];for(;i<a.length&&a[i].trim().startsWith("|");)u.push(Zg(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 Zg(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 cE(t,a){if(a&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return n.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 n.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:i.has(t)?"var(--accent)":"var(--green)"}})}function mi({entries:t,isRunning:a}){const[s,i]=p.useState(!1),c=p.useRef(null);return p.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!a?null:n.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[n.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:[n.jsxs("span",{className:"flex items-center gap-2",children:[a&&n.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),n.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:n.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&n.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 n.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:f?1:.7},children:[cE(u.phase,f),n.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:h}),n.jsx("span",{style:{color:f?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&n.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const Jg={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]=p.useState(null),u=p.useRef(null);p.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),p.useEffect(()=>{if(!(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=Jg[t.category]||Jg.unknown,f=i!=null&&i>0;return n.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:[n.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{style:{fontSize:14},children:d.icon}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&n.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"px-3.5 pb-3",children:[n.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),n.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(a||i!=null)&&n.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&n.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 uE({plugin:t,skill:a,skillContent:s,onApplied:i}){const[c,u]=p.useState("closed"),{config:d}=Ya(),[f,h]=p.useState("claude-cli"),[x,v]=p.useState("opus"),[y,b]=p.useState([]),[j,k]=p.useState(""),[w,C]=p.useState(""),[T,E]=p.useState(null),[R,O]=p.useState(null),[L,P]=p.useState([]),[N,B]=p.useState(!1),z=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(U=>U.id==="claude-cli"&&U.available)&&(h("claude-cli"),v("opus"))},[d]),p.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=p.useCallback(()=>{var D;(D=z.current)==null||D.abort(),u("open")},[]);async function W(){u("loading"),E(null),O(null),P([]);const D=new AbortController;z.current=D;try{const U=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(!U.ok||!U.body){let I=`HTTP ${U.status}`;try{const K=await U.json();K.error&&(I=K.error)}catch{}throw new Error(I)}const F=U.body.getReader(),Y=new TextDecoder;let oe="",M="";for(;;){const{done:I,value:K}=await F.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: "))M=ue.slice(7).trim();else if(ue.startsWith("data: ")){try{const te=JSON.parse(ue.slice(6));M==="progress"?P(ie=>[...ie,{phase:te.phase,message:te.message,timestamp:Date.now()}]):M==="done"||M==="complete"?(k(te.improved),C(te.reasoning||""),b(dc(te.original||s,te.improved)),u("diff_shown")):M==="error"&&(E(te.message||te.description||"Unknown error"),te.category&&O(te),u("open"))}catch{}M=""}}}catch(U){U.name!=="AbortError"&&(E(U.message),u("open"))}finally{z.current=null}}async function q(){B(!0);try{await ke.applyImprovement(t,a,j),i(j),u("closed")}catch(D){E(D.message)}finally{B(!1)}}function ee(){u("closed"),b([]),k(""),C(""),E(null)}if(c==="closed")return n.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),n.jsx("path",{d:"M2 17l10 5 10-5"}),n.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=_();return n.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[n.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:[n.jsxs("div",{className:"flex items-center gap-2.5",children:[n.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),n.jsx("path",{d:"M2 17l10 5 10-5"}),n.jsx("path",{d:"M2 12l10 5 10-5"})]})}),n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),n.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:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),n.jsx("select",{className:"input-field text-[12px] py-1.5",value:f,onChange:D=>{h(D.target.value);const U=d==null?void 0:d.providers.find(F=>F.id===D.target.value);U!=null&&U.models[0]&&v(U.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(D=>D.available).map(D=>n.jsx("option",{value:D.id,children:D.label},D.id))})]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),n.jsx("select",{className:"input-field text-[12px] py-1.5",value:x,onChange:D=>v(D.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(D=>n.jsx("option",{value:D.id,children:D.label},D.id))})]}),c==="loading"?n.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):n.jsx("button",{onClick:W,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&L.length>0&&n.jsx("div",{className:"mt-3",children:n.jsx(mi,{entries:L,isRunning:!0})})]}),T&&n.jsx("div",{className:"mb-4",children:R?n.jsx(fc,{error:R,onRetry:W,onDismiss:()=>{E(null),O(null)}}):n.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:T})}),c==="diff_shown"&&n.jsxs(n.Fragment,{children:[w&&n.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:[n.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),w]}),n.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:y.map((D,U)=>n.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:[n.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:D.type==="added"?"+":D.type==="removed"?"-":" "}),D.content]},U))}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:q,disabled:N,className:"btn btn-primary",children:N?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),n.jsx("button",{onClick:ee,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const ev={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"}},dE={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function fE({change:t,index:a,selected:s,onToggle:i,originalEval:c}){var y;const[u,d]=p.useState(!1),f=ev[t.action]??ev.add,h=dE[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=p.useCallback(()=>i(a),[i,a]);return n.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:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[n.jsx("input",{type:"checkbox",checked:s,onChange:v,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),n.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:f.bg,color:f.color,padding:"1px 6px"},children:f.label}),n.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:x}),n.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),n.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:n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&n.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&n.jsx(pE,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&n.jsx(mE,{original:c,proposed:t.eval}),t.action==="remove"&&c&&n.jsx(hE,{evalCase:c})]})]})}function pE({evalCase:t}){var a;return n.jsxs("div",{className:"pt-2.5 space-y-2",children:[n.jsx(kf,{label:"Prompt",value:t.prompt}),n.jsx(kf,{label:"Expected",value:t.expected_output}),n.jsxs("div",{children:[n.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,")"]}),n.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>n.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[n.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function mE({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 n.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(x=>n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:x.label}),n.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[n.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",wf(x.old,120)]}),n.jsxs("div",{style:{color:"var(--green)"},children:["+ ",wf(x.new,120)]})]})]},x.label)),(f.length>0||h.length>0)&&n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),n.jsxs("div",{className:"mt-1 space-y-0.5",children:[h.map(x=>n.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",x.text]},x.id)),f.map(x=>n.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",x.text]},x.id))]})]}),s.length===0&&f.length===0&&h.length===0&&n.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function hE({evalCase:t}){var a;return n.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[n.jsx(kf,{label:"Prompt",value:t.prompt}),n.jsxs("div",{children:[n.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,")"]}),n.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>n.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function kf({label:t,value:a}){return n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),n.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:wf(a,300)})]})}function wf(t,a){return t.length>a?t.slice(0,a)+"...":t}const tv={remove:0,modify:1,add:2};function xE({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)=>(tv[h.change.action]??2)-(tv[x.change.action]??2));const f=Array.from(a.values()).filter(Boolean).length;return n.jsxs("div",{className:"mt-3 animate-fade-in",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",f,"/",t.length," selected)"]})]}),n.jsxs("div",{className:"flex gap-1.5",children:[n.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"}),n.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"})]})]}),n.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:h,originalIndex:x})=>n.jsx(fE,{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 gE(){var D;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:i,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:f,deselectAllEvalChanges:h,retryEvalsSave:x}=yn(),{aiEditLoading:v,aiEditResult:y,aiEditError:b,aiEditClassifiedError:j,aiEditProgress:k,aiEditEvalChanges:w,aiEditEvalSelections:C,aiEditEvalsRetry:T}=t,[E,R]=p.useState(""),{config:O}=Ya(),[L,P]=p.useState("claude-cli"),[N,B]=p.useState("opus"),z=p.useRef(null);p.useEffect(()=>{var U;(U=z.current)==null||U.focus()},[]),p.useEffect(()=>{if(!O)return;O.providers.find(F=>F.id==="claude-cli"&&F.available)&&(P("claude-cli"),B("opus"))},[O]);const _=O==null?void 0:O.providers.find(U=>U.id===L&&U.available),H=p.useCallback(()=>{const U=E.trim();!U||v||s(U,L,N)},[E,v,s,L,N]),W=p.useCallback(U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),H()),U.key==="Escape"&&(U.preventDefault(),v?u():c())},[H,v,u,c]),q=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),ee=y?dc(t.skillContent,y.improved):[],$=((D=t.evals)==null?void 0:D.evals)??[];return n.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M15 4V2"}),n.jsx("path",{d:"M15 16v-2"}),n.jsx("path",{d:"M8 9h2"}),n.jsx("path",{d:"M20 9h2"}),n.jsx("path",{d:"M17.8 11.8L19 13"}),n.jsx("path",{d:"M15 9h.01"}),n.jsx("path",{d:"M17.8 6.2L19 5"}),n.jsx("path",{d:"M11 6.2L9.7 5"}),n.jsx("path",{d:"M3 21l9-9"})]})}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),n.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:U=>{U.currentTarget.style.background="var(--surface-3)"},onMouseLeave:U=>{U.currentTarget.style.background="transparent"},children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),n.jsxs("div",{className:"px-4 py-3",children:[!y&&n.jsxs(n.Fragment,{children:[n.jsx("textarea",{ref:z,value:E,onChange:U=>R(U.target.value),onKeyDown:W,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}}),n.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[n.jsxs("div",{style:{minWidth:200},children:[n.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),n.jsx("select",{className:"input-field text-[11px] py-1",value:L,onChange:U=>{P(U.target.value);const F=O==null?void 0:O.providers.find(Y=>Y.id===U.target.value);F!=null&&F.models[0]&&B(F.models[0].id)},disabled:v,style:{width:"100%"},children:O==null?void 0:O.providers.filter(U=>U.available).map(U=>n.jsx("option",{value:U.id,children:U.label},U.id))})]}),n.jsxs("div",{style:{minWidth:200},children:[n.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),n.jsx("select",{className:"input-field text-[11px] py-1",value:N,onChange:U=>B(U.target.value),disabled:v,style:{width:"100%"},children:_==null?void 0:_.models.map(U=>n.jsx("option",{value:U.id,children:U.label},U.id))})]}),n.jsx("div",{className:"flex-1"}),v?n.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):n.jsx("button",{onClick:H,disabled:!E.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),v&&k.length>0&&n.jsx("div",{className:"mt-2.5",children:n.jsx(mi,{entries:k,isRunning:!0})})]}),b&&n.jsx("div",{className:"mt-3",children:j?n.jsx(fc,{error:j,onRetry:q,onDismiss:c}):n.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),y&&n.jsxs("div",{className:"animate-fade-in",children:[y.reasoning&&n.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:[n.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),y.reasoning]}),n.jsx("div",{className:"mb-1",children:n.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),n.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:ee.map((U,F)=>n.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:U.type==="added"?"rgba(34,197,94,0.1)":U.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:U.type==="added"?"var(--green)":U.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:U.type==="added"?"3px solid var(--green)":U.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[n.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:U.type==="added"?"+":U.type==="removed"?"-":" "}),U.content]},F))}),n.jsx(xE,{changes:w,selections:C,currentEvals:$,onToggle:d,onSelectAll:f,onDeselectAll:h}),T&&n.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:[n.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),n.jsx("button",{onClick:x,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("button",{onClick:i,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),n.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),n.jsx("button",{onClick:q,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function vE(t,a){const[s,i]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,f]=p.useState(null),[h,x]=p.useState(!1),[v,y]=p.useState(null),[b,j]=p.useState(null),k=p.useCallback(async()=>{try{const T=await ke.getSkillFiles(t,a);i(T.files),j(null)}catch(T){i([]),j(T.message??"Unable to load skill files")}},[t,a]);p.useEffect(()=>{u("SKILL.md"),f(null),y(null),j(null),k()},[t,a,k]);const w=p.useCallback(async T=>{if(u(T),T==="SKILL.md"){f(null),y(null);return}x(!0),y(null);try{const E=await ke.getSkillFile(t,a,T);f(E)}catch(E){y(`Unable to open file: ${E.message}`),f(null)}finally{x(!1)}},[t,a]),C=p.useCallback(()=>{k()},[k]);return{files:s,activeFile:c,secondaryContent:d,loading:h,error:v,loadError:b,selectFile:w,refresh:C,isSkillMd:c==="SKILL.md"}}function yE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function bE(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 eb({expanded:t}){return n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}function tb(){return n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:n.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 jE(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function SE(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("polyline",{points:"1 20 1 14 7 14"}),n.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 nb({node:t,depth:a,activeFile:s,onSelect:i}){const[c,u]=p.useState(!0),d=t.path===s;return t.type==="dir"?n.jsxs("div",{children:[n.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:[n.jsx(eb,{expanded:c}),n.jsx(tb,{}),n.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(f=>n.jsx(nb,{node:f,depth:a+1,activeFile:s,onSelect:i},f.path))]}):n.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:[n.jsx("span",{style:{width:10}}),n.jsx(jE,{}),n.jsx("span",{style:{flex:1},children:t.name}),n.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:yE(t.size)})]})}function kE({files:t,activeFile:a,onSelect:s,onRefresh:i,loadError:c}){const[u,d]=p.useState(!1),f=p.useMemo(()=>bE(t),[t]);return n.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>d(!u),children:[n.jsx(eb,{expanded:u}),n.jsx(tb,{}),n.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),n.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:n.jsx(SE,{})})]}),u&&n.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:c?n.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?n.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):f.map(h=>n.jsx(nb,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function Mo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wE(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function CE(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function nv({content:t}){return n.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 rv({content:t,fileType:a}){if(a==="json"){const s=wE(t);return n.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"?n.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:pi(t)}}):n.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 av(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 EE({file:t,loading:a,error:s,viewMode:i,plugin:c,skill:u,onSaved:d,onDirtyChange:f}){const[h,x]=p.useState(i),[v,y]=p.useState(!1),[b,j]=p.useState(""),[k,w]=p.useState(!1),[C,T]=p.useState(null),E=i!==h?i:h;p.useEffect(()=>{f==null||f(v)},[v,f]);const R=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(j(t.content),y(!0))},[t]),O=p.useCallback(()=>{y(!1)},[]),L=p.useCallback(async()=>{if(!(!c||!u||!t)){w(!0);try{await ke.saveSkillFile(c,u,t.path,b),T("Saved"),y(!1),d==null||d(),setTimeout(()=>T(null),2e3)}catch(B){T(`Save failed: ${B.message}`),setTimeout(()=>T(null),3e3)}finally{w(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!v)return;const B=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),L())};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[v,L]),a)return n.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return n.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:n.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[n.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),n.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return n.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",Mo(t.size),") — cannot be displayed"]});const P=t.content??"",N=CE(t.path);return n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&n.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 ",Mo(512*1024)," — ",Mo(t.size)," total"]}),n.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(N==="md"||N==="json")&&["raw","split","preview"].map(B=>n.jsx("button",{onClick:()=>x(B),style:{padding:"2px 8px",fontSize:11,background:E===B?"var(--accent-muted)":"none",color:E===B?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:B},B)),n.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[Mo(t.size),c&&u&&!t.binary&&!v&&n.jsx("button",{onClick:R,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),v&&n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:L,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"}),n.jsx("button",{onClick:O,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&n.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),n.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:v?n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[n.jsx("textarea",{value:b,onChange:B=>j(B.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}}),n.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:[n.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),n.jsx("button",{onClick:L,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"}),n.jsx("button",{onClick:O,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):E==="split"&&N!=="other"?n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:n.jsx(nv,{content:P})}),n.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:N==="json"?n.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:av(P)}}):n.jsx(rv,{content:P,fileType:N})})]}):E==="preview"&&N!=="other"?N==="json"?n.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:av(P)}}):n.jsx(rv,{content:P,fileType:N}):n.jsx(nv,{content:P})})]})}const NE=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,TE=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function RE(t){const a=t.trim();if(!a)throw new Error("normalizeRemoteUrl: empty input");let s=a.match(NE);if(s)return`https://github.com/${s[1]}/${s[2]}`;if(s=a.match(TE),s)return`https://github.com/${s[1]}/${s[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${t}`)}function rb(t){const a=RE(t);return`https://verified-skill.com/submit?repo=${encodeURIComponent(a)}`}function lv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function AE({remoteUrl:t,fileCount:a,provider:s,model:i,onClose:c,defaultMode:u="manual"}){const[d,f]=p.useState(u),[h,x]=p.useState(""),[v,y]=p.useState(!1),[b,j]=p.useState(!1),[k,w]=p.useState(null),[C,T]=p.useState(null),E=p.useCallback(async()=>{y(!0),w(null);try{const ee=await ke.gitCommitMessage({provider:s,model:i});x(ee.message)}catch(ee){const $=ee instanceof Error?ee.message:String(ee);w($)}finally{y(!1)}},[s,i]);p.useEffect(()=>{u==="ai"&&!h&&E()},[]);const R=p.useCallback(()=>{f("ai"),T(null),h.trim()||E()},[h,E]),O=p.useCallback(()=>{f("manual"),w(null)},[]),L=p.useCallback(async()=>{const ee=h.trim();if(!(!ee||b)){j(!0),T(null);try{const $=await ke.gitPublish({commitMessage:ee}),D=$.remoteUrl??t,U=rb(D);window.open(U,"_blank","noopener,noreferrer");const F=($.commitSha??"").slice(0,7),Y=$.branch??"";lv(`Opening verified-skill.com — ${F} on ${Y}`,"info"),c()}catch($){const D=$ instanceof Error?$.message:String($),U=D.length>200?D.slice(0,200)+"…":D;T(U),lv(`Publish failed: ${U}`,"error")}finally{j(!1)}}},[h,b,t,c]),P=h.trim().length>0&&!b&&!v,N="#E6EDF3",B="#9CA3AF",z="rgba(255,255,255,0.12)",_="#0F1115",H={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:B,fontFamily:"var(--font-mono, monospace)",marginBottom:6,display:"block"},W={flex:1,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,fontFamily:"var(--font-mono, monospace)",background:"transparent",color:B,border:"none",cursor:"pointer",transition:"background 120ms ease, color 120ms ease"},q={...W,background:"rgba(255,255,255,0.08)",color:N,fontWeight:600};return n.jsxs(n.Fragment,{children:[n.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"}}),n.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:24,pointerEvents:"none"},children:n.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:N,fontFamily:"var(--font-mono, monospace)",animation:"publishDrawerIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[n.jsx("strong",{style:{fontSize:16,fontWeight:700,letterSpacing:"-0.01em",color:N,fontFamily:"var(--font-sans, var(--font-mono, sans-serif))"},children:"Publish skill"}),n.jsx("button",{type:"button","aria-label":"Dismiss",onClick:b?void 0:c,disabled:b,style:{background:"none",border:"none",color:B,fontSize:22,lineHeight:1,cursor:b?"not-allowed":"pointer",padding:0,opacity:b?.4:1},children:"×"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:B,fontVariantNumeric:"tabular-nums",marginBottom:18},children:[n.jsx("span",{"aria-hidden":"true",style:{color:"#F59E0B",fontFamily:"monospace"},children:"▮"}),n.jsxs("span",{children:[a," file",a===1?"":"s"," changed"]})]}),n.jsx("div",{style:{height:1,background:z,margin:"0 -24px 18px"}}),n.jsx("span",{style:H,children:"Mode"}),n.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:[n.jsx("button",{type:"button",role:"tab","aria-selected":d==="manual","data-testid":"publish-mode-manual",onClick:O,disabled:b,style:d==="manual"?q:W,children:"Write yourself"}),n.jsx("div",{style:{width:1,background:z}}),n.jsx("button",{type:"button",role:"tab","aria-selected":d==="ai","data-testid":"publish-mode-ai",onClick:R,disabled:b,style:d==="ai"?q:W,children:v&&d==="ai"?"Generating…":"Generate with AI"})]}),n.jsx("label",{htmlFor:"commit-message",style:H,children:"Commit message"}),n.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:N,resize:"vertical",outline:"none"}}),d==="ai"&&n.jsx("button",{type:"button",onClick:E,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?B:"#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"&&n.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:[n.jsx("strong",{style:{fontWeight:600},children:"AI generation failed."})," ",k," ",n.jsx("button",{type:"button",onClick:E,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"})]}),C&&n.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:[n.jsx("strong",{style:{fontWeight:600},children:"Publish failed."})," ",C]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:18,gap:6},children:[n.jsx("div",{style:{minHeight:28},children:d==="ai"&&n.jsx("button",{type:"button","aria-label":"Regenerate",onClick:E,disabled:v||b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:v?"Generating…":"Regenerate"})}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{type:"button","aria-label":"Cancel",onClick:c,disabled:b,style:{padding:"8px 14px",background:"transparent",color:N,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"}),n.jsx("button",{type:"button","aria-label":"Commit & Push",onClick:L,disabled:!P,"data-testid":"publish-commit-push",style:{padding:"8px 16px",background:P?"#22C55E":"rgba(255,255,255,0.06)",color:P?"#0B0F12":B,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"})]})]})]})}),n.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 sv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function ab({remoteUrl:t,provider:a,model:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(0),x=p.useCallback(async()=>{if(!(i||u)){c(!0);try{let y=!1,b=0;try{const E=await ke.gitDiff();y=!!E.hasChanges,b=E.fileCount??0}catch{}if(y){h(b),d(!0);return}const j=await ke.gitPublish(),k=j.remoteUrl??t,w=rb(k);window.open(w,"_blank","noopener,noreferrer");const C=(j.commitSha??"").slice(0,7),T=j.branch??"";sv(`Opening verified-skill.com — ${C} on ${T}`,"info")}catch(y){const b=y instanceof Error?y.message:String(y),j=b.length>200?b.slice(0,200)+"…":b;sv(`Publish failed: ${j}`,"error")}finally{c(!1)}}},[i,u,t]),v=p.useCallback(()=>d(!1),[]);return n.jsxs(n.Fragment,{children:[n.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?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Publishing…"]}):"Publish"}),u&&n.jsx(AE,{remoteUrl:t,fileCount:f,provider:a,model:s,onClose:v})]})}const LE={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function ME(){const[t,a]=p.useState(LE);return p.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 zE=/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Cf(t){if(typeof t!="string")return null;const a=t.trim().match(zE);return a?{major:Number(a[1]),minor:Number(a[2]),patch:Number(a[3])}:null}function Ws(t,a){const s=Cf(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 DE(t,a){const s=Cf(a);if(!s)return{valid:!1,reason:`Invalid semver: ${JSON.stringify(a)}`};if(t==null)return{valid:!0};const i=Cf(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 lb=/^---\n([\s\S]*?)\n---(?:\n|$)/,Ef=/^version:\s*["']?([^"'\n]+?)["']?\s*$/m;function Qo(t){const a=t.match(lb);if(!a)return null;const s=a[1].match(Ef);return s&&s[1].trim()||null}function sb(t,a){const s=`version: "${a}"`,i=t.match(lb);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;Ef.test(c)?h=c.replace(Ef,s):h=`${s}
|
|
93
|
+
${c}`;const x=i[0].endsWith(`---
|
|
94
|
+
`)?`---
|
|
95
|
+
`:"---";return`${f}---
|
|
96
|
+
${h}
|
|
97
|
+
${x}${d}`}function _E(t,a){const s=Qo(a),i=Qo(t);if(s!==null&&i!==null&&s===i)try{const c=Ws(s,"patch");return{contentToSave:sb(t,c),version:c,fromVersion:s}}catch{return{contentToSave:t,version:i,fromVersion:s}}return{contentToSave:t,version:i,fromVersion:s}}function _l(t){return t.testType==="integration"?"integration":"unit"}function Vl(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function ib(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 ob(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const OE=new Set(["benchmark","comparison","baseline"]);function iv(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 cb({entries:t}){const a=t.filter(y=>OE.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?iv(s,c,u,d):[],h=i.length>=2?iv(i,c,u,d):[],x=f[f.length-1],v=h[h.length-1];return n.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[h.length>0&&n.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),f.length>0&&n.jsx("polyline",{points:f.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),v&&n.jsx("circle",{cx:parseFloat(v.split(",")[0]),cy:parseFloat(v.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),x&&n.jsx("circle",{cx:parseFloat(x.split(",")[0]),cy:parseFloat(x.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function ub(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 db={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function BE(t){return Object.hasOwn(db,t)}function IE(t){return BE(t)?db[t]:t}function $E(){const{state:t}=yn(),{plugin:a,skill:s}=t,[i,c]=p.useState([]),[u,d]=p.useState([]),[f,h]=p.useState(!0),[x,v]=p.useState(null),[y,b]=p.useState(new Set),[j,k]=p.useState({}),[w,C]=p.useState(null),[T,E]=p.useState(""),[R,O]=p.useState(!1),[L,P]=p.useState(""),[N,B]=p.useState(""),z=p.useCallback(async()=>{h(!0),v(null);try{const[$,D]=await Promise.all([ke.getCredentials(a,s),ke.getParams(a,s)]);c($.credentials),d(D.params)}catch($){v($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{h(!1)}},[a,s]);p.useEffect(()=>{z()},[z]);const _=p.useCallback(async($,D)=>{O(!0),v(null);try{await ke.setCredential(a,s,$,D),C(null),E(""),await z()}catch(U){v(U instanceof Error?U.message:`Failed to save ${$}`)}finally{O(!1)}},[a,s,z]),H=p.useCallback(async()=>{const $=L.trim().toUpperCase(),D=N.trim();if(!(!$||!D)){O(!0),v(null);try{await ke.setCredential(a,s,$,D),P(""),B(""),await z()}catch(U){v(U instanceof Error?U.message:`Failed to add ${$}`)}finally{O(!1)}}},[a,s,L,N,z]),W=p.useCallback(async $=>{if(y.has($)){b(D=>{const U=new Set(D);return U.delete($),U}),k(D=>{const U={...D};return delete U[$],U});return}try{const U=(await ke.getParamsRevealed(a,s,$)).params.find(F=>F.name===$);U!=null&&U.value&&(k(F=>({...F,[$]:U.value})),b(F=>new Set(F).add($)))}catch{}},[a,s,y]),q=new Set(i.map($=>$.name)),ee=[...i.map($=>{const D=u.find(U=>U.name===$.name);return{name:$.name,status:$.status,maskedValue:(D==null?void 0:D.maskedValue)??""}}),...u.filter($=>!q.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return n.jsxs("div",{className:"py-2 px-3",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),x&&n.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&&n.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!f&&ee.length===0&&!x&&n.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),ee.map($=>n.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[n.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),n.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&n.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[y.has($.name)?j[$.name]??$.maskedValue:$.maskedValue||"***",n.jsx("button",{onClick:()=>W($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${y.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:y.has($.name)?"hide":"show"})]}),w===$.name?n.jsxs("div",{className:"flex gap-1",children:[n.jsx("input",{value:T,onChange:D=>E(D.target.value),onKeyDown:D=>{D.key==="Enter"&&T.trim()&&_($.name,T)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),n.jsx("button",{onClick:()=>_($.name,T),disabled:R||!T.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),n.jsx("button",{onClick:()=>{C(null),E("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):n.jsx("button",{onClick:()=>{C($.name),E("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),n.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[n.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),n.jsxs("div",{className:"flex gap-1.5",children:[n.jsx("input",{value:L,onChange:$=>P($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),n.jsx("input",{value:N,onChange:$=>B($.target.value),onKeyDown:$=>{$.key==="Enter"&&L.trim()&&N.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),n.jsx("button",{onClick:H,disabled:R||!L.trim()||!N.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:R?"not-allowed":"pointer"},children:"Add"})]})]})]})}function fb(t,a,s){const[i,c]=p.useState(null),[u,d]=p.useState(!1),f=p.useRef("");p.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=p.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 UE(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 pb({embedded:t=!1}={}){var M;const{state:a,dispatch:s,saveEvals:i,runCase:c,runAll:u,cancelCase:d,cancelAll:f,generateEvals:h,canEdit:x,canRun:v}=yn(),{evals:y,evalsError:b,selectedCaseId:j,inlineResults:k,caseRunStates:w,generateEvalsLoading:C,generateEvalsProgress:T,generateEvalsError:E}=a,R=p.useMemo(()=>{for(const I of w.values())if(I.status==="running"||I.status==="queued")return!0;return!1},[w]),[O,L]=p.useState(!1),[P,N]=p.useState("all"),B={skill_name:a.skill,evals:[]},z=y??B,_=z.evals,H=p.useMemo(()=>P==="all"?_:_.filter(I=>_l(I)===P),[P,_]),W=H.find(I=>I.id===j)??null;p.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]=p.useState([]),$=p.useMemo(()=>_.some(I=>_l(I)==="integration"),[_]);p.useEffect(()=>{$&&ke.getCredentials(a.plugin,a.skill).then(I=>ee(I.credentials)).catch(()=>ee([]))},[a.plugin,a.skill,$]);const D=p.useMemo(()=>new Set(q.filter(I=>I.status==="missing").map(I=>I.name)),[q]),[U,F]=p.useState(!1),Y=p.useCallback(I=>{F(!1),h(I?{testType:I}:void 0)},[h]);if(!y||_.length===0)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[n.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?n.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):n.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 11l3 3L22 4"}),n.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),n.jsx("div",{className:"text-center",children:b?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),n.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}),n.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"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),n.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),x&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:()=>L(!0),className:"btn btn-primary text-[12px]",children:"Create Test Case"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsxs("div",{className:"flex",children:[n.jsx("button",{onClick:()=>Y("unit"),disabled:C,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:C?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),n.jsx("button",{onClick:()=>F(!U),disabled:C,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),U&&n.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:n.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"})})]})]}),C&&T.length>0&&n.jsx("div",{className:"w-full max-w-md mt-3",children:n.jsx(mi,{entries:T,isRunning:!0})}),E&&n.jsx("div",{className:"w-full max-w-md mt-3",children:n.jsx(fc,{error:E,onRetry:()=>Y()})}),O&&n.jsx(ov,{evals:z,onSave:I=>{i(I),L(!1)},onCancel:()=>L(!1)})]});const oe=!x&&!t&&y!=null&&n.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"," ",n.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]});return n.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[oe,n.jsxs("div",{className:"eval-cases-grid",children:[n.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[n.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:[n.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,")"]}),n.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:!t&&(R?n.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"}):n.jsxs(n.Fragment,{children:[n.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&&n.jsx("button",{onClick:()=>u("comparison"),disabled:!v,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]}))})]}),n.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(I=>n.jsx("button",{onClick:()=>N(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=>_l(K)==="unit").length})`:`Integration (${_.filter(K=>_l(K)==="integration").length})`},I))}),n.jsxs("div",{className:"py-1",children:[H.length===0&&_.length>0&&n.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 te;const K=k.get(I.id),Q=j===I.id,ue=_l(I);return n.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:[n.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5 min-w-0",children:[n.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:[n.jsxs("span",{className:"truncate min-w-0 flex-1",children:["#",I.id," ",I.name]}),n.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"&&((te=I.requiredCredentials)==null?void 0:te.some(ie=>D.has(ie)))&&n.jsx("span",{title:"Configure credentials to run",style:{flexShrink:0,display:"inline-flex"},children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),n.jsx(mb,{result:K})]}),n.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&&n.jsx(VE,{passRate:K.passRate})]})]},I.id)})]}),n.jsx("div",{className:"px-3 py-2",children:x&&n.jsx("button",{onClick:()=>L(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter: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"})}),n.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:n.jsx($E,{})})]}),n.jsx("div",{className:"overflow-auto",children:W?n.jsx(HE,{evalCase:W,result:k.get(W.id),evals:y,caseStatus:((M=w.get(W.id))==null?void 0:M.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}):n.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),O&&n.jsx(ov,{evals:z,onSave:I=>{i(I),L(!1)},onCancel:()=>L(!1)})]})]})}function HE({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}=yn(),{plugin:j,skill:k}=v,{entries:w,loading:C}=fb(j,k,t.id),[T,E]=p.useState(!1),[R,O]=p.useState(t.prompt),[L,P]=p.useState(!1),[N,B]=p.useState(t.expected_output);p.useState(()=>{O(t.prompt),B(t.expected_output)});const z=p.useCallback(M=>{c({...s,evals:s.evals.map(I=>I.id===M.id?M:I)})},[s,c]),_=p.useCallback(()=>{z({...t,prompt:R}),E(!1)},[t,R,z]),H=p.useCallback(()=>{z({...t,expected_output:N}),P(!1)},[t,N,z]),W=p.useCallback(()=>{z({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,z]),q=p.useCallback((M,I)=>{z({...t,assertions:t.assertions.map(K=>K.id===M?{...K,text:I}:K)})},[t,z]),ee=p.useCallback(M=>{z({...t,assertions:t.assertions.filter(I=>I.id!==M)})},[t,z]),$=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(M=>M.id!==t.id)})},[s,t.id,c]),D=a&&a.assertions.length>0&&a.assertions.every(M=>M.pass),U=a&&a.assertions.some(M=>!M.pass),F=_l(t),Y=t.requiredCredentials??[],oe=F==="integration"&&Y.length>0;return n.jsxs("div",{className:"p-5 animate-fade-in",children:[n.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[n.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[n.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?n.jsx("button",{onClick:()=>{if((F==="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 ${F==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:F==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:F==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:F==="unit"?"Unit":"Integration"}):n.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:F==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:F==="unit"?"var(--accent)":"var(--orange)"},children:F==="unit"?"Unit":"Integration"}),n.jsx(mb,{result:a})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[!x&&(i==="running"||i==="queued"?n.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:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:n.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>u(t.id),disabled:!b,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),y&&n.jsx("button",{onClick:()=>d(t.id),disabled:!b,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]})),U&&y&&i!=="running"&&i!=="queued"&&n.jsx("button",{onClick:()=>h(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),y&&i!=="running"&&i!=="queued"&&n.jsx("button",{onClick:$,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.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&&F==="integration"&&n.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:[n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),n.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),D&&n.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:[n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),oe&&n.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),n.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),n.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Y.map(M=>n.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:M},M))})]}),y&&F==="integration"&&n.jsx(WE,{evalCase:t,onUpdate:z}),n.jsx(zo,{title:"Prompt",children:T?n.jsxs("div",{children:[n.jsx("textarea",{value:R,onChange:M=>O(M.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),n.jsxs("div",{className:"flex gap-2 mt-2",children:[n.jsx("button",{onClick:_,className:"btn btn-primary text-[12px]",children:"Save"}),n.jsx("button",{onClick:()=>{O(t.prompt),E(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):n.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&&E(!0)},onMouseEnter:M=>{y&&(M.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:M=>{M.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||n.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"Click to edit prompt...":"No prompt"})})}),n.jsx(zo,{title:"Expected Output",children:L?n.jsxs("div",{children:[n.jsx("textarea",{value:N,onChange:M=>B(M.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),n.jsxs("div",{className:"flex gap-2 mt-2",children:[n.jsx("button",{onClick:H,className:"btn btn-primary text-[12px]",children:"Save"}),n.jsx("button",{onClick:()=>{B(t.expected_output),P(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):n.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:M=>{y&&(M.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:M=>{M.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||n.jsx("span",{style:{fontStyle:"italic"},children:y?"Click to edit expected output...":"No expected output"})})}),n.jsx(zo,{title:`Assertions (${t.assertions.length})`,action:y?n.jsx("button",{onClick:W,className:"btn btn-ghost text-[11px]",children:"+ Add"}):void 0,children:t.assertions.length===0?n.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):n.jsx("div",{className:"space-y-2",children:t.assertions.map(M=>{const I=a==null?void 0:a.assertions.find(Q=>Q.assertion_id===M.id),K=UE(M.id,I,w);return n.jsx(PE,{assertion:M,result:I,badges:K,isReadOnly:!y,onUpdate:Q=>q(M.id,Q),onDelete:()=>ee(M.id)},M.id)})})}),(a==null?void 0:a.output)&&n.jsx(FE,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const M=ub("INEFFECTIVE",a.passRate);return M.recommendations&&M.recommendations.length>0?n.jsx(zo,{title:"Recommendations",children:n.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),n.jsx("ul",{className:"space-y-1.5 ml-1",children:M.recommendations.map((I,K)=>n.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[n.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),I]},K))})]})}):null})(),!x&&n.jsx(hb,{evalId:t.id,sharedEntries:w,sharedLoading:C})]},t.id)}function PE({assertion:t,result:a,badges:s,isReadOnly:i,onUpdate:c,onDelete:u}){const[d,f]=p.useState(!1),[h,x]=p.useState(t.text),[v,y]=p.useState(!1),b=()=>{c(h),f(!1)};return n.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:n.jsxs("div",{className:"flex items-start gap-2",children:[a?n.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?n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}):n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):n.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)&&n.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:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[n.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&n.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)&&n.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?n.jsxs("div",{className:"flex gap-2",children:[n.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}),n.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):n.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)&&n.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)&&n.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:a.reasoning})]}),!i&&n.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:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function zo({title:t,action:a,children:s}){return n.jsxs("div",{className:"mb-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a]}),s]})}function mb({result:t}){const[a,s]=p.useState(!1),i={padding:"2px 8px",borderRadius:9999,flexShrink:0,minWidth:44,justifyContent:"center",position:"relative",cursor:"default"};if(!t||t.status==null)return n.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=ub(d,u),h=t.passRate!=null?`${Math.round(t.passRate*100)}%`:d;return n.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&&n.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 VE({passRate:t}){const a=Math.round(t*100);return n.jsx("div",{className:"flex items-center gap-1",children:n.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${a}%`,background:a>=80?"var(--green)":a>=50?"var(--yellow)":"var(--red)"}})})})}function FE({output:t,durationMs:a,tokens:s}){const[i,c]=p.useState(!1);return n.jsxs("div",{className:"mb-5",children:[n.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:[n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",a!=null&&n.jsxs("span",{style:{fontWeight:400},children:["(",(a/1e3).toFixed(1),"s)"]}),s!=null&&n.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),i&&n.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 n.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:ib(t.timestamp)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),n.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}),n.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Vl(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),n.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&&n.jsx("span",{children:ob(t.durationMs)}),t.tokens!=null&&n.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 n.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),n.jsxs("span",{className:"text-[11px] font-semibold",style:{color:a>=0?"var(--green)":"var(--red)"},children:[i,(a*100).toFixed(1),"%"]}),n.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),n.jsx("div",{className:"space-y-0.5",children:t.assertions.map(a=>n.jsxs("div",{className:"flex items-start gap-1.5",children:[n.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?n.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}):n.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a.text})]},a.id))})]})}function hb({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:i,dispatch:c}=yn(),{plugin:u,skill:d}=i,[f,h]=p.useState(!0),x=a??null,v=s??!1,y=p.useCallback(()=>{h(w=>!w)},[]),b=x?x.slice(0,10):[],j=b.some(w=>{const C=Vd(w.type);return C==="left"||C==="full"}),k=b.some(w=>{const C=Vd(w.type);return C==="right"||C==="full"});return n.jsxs("div",{className:"mb-5",children:[n.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:[n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",x&&x.length>0&&n.jsxs("span",{style:{fontWeight:400},children:["(",x.length," run",x.length!==1?"s":"",")"]})]}),f&&n.jsx("div",{className:"animate-fade-in",children:v?n.jsxs("div",{className:"flex items-center gap-2 py-3",children:[n.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),n.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!x||x.length===0?n.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):n.jsxs("div",{children:[b.length>=2&&n.jsx("div",{className:"mb-2",children:n.jsx(cb,{entries:b})}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!j&&n.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&n.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((w,C)=>{const T=Vd(w.type);return T==="full"?n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(Fd,{entry:w})},C):T==="left"?n.jsxs(p.Fragment,{children:[n.jsx("div",{style:{gridColumn:"1"},children:n.jsx(Fd,{entry:w})}),n.jsx("div",{style:{gridColumn:"2"}})]},C):n.jsxs(p.Fragment,{children:[n.jsx("div",{style:{gridColumn:"1"}}),n.jsx("div",{style:{gridColumn:"2"},children:n.jsx(Fd,{entry:w})})]},C)})]}),n.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:w=>{w.currentTarget.style.textDecoration="underline"},onMouseLeave:w=>{w.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function ov({evals:t,onSave:a,onCancel:s}){const[i,c]=p.useState(""),[u,d]=p.useState(""),[f,h]=p.useState(""),[x,v]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[y,b]=p.useState("unit"),[j,k]=p.useState(""),[w,C]=p.useState([]),[T,E]=p.useState(""),[R,O]=p.useState(""),L=Math.max(0,...t.evals.map(z=>z.id))+1,P=z=>{b(z),z==="unit"&&(C([]),k(""),E(""),O(""))},N=()=>{const z=j.trim().toUpperCase();z&&!w.includes(z)&&C([...w,z]),k("")},B=()=>{if(!i.trim()||!u.trim())return;const z={id:L,name:i.trim(),prompt:u.trim(),expected_output:f.trim(),files:[],assertions:x.filter(_=>_.text.trim()),...y==="integration"?{testType:"integration",...w.length>0?{requiredCredentials:w}:{},...T||R?{requirements:{...T?{platform:T}:{},...R?{chromeProfile:R}:{}}}:{}}:{}};a({...t,evals:[...t.evals,z]})};return n.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:n.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:[n.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),n.jsxs("div",{className:"mb-3",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),n.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(z=>n.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))})]}),n.jsxs("label",{className:"block mb-3",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),n.jsx("input",{value:i,onChange:z=>c(z.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),n.jsxs("label",{className:"block mb-3",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),n.jsx("textarea",{value:u,onChange:z=>d(z.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),n.jsxs("label",{className:"block mb-3",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),n.jsx("textarea",{value:f,onChange:z=>h(z.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),x.map((z,_)=>n.jsxs("div",{className:"flex gap-2 mb-2",children:[n.jsx("input",{value:z.text,onChange:H=>v(x.map((W,q)=>q===_?{...W,text:H.target.value}:W)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),x.length>1&&n.jsx("button",{onClick:()=>v(x.filter((H,W)=>W!==_)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z.id)),n.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"&&n.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),n.jsxs("div",{className:"mb-3",children:[n.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),n.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:w.map(z=>n.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,n.jsx("button",{onClick:()=>C(w.filter(_=>_!==z)),style:{color:"var(--orange)",lineHeight:1},children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z))}),n.jsxs("div",{className:"flex gap-1.5",children:[n.jsx("input",{value:j,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),N())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),n.jsx("button",{onClick:N,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),n.jsxs("label",{className:"block mb-3",children:[n.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),n.jsx("input",{value:T,onChange:z=>E(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),n.jsx("input",{value:R,onChange:z=>O(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),n.jsx("button",{onClick:B,disabled:!i.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function WE({evalCase:t,onUpdate:a}){var d,f;const[s,i]=p.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 n.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),n.jsxs("div",{className:"mb-2.5",children:[n.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),n.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(h=>n.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,n.jsx("button",{onClick:()=>u(h),style:{color:"var(--orange)",lineHeight:1},children:n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h))}),n.jsxs("div",{className:"flex gap-1.5",children:[n.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"}),n.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),n.jsxs("div",{className:"mb-2.5",children:[n.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),n.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"})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),n.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 GE({size:t=15}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"16 18 22 12 16 6"}),n.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function qE({size:t=15}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),n.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function YE({size:t=15}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function KE({size:t=15}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M15 4V2"}),n.jsx("path",{d:"M15 16v-2"}),n.jsx("path",{d:"M8 9h2"}),n.jsx("path",{d:"M20 9h2"}),n.jsx("path",{d:"M17.8 11.8L19 13"}),n.jsx("path",{d:"M15 9h.01"}),n.jsx("path",{d:"M17.8 6.2L19 5"}),n.jsx("path",{d:"M11 6.2L9.7 5"}),n.jsx("path",{d:"M3 21l9-9"})]})}function Gd({size:t=15}){return n.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function XE(){const{state:t,dispatch:a,saveContent:s,isReadOnly:i}=yn(),{plugin:c,skill:u,skillContent:d,isDirty:f,improveTarget:h,aiEditOpen:x}=t,[v,y]=p.useState("split"),[b,j]=p.useState(!1),k=p.useRef(null),[w,C]=p.useState(!1),[T,E]=p.useState(""),[R,O]=p.useState(!1),[L,P]=p.useState(null),[N,B]=p.useState([]),[z,_]=p.useState([]),[H,W]=p.useState(null),q=p.useRef(null),{config:ee}=Ya(),$=ME(),{files:D,activeFile:U,secondaryContent:F,loading:Y,error:oe,loadError:M,selectFile:I,refresh:K,isSkillMd:Q}=vE(c??"",u??""),[ue,te]=p.useState(!1),ie=p.useCallback(xe=>{ue&&!window.confirm("You have unsaved changes. Discard?")||I(xe)},[ue,I]);p.useEffect(()=>()=>{var xe;(xe=q.current)==null||xe.abort()},[]);const{metadata:J,body:he}=Jy(d),je=J["allowed-tools"],Ne=Array.isArray(je)?je:typeof je=="string"?[je]:[],De=J.name,He=J.description,Ue=J.metadata,_e=typeof Ue=="object"&&!Array.isArray(Ue)?Ue:null,Ze=J.version||(_e==null?void 0:_e.version),st=J.tags||(_e==null?void 0:_e.tags),ce=Array.isArray(st)?st:typeof st=="string"?st.split(",").map(xe=>xe.trim()).filter(Boolean):[],ve=new Set(["name","description","metadata","allowed-tools","version","tags"]),ye=Object.entries(J).filter(([xe])=>!ve.has(xe)),Se=p.useCallback(async()=>{const{contentToSave:xe,version:qe,fromVersion:tt}=_E(d,t.savedContent);if(qe!==null){const Nt=DE(tt,qe);if(!Nt.valid){Wd(`Save blocked: ${Nt.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:qe}}))},[s,d,t.savedContent,c,u]),Ae=p.useCallback(xe=>{const qe=Qo(d)??"1.0.0";let tt;try{tt=Ws(qe,xe)}catch(St){const dt=St instanceof Error?St.message:String(St);Wd(`Bump failed: ${dt}`,"error");return}const Nt=sb(d,tt);a({type:"SET_CONTENT",content:Nt}),Wd(`Bumped to v${tt} (${xe}). Click Save to commit.`,"info")},[d,a]),Ge=p.useCallback(xe=>{(xe.ctrlKey||xe.metaKey)&&xe.key==="s"&&(xe.preventDefault(),xe.stopPropagation(),f&&Se()),(xe.ctrlKey||xe.metaKey)&&xe.key==="i"&&(xe.preventDefault(),xe.stopPropagation(),a({type:x?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[f,Se,x,a]),We=p.useCallback(async()=>{var qe,tt;if(!T.trim())return;(qe=q.current)==null||qe.abort();const xe=new AbortController;q.current=xe,O(!0),W(null),_([]),P(null),B([]);try{const Nt=(ee==null?void 0:ee.provider)||"claude-cli",St=(ee==null?void 0:ee.model)||"sonnet",dt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:T,provider:Nt,model:St}),signal:xe.signal});if(!dt.ok||!dt.body){let Tn=`HTTP ${dt.status}`;try{const Rn=await dt.json();Rn.error&&(Tn=Rn.error)}catch{}throw new Error(Tn)}const Dt=dt.body.getReader(),Ft=new TextDecoder;let jr="",en="";for(;;){const{done:Tn,value:Rn}=await Dt.read();if(Tn)break;jr+=Ft.decode(Rn,{stream:!0});const nr=jr.split(`
|
|
98
|
+
`);jr=nr.pop()||"";for(const bn of nr)if(bn.startsWith("event: "))en=bn.slice(7).trim();else if(bn.startsWith("data: ")){try{const Tt=JSON.parse(bn.slice(6));if(en==="progress")_(pt=>[...pt,{phase:Tt.phase,message:Tt.message,timestamp:Date.now()}]);else if(en==="done"||en==="complete"){const pt=["---"];Tt.name&&pt.push(`name: ${Tt.name}`),Tt.description&&pt.push(`description: "${Tt.description.replace(/"/g,'\\"')}"`),Tt.model&&pt.push(`model: ${Tt.model}`),(tt=Tt.allowedTools)!=null&&tt.trim()&&pt.push(`allowed-tools: ${Tt.allowedTools.trim()}`),pt.push("---","",Tt.body||"");const Pe=pt.join(`
|
|
99
|
+
`);P(Pe),B(dc(d,Pe)),O(!1)}else en==="error"&&(W(Tt.message||Tt.description||"Generation failed"),O(!1))}catch{}en=""}}}catch(Nt){Nt.name!=="AbortError"&&W(Nt.message)}finally{O(!1),q.current=null}},[T,ee,d]),wt=p.useCallback(()=>{L&&a({type:"SET_CONTENT",content:L}),C(!1),P(null),B([]),E(""),_([])},[L,a]),Ct=p.useCallback(()=>{C(!1),P(null),B([]),E(""),_([]),W(null)},[]),Et=p.useCallback(()=>{var xe;w?((xe=q.current)==null||xe.abort(),Ct()):(x&&a({type:"CLOSE_AI_EDIT"}),C(!0))},[w,x,a,Ct]),zt=[{mode:"raw",icon:n.jsx(GE,{}),label:"Editor"},{mode:"split",icon:n.jsx(qE,{}),label:"Split"},{mode:"preview",icon:n.jsx(YE,{}),label:"Preview"}];return n.jsxs("div",{className:"flex flex-col",style:{height:"100%",overflow:"auto"},onKeyDown:Ge,tabIndex:-1,children:[n.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:[n.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:zt.map(({mode:xe,icon:qe,label:tt})=>n.jsxs("button",{onClick:()=>y(xe),title:tt,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:[qe,n.jsx("span",{style:{letterSpacing:"0.01em"},children:tt})]},xe))}),Q?i?n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("button",{onClick:()=>{x?a({type:"CLOSE_AI_EDIT"}):(w&&Ct(),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:[n.jsx(KE,{size:13}),n.jsx("span",{children:"AI Edit"})]}),n.jsxs("button",{onClick:Et,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:w?600:400,border:"none",cursor:"pointer",color:w?"var(--purple)":"var(--text-tertiary)",background:w?"var(--purple-muted)":"transparent"},children:[n.jsx(Gd,{size:13}),n.jsx("span",{children:"Regenerate"})]}),n.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),!i&&(()=>{const xe=Qo(d)??"1.0.0";let qe=xe,tt=xe,Nt=xe;try{qe=Ws(xe,"patch"),tt=Ws(xe,"minor"),Nt=Ws(xe,"major")}catch{}const St={padding:"4px 8px"};return n.jsxs("div",{style:{display:"inline-flex",gap:2,alignItems:"center"},"aria-label":"Version bump","data-testid":"version-bump-controls",children:[n.jsx("button",{type:"button",onClick:()=>Ae("patch"),title:`Bump patch: ${xe} → ${qe}`,"aria-label":"Bump patch version",className:"btn btn-ghost text-[11px]",style:St,children:"+patch"}),n.jsx("button",{type:"button",onClick:()=>Ae("minor"),title:`Bump minor: ${xe} → ${tt}`,"aria-label":"Bump minor version",className:"btn btn-ghost text-[11px]",style:St,children:"+minor"}),n.jsx("button",{type:"button",onClick:()=>Ae("major"),title:`Bump major: ${xe} → ${Nt}`,"aria-label":"Bump major version",className:"btn btn-ghost text-[11px]",style:St,children:"+major"})]})})(),f&&n.jsx("button",{onClick:()=>a({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),n.jsx("button",{onClick:Se,disabled:!f||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"}),$.hasRemote&&$.remoteUrl&&n.jsx(ab,{remoteUrl:$.remoteUrl,provider:ee==null?void 0:ee.provider,model:ee==null?void 0:ee.model})]}):null]}),c&&u&&n.jsx(kE,{files:D,activeFile:U,onSelect:ie,onRefresh:K,loadError:M}),!Q&&n.jsx(EE,{file:F,loading:Y,error:oe,viewMode:v,plugin:c??void 0,skill:u??void 0,onSaved:()=>{I(U),K()},onDirtyChange:te}),Q&&n.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:v==="raw"||v==="preview"?"1fr":"1fr 1fr",minHeight:"60vh"},children:[v!=="preview"&&n.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:v==="split"?"1px solid var(--border-subtle)":"none"},children:n.jsx("textarea",{ref:k,value:d,onChange:xe=>{!i&&!b&&a({type:"SET_CONTENT",content:xe.target.value})},onKeyDown:Ge,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"&&n.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:n.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(De||Ze||He)&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[De&&n.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:De}),Ze&&n.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",Ze]})]}),He&&n.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:He})]}),ce.length>0&&n.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:ce.map(xe=>n.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))}),Ne.length>0&&n.jsx("div",{style:{marginBottom:16},children:n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),Ne.map(xe=>n.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&&n.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:ye.map(([xe,qe],tt)=>{const Nt=Array.isArray(qe)?qe.join(", "):typeof qe=="object"?Object.entries(qe).map(([St,dt])=>`${St}: ${Array.isArray(dt)?dt.join(", "):dt}`).join(" | "):qe;return n.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:tt>0?"1px solid var(--border-subtle)":"none"},children:[n.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:xe}),n.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Nt})]},xe)})}),(De||He||ce.length>0||Ne.length>0||ye.length>0)&&he&&n.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),he&&n.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:pi(he)}})]})})]}),Q&&x&&n.jsx(gE,{}),Q&&w&&n.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:n.jsxs("div",{className:"px-4 py-3",children:[!L&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(Gd,{size:14}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),n.jsx("div",{className:"flex gap-2 mb-2",children:n.jsx("textarea",{value:T,onChange:xe=>E(xe.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:R,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:R?.5:1},onKeyDown:xe=>{xe.key==="Enter"&&(xe.ctrlKey||xe.metaKey)&&T.trim()&&!R&&(xe.preventDefault(),We())}})}),n.jsxs("div",{className:"flex items-center gap-2",children:[R?n.jsx("button",{onClick:()=>{var xe;(xe=q.current)==null||xe.abort(),O(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):n.jsx("button",{onClick:We,disabled:!T.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),n.jsx("button",{onClick:Ct,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),R&&z.length>0&&n.jsx("div",{className:"mt-2",children:n.jsx(mi,{entries:z,isRunning:!0})}),H&&n.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,n.jsx("button",{onClick:We,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),L&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(Gd,{size:14}),n.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),n.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:N.map((xe,qe)=>n.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:[n.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:xe.type==="added"?"+":xe.type==="removed"?"-":" "}),xe.content]},qe))}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("button",{onClick:wt,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),n.jsx("button",{onClick:Ct,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Q&&h!==null&&c&&u&&n.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:n.jsx(uE,{plugin:c,skill:u,skillContent:d,onApplied:xe=>{a({type:"SET_CONTENT",content:xe}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})}),Q&&n.jsx(QE,{})]})}function QE(){var h;const[t,a]=p.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}=yn(),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=p.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 n.jsxs("details",{"data-testid":"editor-eval-cases-section",open:t,onToggle:u,style:{borderTop:"1px solid var(--border-subtle)",background:"var(--bg-canvas)"},children:[n.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:[n.jsx("span",{children:"Eval cases"}),f&&n.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&&n.jsx("div",{"data-testid":"editor-eval-cases-body",style:{height:520,overflow:"hidden"},children:n.jsx(pb,{embedded:!0})})]})}function ZE(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 JE={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 Nf({provider:t,size:a="sm"}){if(!t)return null;const s=JE[t],i=a==="md"?11:9;return n.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 eN({content:t,defaultExpanded:a=!0}){const[s,i]=p.useState(a),{metadata:c,body:u}=Jy(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 n.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[n.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:[n.jsxs("div",{className:"flex items-center gap-2.5",children:[n.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),n.jsxs("div",{children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),n.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),n.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:n.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),s&&n.jsxs("div",{className:"px-5 py-4 animate-fade-in",children:[d&&n.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 n.jsxs("div",{className:"px-3 py-2.5 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--text-tertiary)"},children:v}),n.jsx("div",{className:"text-[12px]",style:{color:"var(--text-primary)"},children:b})]},v)})}),h.length>0&&n.jsxs("div",{className:"mb-4",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),n.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(v=>n.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&&n.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:pi(u)}})]})]})}function tN(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 nN(t){const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}function rN(t){const a=nN(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 xb({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 n.jsxs("div",{children:[n.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:[n.jsx("span",{style:{width:10,display:"inline-block"},children:x?"▾":"▸"}),n.jsx("span",{children:"📁"}),n.jsx("span",{children:t.name})]}),x&&n.jsx("div",{role:"group",children:t.children.map(y=>n.jsx(xb,{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 n.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:[n.jsx("span",{style:{width:10,display:"inline-block"},children:" "}),n.jsx("span",{children:rN(t.name)}),n.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]})}function aN({files:t,activePath:a,onSelect:s}){const i=p.useMemo(()=>tN(t),[t]),c=p.useMemo(()=>{const j=new Set;if(a&&a.includes("/")){const k=a.split("/");for(let w=1;w<k.length;w++)j.add(k.slice(0,w).join("/"))}return i.children.forEach(k=>{k.type==="dir"&&j.add(k.path)}),j},[i,a]),[u,d]=p.useState(c);p.useEffect(()=>{d(j=>{const k=new Set(j);let w=!1;return c.forEach(C=>{k.has(C)||(k.add(C),w=!0)}),w?k:j})},[c]);const f=j=>{d(k=>{const w=new Set(k);return w.has(j)?w.delete(j):w.add(j),w})},h=p.useMemo(()=>{const j=[],k=w=>{for(const C of w)j.push({path:C.path,type:C.type}),C.type==="dir"&&u.has(C.path)&&k(C.children)};return k(i.children),j},[i,u]),x=p.useRef(null),[v,y]=p.useState(()=>Math.max(0,h.findIndex(j=>j.path===a)));p.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(w=>Math.min(h.length-1,w+1));else if(j.key==="ArrowUp")j.preventDefault(),y(w=>Math.max(0,w-1));else if(j.key==="Enter"){j.preventDefault();const w=h[v];if(!w)return;w.type==="dir"?f(w.path):s(w.path)}else j.key==="Escape"&&(j.preventDefault(),(k=x.current)==null||k.blur())};return i.children.length===0?n.jsx("div",{"data-testid":"source-tree-empty",style:{padding:16,fontSize:12,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:"No files found."}):n.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 n.jsx(xb,{node:j,depth:0,activePath:a,focusedPath:(k=h[v])==null?void 0:k.path,onSelect:s,expanded:u,onToggle:f},j.path)})})}const lN=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"]),sN=new Set(["png","jpg","jpeg","gif","webp","ico"]);function iN(t){const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}function oN(t){const a=iN(t);return a==="md"?"markdown":sN.has(a)?"image":lN.has(a)?"text":"binary"}function cN({content:t}){return n.jsx("div",{"data-testid":"source-md-viewer",children:n.jsx(eN,{content:t})})}function uN({content:t,path:a}){const s=t.split(`
|
|
100
|
+
`),i=s.length>5e3,c=i?s.slice(0,5e3).join(`
|
|
101
|
+
`):t;return n.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:[n.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)"]}),n.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 dN({plugin:t,skill:a,path:s}){const i=`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}&raw=1`;return n.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:[n.jsx("img",{src:i,alt:s,style:{maxWidth:"100%",maxHeight:"60vh",objectFit:"contain"}}),n.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:s})]})}function fN({path:t,size:a}){return n.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:[n.jsxs("div",{style:{fontSize:14,fontWeight:500,marginBottom:6},children:["Binary file — ",ZE(a)]}),n.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)"},children:t})]})}function pN({plugin:t,skill:a,provider:s}){const[i,c]=p.useState([]),[u,d]=p.useState("SKILL.md"),[f,h]=p.useState(null),[x,v]=p.useState(!0),[y,b]=p.useState(null),[j,k]=p.useState(null),w=s??j;p.useEffect(()=>{if(s!==void 0)return;let T=!1;return ke.getSkillVersionsEnvelope(t,a).then(E=>{T||k(E.provider??null)}).catch(()=>{}),()=>{T=!0}},[t,a,s]),p.useEffect(()=>{let T=!1;return v(!0),b(null),ke.getSkillFiles(t,a).then(E=>{var L;if(T)return;c(E.files);const O=E.files.some(P=>P.path==="SKILL.md")?"SKILL.md":((L=E.files.find(P=>P.type==="file"))==null?void 0:L.path)??"";d(O),O||v(!1)}).catch(E=>{T||(b(E instanceof Error?E.message:String(E)),v(!1))}),()=>{T=!0}},[t,a]),p.useEffect(()=>{if(!u)return;let T=!1;return v(!0),b(null),ke.getSkillFile(t,a,u).then(E=>{T||(h(E),v(!1))}).catch(E=>{T||(b(E instanceof Error?E.message:String(E)),v(!1))}),()=>{T=!0}},[t,a,u]);const C=()=>{if(y)return n.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 n.jsx("div",{"data-testid":"source-loading",style:{padding:16,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",fontSize:13},children:"Loading…"});const T=oN(u);return T==="markdown"?n.jsx(cN,{content:f.content??""}):T==="text"&&!f.binary?n.jsx(uN,{content:f.content??"",path:u}):T==="image"?n.jsx(dN,{plugin:t,skill:a,path:u}):n.jsx(fN,{path:u,size:f.size})};return n.jsxs("div",{"data-testid":"source-panel",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:400,gap:12},children:[w&&n.jsxs("div",{"data-testid":"source-panel-header",style:{display:"flex",alignItems:"center",gap:8,paddingLeft:4},children:[n.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Provider:"}),n.jsx(Nf,{provider:w})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"260px 1fr",gap:16,flex:1,minHeight:0},children:[n.jsx("aside",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:"75vh"},children:n.jsx(aN,{files:i,activePath:u,onSelect:d})}),n.jsx("main",{style:{minWidth:0},children:C()})]})]})}function Un(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 gb(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function mN({evalId:t}){const{state:a}=yn(),{entries:s,loading:i}=fb(a.plugin,a.skill,t),c=!!s&&s.length>0;return!i&&!c?null:n.jsx("div",{"data-testid":`run-case-history-${t}`,className:"mt-2 ml-3 pl-3",style:{borderLeft:"1px solid var(--border-subtle)"},children:n.jsx(hb,{evalId:t,sharedEntries:s,sharedLoading:i})})}function hN(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function xN(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 gN(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 cv(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 vN(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function yN(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 bN={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function jN(t,a){if(!t)return null;const s=bN[t];if(s==null||s===0)return null;const i=s*a*.5,c=s*a*2;return`${Un(i)}–${Un(c)}`}function SN(){const{state:t,runCase:a,runAll:s,cancelCase:i,cancelAll:c,canEdit:u,canRun:d}=yn(),{evals:f,caseRunStates:h,bulkRunActive:x,latestBenchmark:v,inlineResults:y}=t,{config:b}=Ya(),j=(f==null?void 0:f.evals)??[],k=p.useMemo(()=>{for(const B of h.values())if(B.status==="running"||B.status==="queued")return!0;return!1},[h]),w=j.filter(B=>{const z=h.get(B.id);return z&&(z.status==="complete"||z.status==="error"||z.status==="cancelled")}).length,C=j.filter(B=>{const z=h.get(B.id);return z&&(z.status==="running"||z.status==="queued")}).length,T=p.useRef(null),[E,R]=p.useState(0);p.useEffect(()=>{if(k&&!T.current&&(T.current=Date.now()),!k){T.current=null,R(0);return}const B=setInterval(()=>{T.current&&R(Math.round((Date.now()-T.current)/1e3))},1e3);return()=>clearInterval(B)},[k]);const O=j.reduce((B,z)=>B+z.assertions.length,0),L=j.length+O,P=p.useMemo(()=>yN(j.length,O),[j.length,O]),N=p.useMemo(()=>jN((b==null?void 0:b.provider)??null,L),[b==null?void 0:b.provider,L]);return n.jsxs("div",{className:"p-5",children:[!u&&f!=null&&n.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:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsxs("span",{children:["Read-only — to author or modify tests, install this skill as source via"," ",n.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]})]}),n.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),k&&n.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[C," running"]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[k&&n.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:n.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),u&&n.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"}),n.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&&n.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&&n.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[n.jsxs("span",{children:["Est. duration: ",P]}),N&&n.jsxs("span",{children:["Est. cost: ",N]}),!N&&(b==null?void 0:b.provider)&&(b.provider==="claude-cli"||b.provider==="codex-cli")&&n.jsx("span",{children:"Cost: Included"}),!N&&(b==null?void 0:b.provider)&&(b.provider==="ollama"||b.provider==="lm-studio"||b.provider==="gemini-cli")&&n.jsx("span",{children:"Cost: Free"})]})]}),k&&j.length>0&&n.jsxs("div",{className:"mb-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",w,"/",j.length," cases"]}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(w/j.length*100),"%"]})]}),n.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${w/j.length*100}%`,background:"var(--accent)"}})}),n.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",E>=60?`${Math.floor(E/60)}m ${E%60}s`:`${E}s`]}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",P]})]})]}),n.jsx("div",{className:"space-y-3 stagger-children",children:j.map(B=>{const z=y.get(B.id),_=h.get(B.id),H=(_==null?void 0:_.status)??"idle",W=v==null?void 0:v.cases.find(q=>q.eval_id===B.id);return n.jsxs(p.Fragment,{children:[n.jsx(wN,{name:B.name,evalId:B.id,result:z,caseCost:W==null?void 0:W.cost,caseBillingMode:W==null?void 0:W.billingMode,caseInputTokens:W==null?void 0:W.inputTokens,caseOutputTokens:W==null?void 0:W.outputTokens,caseStatus:H,runMode:(_==null?void 0:_.mode)??null,comparisonDetail:W==null?void 0:W.comparisonDetail,canEdit:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>i(q)}),n.jsx(mN,{evalId:B.id})]},B.id)})}),!k&&v&&v.cases.length>0&&n.jsxs("div",{className:"mt-5",children:[n.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:hN(v.type)}),n.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&&n.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: ${gb(v.totalInputTokens,v.totalOutputTokens)}`,v.totalCost!=null&&` | Cost: ${Un(v.totalCost)}`]}),u&&v.overall_pass_rate>=.9999&&!v.comparison&&n.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&&n.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const B=xN(v.model,v.timestamp);return B?n.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:B}):n.jsx("div",{className:"mb-3"})})(),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(uv,{label:"Skill",value:v.comparison.skillPassRate,color:"var(--accent)"}),n.jsx(uv,{label:"Baseline",value:v.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),n.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&&` | ${IE(v.verdict)}`]}),(()=>{const B=v.cases.reduce((_,H)=>_+H.assertions.length,0),z=gN(v.comparison.delta,B,v.cases.length);return n.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:z})})()]})]})]})}const kN={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 wN({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[w,C]=p.useState(!1),T=f==="running"||f==="queued",E=f==="complete"||f==="error";return n.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:T?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:T?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[f==="running"&&n.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),f==="queued"&&n.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),n.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",a," ",t]}),h&&(T||E)&&(()=>{const R=kN[h];return R?n.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:R.bg,color:R.color,padding:"1px 6px"},children:R.label}):null})()]}),n.jsxs("div",{className:"flex items-center gap-2",children:[T?n.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"}):n.jsxs(n.Fragment,{children:[v&&n.jsx("button",{onClick:()=>j(a),className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),n.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&&n.jsx("button",{onClick:()=>b(a),className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&n.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&&n.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:gb(u,d)}),i!=null&&n.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Un(i,c)}),f==="cancelled"&&n.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&n.jsxs("div",{className:"px-4 pb-3",children:[n.jsx("div",{className:"space-y-1",children:s.assertions.map(R=>n.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[n.jsx("span",{style:{color:R.pass?"var(--green)":"var(--red)"},children:R.pass?"PASS":"FAIL"}),n.jsx("span",{style:{color:"var(--text-secondary)"},children:R.text})]},R.assertion_id))}),s.output&&n.jsx("button",{onClick:()=>C(!w),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:w?"Hide output":"Show output"}),w&&s.output&&n.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&&n.jsx("div",{className:"px-4 pb-3",children:n.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:n.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const R=cv(x.skillContentScore,x.baselineContentScore),O=cv(x.skillStructureScore,x.baselineStructureScore),L=vN(x.winner);return n.jsxs(n.Fragment,{children:[n.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",R.skill,"% / Baseline ",R.baseline,"%"]}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),n.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",O.skill,"% / Baseline ",O.baseline,"%"]}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),n.jsx("span",{style:{color:L.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:L.text})]})})()})})}),s&&s.errorMessage&&n.jsx(CN,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const qd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function CN({errorMessage:t,classifiedError:a}){const[s,i]=p.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 n.jsx("div",{className:"px-4 pb-3",children:n.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[n.jsx("span",{style:{fontSize:12},children:d}),n.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),n.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&&n.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&n.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 uv({label:t,value:a,color:s}){return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(a*100),"%"]})]}),n.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${a*100}%`,background:s}})})]})}const dv={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)"}},EN={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 NN(){const{state:t,dispatch:a,runActivationTest:s,cancelActivation:i,generateActivationPrompts:c,loadTestCasesFromSkillMd:u,saveTestCasesToSkillMd:d}=yn(),{plugin:f,skill:h,activationPrompts:x,activationResults:v,activationSummary:y,activationRunning:b,activationError:j,activationStartedAt:k,activationClassifyingStatus:w,generatingPrompts:C,generatingPromptsError:T,activationPromptsSource:E,savingTestCases:R,savingTestCasesError:O,savingTestCasesSuccess:L,activationHistory:P}=t,{state:N}=ur(),B=N.skills.find(te=>te.plugin===f&&te.skill===h),z=(B==null?void 0:B.resolvedVersion)??(B==null?void 0:B.version)??null,[_,H]=p.useState(x),[W,q]=p.useState(null),[ee,$]=p.useState(!1);p.useEffect(()=>{x&&x!==_&&H(x)},[x]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:_})},[_,a]),p.useEffect(()=>{fetch(`/api/skills/${f}/${h}/description`).then(te=>te.json()).then(te=>q(te.rawContent||te.description||null)).catch(()=>q(null))},[f,h]),p.useEffect(()=>{(!x||x.trim().length===0)&&u()},[f,h]);function D(){s(_)}function U(){c(8)}function F(){d()}const Y=_.trim().split(`
|
|
102
|
+
`).filter(Boolean).length,oe=te=>te.verdict==="scope_warning"||te.verdict==="drift_warning",M=v.filter(te=>(te.classification==="TP"||te.classification==="TN")&&!oe(te)),I=v.filter(te=>(te.classification==="FP"||te.classification==="FN")&&!oe(te));v.filter(oe);const K=(W==null?void 0:W.replace(/^---[\s\S]*?---\s*/,"").trim())??null,Q=_.trim().length>0,ue=K?pi(K):"";return n.jsxs("div",{className:"p-5 space-y-5",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),n.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."})]}),n.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[n.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),E==="skill-md"&&n.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"}),E==="ai-generated"&&n.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"})]}),n.jsxs("div",{className:"flex gap-1.5",children:[n.jsx("button",{onClick:F,disabled:R||!Q||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:R?"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:te=>{Q&&!R&&(te.currentTarget.style.background="var(--surface-3)")},onMouseLeave:te=>{R||(te.currentTarget.style.background="var(--surface-2)")},children:R?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"spinner",style:{borderTopColor:"var(--green)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Saving..."]}):n.jsxs(n.Fragment,{children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),n.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),n.jsx("polyline",{points:"7 3 7 8 15 8"})]}),"Save as test cases"]})}),n.jsx("button",{onClick:U,disabled:C||!K||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:C?"var(--surface-3)":"var(--surface-2)",color: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:te=>{K&&!C&&(te.currentTarget.style.background="var(--surface-3)")},onMouseLeave:te=>{C||(te.currentTarget.style.background="var(--surface-2)")},children:C?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.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"]})})]})]}),L&&n.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--green)",background:"var(--green-muted)"},"aria-live":"polite",children:L}),O&&n.jsxs("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},"aria-live":"polite",children:["Save failed: ",O]}),!K&&!b&&n.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."}),T&&n.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:T}),n.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:_,onChange:te=>H(te.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`}),n.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[n.jsx("span",{children:"One prompt per line"}),n.jsx(Do,{}),n.jsx("span",{children:"No prefix = auto-classify"}),n.jsx(Do,{}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),n.jsx(Do,{}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),n.jsx(Do,{}),n.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[Y," prompt",Y!==1?"s":""]})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:D,disabled:b||!_.trim(),className:"btn btn-primary",children:b?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):n.jsxs(n.Fragment,{children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("circle",{cx:"12",cy:"12",r:"6"}),n.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),b&&n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:i,className:"btn btn-secondary text-[12px]",children:"Cancel"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[w||`${v.length} / ${Y} prompts tested`,k&&n.jsx(LN,{startedAt:k})]})]})]})]}),n.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[n.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:K?n.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:ue}}):n.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),j&&n.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&&n.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[n.jsx("div",{className:"spinner-lg mx-auto mb-4"}),n.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),v.length>0&&n.jsxs("div",{className:"space-y-5",children:[I.length>0&&n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),n.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",I.length,")"]}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),n.jsx("div",{className:"space-y-1.5 stagger-children",children:I.map((te,ie)=>n.jsx(fv,{result:te},`incorrect-${ie}`))})]}),M.length>0&&n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("polyline",{points:"16 10 11 15 8 12"})]}),n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",M.length,")"]})]}),n.jsx("div",{className:"space-y-1.5 stagger-children",children:M.map((te,ie)=>n.jsx(fv,{result:te},`correct-${ie}`))})]})]}),y&&n.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[n.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&&n.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"]}),n.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[n.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`}),n.jsx(Yd,{label:"Recall",value:y.recall,description:"Of expected activations, how many fired?",detail:`${y.tp} activated / ${y.tp+y.fn} expected`}),n.jsx(Yd,{label:"Reliability",value:y.reliability,description:"Overall correct classification rate",detail:`${y.tp+y.tn} correct / ${y.total} total`})]}),n.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),n.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[n.jsx(_o,{label:"True Positive",abbr:"TP",count:y.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),n.jsx(_o,{label:"False Positive",abbr:"FP",count:y.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),n.jsx(_o,{label:"False Negative",abbr:"FN",count:y.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),n.jsx(_o,{label:"True Negative",abbr:"TN",count:y.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]}),n.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:"," ",n.jsxs("span",{style:{color:(y.scopeWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[y.scopeWarnings??0," scope"]}),", ",n.jsxs("span",{style:{color:(y.driftWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[y.driftWarnings??0," drift"]})]})]})]}),n.jsx(TN,{history:P,expanded:ee,onToggle:()=>$(!ee),skillVersion:z})]})}function TN({history:t,expanded:a,onToggle:s,skillVersion:i}){return t===null?null:n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.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:[n.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&n.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),n.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:n.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&n.jsx("div",{className:"px-4 py-3",children:t.length===0?n.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):n.jsx("div",{className:"space-y-2",children:t.map(c=>n.jsx(RN,{run:c,skillVersion:i},c.id))})})]})}function RN({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 n.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[n.jsx("div",{className:"flex-1 min-w-0",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:AN(t.timestamp)}),n.jsx(fi,{version:a??null,size:"sm","data-testid":"activation-row-version"}),n.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),n.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),n.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:i,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),n.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 AN(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 Do(){return n.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function fv({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=dv[s]||dv.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"?EN[t.verdict]:void 0;return n.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:[n.jsx("div",{className:"flex-shrink-0 mt-0.5",children:n.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?n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}):a?n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.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"}),n.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),n.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"flex items-center gap-2 mb-1",children:n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),n.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[n.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}),n.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&n.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&n.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 n.jsxs("div",{className:"text-center",children:[n.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),n.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),n.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),n.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:i})]})}function _o({abbr:t,count:a,bg:s,color:i,description:c}){return n.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[n.jsx("div",{className:"text-[20px] font-bold",style:{color:i},children:a}),n.jsx("div",{className:"text-[11px] font-semibold",style:{color:i},children:t}),n.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function LN({startedAt:t}){const[a,s]=p.useState(0);return p.useEffect(()=>{const i=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(i)},[t]),n.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}function MN(t){return t==="benchmark"||t==="activation"||t==="ab"}function zN({mode:t}){var f;const{state:a,runAll:s}=yn(),i=p.useRef(!1),u=(((f=a.evals)==null?void 0:f.evals)??[]).length,d=a.evals!=null;return p.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"?n.jsx(NN,{}):n.jsx(SN,{})}const Kd={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},pv={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},Tf=600,Rf=180,xn=40,Xd=Tf-xn*2,xa=Rf-xn*2,DN=[25,50,75,100];function mv(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function _N(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function ON({entries:t,onPointClick:a}){const[s,i]=p.useState(null),c=p.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((x,v)=>{const y=xn+v/(u-1)*Xd,b=x.passRate*100,j=xn+xa-b/100*xa;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 n.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[n.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),n.jsx("div",{className:"flex items-center gap-5 mb-3",children:h.map(x=>n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Kd[x]??"var(--text-tertiary)"}}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:pv[x]??x})]},x))}),n.jsxs("svg",{width:Tf,height:Rf,viewBox:`0 0 ${Tf} ${Rf}`,style:{display:"block",overflow:"visible"},children:[DN.map(x=>{const v=xn+xa-x/100*xa;return n.jsxs("g",{children:[n.jsx("line",{x1:xn,y1:v,x2:xn+Xd,y2:v,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),n.jsxs("text",{x:xn-8,y:v+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[x,"%"]})]},x)}),n.jsx("line",{x1:xn,y1:xn+xa,x2:xn+Xd,y2:xn+xa,stroke:"var(--border-subtle)",strokeWidth:1}),n.jsx("text",{x:xn-8,y:xn+xa+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),n.jsx("polyline",{points:f,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((x,v)=>n.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)),BN(u).map(x=>n.jsx("text",{x:d[x].x,y:xn+xa+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:mv(c[x].timestamp)},x))]}),s&&n.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:[n.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:mv(s.entry.timestamp)}),n.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),n.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n.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:pv[s.entry.type]??s.entry.type}),n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),n.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[n.jsx("span",{children:_N(s.entry.totalDurationMs)}),n.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function BN(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 Gs=new Map;let gn=null,qo=null,Oo=1e3,Ol=0;function vb(){if(gn)return;gn=new EventSource("/api/events");const t=a=>s=>{let i={};try{i=s.data?JSON.parse(s.data):{}}catch{}const c=Gs.get(a);if(c)for(const u of c)u(i)};gn.addEventListener("benchmark:complete",t("benchmark:complete")),gn.addEventListener("history:written",t("history:written")),gn.addEventListener("leaderboard:updated",t("leaderboard:updated")),gn.onerror=()=>{gn==null||gn.close(),gn=null,Ol>0&&(qo=setTimeout(()=>{Oo=Math.min(Oo*2,3e4),vb()},Oo))},gn.onopen=()=>{Oo=1e3}}function IN(){qo!=null&&(clearTimeout(qo),qo=null),gn==null||gn.close(),gn=null}function $N(t,a){return Gs.has(t)||Gs.set(t,new Set),Gs.get(t).add(a),Ol++,vb(),()=>{var s;(s=Gs.get(t))==null||s.delete(a),Ol--,Ol<=0&&(Ol=0,queueMicrotask(()=>{Ol<=0&&IN()}))}}function Zo(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>$N(t,c=>s.current(c)),[t])}function Jo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function UN(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function HN({rate:t,label:a}){const s=Math.round(t*100);return n.jsx("div",{className:"flex items-center gap-3",children:n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:a}),n.jsxs("span",{className:"text-[11px] font-semibold",style:{color:Jo(t)},children:[s,"%"]})]}),n.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:Jo(t)}})})]})})}function PN({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 n.jsxs("svg",{width:a,height:s,style:{display:"block"},children:[n.jsx("path",{d,fill:"var(--accent-muted)"}),n.jsx("path",{d:f,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),n.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function VN({plugin:t,skill:a}){const s=`stats/${t}/${a}`,i=p.useCallback(()=>ke.getStats(t,a),[t,a]),{data:c,loading:u}=qa(s,i),d=p.useCallback(()=>In(s),[s]);if(Zo("benchmark:complete",d),Zo("history:written",d),u)return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"skeleton h-24 rounded-xl"}),n.jsx("div",{className:"skeleton h-48 rounded-xl"}),n.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return n.jsxs("div",{className:"text-center py-12",children:[n.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[n.jsx("path",{d:"M18 20V10"}),n.jsx("path",{d:"M12 20V4"}),n.jsx("path",{d:"M6 20v-6"})]})}),n.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),n.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 n.jsxs("div",{className:"space-y-4 stagger-children",children:[n.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),n.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),n.jsxs("div",{className:"text-[24px] font-bold",style:{color:Jo(f)},children:[Math.round(f*100),"%"]})]}),n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),n.jsxs("div",{className:"text-[24px] font-bold",style:{color:x>=0?"var(--green)":"var(--red)"},children:[x>=0?"+":"",Math.round(x*100),"%"]})]}),n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),n.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),n.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Un(c.totalCost)})]}),c.costPerRun!=null&&n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),n.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Un(c.costPerRun)})]})]}),c.trendPoints.length>=2&&n.jsxs("div",{className:"glass-card p-5",children:[n.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),n.jsx(PN,{points:c.trendPoints})]}),c.modelStats.length>0&&n.jsxs("div",{className:"glass-card p-5",children:[n.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[n.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),n.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),n.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),n.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),n.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),n.jsx("tbody",{children:c.modelStats.map(y=>n.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[n.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:y.model}),n.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.runs}),n.jsx("td",{style:{padding:"8px",textAlign:"center"},children:n.jsxs("span",{className:"font-semibold",style:{color:Jo(y.avgPassRate)},children:[Math.round(y.avgPassRate*100),"%"]})}),n.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:UN(y.avgDurationMs)}),n.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.avgCost!=null?Un(y.avgCost):"N/A"})]},y.model))})]})]}),v.length>0&&n.jsxs("div",{className:"glass-card p-5",children:[n.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),n.jsx("div",{className:"space-y-3",children:v.map(y=>n.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:[n.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[n.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]}),n.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:y.evalName}),n.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[y.totalRuns," runs"]})]}),n.jsx(HN,{rate:y.passRate,label:y.text})]},`${y.evalId}:${y.id}`))})]})]})}function FN({plugin:t,skill:a}){const[s,i]=p.useState(null),[c,u]=p.useState(null),[d,f]=p.useState({}),[h,x]=p.useState({});p.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?n.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],w=b.length>0?b[0].pass_rate:null;return n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.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:C=>{j||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{j||(C.currentTarget.style.background="transparent")},children:[n.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:n.jsx("polyline",{points:"9 18 15 12 9 6"})}),n.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]}),n.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:y.name}),b.length>=2&&n.jsx(cb,{entries:b}),w!=null&&n.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Vl(w)},children:[Math.round(w*100),"%"]}),b.length>0&&n.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),j&&n.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?n.jsxs("div",{className:"p-4 flex items-center gap-2",children:[n.jsx("div",{className:"spinner",style:{width:14,height:14}}),n.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?n.jsx("div",{className:"p-4",children:n.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):n.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,T)=>n.jsxs("div",{className:"p-4",style:{background:T===0?"var(--surface-2)":"transparent"},children:[n.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:ib(C.timestamp)}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),n.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),n.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Vl(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),n.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&n.jsx("span",{children:ob(C.durationMs)}),C.tokens!=null&&n.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),n.jsx("div",{className:"space-y-1",children:C.assertions.map(E=>n.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[n.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:E.pass?"var(--green)":"var(--red)"},children:n.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:E.pass?n.jsx("polyline",{points:"20 6 9 17 4 12"}):n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:E.text}),E.reasoning&&n.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:E.reasoning})]})]},E.id))})]},T))})})]},y.id)})}):n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function WN(){const{state:t,dispatch:a}=yn(),{plugin:s,skill:i}=t,{state:c}=ur(),u=c.skills.find(F=>F.plugin===s&&F.skill===i),d=(u==null?void 0:u.resolvedVersion)??(u==null?void 0:u.version)??null,[f,h]=p.useState("timeline"),[x,v]=p.useState(""),[y,b]=p.useState(""),[j,k]=p.useState(!1),[w,C]=p.useState([]),[T,E]=p.useState(null),[R,O]=p.useState(!1),[L,P]=p.useState(null),[N,B]=p.useState(!1),z=`history/${s}/${i}?model=${x}&type=${y}`,_=p.useCallback(()=>ke.getHistory(s,i,{model:x||void 0,type:y||void 0}),[s,i,x,y]),{data:H,loading:W}=qa(z,_),q=H??[];p.useEffect(()=>{!H||H.length<2||ke.compareRuns(s,i,H[0].timestamp,H[1].timestamp).then(F=>{const Y=F.regressions.filter(oe=>oe.change==="regression");a({type:"SET_REGRESSIONS",regressions:Y})}).catch(()=>{})},[H,s,i,a]);const ee=p.useCallback(()=>In(z),[z]);Zo("history:written",ee);const $=p.useCallback(async F=>{if(j){C(Y=>Y.includes(F)?Y.filter(oe=>oe!==F):Y.length>=2?[Y[1],F]:[...Y,F]);return}B(!0);try{const Y=await ke.getHistoryEntry(s,i,F);P(Y)}catch{}finally{B(!1)}},[s,i,j]),D=p.useCallback(async()=>{if(w.length===2){O(!0);try{const F=await ke.compareRuns(s,i,w[0],w[1]);E(F)}catch{}finally{O(!1)}}},[s,i,w]),U=[...new Set(q.map(F=>F.model))];return W?n.jsxs("div",{className:"p-5",children:[n.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),n.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"skeleton h-12 rounded-lg"}),n.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):n.jsxs("div",{className:"p-5",children:[n.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(F=>n.jsx("button",{onClick:()=>h(F),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:f===F?"var(--accent-muted)":"transparent",color:f===F?"var(--accent)":"var(--text-tertiary)"},children:F==="timeline"?"Timeline":F==="per-eval"?"Per Eval":"Statistics"},F))}),f==="timeline"&&n.jsxs("div",{children:[q.length>0&&n.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:n.jsx(ON,{entries:q,onPointClick:F=>$(F.timestamp)})}),n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsxs("select",{value:x,onChange:F=>v(F.target.value),className:"input-field text-[12px]",style:{width:150},children:[n.jsx("option",{value:"",children:"All Models"}),U.map(F=>n.jsx("option",{value:F,children:F},F))]}),n.jsxs("select",{value:y,onChange:F=>b(F.target.value),className:"input-field text-[12px]",style:{width:150},children:[n.jsx("option",{value:"",children:"All Types"}),n.jsx("option",{value:"benchmark",children:"Benchmark"}),n.jsx("option",{value:"comparison",children:"Comparison"}),n.jsx("option",{value:"baseline",children:"Baseline"}),n.jsx("option",{value:"model-compare",children:"Model Compare"}),n.jsx("option",{value:"improve",children:"AI Improve"}),n.jsx("option",{value:"instruct",children:"AI Edit"}),n.jsx("option",{value:"ai-generate",children:"AI Generate"}),n.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>{k(!j),C([]),E(null)},className:`btn text-[12px] ${j?"btn-primary":"btn-secondary"}`,children:j?"Exit Compare":"Compare Runs"}),j&&w.length===2&&n.jsx("button",{onClick:D,disabled:R,className:"btn btn-primary text-[12px]",children:R?"Comparing...":"Compare"})]}),n.jsx("div",{className:"space-y-2",children:q.length===0?n.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):q.map(F=>{const Y=w.includes(F.timestamp);return n.jsx("button",{onClick:()=>$(F.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:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[j&&n.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&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})})}),n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(F.timestamp).toLocaleString()}),n.jsx("span",{className:"pill text-[9px]",style:{background:F.type==="comparison"?"var(--purple-muted)":F.type==="baseline"?"var(--surface-3)":F.type==="model-compare"?"var(--accent-muted)":F.type==="improve"||F.type==="instruct"?"var(--purple-muted)":F.type==="ai-generate"?"var(--green-muted)":F.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:F.type==="comparison"?"var(--purple)":F.type==="baseline"?"var(--text-tertiary)":F.type==="model-compare"?"var(--accent)":F.type==="improve"||F.type==="instruct"?"var(--purple)":F.type==="ai-generate"?"var(--green)":F.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:F.type==="model-compare"?"model compare":F.type==="improve"?"ai improve":F.type==="instruct"?"ai edit":F.type==="ai-generate"?"ai generate":F.type==="eval-generate"?"eval generate":F.type})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(fi,{version:d,size:"sm","data-testid":"history-row-version"}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:F.model}),F.totalCost!=null&&F.totalCost>0&&n.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Un(F.totalCost)}),n.jsxs("span",{className:"text-[12px] font-semibold",style:{color:F.passRate>=.8?"var(--green)":F.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(F.passRate*100),"%"]})]})]})},F.timestamp)})}),T&&n.jsx(GN,{result:T}),L&&!j&&n.jsx(qN,{run:L,onClose:()=>P(null)})]}),f==="per-eval"&&n.jsx(FN,{plugin:s,skill:i}),f==="statistics"&&n.jsx(VN,{plugin:s,skill:i})]})}function GN({result:t}){const a=t.regressions.filter(i=>i.change==="regression"),s=t.regressions.filter(i=>i.change==="improvement");return n.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.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)&&n.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[n.jsxs("span",{children:["Run A cost: ",Un(t.runA.totalCost??null)]}),n.jsxs("span",{children:["Run B cost: ",Un(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&n.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Un(t.runB.totalCost-t.runA.totalCost)]})]}),a.length>0&&n.jsxs("div",{className:"mb-3",children:[n.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",a.length,")"]}),a.map(i=>n.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",n.jsx("span",{style:{color:"var(--red)"},children:i.assertionId})," (was passing, now failing)"]},`${i.evalId}-${i.assertionId}`))]}),s.length>0&&n.jsxs("div",{className:"mb-3",children:[n.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(i=>n.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",n.jsx("span",{style:{color:"var(--green)"},children:i.assertionId})," (was failing, now passing)"]},`${i.evalId}-${i.assertionId}`))]}),n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),n.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:n.jsxs("table",{className:"w-full text-[12px]",children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"var(--surface-2)"},children:[n.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),n.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),n.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),n.jsx("tbody",{children:t.caseDiffs.map(i=>n.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[n.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",i.eval_id," ",i.eval_name]}),n.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}),n.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 qN({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?n.jsx(YN,{run:t,onClose:a}):n.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),n.jsx("button",{onClick:a,className:"btn btn-ghost text-[11px]",children:"Close"})]}),n.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: ${Un(t.totalCost)}`]}),n.jsx("div",{className:"space-y-2",children:t.cases.map(s=>n.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),n.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&n.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Un(s.cost)}),n.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 YN({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?dc(t.improve.original,t.improve.improved):[],[t.improve]),i=p.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=p.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 n.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.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:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),n.jsx("path",{d:"M2 17l10 5 10-5"}),n.jsx("path",{d:"M2 12l10 5 10-5"})]})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),n.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[n.jsxs("span",{style:{color:"var(--green)"},children:["+",i.added]}),n.jsxs("span",{style:{color:"var(--red)"},children:["-",i.removed]})]}),n.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:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&n.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:[n.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),n.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:n.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:n.jsx("tbody",{children:c.map((d,f)=>n.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[n.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??""}),n.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??""}),n.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"?"-":" "}),n.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 yb({data:t}){if(t.length<2)return n.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,w)=>{const C=c+w/(f-1)*u,T=c+d-(k-h)/v*d;return`${C.toFixed(1)},${T.toFixed(1)}`}),b=a[a.length-1],j=Vl(b);return n.jsxs("svg",{width:s,height:i,viewBox:`0 0 ${s} ${i}`,style:{display:"block"},children:[n.jsx("polyline",{points:y.join(" "),fill:"none",stroke:j,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,w]=y[y.length-1].split(",");return n.jsx("circle",{cx:k,cy:w,r:2.5,fill:j})})()]})}function KN(){return n.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:n.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 XN({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 n.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[i,t.toFixed(1),"%"]})}function QN({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 n.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),n.jsxs("span",{className:"pill",style:{background:i.bg,color:i.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function ZN({warning:t}){return n.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:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.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"}),n.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),n.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function JN({active:t,onChange:a,hasBaseline:s}){return n.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[n.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"}),n.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 eT(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 bb=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function tT({entries:t}){return n.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(a=>n.jsx("th",{style:bb(a==="#"?"center":"left"),children:a},a))})}),n.jsx("tbody",{children:t.map(a=>n.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:[n.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:a.rank}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:a.model}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:a.provider}),a.isBest&&n.jsx(KN,{})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("span",{className:"pill",style:{background:a.passRate>=.7?"var(--green-muted)":a.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Vl(a.passRate),fontSize:11,fontWeight:600},children:[Math.round(a.passRate*100),"%"]})}),n.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.rubricScore!=null?a.rubricScore.toFixed(1):"--"}),n.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`}),n.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.cost!=null?`$${a.cost.toFixed(4)}`:"N/A"}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(yb,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function nT({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,i)=>(i.amplificationPct??0)-(s.amplificationPct??0));return a.length===0?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("div",{className:"text-center",children:n.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",n.jsx("code",{children:"--baseline"})," flag."]})})}):n.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[n.jsx("thead",{children:n.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>n.jsx("th",{style:bb(s==="#"?"center":"left"),children:s},s))})}),n.jsx("tbody",{children:a.map((s,i)=>n.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:[n.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:i+1}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Vl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),n.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),n.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?n.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"]}):"--"}),n.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?n.jsx(XN,{pct:s.amplificationPct}):"--"}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(yb,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function rT(){const{state:t}=yn(),{plugin:a,skill:s}=t,[i,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>ke.getLeaderboard(a,s),[a,s]),{data:f,loading:h,error:x}=qa(u,d),v=(f==null?void 0:f.entries)??[],y=(x==null?void 0:x.message)??null;p.useEffect(()=>{c("rankings")},[a,s]);const b=p.useCallback(()=>In(u),[u]);Zo("leaderboard:updated",b);const j=p.useMemo(()=>eT(v),[v]),k=j.some(T=>T.hasBaseline),w=v[0],C=w==null?void 0:w.judgeBiasWarning;return h?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"spinner spinner-lg"})}):y?n.jsx("div",{className:"flex items-center justify-center h-full px-8",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Failed to load leaderboard"}),n.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:y})]})}):j.length===0?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[n.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:n.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 20V10"}),n.jsx("path",{d:"M12 20V4"}),n.jsx("path",{d:"M6 20v-6"})]})}),n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),n.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),n.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"'}),n.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",n.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):n.jsxs("div",{className:"p-5 animate-fade-in",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),n.jsx(JN,{active:i,onChange:c,hasBaseline:k})]}),n.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":""]})]}),C&&n.jsx(ZN,{warning:C}),i==="rankings"?n.jsx(tT,{entries:j}):n.jsx(nT,{entries:j}),i==="amplification"&&(w==null?void 0:w.skillQualityScore)!=null&&(w==null?void 0:w.skillQualityRating)&&n.jsx(QN,{score:w.skillQualityScore,rating:w.skillQualityRating})]})}function aT(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 Zf({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:i,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:f}){const[h,x]=p.useState(u),[v,y]=p.useState("unified"),b=p.useRef(null),j=p.useRef(null),k=p.useMemo(()=>aT(t),[t]),w=p.useMemo(()=>{const L=k.filter(N=>N.type==="add").length,P=k.filter(N=>N.type==="remove").length;return{added:L,removed:P}},[k]),C=p.useMemo(()=>{let L=0,P=0;return k.filter(N=>N.type!=="header").map(N=>N.type==="remove"?(L++,{...N,origNum:L,newNum:null}):N.type==="add"?(P++,{...N,origNum:null,newNum:P}):(L++,P++,{...N,origNum:L,newNum:P}))},[k]),T=p.useMemo(()=>{const L=[],P=[];for(const N of C)if(N.type==="remove")L.push(N);else if(N.type==="add")P.push(N);else{for(;L.length<P.length;)L.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<L.length;)P.push({type:"context",content:"",origNum:null,newNum:null});L.push(N),P.push(N)}for(;L.length<P.length;)L.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<L.length;)P.push({type:"context",content:"",origNum:null,newNum:null});return{left:L,right:P}},[C]),E=p.useCallback(L=>{const P=L==="left"?b.current:j.current,N=L==="left"?j.current:b.current;P&&N&&(N.scrollTop=P.scrollTop)},[]);if(!t||k.length===0)return n.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),f&&n.jsx("button",{onClick:f,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const R=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",O=n.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[a," → ",s]}),n.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[n.jsxs("span",{style:{color:"var(--green)"},children:["+",w.added]}),n.jsxs("span",{style:{color:"var(--red)"},children:["-",w.removed]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{onClick:()=>y(v==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:v==="unified"?"Side-by-side":"Unified"}),u&&n.jsx("button",{onClick:()=>x(!h),className:"btn btn-ghost text-[11px]",children:h?"Expand":"Collapse"})]})]}),i&&n.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"?n.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:n.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:n.jsx("tbody",{children:C.map((L,P)=>n.jsxs("tr",{style:{background:L.type==="add"?"rgba(34,197,94,0.08)":L.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[n.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:L.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:L.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:L.origNum??""}),n.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:L.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:L.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:L.newNum??""}),n.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:L.type==="add"?"var(--green)":L.type==="remove"?"var(--red)":"transparent",borderRight:L.type==="add"?"2px solid var(--green)":L.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:L.type==="add"?"+":L.type==="remove"?"-":" "}),n.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:L.type==="add"?"var(--green)":L.type==="remove"?"var(--red)":"var(--text-secondary)"},children:L.content||""})]},P))})})}):n.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:[n.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>E("left"),children:n.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:n.jsx("tbody",{children:T.left.map((L,P)=>n.jsxs("tr",{style:{background:L.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[n.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:L.origNum??""}),n.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:L.type==="remove"?"var(--red)":"var(--text-secondary)"},children:L.content||""})]},P))})})}),n.jsx("div",{ref:j,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>E("right"),children:n.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:n.jsx("tbody",{children:T.right.map((L,P)=>n.jsxs("tr",{style:{background:L.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[n.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:L.newNum??""}),n.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:L.type==="add"?"var(--green)":"var(--text-secondary)"},children:L.content||""})]},P))})})})]}))]});return d==="modal"?n.jsx("div",{className:R,children:n.jsx("div",{style:{width:"80%",maxWidth:900},children:O})}):O}const Qd="https://verified-skill.com/submit",lT=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function sT(t){if(!t)return Qd;const a=t.trim();return!a||!lT.test(a)?Qd:`${Qd}?repo=${encodeURIComponent(a)}`}const iT={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 oT({size:t}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[n.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"}),n.jsx("path",{d:"M7.5 10.5L9.5 12.5L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function cT({size:t}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[n.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"}),n.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 hv={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)"}},uT={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function jb(t){return uT[t]??t}function dT({size:t}){return n.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[n.jsx("path",{d:"M10 2L1.5 17.5H18.5L10 2Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),n.jsx("path",{d:"M10 8V12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"10",cy:"14.5",r:"1",fill:"currentColor"})]})}function fT({tier:t,size:a}){return t==="TAINTED"?n.jsx(dT,{size:a}):t==="CERTIFIED"?n.jsx(cT,{size:a}):n.jsx(oT,{size:a})}function rA({tier:t,size:a="md",isTainted:s}){const i=iT[a],c=s?"TAINTED":t,u=hv[c]??hv.VERIFIED;return n.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:[n.jsx(fT,{tier:c,size:i.icon}),jb(c)]})}const xv={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 pT(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function mT(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 hT(){const{state:t}=yn(),{plugin:a,skill:s}=t,i=ur(),{onSkillUpdated:c,updateCount:u}=i,d=p.useMemo(()=>i.state.skills.find(Y=>Y.plugin===a&&Y.skill===s)??null,[i.state.skills,a,s]),f=`versions-envelope/${a}/${s}`,h=p.useCallback(()=>ke.getSkillVersionsEnvelope(a,s),[a,s]),{data:x,loading:v}=qa(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,w]=p.useState(null),[C,T]=p.useState(null),[E,R]=p.useState(null),[O,L]=p.useState(!1),[P,N]=p.useState("idle"),[B,z]=p.useState(null),_=p.useRef(null),H=p.useRef(null),W=p.useMemo(()=>(y==null?void 0:y.find(Y=>Y.isInstalled))??null,[y]),q=p.useMemo(()=>(y==null?void 0:y[0])??null,[y]),ee=W&&q&&W.version!==q.version,$=p.useCallback(Y=>{k?!C&&Y!==k?T(Y):(w(Y),T(null),R(null)):(w(Y),R(null))},[k,C]),D=p.useCallback(async(Y,oe)=>{L(!0);try{const M=await ke.getVersionDiff(a,s,Y,oe);R(M)}catch{R(null)}finally{L(!1)}},[a,s]);p.useEffect(()=>{if(k&&C){const Y=y||[],oe=Y.findIndex(Q=>Q.version===k),M=Y.findIndex(Q=>Q.version===C),[I,K]=oe>M?[k,C]:[C,k];D(I,K)}},[k,C,y,D]);const U=p.useCallback(()=>{!W||!q||(w(W.version),T(q.version))},[W,q]),F=p.useCallback(async()=>{N("updating"),z(null);const Y=new AbortController;_.current=Y;try{const oe=await ke.postSkillUpdate(a,s,Y.signal);if(oe.ok)N("done"),c(a,s);else{const M=`Update failed (HTTP ${oe.status}): ${oe.body||"no response body"}`;N("error"),z(M)}}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError")return;const M=oe instanceof Error?oe.message:"Network error";N("error"),z(M)}finally{_.current===Y&&(_.current=null)}},[a,s,c]);if(p.useEffect(()=>()=>{var Y;(Y=_.current)==null||Y.abort(),_.current=null},[]),v)return n.jsxs("div",{className:"p-5",children:[n.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"skeleton h-14 rounded-lg"}),n.jsx("div",{className:"skeleton h-14 rounded-lg"}),n.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!y||y.length===0){if((d==null?void 0:d.origin)==="source"){const oe=sT((d==null?void 0:d.homepage)??null);return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[n.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),n.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."}),n.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?n.jsxs("div",{className:"p-5",children:[n.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),n.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:[n.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:d.version}),n.jsx(Nf,{provider:b}),n.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"})]})}),n.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."})]})]})]}):n.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:n.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return n.jsxs("div",{className:"p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),n.jsxs("div",{className:"flex items-center gap-2",children:[ee&&n.jsx("button",{onClick:U,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),ee&&P!=="done"&&(P==="error"?n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:B||"Update failed"}),n.jsx("button",{onClick:F,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):n.jsx("button",{onClick:F,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&&n.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&&!C&&n.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]}),n.jsxs("div",{className:"relative",children:[n.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),n.jsx("div",{className:"space-y-1",children:y.map(Y=>{const oe=xv[Y.certTier]||xv.COMMUNITY,M=Y.version===k||Y.version===C,I=Y.isInstalled;return n.jsxs("button",{onClick:()=>$(Y.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:M?"var(--accent-muted)":"transparent",border:M?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:K=>{M||(K.currentTarget.style.background="var(--surface-1)")},onMouseLeave:K=>{M||(K.currentTarget.style.background="transparent")},children:[n.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)"}}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:Y.version}),n.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:oe.bg,color:oe.text},children:jb(Y.certTier)}),n.jsx(Nf,{provider:b}),I&&n.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"})]}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(Y.createdAt).toLocaleDateString()})]}),(()=>{const K=mT(Y.diffSummary);return K?n.jsx("div",{"data-testid":"version-row-diff-summary",className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:pT(K,80)}):null})()]},Y.version)})}),n.jsx("div",{ref:H,style:{height:1}})]}),O&&n.jsx("div",{className:"mt-4",children:n.jsx("div",{className:"skeleton h-48 rounded-xl"})}),E&&!O&&n.jsx("div",{className:"mt-4",children:n.jsx(Zf,{contentDiff:E.contentDiff,fromLabel:E.from,toLabel:E.to,diffSummary:E.diffSummary,renderContext:"inline",onRetry:()=>k&&C&&D(E.from,E.to)})})]})}function xT(t){return t==="timeline"||t==="models"||t==="versions"}function gT({view:t}){return t==="models"?n.jsx(rT,{}):t==="versions"?n.jsx(hT,{}):n.jsx(WN,{})}function vT(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 yT(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 Il(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function bT(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 jT({onCreated:t,resolveAiConfigOverride:a,forceLayout:s,flushPendingForSkillName:i}){const[c,u]=p.useState("ai"),[d,f]=p.useState(null),[h,x]=p.useState(!0),{config:v}=Ya(),[y,b]=p.useState(""),[j,k]=p.useState(s??3),[w,C]=p.useState(""),[T,E]=p.useState(""),[R,O]=p.useState(""),[L,P]=p.useState(""),[N,B]=p.useState(""),[z,_]=p.useState(""),[H,W]=p.useState("write"),[q,ee]=p.useState([]),[$,D]=p.useState(!1),[U,F]=p.useState(null),[Y,oe]=p.useState(null),[M,I]=p.useState(null),[K,Q]=p.useState("vskill"),[ue,te]=p.useState("1.0.0"),[ie,J]=p.useState(!0),he=p.useCallback(async()=>{try{const Pe=await ke.detectEngines();I(Pe),Q(it=>it!=="vskill"?it:Pe.vskillSkillBuilder?"vskill":Pe.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{I({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{he()},[he]);const[je,Ne]=p.useState(""),[De,He]=p.useState(!1),[Ue,_e]=p.useState(!1),[Ze,st]=p.useState(null),[ce,ve]=p.useState(null),[ye,Se]=p.useState([]),Ae=p.useRef(null),Ge=p.useRef(null),We=p.useRef(null),wt=p.useRef(null),Ct=p.useRef(null),[Et,zt]=p.useState(!1),[xe,qe]=p.useState(!1),tt=p.useRef(y),Nt=p.useRef(w),St=p.useRef(T);p.useEffect(()=>{tt.current=y},[y]),p.useEffect(()=>{Nt.current=w},[w]),p.useEffect(()=>{St.current=T},[T]),p.useEffect(()=>{ke.getProjectLayout().then(Pe=>{if(f(Pe),s)return;k(Pe.suggestedLayout);const it=Pe.detectedLayouts.find(un=>un.layout===Pe.suggestedLayout);it!=null&&it.existingPlugins.length&&C(it.existingPlugins[0])}).catch(()=>{}).finally(()=>x(!1))},[s]),p.useEffect(()=>{var Pe;c==="ai"&&((Pe=Ae.current)==null||Pe.focus())},[c]),p.useEffect(()=>()=>{var Pe;(Pe=Ge.current)==null||Pe.abort()},[]);const dt=p.useMemo(()=>{var Pe;return d?((Pe=d.detectedLayouts.find(it=>it.layout===j))==null?void 0:Pe.existingPlugins)||[]:[]},[d,j]),Dt=w==="__new__"?T:w,Ft=d?bT(d.root,j,Dt||"{plugin}",y||"{skill}"):"",jr=p.useMemo(()=>d?d.detectedLayouts.filter(Pe=>Pe.layout!==4):[],[d]),en=p.useMemo(()=>{if(!d)return null;const Pe=d.detectedLayouts.find(rn=>rn.layout===2&&rn.existingPlugins.length>0),it=d.detectedLayouts.find(rn=>rn.layout===1&&rn.existingPlugins.length>0),un=Pe||it;return un?{layout:un.layout,plugins:un.existingPlugins}:null},[d]),Tn=p.useCallback(()=>{if(a)return a();if(!v)return{provider:"claude-cli",model:"sonnet"};const Pe=v.provider||"claude-cli",it=v.model||"sonnet";return{provider:Pe,model:it}},[v,a]),Rn=p.useCallback(()=>{var Pe;(Pe=Ge.current)==null||Pe.abort(),He(!1)},[]),nr=p.useCallback(()=>{st(null),ve(null)},[]),bn=p.useCallback(async()=>{var rn,rr;if(st(null),ve(null),Se([]),We.current=null,wt.current=null,!je.trim()){st("Describe what your skill should do");return}He(!0);const Pe=new AbortController;Ge.current=Pe;const{provider:it,model:un}=Tn();try{const Hn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(vT({prompt:je.trim(),provider:it,model:un,targetAgents:q})),signal:Pe.signal});if(!Hn.ok||!Hn.body){let Z=`HTTP ${Hn.status}`;try{const be=await Hn.json();be.error&&(Z=be.error)}catch{}throw new Error(Z)}const Kl=Hn.body.getReader(),Qa=new TextDecoder;let Sr="",jn="";for(;;){const{done:Z,value:be}=await Kl.read();if(Z)break;Sr+=Qa.decode(be,{stream:!0});const we=Sr.split(`
|
|
108
|
+
`);Sr=we.pop()||"";for(const _t of we)if(_t.startsWith("event: "))jn=_t.slice(7).trim();else if(_t.startsWith("data: ")){try{const Te=JSON.parse(_t.slice(6));if(jn==="progress")Se(ht=>[...ht,{phase:Te.phase,message:Te.message,timestamp:Date.now()}]);else if(jn==="provenance")wt.current={resolvedModelId:typeof Te.resolvedModelId=="string"?Te.resolvedModelId:null,snapshotDate:typeof Te.snapshotDate=="string"?Te.snapshotDate:null};else if(jn==="done"||jn==="complete"){const ht={prompt:je.trim(),provider:Tn().provider,model:Tn().model,resolvedModelId:((rn=wt.current)==null?void 0:rn.resolvedModelId)??null,snapshotDate:((rr=wt.current)==null?void 0:rr.snapshotDate)??null,reasoning:Te.reasoning||""},dn=yT({userName:tt.current,userPlugin:Nt.current,userNewPlugin:St.current,aiName:Te.name,aiSuggestedPlugin:Te.suggestedPlugin&&Te.suggestedPlugin.plugin?{plugin:Te.suggestedPlugin.plugin,layout:Te.suggestedPlugin.layout}:null,forceLayout:s});if(dn.applyName!==null&&b(dn.applyName),O(Te.description),P(Te.model||""),B(Te.allowedTools||""),_(Te.body),_e(!0),We.current=ht,u("manual"),s===3)k(3),C(""),E("");else if(dn.applySuggestedPlugin&&dn.suggestedPluginValue){const an=dn.suggestedPluginValue;if(((d==null?void 0:d.detectedLayouts.flatMap(kr=>kr.existingPlugins))??[]).includes(an.plugin))if(C(an.plugin),an.layout&&(an.layout===1||an.layout===2))k(an.layout);else{const kr=d==null?void 0:d.detectedLayouts.find(wa=>wa.existingPlugins.includes(an.plugin));kr&&(kr.layout===1||kr.layout===2)&&k(kr.layout)}else C("__new__"),E(an.plugin)}else!dn.applySuggestedPlugin&&Nt.current.trim().length===0&&St.current.trim().length===0&&j===3&&en&&qe(!0);const Gr={name:Te.name,plugin:Dt||"",layout:j,description:Te.description,model:Te.model||void 0,allowedTools:Te.allowedTools||void 0,body:Te.body,aiMeta:ht};ke.saveDraft(Gr).then(an=>{zt(!0),an!=null&&an.dir&&(Ct.current=an.dir)}).catch(()=>{})}else jn==="error"&&(st(Te.message||Te.description||"Unknown error"),Te.category&&ve(Te))}catch{}jn=""}}}catch(Hn){Hn.name!=="AbortError"&&st(Hn.message)}finally{He(!1),Ge.current=null}},[je,Tn,j,en,Dt,d,q,s]),Tt=p.useCallback(async()=>{var Pe;if(F(null),oe(null),!y.trim()){F("Skill name is required");return}if(!R.trim()){F("Description is required");return}if(j!==3&&!Dt.trim()){F("Plugin name is required");return}if(!ie){F("Version is not valid semver");return}D(!0);try{if(i)try{await i(Il(y))}catch(un){F(`Could not finalize previous delete of ${Il(y)}: ${un.message}. Cancel the pending delete and try again.`),D(!1);return}const it=await ke.createSkill({name:Il(y),plugin:Dt||"",layout:j,description:R,model:L||void 0,allowedTools:N||void 0,body:z,aiMeta:We.current||void 0,draftDir:Ct.current||void 0,version:ue.trim()||void 0,engine:K});Ct.current=null,t(it.plugin,it.skill)}catch(it){if(it instanceof Vr&&it.status===409&&((Pe=it.details)==null?void 0:Pe.code)==="skill-already-exists"){const un=typeof it.details.plugin=="string"?it.details.plugin:"",rn=typeof it.details.skill=="string"?it.details.skill:Il(y);oe("Skill already existed — opened it."),Ct.current=null,t(un,rn)}else F(it.message)}finally{D(!1)}},[y,R,j,Dt,L,N,z,ue,ie,K,t,i]),pt=p.useCallback(()=>{en&&(k(en.layout),C(en.plugins[0]),qe(!1))},[en]);return{mode:c,setMode:u,layout:d,layoutLoading:h,selectedLayout:j,setSelectedLayout:k,creatableLayouts:jr,availablePlugins:dt,pathPreview:Ft,plugin:w,setPlugin:C,newPlugin:T,setNewPlugin:E,effectivePlugin:Dt,name:y,setName:b,description:R,setDescription:O,model:L,setModel:P,allowedTools:N,setAllowedTools:B,body:z,setBody:_,bodyViewMode:H,setBodyViewMode:W,aiPrompt:je,setAiPrompt:Ne,generating:De,aiGenerated:Ue,aiError:Ze,aiClassifiedError:ce,aiProgress:ye,promptRef:Ae,handleGenerate:bn,handleCancelGenerate:Rn,clearAiError:nr,targetAgents:q,setTargetAgents:ee,draftSaved:Et,showPluginRecommendation:xe,setShowPluginRecommendation:qe,pluginLayoutInfo:en,applyPluginRecommendation:pt,creating:$,error:U,info:Y,handleCreate:Tt,engineDetection:M,refreshEngineDetection:he,engine:K,setEngine:Q,version:ue,setVersion:te,versionValid:ie,setVersionValid:J,standaloneLocked:s===3}}const ST={flushBySkillName:async()=>{}},Sb=p.createContext(ST);function kT(){return p.useContext(Sb)}function kb(){return n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:n.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 wT(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function wb({node:t,depth:a=0}){var s;return n.jsxs(n.Fragment,{children:[n.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"?n.jsx(kb,{}):n.jsx(wT,{}),n.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(i=>n.jsx(wb,{node:i,depth:a+1},i.name))]})}function CT(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 ET({skillName:t,hasEvals:a,isDraft:s}){const i=CT(t,a,s);return n.jsxs("div",{className:"glass-card p-4",children:[n.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[n.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:n.jsx(kb,{})}),"Skill Structure"]}),n.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:n.jsx(wb,{node:i})})]})}const ga={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Zd({size:t=14,color:a="currentColor"}){return n.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.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 NT({onCreated:t,onCancel:a}){const{flushBySkillName:s}=kT(),i=jT({onCreated:t,flushPendingForSkillName:s});return n.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[n.jsxs("div",{className:"mb-5",children:[n.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),n.jsx("div",{className:"flex items-center justify-between mt-2",children:n.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[n.jsx("button",{onClick:()=>i.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:i.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:i.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:i.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Zd,{size:12}),"AI-Assisted"]})}),n.jsx("button",{onClick:()=>i.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:i.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:i.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:i.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),i.layoutLoading&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),n.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!i.layoutLoading&&i.layout&&i.mode==="ai"&&n.jsxs("div",{className:"space-y-4 animate-fade-in",children:[n.jsxs("div",{className:"glass-card p-4",children:[n.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[n.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:n.jsx(Zd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),n.jsx("textarea",{ref:i.promptRef,value:i.aiPrompt,onChange:c=>i.setAiPrompt(c.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:i.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...ga,minHeight:"120px"},onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),i.handleGenerate())}}),n.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),i.generating&&i.aiProgress.length>0&&n.jsx(mi,{entries:i.aiProgress,isRunning:!0}),i.aiError&&n.jsx("div",{children:i.aiClassifiedError?n.jsx(fc,{error:i.aiClassifiedError,onRetry:i.handleGenerate,onDismiss:i.clearAiError}):n.jsxs("div",{children:[n.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:i.aiError}),n.jsx("button",{onClick:i.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),n.jsxs("div",{className:"flex items-center gap-3",children:[i.generating?n.jsx("button",{onClick:i.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"}):n.jsxs("button",{onClick:i.handleGenerate,disabled:!i.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:i.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:i.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:i.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[n.jsx(Zd,{size:14}),"Generate"]}),n.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"}),!i.generating&&n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",n.jsx("button",{onClick:()=>i.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!i.layoutLoading&&i.layout&&i.mode==="manual"&&n.jsxs("div",{className:"space-y-4 animate-fade-in",children:[n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),i.creatableLayouts.length>1&&n.jsxs("div",{className:"mb-3",children:[n.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),n.jsx("div",{className:"flex gap-2",children:i.creatableLayouts.map(c=>n.jsx("button",{onClick:()=>{i.setSelectedLayout(c.layout),i.setPlugin(c.existingPlugins[0]||""),i.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:i.selectedLayout===c.layout?"var(--accent)":"var(--surface-3)",color:i.selectedLayout===c.layout?"#fff":"var(--text-secondary)",border:`1px solid ${i.selectedLayout===c.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:c.label},c.layout))})]}),i.selectedLayout!==3&&n.jsxs("div",{className:"mb-3",children:[n.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),n.jsxs("select",{value:i.plugin,onChange:c=>{i.setPlugin(c.target.value),i.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ga,children:[i.availablePlugins.map(c=>n.jsx("option",{value:c,children:c},c)),n.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),i.plugin==="__new__"&&n.jsx("input",{type:"text",value:i.newPlugin,onChange:c=>i.setNewPlugin(Il(c.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:ga})]}),n.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:i.pathPreview})]}),i.showPluginRecommendation&&i.pluginLayoutInfo&&i.selectedLayout===3&&n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),n.jsxs("span",{children:["Plugins detected (",n.jsx("strong",{children:i.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[n.jsx("button",{onClick:i.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),n.jsx("button",{onClick:()=>i.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:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),n.jsxs("div",{className:"glass-card p-4",children:[n.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),n.jsxs("div",{className:"mb-3",children:[n.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",n.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),n.jsx("input",{type:"text",value:i.name,onChange:c=>i.setName(Il(c.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ga})]}),n.jsxs("div",{className:"mb-3",children:[n.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",n.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),n.jsx("textarea",{value:i.description,onChange:c=>i.setDescription(c.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...ga,minHeight:"72px"}})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),n.jsxs("select",{value:i.model,onChange:c=>i.setModel(c.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ga,children:[n.jsx("option",{value:"",children:"Any"}),n.jsx("option",{value:"opus",children:"Opus"}),n.jsx("option",{value:"sonnet",children:"Sonnet"}),n.jsx("option",{value:"haiku",children:"Haiku"})]})]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),n.jsx("input",{type:"text",value:i.allowedTools,onChange:c=>i.setAllowedTools(c.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ga})]})]})]}),n.jsxs("div",{className:"glass-card p-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2.5",children:[n.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),n.jsxs("div",{children:[n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),n.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),n.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(c=>n.jsxs("button",{onClick:()=>i.setBodyViewMode(c),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:i.bodyViewMode===c?"var(--surface-4)":"transparent",color:i.bodyViewMode===c?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:i.bodyViewMode===c?600:400,border:"none",cursor:"pointer"},children:[c==="write"?n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"16 18 22 12 16 6"}),n.jsx("polyline",{points:"8 6 2 12 8 18"})]}):n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),n.jsx("span",{children:c==="write"?"Write":"Preview"})]},c))})]}),i.bodyViewMode==="write"?n.jsx("textarea",{value:i.body,onChange:c=>i.setBody(c.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:{...ga,minHeight:"150px"}}):i.body.trim()?n.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:pi(i.body)}}):n.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:n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),n.jsx(ET,{skillName:i.name||"{skill}",hasEvals:!1,isDraft:i.draftSaved}),i.error&&n.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:i.error}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:i.handleCreate,disabled:i.creating||!i.name||!i.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:i.creating||!i.name||!i.description?"var(--surface-3)":"var(--accent)",color:i.creating||!i.name||!i.description?"var(--text-tertiary)":"#fff",cursor:i.creating||!i.name||!i.description?"not-allowed":"pointer",border:"none"},children:i.creating?"Creating...":"Create Skill"}),n.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 gv(){return n.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:n.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:[n.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"}),n.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),n.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function qs({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=ur(),[u,d]=p.useState(!1);return t==="no-selection"?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[n.jsx("div",{className:"mb-5",children:u?n.jsx(gv,{}):n.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),n.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),n.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"?n.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[n.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:n.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:n.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"})})}),n.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),n.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",n.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"]}),n.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:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="no-project-skills"?n.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:[n.jsx("div",{className:"mb-5",children:u?n.jsx(gv,{}):n.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),n.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),n.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."}),n.jsxs("div",{className:"flex gap-3",children:[n.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:[n.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:[n.jsx("circle",{cx:"9",cy:"21",r:"1"}),n.jsx("circle",{cx:"20",cy:"21",r:"1"}),n.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"]}),n.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:[n.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:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create new skill"]})]})]}):t==="error"?n.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:n.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:[n.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&n.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"})]})}):n.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[n.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),n.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 TT(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const RT={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 Cb(){const[t,a]=p.useState([]),[s,i]=p.useState(!0),[c,u]=p.useState(new Set),[d,f]=p.useState(new Map),[h,x]=p.useState(!1),[v,y]=p.useState(new Set),[b,j]=p.useState(new Map),[k,w]=p.useState(null),[C,T]=p.useState(null),[E,R]=p.useState(!1),O=p.useCallback(async()=>{i(!0);try{const H=await ke.getSkillUpdates();a(H.filter(W=>W.updateAvailable))}catch{a([])}finally{i(!1)}},[]);p.useEffect(()=>{O()},[O]);const L=p.useMemo(()=>t.filter(H=>!H.pinned),[t]),P=p.useCallback(H=>{u(W=>{const q=new Set(W);return q.has(H)?q.delete(H):q.add(H),q})},[]),N=p.useCallback(()=>{c.size===L.length?u(new Set):u(new Set(L.map(H=>H.name)))},[c,L]),B=p.useCallback(()=>{const H=[...c];if(!H.length)return;x(!0),f(new Map(H.map(q=>[q,{skill:q,status:"pending"}])));const W=ke.startBatchUpdate(H);W.addEventListener("progress",q=>{try{const ee=JSON.parse(q.data);f($=>new Map($).set(ee.skill,ee))}catch{}}),W.addEventListener("done",q=>{W.close(),x(!1);try{const ee=JSON.parse(q.data);w(`Updated ${ee.updated??0} skills, ${ee.failed??0} failed`),setTimeout(()=>w(null),5e3)}catch{}O()}),W.addEventListener("error",()=>{W.close(),x(!1),w("Batch update failed"),setTimeout(()=>w(null),5e3)})},[c,O]),z=p.useCallback(async H=>{const W=H.name.split("/"),q=W.length>=3?W[W.length-2]:W[0],ee=W[W.length-1];y($=>new Set($).add(H.name)),j($=>{const D=new Map($);return D.delete(H.name),D});try{const $=await ke.postSkillUpdate(q,ee);if($.ok)O();else{const D=`Update failed (HTTP ${$.status}): ${$.body}`;j(U=>new Map(U).set(H.name,D)),w(`Couldn't update ${ee} — HTTP ${$.status}`),setTimeout(()=>w(null),5e3)}}catch($){const D=$ instanceof Error?$.message:"Network error";j(U=>new Map(U).set(H.name,D)),w(`Couldn't update ${ee} — ${D}`),setTimeout(()=>w(null),5e3)}finally{y($=>{const D=new Set($);return D.delete(H.name),D})}},[O]),_=p.useCallback(async H=>{if(!H.latest)return;const W=H.name.split("/"),q=W.length>=3?W[W.length-2]:W[0],ee=W[W.length-1];R(!0);try{const $=await ke.getVersionDiff(q,ee,H.installed,H.latest);T({skill:H,diff:$})}catch{T(null)}finally{R(!1)}},[]);return s?n.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[n.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"skeleton h-16 rounded-lg"}),n.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?n.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[n.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:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),n.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),n.jsx("button",{onClick:O,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):n.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&n.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}),n.jsxs("div",{className:"flex items-center justify-between mb-5",children:[n.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",L.length,")"]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{onClick:O,className:"btn btn-ghost text-[12px]",disabled:h,children:"Refresh"}),n.jsx("button",{onClick:B,disabled:c.size===0||h,className:"btn btn-primary text-[12px]",children:h?"Updating...":`Update Selected (${c.size})`})]})]}),n.jsx("div",{className:"flex items-center gap-2 mb-3",children:n.jsxs("button",{onClick:N,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[n.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===L.length&&L.length>0?"var(--accent)":"var(--border-default)",background:c.size===L.length&&L.length>0?"var(--accent)":"transparent"},children:c.size===L.length&&L.length>0&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),n.jsx("div",{className:"space-y-2",children:t.map(H=>{const W=H.name.split("/").pop()||H.name,q=H.latest?TT(H.installed,H.latest):"patch",ee=RT[q],$=!!H.pinned,D=v.has(H.name),U=d.get(H.name),F=c.has(H.name);return n.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:()=>!$&&P(H.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:n.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:F?"var(--accent)":"var(--border-default)",background:F?"var(--accent)":"transparent",opacity:$?.4:1},children:F&&n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:W}),$&&n.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),n.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:ee.bg,color:ee.text},children:q})]}),n.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",$&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),U&&n.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:U.status==="done"?"var(--green-muted)":U.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:U.status==="done"?"var(--green)":U.status==="error"?"var(--red)":"var(--yellow)"},children:[U.status,U.error&&`: ${U.error}`]}),n.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[n.jsx("button",{onClick:()=>_(H),className:"btn btn-ghost text-[11px]",disabled:E,children:"View Changes"}),n.jsx("button",{onClick:()=>z(H),disabled:$||D||h,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:D?n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(U==null?void 0:U.status)==="done"?n.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.name)})}),C&&n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>T(null),children:n.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[n.jsx("div",{className:"mb-2 flex justify-end",children:n.jsx("button",{onClick:()=>T(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),n.jsx(Zf,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const AT=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Cb},Symbol.toStringTag,{value:"Module"}));function LT(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function MT(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function zT(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 Eb(t){const{author:a,repoUrl:s}=t,i=zT(s??null),c=a&&a.trim()!==""?a:i??"—",[u,d]=p.useState(!1),f=p.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?n.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()===""?n.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):n.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,n.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function Nb(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function DT(t,a){const s=Nb(t),i=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return i?`${s}/blob/HEAD/${i}`:`${s}/blob/HEAD/`}function vv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function Tb(t){const{repoUrl:a,skillPath:s,absolutePath:i}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),f=s?vv(s):i?vv(i):"source",h=p.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=DT(a,s);return n.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:[n.jsx("span",{children:f}),n.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!i&&!s)return n.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 n.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:[n.jsx("span",{children:f}),n.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}const _T=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/,OT=/^[A-Za-z0-9._-]+$/;function BT(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;let s;try{s=Nb(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!_T.test(d)||!f||!OT.test(f)?null:{owner:d,repo:f}}function IT(t){const a=BT(t.repoUrl??null);if(!a)return null;const s=`https://github.com/${a.owner}/${a.repo}`;return n.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 yv(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Rb(t){return t.skill?UT({skill:t.skill}):PT({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function $T(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 UT({skill:t}){const[a,s]=p.useState(!1),i=(t.sourcePath??t.dir)||"—",c=p.useCallback(async()=>{var f;try{await((f=navigator.clipboard)==null?void 0:f.writeText(i)),s(!0),setTimeout(()=>s(!1),1500),yv(ae.toasts.pathCopied,"info")}catch{yv(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 n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[n.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),n.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),n.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[n.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${u}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:d}}),u]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[n.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}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("span",{"data-testid":"detail-header-version",children:n.jsx(fi,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})}),t.pluginName&&t.pluginVersion&&n.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:[n.jsx("span",{children:"from"}),n.jsx("span",{style:{color:"var(--text-secondary)"},children:t.pluginName}),n.jsx("span",{"aria-hidden":"true",children:"@"}),n.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:t.pluginVersion})]}),t.origin==="source"&&n.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:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),n.jsx("path",{d:"M10 11v6"}),n.jsx("path",{d:"M14 11v6"}),n.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]}),n.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:[n.jsx(Eb,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),n.jsx(IT,{repoUrl:t.repoUrl??null}),n.jsx(Tb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),n.jsx(HT,{skill:t}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.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:$T(i)}),n.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:[n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),n.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 HT({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 n.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:[n.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),n.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:i})]})}function PT({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(T=>T.status==="running"||T.status==="queued"),b=d==null?void 0:d.overall_pass_rate,j=(u==null?void 0:u.evals.reduce((T,E)=>T+E.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,w=LT(b),C=MT(b);return n.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:[n.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[n.jsx("span",{style:{color:"var(--text-tertiary)"},children:i}),n.jsx(VT,{}),n.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&n.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:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),f&&n.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&&n.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[n.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&n.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:T=>{y||(T.currentTarget.style.color="var(--red)")},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-tertiary)"},children:n.jsx(FT,{})}),x.length>0&&n.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.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"}),n.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),n.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),x.length," regression",x.length>1?"s":""]}),v>0&&n.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",v]}),n.jsx("span",{className:"pill",style:{background:C,color:w},children:b!=null?`${Math.round(b*100)}%`:"--"}),n.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",j," assert",j!==1?"s":""]})]})]})}function VT(){return n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}function FT(){return n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.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"}),n.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),n.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function va(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 n.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?n.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,n.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?n.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?n.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?n.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:f}):null,d?n.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 WT="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 GT(t){const{onNavigate:a}=t,[s,i]=p.useState(t.open??!1),c=p.useCallback(()=>i(!1),[]);p.useEffect(()=>{if(!s)return;const d=f=>{f.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{a==null||a(d),i(!1)},[a]);return n.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[n.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&&n.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:[n.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:WT}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[n.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Jd,children:"Tests →"}),n.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Jd,children:"Run →"}),n.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 qT(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const YT="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function KT({value:t}){const[a,s]=p.useState(!1),i=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[t]);return n.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 bv({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 n.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:i,background:s},children:a})}function XT(t={}){const{status:a,loading:s}=Gy();if(s||!a)return null;if(a.status==="github")return n.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:[n.jsx(bv,{tone:"ok",label:"Publish-ready"}),n.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",a.githubOrigin]}),n.jsx("div",{style:{marginLeft:"auto"},children:n.jsx(ab,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?qT(t.projectBasename??""):YT;return n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[n.jsx(bv,{tone:"warn",label:a.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),n.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.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}),n.jsx(KT,{value:i})]})]})}function QT({plugin:t,skill:a}){const[s,i]=p.useState([]),[c,u]=p.useState([]),[d,f]=p.useState(!0),[h,x]=p.useState(null);p.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?n.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"}):n.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[n.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:[n.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.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"}),n.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"})]})}),n.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),n.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),n.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&n.jsxs("div",{className:"space-y-3 mb-4",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(y=>n.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:y.server}),n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:y.transport})]}),n.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?n.jsxs(n.Fragment,{children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):n.jsxs(n.Fragment,{children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),n.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"]})})]}),n.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:y.url}),n.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.matchedTools.map(b=>n.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&&n.jsxs("div",{children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),n.jsx("div",{className:"space-y-1.5",children:c.map(y=>n.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:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.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"})}),n.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:y.name}),n.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 ZT="https://verified-skill.com/docs/parameters-and-secrets",JT="Stored as KEY=value in this skill's local .env.local (gitignored). Resolved from process.env first, then .env.local.";function jv({onToggleAdd:t,addFormOpen:a}){return n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wider flex items-center gap-1.5",style:{color:"var(--text-tertiary)"},children:["Parameters & Secrets",n.jsx("span",{"aria-label":"About Parameters & Secrets",title:JT,style:{cursor:"help",fontSize:11,color:"var(--text-tertiary)",opacity:.7,display:"inline-block",lineHeight:1},children:"ⓘ"})]}),n.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 eR(){return n.jsxs("div",{className:"px-4 py-5 rounded-xl flex flex-col gap-2",style:{background:"var(--surface-2)"},children:[n.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-secondary)"},children:"No parameters yet"}),n.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:["Values are stored as ",n.jsx("code",{style:{fontSize:11},children:"KEY=value"})," in this skill's local"," ",n.jsx("code",{style:{fontSize:11},children:".env.local"})," (auto-added to"," ",n.jsx("code",{style:{fontSize:11},children:".gitignore"}),"). They appear here when declared as"," ",n.jsx("code",{style:{fontSize:11},children:"requiredCredentials"})," in"," ",n.jsx("code",{style:{fontSize:11},children:"evals.json"}),", or when you add custom ones below."]}),n.jsx("a",{href:ZT,target:"_blank",rel:"noopener noreferrer",className:"text-[11px]",style:{color:"var(--accent)",textDecoration:"none"},children:"Learn more →"})]})}function tR({plugin:t,skill:a}){const[s,i]=p.useState([]),[c,u]=p.useState(!0),[d,f]=p.useState(null),[h,x]=p.useState(""),[v,y]=p.useState(!1),[b,j]=p.useState(null),[k,w]=p.useState(""),[C,T]=p.useState(""),[E,R]=p.useState(!1),[O,L]=p.useState(new Set),P=p.useCallback(async()=>{u(!0);try{const[_,H]=await Promise.all([ke.getCredentials(t,a).catch(()=>({credentials:[]})),ke.getParams(t,a).catch(()=>({params:[]}))]),W=new Map(H.params.map($=>[$.name,$])),q=new Set,ee=[];for(const $ of _.credentials){q.add($.name);const D=W.get($.name);ee.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:D==null?void 0:D.maskedValue})}for(const $ of H.params)q.has($.name)||ee.push({name:$.name,status:$.status,maskedValue:$.maskedValue});i(ee)}finally{u(!1)}},[t,a]);p.useEffect(()=>{P()},[P]);const N=p.useCallback(async _=>{if(O.has(_)){L(H=>{const W=new Set(H);return W.delete(_),W}),i(H=>H.map(W=>W.name===_?{...W,revealedValue:void 0}:W));return}try{const W=(await ke.getParamsRevealed(t,a,_)).params.find(q=>q.name===_);W&&(i(q=>q.map(ee=>ee.name===_?{...ee,revealedValue:W.value}:ee)),L(q=>new Set(q).add(_)))}catch{}},[t,a,O]),B=async(_,H)=>{if(!(!_.trim()||!H.trim())){y(!0),j(null);try{await ke.setCredential(t,a,_,H),f(null),x(""),L(new Set),P()}catch(W){j(W.message)}finally{y(!1)}}},z=async()=>{if(!(!k.trim()||!C.trim())){y(!0),j(null);try{await ke.setCredential(t,a,k.trim().toUpperCase(),C),w(""),T(""),R(!1),P()}catch(_){j(_.message)}finally{y(!1)}}};return c?n.jsxs("div",{className:"mt-6",children:[n.jsx(jv,{onToggleAdd:()=>{},addFormOpen:!1}),n.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):n.jsxs("div",{className:"mt-6",children:[n.jsx(jv,{onToggleAdd:()=>R(!E),addFormOpen:E}),b&&n.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&&!E?n.jsx(eR,{}):n.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(_=>n.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:[n.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:_.name}),_.maskedValue&&n.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:O.has(_.name)&&_.revealedValue!=null?_.revealedValue:_.maskedValue}),_.maskedValue&&n.jsx("button",{onClick:()=>N(_.name),className:"btn btn-ghost px-1",title:O.has(_.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:O.has(_.name)?n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.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"}),n.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"}),n.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n.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&&n.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:_.source}),d===_.name?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("input",{value:h,onChange:H=>x(H.target.value),onKeyDown:H=>{H.key==="Enter"&&B(_.name,h)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),n.jsx("button",{onClick:()=>B(_.name,h),disabled:v||!h.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:v?"...":"Save"}),n.jsx("button",{onClick:()=>{f(null),x("")},className:"btn btn-ghost text-[10px] px-1",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):n.jsx("button",{onClick:()=>{f(_.name),x("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},_.name))}),E&&n.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[n.jsxs("div",{className:"flex gap-2 mb-2",children:[n.jsx("input",{value:k,onChange:_=>w(_.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),n.jsx("input",{value:C,onChange:_=>T(_.target.value),onKeyDown:_=>{_.key==="Enter"&&z()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),n.jsxs("div",{className:"flex justify-end gap-1.5",children:[n.jsx("button",{onClick:()=>{R(!1),w(""),T("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),n.jsx("button",{onClick:z,disabled:v||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:v?"Saving...":"Save"})]})]})]})}function Sv({children:t}){return n.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 nR({plugin:t,skill:a}){return n.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[n.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[n.jsx(Sv,{children:"Setup"}),n.jsx(QT,{plugin:t,skill:a})]}),n.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[n.jsx(Sv,{children:"Credentials"}),n.jsx(tR,{plugin:t,skill:a})]})]})}function rR(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 Vs(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 aR(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function lR(t){const a=t.installMethod;if(!a)return null;const s=a==="authored"?"Authored":a==="copied"?"Copied":"Symlinked";return n.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 sR(t,a){const s=t.evalCount??0;return!t.hasEvals||s<=0?null:n.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 iR(t){var y,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,f=u??(oR(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=n.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},children:[n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[n.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}),n.jsx(fi,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),lR(a),sR(a,s)]}),n.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:[n.jsx(Eb,{author:a.author??null,repoUrl:f}),a.category?n.jsxs("span",{children:["· ",a.category]}):null,n.jsx(Tb,{repoUrl:f,skillPath:d??null,absolutePath:a.dir}),a.lastModified?n.jsxs("span",{title:a.lastModified,children:["· Updated ",Vs(a.lastModified)]}):null]})]}),a.origin!=="installed"&&!a.pluginMarketplace&&a.installMethod!=="copied"&&a.installMethod!=="symlinked"&&n.jsx(XT,{}),n.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:[n.jsx(va,{title:"Benchmark",value:aR(a),subtitle:a.lastBenchmark?Vs(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:n.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:n.jsx(GT,{onNavigate:s})})}),n.jsx(va,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),n.jsx(va,{title:"Activations",value:i,subtitle:c?`Last: ${Vs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),n.jsx(va,{title:"Last run",value:Vs(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),n.jsx(va,{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}),n.jsx(va,{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}),n.jsx(va,{title:"Size",value:rR(a.sizeBytes),"data-testid":"metric-size"}),n.jsx(va,{title:"Last modified",value:Vs(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return n.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,n.jsx(nR,{plugin:a.plugin,skill:a.skill})]})}function oR(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function cR({skill:t}){const{onSkillUpdated:a}=ur(),{toast:s}=lc(),[i,c]=p.useState("idle"),[u,d]=p.useState(null),[f,h]=p.useState(!1),[x,v]=p.useState(null),[y,b]=p.useState(!1),j=p.useRef(null),k=p.useCallback(async()=>{if(!t||i==="updating")return;const E=new AbortController;j.current=E,c("updating"),d(null);try{const R=await ke.postSkillUpdate(t.plugin,t.skill,E.signal);if(R.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const O=`Update failed (HTTP ${R.status}): ${R.body}`;c("idle"),d(O),s({message:`Couldn't update ${t.skill} — HTTP ${R.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return;const O=R instanceof Error?R.message:"Network error";c("idle"),d(O),s({message:`Couldn't update ${t.skill} — ${O}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}finally{j.current===E&&(j.current=null)}},[t,i,a,s]);if(p.useEffect(()=>{if(!f||x!=null||!t||!t.latestVersion)return;let E=!1;return b(!0),ke.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(R=>{E||v(R)}).catch(()=>{E||v(null)}).finally(()=>{E||b(!1)}),()=>{E=!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]),p.useEffect(()=>()=>{var E;(E=j.current)==null||E.abort()},[]),!t||t.updateAvailable!==!0)return null;const w=t.latestVersion,C=i==="updating"?"Updating…":w?`Update to ${w}`:"Update",T=i==="updating";return n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{k()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:C}),n.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>h(E=>!E),disabled:T||!w,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"&&n.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"&&n.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:u}),f&&w&&n.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[y&&n.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!y&&x&&n.jsx(Zf,{contentDiff:x.contentDiff,fromLabel:x.from,toLabel:x.to,diffSummary:x.diffSummary??void 0,renderContext:"inline"}),!y&&!x&&n.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const uR=3e4;function dR({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=ur(),[u,d]=p.useState(!1),[f,h]=p.useState(!1),[,x]=p.useState(0),v=p.useRef(null),y=p.useRef(null),b=`${t}/${a}`,j=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const w=setInterval(()=>x(C=>(C+1)%1e6),250);return()=>clearInterval(w)},[u]),p.useEffect(()=>{if(!u||!j)return;const w=y.current??0;j.receivedAt<w||(v.current&&(clearTimeout(v.current),v.current=null),d(!1),h(!1),y.current=null)},[u,j]),p.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},uR);try{await ke.rescanSkill(t,a),v.current&&(clearTimeout(v.current),v.current=null);const w=c.updatesById.get(b),C=y.current??0,T=!!w&&w.receivedAt>=C;d(!1),T||h(!0),y.current=null}catch{v.current&&(clearTimeout(v.current),v.current=null),d(!1),y.current=null}}};return n.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[n.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&&n.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&&n.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function fR(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 pR({tabs:t,active:a,onChange:s,parentTabId:i}){const[c,u]=p.useState(null),d=f=>{s?s(f):fR(i,f)};return n.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 n.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 mR=[{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 Ab(t){return mR.filter(a=>a.visibleWhen?a.visibleWhen({isReadOnly:t}):!0)}const hR={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?hR[t]??null:null}function Af(t){const a=new URLSearchParams(t),s=a.get("tab"),i=a.get("panel");return ec(s)??ec(i)??{tab:"overview"}}function Lb(t,a){return!a||new Set(Ab(!0).map(i=>i.id)).has(t)?t:"source"}const Hl={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 Zs(t){const a=Hl[t];return a&&a.length>0?a[0].id:""}function Mb(t,a){const s=Hl[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 xR(t){return t==="run"?"mode":t==="history"?"view":null}function gR(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}=ur();return t.isMobile?n.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:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function vR(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return yR(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=ur(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const x=()=>d(window.location.hash);return window.addEventListener("hashchange",x),()=>window.removeEventListener("hashchange",x)},[]),u==="#/updates")return n.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[n.jsx(ef,{}),n.jsx(Cb,{})]});if(a.mode==="create")return n.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[n.jsx(ef,{}),n.jsx(NT,{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?n.jsx(qs,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?n.jsx(qs,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(x=>x.scopeV2==="available-project")?n.jsx(qs,{variant:"no-project-skills"}):n.jsx(qs,{variant:"no-selection"});const f=a.selectedSkill,h=a.skills.find(x=>x.plugin===f.plugin&&x.skill===f.skill)??null;return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsx(ef,{}),n.jsx(bR,{skillInfo:h,allSkills:a.skills,onSelectSkill:x=>s(x)})]})}function yR(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return SR();if(t.loadError)return kR(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0,c=t.activeDetailSub??Zs(s);return zb(a,s,t.onDetailTabChange,c,t.onDetailSubChange,i)}function bR({skillInfo:t,allSkills:a,onSelectSkill:s}){const i=p.useMemo(()=>typeof window>"u"?{tab:"overview"}:Af(window.location.search),[]),[c,u]=p.useState(i.tab),[d,f]=p.useState(()=>i.mode?i.mode:i.view?i.view:Mb(i.tab,typeof window<"u"?window.location.search:""));p.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const v=Lb(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]),p.useEffect(()=>{f(Zs(c))},[c]),p.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=xR(c),y=Hl[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=p.useMemo(()=>t?zb(t,c,u,d,f,{}):n.jsx(qs,{variant:"no-selection"}),[t,c,d,a,s]);return n.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:h})}function jR(t,a,s){const i=Ab(s);return n.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 n.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 SR(){return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[n.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"}),n.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 kR(t,a){return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Rb({skill:t}),n.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[n.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]}),n.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:a})]})]})}function wR({active:t,sub:a}){if(t==="edit")return n.jsx(XE,{});if(t==="tests")return n.jsx(pb,{});if(t==="run"){const s=MN(a)?a:"benchmark";return n.jsx(zN,{mode:s})}if(t==="history"){const s=xT(a)?a:"timeline";return n.jsx(gT,{view:s})}return null}function CR({active:t,sub:a}){const{state:s,dispatch:i}=yn();return p.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 zb(t,a,s,i="",c,u){var b;const d=t.origin==="installed",f=Lb(a,d),h=j=>{const k=gR(j);s==null||s(k.tab),c&&(k.mode?c(k.mode):k.view&&c(k.view))},x=n.jsx(iR,{skill:t,onNavigate:h,repoUrl:t.homepage??null}),v=u!=null?n.jsxs(iE,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[n.jsx(CR,{active:f,sub:i}),n.jsx(wR,{active:f,sub:i})]},`${t.plugin}/${t.skill}`):n.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"&&n.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:[n.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:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.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&&n.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 n.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[n.jsx("div",{style:{padding:16,paddingBottom:12},children:Rb({skill:t})}),n.jsx(cR,{skill:t}),y,t.origin==="installed"&&t.scopeV2!=="available-plugin"&&n.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:n.jsx(dR,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),jR(f,s,d),Hl[f]&&n.jsx(pR,{parentTabId:f,tabs:Hl[f],active:i||(((b=Hl[f][0])==null?void 0:b.id)??""),onChange:c}),n.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"?n.jsx(pN,{plugin:t.plugin,skill:t.skill}):v})]})}function ER(){const{updateCount:t,state:a,dismissUpdateNotification:s}=ur(),i=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!i)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[i,s]),i?n.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:[n.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),n.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"}),n.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 NR=[{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 TR({open:t,onClose:a,groups:s=NR,title:i=ae.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var f,h;(h=(f=c.current)==null?void 0:f.focus)==null||h.call(f),c.current=null}},[t]),p.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?n.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:n.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:[n.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:i}),n.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=>n.jsxs("section",{style:{marginBottom:12},children:[n.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),n.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(f=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[n.jsx("span",{children:f.label}),n.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 RR(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 i.push({action:"clone",label:a.cloneToAuthoring}),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 AR({state:t,onClose:a,onAction:s,itemsOverride:i}){const c=p.useRef(null),u=p.useRef(null),[d,f]=p.useState(0),h=p.useMemo(()=>t.skill?i??RR(t.skill):[],[t.skill,i]),x=p.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,w=t.y;return k+b+y>window.innerWidth&&(k=Math.max(y,t.x-b)),w+j+y>window.innerHeight&&(w=Math.max(y,t.y-j)),{left:k,top:w}},[t.x,t.y,h.length]);p.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=p.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 p.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:n.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)=>n.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 LR=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function MR(t){const{skill:a,onCloned:s,onCancel:i}=t,[c,u]=p.useState({target:"standalone",plugin:"",pluginName:""}),[d,f]=p.useState(!1),[h,x]=p.useState(null),v=p.useRef(null),y=p.useRef(null),b=p.useRef(null);p.useEffect(()=>(b.current=document.activeElement??null,requestAnimationFrame(()=>{var w;return(w=y.current)==null?void 0:w.focus()}),()=>{var w,C;(C=(w=b.current)==null?void 0:w.focus)==null||C.call(w),b.current=null}),[]),p.useEffect(()=>{function w(C){C.key==="Escape"&&(C.stopPropagation(),i())}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[i]);const j=d||c.target==="plugin"&&!c.plugin.trim()||c.target==="new-plugin"&&!LR.test(c.pluginName.trim()),k=p.useCallback(async w=>{if(w.preventDefault(),!j){f(!0),x(null);try{const C={source:a.skill,sourcePlugin:a.plugin,target:c.target};c.target==="plugin"&&(C.plugin=c.plugin.trim()),c.target==="new-plugin"&&(C.pluginName=c.pluginName.trim());const T=await fetch("/api/skills/clone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),E=await T.json().catch(()=>({}));if(!T.ok||!E.ok){x(E.message||E.error||`HTTP ${T.status}`);return}s({target:E.target??"",files:E.files??null})}catch(C){x(C.message??"Network error")}finally{f(!1)}}},[j,c,a,s]);return n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"clone-dialog-title",ref:v,"data-testid":"clone-to-authoring-dialog",style:zR,onClick:w=>{w.target===w.currentTarget&&i()},children:n.jsxs("form",{onSubmit:k,style:DR,children:[n.jsx("h2",{id:"clone-dialog-title",style:_R,children:"Clone to authoring"}),n.jsxs("p",{style:OR,children:["Fork ",n.jsx("code",{style:wv,children:a.skill})," into the authoring scope so you can edit it."]}),n.jsxs("fieldset",{style:BR,children:[n.jsx("legend",{style:IR,children:"Target"}),n.jsxs("label",{style:tf,children:[n.jsx("input",{type:"radio",name:"target",value:"standalone",checked:c.target==="standalone",onChange:()=>u(w=>({...w,target:"standalone"})),"data-testid":"clone-target-standalone"}),n.jsxs("span",{style:nf,children:[n.jsx("strong",{children:"Standalone"}),n.jsxs("span",{style:rf,children:["Lands at ",n.jsxs("code",{style:wv,children:["skills/",a.skill,"-fork/"]})]})]})]}),n.jsxs("label",{style:tf,children:[n.jsx("input",{type:"radio",name:"target",value:"plugin",checked:c.target==="plugin",onChange:()=>u(w=>({...w,target:"plugin"})),"data-testid":"clone-target-plugin"}),n.jsxs("span",{style:nf,children:[n.jsx("strong",{children:"Add to existing plugin"}),n.jsx("span",{style:rf,children:"Lands inside a plugin you already author."})]})]}),c.target==="plugin"&&n.jsx("input",{type:"text",placeholder:"plugin name or path",value:c.plugin,onChange:w=>u(C=>({...C,plugin:w.target.value})),"data-testid":"clone-plugin-input",autoFocus:!0,style:kv}),n.jsxs("label",{style:tf,children:[n.jsx("input",{type:"radio",name:"target",value:"new-plugin",checked:c.target==="new-plugin",onChange:()=>u(w=>({...w,target:"new-plugin"})),"data-testid":"clone-target-new-plugin"}),n.jsxs("span",{style:nf,children:[n.jsx("strong",{children:"Create new plugin"}),n.jsx("span",{style:rf,children:"Scaffolds a fresh plugin folder with this skill inside."})]})]}),c.target==="new-plugin"&&n.jsx("input",{type:"text",placeholder:"plugin-name (kebab-case)",value:c.pluginName,onChange:w=>u(C=>({...C,pluginName:w.target.value})),"data-testid":"clone-new-plugin-name-input",autoFocus:!0,style:kv})]}),h&&n.jsx("div",{role:"alert",style:$R,"data-testid":"clone-error",children:h}),n.jsxs("div",{style:UR,children:[n.jsx("button",{type:"button",ref:y,onClick:i,disabled:d,style:HR,"data-testid":"clone-cancel",children:"Cancel"}),n.jsx("button",{type:"submit",disabled:j,style:PR,"data-testid":"clone-submit",children:d?"Cloning…":"Clone"})]})]})})}const zR={position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},DR={background:"var(--bg, #fff)",color:"var(--text, #111)",borderRadius:12,padding:"24px 28px",minWidth:460,maxWidth:560,boxShadow:"0 24px 60px rgba(0,0,0,0.5)",border:"1px solid var(--border, rgba(0,0,0,0.10))"},_R={fontSize:18,fontWeight:700,margin:0},OR={margin:"12px 0 18px",fontSize:14,color:"var(--text-muted, #555)"},BR={border:"none",padding:0,margin:"0 0 16px"},IR={fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1.2,color:"var(--text-muted, #555)",padding:0,marginBottom:10},tf={display:"flex",alignItems:"flex-start",gap:10,padding:"10px 4px",cursor:"pointer",borderRadius:6},nf={display:"flex",flexDirection:"column",gap:2,fontSize:14},rf={fontSize:12,color:"var(--text-muted, #777)"},kv={display:"block",width:"100%",padding:"8px 12px",margin:"4px 0 8px 28px",maxWidth:380,fontSize:14,borderRadius:6,border:"1px solid var(--border, rgba(0,0,0,0.20))",background:"var(--bg, #fff)",color:"var(--text, #111)",fontFamily:"var(--font-geist-mono, monospace)"},wv={fontFamily:"var(--font-geist-mono, monospace)",fontSize:13,padding:"1px 6px",borderRadius:4,background:"rgba(127,127,127,0.12)"},$R={fontSize:13,color:"#c62828",background:"rgba(198,40,40,0.10)",border:"1px solid rgba(198,40,40,0.40)",padding:"8px 12px",borderRadius:6,margin:"0 0 12px"},UR={display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},HR={padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, rgba(0,0,0,0.20))",background:"transparent",color:"var(--text, #111)",cursor:"pointer",fontSize:14},PR={padding:"8px 16px",borderRadius:6,border:"1px solid var(--accent, #06b6d4)",background:"var(--accent, #06b6d4)",color:"#fff",cursor:"pointer",fontSize:14,fontWeight:600},Cv=t=>`${t.plugin}/${t.skill}`;function Ev(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=p.useRef(s),d=p.useRef(i),f=p.useRef(c);u.current=s,d.current=i,f.current=c;const h=p.useRef(new Map),[,x]=p.useState(0),v=p.useCallback(()=>x(E=>E+1),[]),y=p.useCallback(async E=>{var R,O;try{await f.current(E.skill.plugin,E.skill.skill),(R=u.current)==null||R.call(u,E.skill)}catch(L){(O=d.current)==null||O.call(d,E.skill,L)}finally{h.current.delete(Cv(E.skill)),v()}},[v]),b=p.useCallback(E=>{const R=Cv(E),O=h.current.get(R);O!=null&&O.timeoutId&&clearTimeout(O.timeoutId);const L={skill:E,timeoutId:null};L.timeoutId=setTimeout(()=>{L.timeoutId=null,y(L)},a),h.current.set(R,L),v()},[a,y,v]),j=p.useCallback(E=>{const R=h.current.get(E);R&&(R.timeoutId&&clearTimeout(R.timeoutId),h.current.delete(E),v())},[v]),k=p.useCallback(async()=>{const E=Array.from(h.current.values());for(const R of E)R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null);await Promise.all(E.map(R=>y(R)))},[y]),w=p.useCallback(E=>h.current.has(E),[]),C=p.useCallback(async E=>{const R=h.current.get(E);R&&(R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null),await y(R))},[y]),T=p.useCallback(async E=>{const R=Array.from(h.current.values()).filter(O=>O.skill.skill===E);for(const O of R)O.timeoutId&&(clearTimeout(O.timeoutId),O.timeoutId=null);await Promise.all(R.map(O=>y(O)))},[y]);return p.useEffect(()=>{const E=()=>{k()};return window.addEventListener("beforeunload",E),()=>{window.removeEventListener("beforeunload",E)}},[k]),p.useEffect(()=>{const E=h.current;return()=>{for(const R of E.values())R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null,y(R));E.clear()}},[]),{enqueueDelete:b,cancelDelete:j,flushPending:k,isPending:w,flushKey:C,flushBySkillName:T}}const VR={"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 FR(t){return t?VR[t]??null:null}function WR({open:t,providerKey:a,onClose:s}){const i=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=f=>{f.key==="Escape"&&(f.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.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=FR(a),u=(c==null?void 0:c.name)??ae.setupDrawer.fallbackTitle;return ac.createPortal(n.jsxs(n.Fragment,{children:[n.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"}}),n.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:[n.jsx(GR,{title:u,onClose:s}),n.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?n.jsx(qR,{content:c}):n.jsx(YR,{})}),n.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 GR({title:t,onClose:a}){return n.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[n.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ae.setupDrawer.title(t)}),n.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 qR({content:t}){var a,s;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[n.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&n.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(i=>n.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&&n.jsxs("section",{children:[n.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ae.setupDrawer.requiredEnv}),n.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(i=>n.jsx("li",{children:n.jsx(KR,{name:i})},i))})]}),t.keyUrl&&n.jsx(XR,{href:t.keyUrl,label:ae.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&n.jsxs("section",{children:[n.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ae.setupDrawer.installRun}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((i,c)=>n.jsx(af,{code:i},`install-${c}`)),(s=t.start)==null?void 0:s.map((i,c)=>n.jsx(af,{code:i},`start-${c}`)),t.pullExample&&n.jsx(af,{code:t.pullExample})]})]}),n.jsx("footer",{style:{marginTop:8},children:n.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 YR(){return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[n.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ae.setupDrawer.fallbackTitle}),n.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ae.setupDrawer.fallbackBody})]})}function KR({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return n.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:[n.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),n.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 af({code:t}){return n.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 XR({href:t,label:a,testId:s}){return n.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 QR(){const[t,a]=p.useState(!1),[s,i]=p.useState(null),c=p.useRef(null),u=p.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=p.useCallback(()=>{a(!1);const f=c.current;f&&"focus"in f&&typeof f.focus=="function"&&queueMicrotask(()=>f.focus())},[]);return p.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function ZR(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 JR({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:i,onSwitch:c,onOpenSetup:u,onClose:d}){const f=p.useRef(null);p.useEffect(()=>{const v=y=>{y.key==="Escape"&&(y.preventDefault(),d())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[d]),p.useEffect(()=>{const v=b=>{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=p.useMemo(()=>ZR(t),[t]),x=t.find(v=>v.id===s)??t.find(v=>v.id===a)??t[0];return typeof document>"u"?null:ac.createPortal(n.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:[n.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[n.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&&n.jsx(Nv,{}),h.detected.map(v=>v.kind==="aggregate"?n.jsx(t4,{row:v,onFocus:()=>{var y;return i(((y=v.consumers[0])==null?void 0:y.id)??a??"")}},v.key):n.jsx(e4,{agent:v.agent,focused:v.agent.id===s,active:v.agent.id===a,onClick:()=>i(v.agent.id)},v.key)),h.notDetected.length>0&&n.jsxs(n.Fragment,{children:[n.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=>n.jsx(n4,{agent:v.agent},v.key))]})]}),n.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:x?n.jsx(r4,{agent:x,activeAgentId:a,onSwitch:()=>c(x.id)}):n.jsx(Nv,{})})]}),n.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 e4({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 n.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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),n.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),n.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 t4({row:t,onFocus:a}){return n.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:[n.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),n.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>n.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)),n.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function n4({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 n.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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),n.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&n.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 r4({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 n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),n.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":l4(t.health)})]}),n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[n.jsx(Bo,{label:ae.scopePicker.statsInstalled,value:String(t.installedCount)}),n.jsx(Bo,{label:ae.scopePicker.statsGlobal,value:String(t.globalCount)}),n.jsx(Bo,{label:ae.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),n.jsx(Bo,{label:ae.scopePicker.statsLastSync,value:t.lastSync?a4(t.lastSync):"—"})]}),n.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 Bo({label:t,value:a}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function Nv(){return n.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function a4(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 l4(t){switch(t){case"ok":return ae.scopePicker.statsHealthOk;case"stale":return ae.scopePicker.statsHealthStale;case"missing":return ae.scopePicker.statsHealthMissing}}function s4(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 i4({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=p.useState(!1),[d,f]=p.useState(null),h=p.useRef(null),x=p.useMemo(()=>t.find(j=>j.id===a)??t[0]??null,[t,a]),v=p.useMemo(()=>x?x.health==="ok"?"var(--color-ok, #22c55e)":x.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[x]),y=p.useCallback(()=>{var j;u(!1),(j=h.current)==null||j.focus()},[]),b=p.useCallback(j=>{s(j),u(!1)},[s]);return n.jsxs(n.Fragment,{children:[n.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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:v,flexShrink:0}}),n.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(x==null?void 0:x.displayName)??"Select agent"}),n.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,")"]}),n.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&n.jsx(JR,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:f,onSwitch:b,onOpenSetup:j=>{i(j),y()},onClose:y})]})}const Db="vskill-ccode-banner-dismissed",o4=new Set(["claude-cli","claude-code"]);function c4(){try{return sessionStorage.getItem(Db)==="true"}catch{return!1}}function u4(){try{sessionStorage.setItem(Db,"true")}catch{}}function d4({activeAgentId:t}){const[a,s]=p.useState(()=>c4()),i=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{u4(),s(!0)},[]);return!t||!o4.has(t)||a?null:n.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:[n.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("span",{children:[ae.claudeCodeLabel.firstUseBanner," "]}),n.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})]}),n.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 f4(){const[t,a]=p.useState(null),[s,i]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const f=await ke.getAgents();a(f),i("ready"),u(null)}catch(f){i("error"),u(f.message)}},[]);return p.useEffect(()=>{d()},[d]),p.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 Io="workspace",p4=["skills","agents"];async function m4(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function h4(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 x4(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 g4(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 lf(){for(const t of p4)In(t)}function v4(){const{data:t,loading:a,error:s,revalidate:i}=qa(Io,m4),c=t,u=c==null?void 0:c.projects.find(x=>x.id===c.activeProjectId),d=p.useCallback(async x=>{await h4(x),In(Io),lf()},[]),f=p.useCallback(async x=>{await x4(x),In(Io),lf()},[]),h=p.useCallback(async x=>{await g4(x),In(Io),lf()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:f,removeProject:h,revalidate:i}}function y4({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=p.useState(!1),[f,h]=p.useState(!1),[x,v]=p.useState(""),[y,b]=p.useState(null),[j,k]=p.useState(null),[w,C]=p.useState(null),[T,E]=p.useState(!1),R=p.useRef(null),O=(t==null?void 0:t.projects)??[],L=O.find(z=>z.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function z(_){R.current&&!R.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 N(){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 B(z){if(z.length<=50)return z;const _=z.split("/");return _.length<=4?z:`${_.slice(0,3).join("/")}/…/${_.slice(-2).join("/")}`}return n.jsxs("div",{ref:R,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[n.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(L==null?void 0:L.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:[n.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(L==null?void 0:L.colorDot)??"var(--text-tertiary, #999)"}}),n.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L?L.name:"No project"}),n.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&n.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:[O.length===0&&n.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."}),O.length>0&&n.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:O.map(z=>{const _=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),W=j===z.id;return n.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}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:W&&!_?"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:[n.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"}}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[n.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&n.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),n.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:B(z.path)}),_&&n.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),n.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:W?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:n.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:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),n.jsx("path",{d:"M10 11v6"}),n.jsx("path",{d:"M14 11v6"}),n.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),n.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:f?8:6},children:[!f&&n.jsxs("button",{type:"button",onClick:()=>void N(),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:[n.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:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),f&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[n.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"}}),n.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[n.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"}),n.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&&n.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:y})]})]})]}),w&&n.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[n.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),n.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:[n.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",w.name]}),n.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:"}),n.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${w.path}" && npx vskill@latest studio`}),n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${w.path}" && npx vskill@latest studio`),E(!0),setTimeout(()=>E(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:T?"Copied!":"Copy command"}),n.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function b4(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 j4({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=p.useState(""),[d,f]=p.useState(0),h=p.useMemo(()=>b4(a,c),[a,c]);p.useEffect(()=>{t||(u(""),f(0))},[t]),p.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?n.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:[n.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:i}),n.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[n.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"}),n.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[h.length===0&&n.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),h.map((v,y)=>n.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:[n.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:v.colorDot}}),n.jsxs("span",{className:"flex-1",children:[n.jsx("span",{className:"vskill-palette-name",children:v.name}),n.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:v.path})]})]},v.id))]})]})]}):null}const Tv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function S4({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,f]=p.useState("destination"),[h,x]=p.useState(s),[v,y]=p.useState(""),[b,j]=p.useState(""),[k,w]=p.useState(""),[C,T]=p.useState([]),[E,R]=p.useState(!1),[O,L]=p.useState(null);if(p.useEffect(()=>{t&&(f("destination"),x(s),y(""),j(""),w(""),L(null))},[t,s]),p.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(D=>D.json()).then(D=>{$&&T(D.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),p.useEffect(()=>{if(!t)return;function $(D){D.key==="Escape"&&(D.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const P=C.length>0,N=i&&P,B=i,z=Tv.test(v),_=h==="existing-plugin"?b.length>0:Tv.test(b),H=!E&&z&&(h==="standalone"||_),W=k4(c,h,b,v);async function q(){L(null),R(!0);try{const U=new URLSearchParams;U.set("mode",h),U.set("skillName",v),b&&U.set("pluginName",b);const F=await fetch(`/api/authoring/skill-exists?${U.toString()}`),Y=await F.json();if(!F.ok){L(Y.error??`Check failed: ${F.status}`);return}if(Y.exists){L(`Skill '${v}' already exists${Y.path?` at ${Y.path}`:""}`);return}}catch(U){L(U instanceof Error?U.message:String(U));return}finally{R(!1)}const $=new URLSearchParams;$.set("mode",h),$.set("skillName",v),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const D=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=D),a()}async function ee(){L(null),R(!0);try{const $=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 $.json();if(!$.ok||!D.ok){L(D.error??`Create failed: ${$.status}`);return}In("skills"),u==null||u({mode:h,skillName:v,pluginName:D.pluginName??null,skillMdPath:D.skillMdPath}),a()}catch($){L($ instanceof Error?$.message:String($))}finally{R(!1)}}return n.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:[n.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),n.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:[n.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:[n.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"}),n.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&n.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[n.jsx(sf,{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")}),n.jsx(sf,{title:"Add to existing plugin",subtitle:N?`${C.length} plugin source${C.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:!N,selected:h==="existing-plugin",onClick:()=>N&&x("existing-plugin")}),n.jsx(sf,{title:"Plugin (multi-skill)",subtitle:B?"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:!B,selected:h==="new-plugin",onClick:()=>B&&x("new-plugin")})]}),d==="details"&&n.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[h==="new-plugin"&&n.jsx($o,{label:"Plugin name",hint:"kebab-case",children:n.jsx("input",{type:"text",value:b,onChange:$=>j($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:Uo(!b||_)})}),h==="existing-plugin"&&n.jsx($o,{label:"Plugin",children:n.jsxs("select",{value:b,onChange:$=>j($.target.value),style:{...Uo(!0),fontFamily:"var(--font-mono)"},children:[n.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>n.jsx("option",{value:$.name,children:$.name},$.path))]})}),n.jsx($o,{label:"Skill name",hint:"kebab-case",children:n.jsx("input",{type:"text",value:v,onChange:$=>y($.target.value.trim()),placeholder:"my-new-skill",autoFocus:h!=="new-plugin",style:Uo(!v||z)})}),n.jsx($o,{label:"Description",hint:"One short sentence — shown in frontmatter",children:n.jsx("textarea",{value:k,onChange:$=>w($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Uo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),W&&n.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:[n.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),W.map(($,D)=>n.jsx("div",{children:$},D))]}),O&&n.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:O})]}),n.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:[n.jsx("button",{type:"button",onClick:a,style:of,children:"Cancel"}),d==="destination"&&n.jsx("button",{type:"button",onClick:()=>f("details"),style:Rv,children:"Continue →"}),d==="details"&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:()=>f("destination"),style:of,children:"← Back"}),n.jsx("button",{type:"button",onClick:()=>void q(),disabled:!H,style:{...of,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"}),n.jsx("button",{type:"button",onClick:()=>void ee(),disabled:!H,style:{...Rv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:E?"Creating…":"Create empty scaffold"})]})]})]})]})}function sf({title:t,subtitle:a,description:s,icon:i,selected:c,disabled:u,onClick:d}){return n.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:[n.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:i}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),n.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),n.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function $o({label:t,hint:a,children:s}){return n.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[n.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&n.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function Uo(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 Rv={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"},of={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 k4(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 _b(t){return t.trim().toLowerCase()}function w4(t,a){const s=_b(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function C4(t,a){const s=_b(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function E4({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=p.useState(null),[f,h]=p.useState([]),[x,v]=p.useState(null),[y,b]=p.useState(null),[j,k]=p.useState(!1),[w,C]=p.useState(null),[T,E]=p.useState(""),[R,O]=p.useState("");p.useEffect(()=>{x?E(""):O("")},[x]);const L=p.useMemo(()=>w4(f,T),[f,T]),P=p.useMemo(()=>C4((y==null?void 0:y.plugins)??[],R),[y,R]);return p.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(N=>N.json()).then(N=>{if(N.error)throw new Error(N.error);h(N.marketplaces??[])}).catch(N=>C(N instanceof Error?N.message:String(N))).finally(()=>k(!1)))},[t]),p.useEffect(()=>{if(!x){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(x)}`).then(N=>N.json()).then(N=>{if(N.error)throw new Error(N.error);b(N)}).catch(N=>C(N instanceof Error?N.message:String(N))).finally(()=>k(!1))},[x]),p.useEffect(()=>{if(!t)return;function N(B){B.key==="Escape"&&a()}return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,a]),t?n.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[n.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),n.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:[n.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&&n.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"}),n.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"}),n.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:"✕"})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[j&&n.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),w&&n.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:w}),!x&&!j&&f.length===0&&!w&&n.jsx(N4,{}),!x&&f.length>0&&n.jsx(Av,{value:T,onChange:E,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!x&&f.length>0&&L.length===0&&n.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",T,"”."]}),!x&&L.map(N=>n.jsxs("button",{type:"button",onClick:()=>v(N.name),style:R4,onMouseEnter:B=>{B.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:N.name}),n.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.source})]},N.name)),x&&y&&n.jsxs(n.Fragment,{children:[y.description&&n.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:y.description}),y.plugins.length===0&&n.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),y.plugins.length>0&&n.jsx(Av,{value:R,onChange:O,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),y.plugins.length>0&&P.length===0&&n.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",R,"”."]}),P.map(N=>{const B=c.has(N.name);return n.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:n.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[N.name,N.version&&n.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:N.version}),N.category&&n.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:N.category})]}),N.description&&n.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:N.description})]}),B&&i?n.jsx("button",{type:"button",disabled:u===N.name,onClick:async()=>{d(N.name);try{await i(N.name)}finally{d(null)}},"aria-label":`Uninstall ${N.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===N.name?"wait":"pointer",opacity:u===N.name?.6:1,fontFamily:"inherit"},children:u===N.name?"Uninstalling…":"Uninstall"}):n.jsx("button",{type:"button",disabled:B,onClick:()=>s(N.name,x),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:B?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:B?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:B?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:B?"default":"pointer",fontFamily:"inherit",boxShadow:B?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:B?"Installed":"Install"})]})},N.name)})]})]}),!x&&n.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:n.jsx(T4,{onAdded:()=>{In("marketplaces"),fetch("/api/plugins/marketplaces").then(N=>N.json()).then(N=>h(N.marketplaces??[]))}})})]})]}):null}function Av({value:t,onChange:a,placeholder:s,ariaLabel:i,testId:c}){return n.jsx("div",{style:{padding:"0 4px 10px"},children:n.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 N4(){return n.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",n.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[n.jsx("li",{children:n.jsx("code",{children:"anthropics/claude-plugins-official"})}),n.jsx("li",{children:n.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function T4({onAdded:t}){const[a,s]=p.useState(""),[i,c]=p.useState(!1),[u,d]=p.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 n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[n.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.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"}}),n.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&&n.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const R4={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},cf=12;function A4({job:t,onDone:a}){const[s,i]=p.useState([]),[c,u]=p.useState("running"),[d,f]=p.useState(!1);if(p.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 w=k.body.getReader(),C=new TextDecoder;let T="";for(;;){const{value:E,done:R}=await w.read();if(R)break;T+=C.decode(E,{stream:!0});const O=T.split(/\n\n/);T=O.pop()??"";for(const L of O){const P=L.match(/^data:\s*(.*)$/m);if(P)try{const N=JSON.parse(P[1]);N.type==="stdout"&&N.line?(b=[...b,N.line].slice(-cf),i(b)):N.type==="stderr"&&N.line?(b=[...b,`⚠ ${N.line}`].slice(-cf),i(b)):N.type==="done"?(j=N.ok?"ok":"failed",u(j),dy(),In("skills"),a({ok:N.ok??!1,code:N.code??null,lines:b})):N.type==="error"&&N.error&&(b=[...b,`✘ ${N.error}`].slice(-cf),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 n.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:[n.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:[n.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:h,width:16,textAlign:"center"},children:c==="running"?n.jsx(L4,{}):x}),n.jsxs("span",{style:{flex:1,minWidth:0},children:[n.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[v,": ",t.plugin,n.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&n.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]})]}),n.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-primary)"},children:d?"▾":"▸"})]}),d&&n.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 L4(){return n.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:n.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const M4=3e3,z4={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Lv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function D4(){const{toast:t}=lc(),a=p.useRef(new Map),s=p.useCallback(i=>{if(!Lv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<M4)return;a.current.set(i.provider,c);const d=z4[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 p.useEffect(()=>{function i(c){const u=c.detail;!u||!Lv(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 Ob="vskill.studio.prefs";function Bb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Ib(){const t=Bb();if(!t)return{};try{const a=t.getItem(Ob);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function _4(t,a){const s=Bb();if(s)try{const c={...Ib(),[t]:a};s.setItem(Ob,JSON.stringify(c))}catch{}}function O4(t,a){const i=Ib()[t];return i===void 0?a:i}const Mv={open:!1,x:0,y:0,skill:null};function B4(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function xr(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function I4(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}async function zv(t,a){var s;try{await ke.revealInEditor(t.plugin,t.skill,a),xr(ae.toasts.openingInEditor,"info")}catch(i){if(i instanceof Vr){const c=(s=i.details)==null?void 0:s.error;if(i.status===404){xr(ae.toasts.skillNotFound,"error");return}if(i.status===500&&c==="no_editor"){xr(ae.toasts.noEditor,"error");return}}xr(ae.toasts.openFailed,"error")}}async function $4(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{xr(ae.toasts.permissionDenied,"error");return}xr(ae.toasts.pathCopied,"info");return;case"reveal":case"edit":await zv(a,"SKILL.md");return;case"open":await zv(a);return;case"run-benchmark":xr(ae.toasts.benchmarkQueued,"info");return;case"duplicate":xr(ae.toasts.skillDuplicated,"info");return;case"clone":try{window.dispatchEvent(new CustomEvent("studio:request-clone",{detail:{skill:a}}))}catch{}return;case"update":xr(ae.toasts.skillUpdated,"info");return;case"uninstall":xr(ae.toasts.uninstallNotImplemented,"info");return;case"delete":I4(a);return;default:return}}function U4(t){return t.startsWith("#/create")}function H4(t){return t.startsWith("#/updates")}function $b(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function P4(){return $b(U4)}function V4(){return $b(H4)}function F4(){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 W4(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function G4(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(F4())},[]);const s=W4();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return n.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:[n.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:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),n.jsx("span",{children:"Find skills"}),n.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 q4=p.lazy(()=>Gl(()=>import("./FindSkillsPalette-DsSgotS9.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),Y4=p.lazy(()=>Gl(()=>import("./SkillDetailPanel-DAD2yJO-.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),K4=p.lazy(()=>Gl(()=>import("./CreateSkillPage-CvdYq8Rr.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),X4=p.lazy(()=>Gl(()=>Promise.resolve().then(()=>AT),void 0).then(t=>({default:t.UpdatesPanel})));function Q4(){return n.jsx(d2,{children:n.jsx(o2,{children:n.jsxs(uk,{children:[n.jsx(Z4,{}),n.jsx(ER,{})]})})})}function Z4(){var Sr,jn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ur(),{config:f}=Ya(),{resolvedTheme:h,setTheme:x}=uy(),{toast:v}=lc(),[y,b]=p.useState(()=>WC()),[j]=p.useState(!0),[k,w]=p.useState(!1),[C,T]=p.useState(!1),[E,R]=p.useState(()=>typeof window>"u"?"overview":Af(window.location.search).tab),[O,L]=p.useState(()=>{if(typeof window>"u")return"";const Z=Af(window.location.search);return Z.mode?Z.mode:Z.view?Z.view:Mb(Z.tab,window.location.search)}),P=p.useCallback(Z=>{R(be=>(be!==Z&&L(Zs(Z)),Z))},[]);p.useEffect(()=>{if(typeof window>"u")return;const Z=()=>{const be=new URLSearchParams(window.location.search),we=be.get("tab"),_t=be.get("panel"),Te=ec(we)??ec(_t);if(!Te)return;const ht=new URLSearchParams(window.location.search);ht.delete("panel"),ht.delete("sub"),Te.tab==="overview"?ht.delete("tab"):ht.set("tab",Te.tab),ht.delete("mode"),ht.delete("view"),Te.mode&&ht.set("mode",Te.mode),Te.view&&ht.set("view",Te.view);const dn=ht.toString(),Gr=`${window.location.pathname}${dn?"?"+dn:""}${window.location.hash}`,an=`${window.location.pathname}${window.location.search}${window.location.hash}`;Gr!==an&&window.history.replaceState(null,"",Gr),R(Te.tab),Te.mode?L(Te.mode):Te.view?L(Te.view):L(Zs(Te.tab))};return Z(),window.addEventListener("popstate",Z),()=>window.removeEventListener("popstate",Z)},[]),p.useEffect(()=>{if(typeof window>"u")return;const Z=new URLSearchParams(window.location.search);Z.delete("panel"),Z.delete("sub"),E==="overview"?Z.delete("tab"):Z.set("tab",E),Z.delete("mode"),Z.delete("view"),!(O===Zs(E))&&O&&(E==="run"?Z.set("mode",O):E==="history"&&Z.set("view",O));const we=Z.toString(),_t=`${window.location.pathname}${we?"?"+we:""}${window.location.hash}`,Te=`${window.location.pathname}${window.location.search}${window.location.hash}`;_t!==Te&&window.history.replaceState(null,"",_t)},[E,O]);const[N,B]=p.useState(Mv),z=p.useCallback((Z,be)=>{B(B4(Z,be))},[]),_=f4(),[H,W]=p.useState(()=>O4("activeAgent",null)),q=p.useCallback(Z=>{W(Z),_4("activeAgent",Z),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:Z}}))},[]);p.useEffect(()=>{var Z;!H&&((Z=_.response)!=null&&Z.suggested)&&q(_.response.suggested)},[H,(Sr=_.response)==null?void 0:Sr.suggested,q]);const ee=p.useMemo(()=>_.response?s4(_.response):[],[_.response]),{workspace:$,switchProject:D,addProject:U,removeProject:F,activeProject:Y}=v4(),[oe,M]=p.useState(!1),[I,K]=p.useState(!1),[Q,ue]=p.useState("standalone"),te=p.useCallback((Z="standalone")=>{ue(Z),K(!0)},[]);p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;te((we==null?void 0:we.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",Z),()=>window.removeEventListener("studio:request-create-skill",Z)},[te]);const[ie,J]=p.useState(!1),[he,je]=p.useState(null),[Ne,De]=p.useState(null);p.useEffect(()=>{function Z(){J(!0)}return window.addEventListener("studio:open-marketplace",Z),()=>window.removeEventListener("studio:open-marketplace",Z)},[]);const He=p.useMemo(()=>{const Z=new Set;for(const be of t.skills)be.source==="plugin"&&be.pluginName&&Z.add(be.pluginName);return Z},[t.skills]);jf([{key:"p",meta:!0,handler:Z=>{var we;const be=typeof document<"u"?document.activeElement:null;be&&be.tagName==="INPUT"||((we=Z==null?void 0:Z.preventDefault)==null||we.call(Z),M(_t=>!_t))}}],{enabled:!0});const Ue=QR(),_e=Ue.open;p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;we!=null&&we.provider&&_e(we.provider)}return window.addEventListener("studio:open-setup-drawer",Z),()=>window.removeEventListener("studio:open-setup-drawer",Z)},[_e]);const Ze=p.useCallback(()=>{B(Mv)},[]);p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;we!=null&&we.message&&v({message:we.message,severity:we.severity??"info"})}return window.addEventListener("studio:toast",Z),()=>window.removeEventListener("studio:toast",Z)},[v]),D4();const[st,ce]=p.useState(!1),[ve,ye]=p.useState(void 0);p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;ye(we==null?void 0:we.provider),ce(!0)}return window.addEventListener("studio:open-settings",Z),()=>window.removeEventListener("studio:open-settings",Z)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${y}px`)},[y]),p.useEffect(()=>{function Z(){i()}return window.addEventListener("studio:content-saved",Z),()=>window.removeEventListener("studio:content-saved",Z)},[i]);const[Se,Ae]=p.useState(null),[Ge,We]=p.useState(()=>new Set),wt=p.useRef(!1),Ct=p.useMemo(()=>yC(),[]),Et=p.useCallback(Z=>`${Z.plugin}/${Z.skill}`,[]),zt=p.useCallback(Z=>{We(be=>{const we=new Set(be);return we.add(Et(Z)),we})},[Et]),xe=p.useCallback(Z=>{We(be=>{const we=new Set(be);return we.delete(Et(Z)),we})},[Et]),qe=Ev({delayMs:1e4,onCommit:Z=>{i(),xe(Z)},onFailure:(Z,be)=>{xe(Z),v({message:`Couldn't delete ${Z.skill}: ${be.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{zt(Z),qe.enqueueDelete(Z)}}})}});p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;we!=null&&we.skill&&Ae(we.skill)}return window.addEventListener("studio:request-delete",Z),()=>window.removeEventListener("studio:request-delete",Z)},[]);const[tt,Nt]=p.useState(null);p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;we!=null&&we.skill&&Nt(we.skill)}return window.addEventListener("studio:request-clone",Z),()=>window.removeEventListener("studio:request-clone",Z)},[]);const[St,dt]=p.useState(null),Dt=Ev({delayMs:250,apiCall:(Z,be)=>api.uninstallSkill(Z,be),onCommit:Z=>{i(),xe(Z)},onFailure:(Z,be)=>{var we;if(xe(Z),be instanceof Vr&&((we=be.details)==null?void 0:we.code)==="not-installed"){v({message:`${Z.skill} is a source-authored skill — use Delete instead`,severity:"info",durationMs:4e3});return}v({message:`Couldn't uninstall ${Z.skill}: ${be.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{zt(Z),Dt.enqueueDelete(Z)}}})}});p.useEffect(()=>{function Z(be){if(!(be instanceof CustomEvent))return;const we=be.detail;we!=null&&we.skill&&dt(we.skill)}return window.addEventListener("studio:request-uninstall",Z),()=>window.removeEventListener("studio:request-uninstall",Z)},[]);const Ft=p.useCallback(async Z=>{await Promise.all([qe.flushBySkillName(Z),Dt.flushBySkillName(Z)])},[qe,Dt]),jr=p.useMemo(()=>({flushBySkillName:Ft}),[Ft]),en=p.useCallback(()=>{const Z=St;if(dt(null),!Z)return;const be={plugin:Z.plugin,skill:Z.skill};zt(be),Dt.enqueueDelete(be),v({message:`Uninstalled ${Z.skill}. Sent to your ${Ct}.`,severity:"info",durationMs:4e3})},[St,zt,Dt,v,Ct]),Tn=p.useCallback(()=>{dt(null)},[]),Rn=p.useCallback(()=>{const Z=Se;if(Ae(null),!Z)return;const be={plugin:Z.plugin,skill:Z.skill};zt(be),qe.enqueueDelete(be);const we=wt.current?"":`Sent to your ${Ct}. Open Trash to restore. `;wt.current=!0,v({message:`${we}Deleted ${Z.skill}`,severity:"info",durationMs:1e4,action:{label:ae.actions.undo,onInvoke:()=>{qe.cancelDelete(Et(be)),xe(be)}}})},[Se,zt,xe,qe,v,Ct,Et]),nr=p.useCallback(()=>{Ae(null)},[]),bn=p.useMemo(()=>t.skills.filter(Z=>!Ge.has(Et(Z))),[t.skills,Ge,Et]),Tt=JC(bn,(Y==null?void 0:Y.path)??null),pt=p.useMemo(()=>t.selectedSkill?t.skills.find(Z=>Z.plugin===t.selectedSkill.plugin&&Z.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Pe=p.useRef(null);p.useEffect(()=>{if(!pt||typeof window>"u"||new URLSearchParams(window.location.search).get("tab")||!(pt.origin==="installed"))return;const we=`${pt.plugin}/${pt.skill}`;Pe.current!==we&&(Pe.current=we,E==="overview"&&R("source"))},[pt==null?void 0:pt.plugin,pt==null?void 0:pt.skill,pt==null?void 0:pt.origin]);const it=p.useCallback(Z=>{a({plugin:Z.plugin,skill:Z.skill,origin:Z.origin,source:Z.source})},[a]),un=p.useMemo(()=>{if(!t.selectedSkill)return"";const Z=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${Z})`},[t.selectedSkill]),[rn,rr]=p.useState(null);jf([{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:()=>w(Z=>!Z)},{key:"cmd+shift+d",handler:()=>x(h==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>x(h==="light"?"dark":"light")},{key:"cmd+b",handler:()=>T(Z=>!Z)},{key:"ctrl+b",handler:()=>T(Z=>!Z)}]);const Hn=P4(),Qa=V4()?n.jsx(p.Suspense,{fallback:n.jsx("div",{style:{padding:40},children:"Loading…"}),children:n.jsx(X4,{})}):Hn?n.jsx(p.Suspense,{fallback:n.jsx("div",{style:{padding:40},children:"Loading…"}),children:n.jsx(K4,{})}):n.jsx(vR,{selectedSkillInfo:pt,activeDetailTab:E,onDetailTabChange:P,activeDetailSub:O,onDetailSubChange:L,allSkills:t.skills,onSelectSkill:it});return n.jsxs(Sb.Provider,{value:jr,children:[n.jsx(f2,{sidebarWidth:y,sidebarHidden:C||t.isMobile&&t.mobileView==="detail",banner:n.jsx(eE,{connected:j}),liveMessage:un,topRail:n.jsx(xk,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>te("standalone"),projectPickerSlot:$&&$.projects.length>0?n.jsx(y4,{workspace:$,onSwitch:D,onAdd:U,onRemove:F}):void 0,findSkillsSlot:n.jsx(G4,{})}),sidebar:n.jsx(_C,{skills:bn,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:it,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:Tt,onSkillsChanged:i,topSlot:_.status==="ready"&&ee.length>0?n.jsxs(n.Fragment,{children:[n.jsx(i4,{agents:ee,activeAgentId:H,onActiveAgentChange:q,onOpenSetup:Z=>Ue.open(Z)}),n.jsx(d4,{activeAgentId:H})]}):null}),resizeHandle:n.jsx(qC,{initialWidth:y??Qs,onChange:b}),main:Qa,statusBar:n.jsx(Nk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(jn=f==null?void 0:f.providers)==null?void 0:jn.map(Z=>{const be=Z.id;return{id:be,label:Z.label,available:Z.available,kind:be==="ollama"||be==="lm-studio"?"start-service":be==="anthropic"||be==="openrouter"?"api-key":"cli-install"}})})}),n.jsx(TR,{open:k,onClose:()=>w(!1)}),n.jsx(WR,{open:Ue.isOpen,providerKey:Ue.providerKey,onClose:Ue.close}),n.jsx(AR,{state:N,onClose:Ze,onAction:(Z,be)=>$4(Z,be)}),n.jsx(p.Suspense,{fallback:null,children:n.jsx(q4,{onSelect:Z=>{const be=Z.name.split("/");be.length===3&&rr({owner:be[0],repo:be[1],slug:be[2],displayName:Z.displayName??Z.name})}})}),rn&&n.jsx(p.Suspense,{fallback:null,children:n.jsx(Y4,{selectedSkill:rn,onClose:()=>rr(null)})}),n.jsx(j4,{open:oe,projects:($==null?void 0:$.projects)??[],onSwitch:Z=>{D(Z)},onClose:()=>M(!1)}),n.jsx(S4,{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:Z=>{i(),setTimeout(()=>{u(Z.pluginName??"",Z.skillName)},500)}}),n.jsx(E4,{open:ie,onClose:()=>J(!1),installedNames:He,onInstall:(Z,be)=>{je({plugin:Z,marketplace:be,ref:`${Z}@${be}`}),J(!1)},onUninstall:async Z=>{if(await new Promise(we=>{De({plugin:Z,resolve:we})}))try{const we=await fetch(`/api/plugins/${encodeURIComponent(Z)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),_t=await we.json().catch(()=>({}));if(!we.ok||!_t.ok){v({message:_t.error??`Uninstall failed (${we.status})`,severity:"error"});return}const Te=_t.fallback==="orphan-cache-removed"?`Removed orphaned ${Z}.`:`Uninstalled ${Z}.`;v({message:Te,severity:"success"}),i()}catch(we){v({message:we instanceof Error?we.message:String(we),severity:"error"})}}}),n.jsx(sy,{open:st,onClose:()=>ce(!1),initialProvider:ve,onToast:Z=>v({message:Z,severity:"info"})}),n.jsx(A4,{job:he,onDone:Z=>{Z.ok&&(i(),setTimeout(()=>je(null),3e3))}}),n.jsx(Go,{open:Se!==null,title:Se?`Delete "${Se.skill}"?`:"",body:`It will be sent to your ${Ct}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Rn,onCancel:nr}),n.jsx(Go,{open:St!==null,title:St?`Uninstall "${St.skill}"?`:"",body:`It will be sent to your ${Ct} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:en,onCancel:Tn}),n.jsx(Go,{open:Ne!==null,title:Ne?`Uninstall ${Ne.plugin}?`:"",body:Ne?`This removes the ${Ne.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ne==null||Ne.resolve(!0),De(null)},onCancel:()=>{Ne==null||Ne.resolve(!1),De(null)}}),tt&&n.jsx(MR,{skill:tt,onCloned:Z=>{v({message:ae.toasts.cloneSucceeded,severity:"info"}),Nt(null);try{window.dispatchEvent(new CustomEvent("studio:skills-changed",{detail:Z}))}catch{}i()},onCancel:()=>Nt(null)})]})}const Dv="vskill.migrations.scope-rename.v1",J4={own:"authoring-project",installed:"available-project",global:"available-personal"},eA=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function tA(t){if(t.getItem(Dv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(eA);if(!c)continue;const[,u,d]=c,f=J4[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(Dv,"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{tA(window.localStorage)}catch{}rj.createRoot(document.getElementById("root")).render(n.jsx(p.StrictMode,{children:n.jsx(wS,{children:n.jsx(Sk,{children:n.jsx(Q4,{})})})}));export{fc as E,Jv as L,mi as P,Le as R,ET as S,rA as T,Gl as _,ke as a,ur as b,Ib as c,kT as d,jT as e,pi as f,O4 as g,lc as h,jb as i,n as j,p as r,Il as t,Ya as u,_4 as w};
|